Let's discuss (feel free to stop me if there was too much discussion and no code!) the client architecture here
As mentioned in #3 I'd suggest structuring out the client in the following spirit (this is just a mock-up):
class Endpoint:
"""Endpoint implements all HTTP methods
serves as a base class for the real endpoints.
"""
def __init__(self, root, path, token):
self.path = path
def _get(**params):
return requests.get(
urllib.parse.urljoin(root, path),
headers={'x-storage-token':self.token},
params=params)
# either make a subclass
class BucketEndpoint(Endpoint):
def listBuckets(self, *args, **kwargs):
return self._get(*args, **kwargs)
class StorageClient:
def __init__(self, token):
self.token = token
self.root = 'http://something.com'
self.buckets = BucketsEndpoint(self.root, 'buckets'):
# and use like this:
client = StorageClient('apitoken')
client.buckets.listBuckets(id='1234')
but @Ogaday mentioned he was developing his own client, so he might already have an alternative. How do you feel about it?
Let's discuss (feel free to stop me if there was too much discussion and no code!) the client architecture here
As mentioned in #3 I'd suggest structuring out the client in the following spirit (this is just a mock-up):
but @Ogaday mentioned he was developing his own client, so he might already have an alternative. How do you feel about it?