aiolxd.api.resource¶
API resources base classes.
-
class
aiolxd.api.resource.
Collection
(resource_collection, name='')¶ Property to wrap an ResourceCollection.
Parameters: - resource_collection (ResourceCollection) – the resource collection to wrap.
- name (str) – the name of the collection in the API (if not specified, the name of the attribute for the Collection is used).
-
class
aiolxd.api.resource.
NamedResource
(remote, uri)¶ A resource with a name.
Named resouces can be renamed via
rename()
call.-
id_attribute
= 'name'¶
-
rename
(name)¶ Rename an resource with the specified name.
This updates the URI of this resource to the new one.
-
-
class
aiolxd.api.resource.
Resource
(remote, uri)¶ An API resource.
-
delete
()¶ Delete this resource.
-
details
()¶ Return details about this resource.
If a previous read() operation has been performed for this resouce, details from the response are returned, otherwise
None
is returned.
-
id
¶ Return the unique identifier for a resource.
-
id_attribute
¶ Name of the attribute that uniquely identifies this resource
-
classmethod
id_from_details
(details)¶ Return the ID for a resource from details.
-
read
()¶ Return details for this resource.
-
replace
(details, etag=True)¶ Replace resource details.
If etag is True, ETag header is set with value from last read() call, if available.
-
update
(details, etag=True)¶ Update resource details.
If etag is True, ETag header is set with value from last read() call, if available.
-
update_details
(details)¶ Update deatils for the resource.
-
-
class
aiolxd.api.resource.
ResourceCollection
(remote, uri, raw=False)¶ A collection for API resources of a type.
-
create
(details)¶ Create a new resource in the collection.
-
get
(id)¶ Return a single resource in the collection.
This performs a
GET
call to fetch resource details.
-
get_resource
(id)¶ Return a resource with the specified ID.
-
raw
()¶ Return a copy of this collection which returns raw responses.
-
read
(recursion=False)¶ Return resources for this collection.
If recursion is True, details for resources are fetched in a single request.
-
resource_class
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
…
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): … def setx(self, value): … x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
resource_from_details
(details)¶ Return an instance of a resource for the collection from details.
-