kloudless.resources.base - Resource¶
-
class
kloudless.resources.base.Response(client, url, response=None)¶ Bases:
objectBase Response class for this library.
Instance attributes
Variables: - url (str) – Base url which would be used as prefix for all http method calls
- query_params (dict) – Query parameter from request
- client –
kloudless.client.Clientorkloudless.account.Account - response –
requests.Responseif available
-
get(path='', **kwargs)¶ - Performs http GET request through
self.client.get.Note that the actually request url would haveself.urlas prefix.Returns: kloudless.resources.base.Responseor its subclass
-
post(path='', data=None, json=None, **kwargs)¶ - Performs http POST request through
self.client.post.Note that the actually request url would haveself.urlas prefix.Returns: kloudless.resources.base.Responseor its subclass
-
put(path='', data=None, **kwargs)¶ - Performs http PUT request through
self.client.put.Note that the actually request url would haveself.urlas prefix.Returns: kloudless.resources.base.Responseor its subclass
-
patch(path='', data=None, **kwargs)¶ - Performs http PATCH request through
self.client.patch.Note that the actually request url would haveself.urlas prefix.Returns: kloudless.resources.base.Responseor its subclass
-
delete(path='', **kwargs)¶ - Performs http DELETE request through
self.client.delete.Note that the actually request url would haveself.urlas prefix.Returns: kloudless.resources.base.Responseor its subclass
-
refresh()¶ Performs GET request through
self.client.gettoself.url, then refreshself. The original query parameters and headers would be reused if original request is http GET request.
-
class
kloudless.resources.base.ResponseJson(data, **kwargs)¶ Bases:
kloudless.resources.base.ResponseBase Response class for JSON response.
Instance attributes
Variables: data (dict) – JSON data -
refresh()¶ Perform GET request through
self.client.gettoself.url, then refreshself. The original query parameters and headers would be reused if original request is http GET request.
-
-
class
kloudless.resources.base.Resource(**kwargs)¶ Bases:
kloudless.resources.base.ResponseJsonRepresents a resource object from API response. A resource object contains an identifier and endpoint ( /{resource_type}/{identifier} ) for retrieving its metadata.
Example resources include: Files and folders in the Storage API, calendar events in the Calendar API, and events in Events API.
-
class
kloudless.resources.base.ResourceList(**kwargs)¶ Bases:
kloudless.resources.base.ResponseJsonRepresents a list of resources from API response. ResourceList itself is also an iterable thorough
self.objects.Instance attributes
Variables: objects – list of kloudless.resource.base.Resourceinstance-
get_next_page()¶ Get the resources of the next page, if any.
Returns: kloudless.resources.base.ResourceListRaise: kloudless.exceptions.NoNextPage
-
get_paging_iterator(max_resources=None)¶ Generator to iterate thorough all resources under
self.objectsand all resources in the following page, if any.If retrieving events,
self.latest_cursoris available after iterating thorough all events withoutmax_resourcesspecified.Parameters: max_resources – the maximum quantity of resources that would be contained in the returned generator Returns: generator that yield kloudless.resources.base.Resourceinstance
-