rbtools.api.factory¶
Resource creation method(s).
Functions
|
Construct and return a resource object. |
- rbtools.api.factory.create_resource(*, transport: Transport, payload: JSONDict, url: str, mime_type: str | None = None, item_mime_type: str | None = None, guess_token: bool = True, force_resource_type: type[Resource] | None = None) Resource[source]¶
Construct and return a resource object.
Changed in version 6.0:
Added the
force_resource_typeargument.Made all arguments keyword-only.
- Parameters:
transport (
rbtools.api.transport.Transport) – The API transport.payload (
dict) – The payload returned from the API endpoint.url (
str) – The URL of the API endpoint.mime_type (
str, optional) – The MIME type of the API response. This is used to find a resource specific class. If no resource specific class exists, one of the generic base classes (ResourceorResourceList) will be used.item_mime_type (
str, optional) – The MIME type to use when constructing individual items within a list resource.guess_token (
bool, optional) – Whether to guess the key for the API response body. IfFalse, we assume that the resource body is the body of the payload itself. This is important for constructing item resources from a resource list.force_resource_type (
type, optional) –The resource class to instantiate.
Added in version 6.0.
- Returns:
The resource instance.
- Return type:
rbtools.api.resource.Resource