kloudless.resources.base
- Resource¶
-
class
kloudless.resources.base.
Response
(client, url, response=None)¶ Bases:
object
Base 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.Client
orkloudless.account.Account
- response –
requests.Response
if available
-
get
(path='', **kwargs)¶ - Performs http GET request through
self.client.get
.Note that the actually request url would haveself.url
as prefix.Returns: kloudless.resources.base.Response
or 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.url
as prefix.Returns: kloudless.resources.base.Response
or its subclass
-
put
(path='', data=None, **kwargs)¶ - Performs http PUT request through
self.client.put
.Note that the actually request url would haveself.url
as prefix.Returns: kloudless.resources.base.Response
or its subclass
-
patch
(path='', data=None, **kwargs)¶ - Performs http PATCH request through
self.client.patch
.Note that the actually request url would haveself.url
as prefix.Returns: kloudless.resources.base.Response
or its subclass
-
delete
(path='', **kwargs)¶ - Performs http DELETE request through
self.client.delete
.Note that the actually request url would haveself.url
as prefix.Returns: kloudless.resources.base.Response
or its subclass
-
refresh
()¶ Performs GET request through
self.client.get
toself.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.Response
Base Response class for JSON response.
Instance attributes
Variables: data (dict) – JSON data -
refresh
()¶ Perform GET request through
self.client.get
toself.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.ResponseJson
Represents 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.ResponseJson
Represents 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.Resource
instance-
get_next_page
()¶ Get the resources of the next page, if any.
Returns: kloudless.resources.base.ResourceList
Raise: kloudless.exceptions.NoNextPage
-
get_paging_iterator
(max_resources=None)¶ Generator to iterate thorough all resources under
self.objects
and all resources in the following page, if any.If retrieving events,
self.latest_cursor
is available after iterating thorough all events withoutmax_resources
specified.Parameters: max_resources – the maximum quantity of resources that would be contained in the returned generator Returns: generator that yield kloudless.resources.base.Resource
instance
-