allisson/python-simple-rest-client

Resource names with dash

Closed this issue · 1 comments

I have api url with dash, like "api/device-types"
So impossibe to use api.device-types.list
may be add something like resource_url parameter?

You can use this:

from simple_rest_client.api import API
from simple_rest_client.resource import Resource


class DeviceTypesResource(Resource):
    actions = {
        'list': {
            'method': 'GET',
            'url': 'device-types'
        },
        'retrieve': {
            'method': 'GET',
            'url': 'device-types/{}',
        }
    }


api = API(api_root_url='https://myexample.com/api/', timeout=5)
api.add_resource(resource_name='device_types', resource_class=DeviceTypesResource)
api.device_types.list()
api.device_types.retrieve(1)