djblets.extensions.resources¶
- class ExtensionResource(extension_manager)[source]¶
- Bases: - WebAPIResource- Provides information on installed extensions. - model[source]¶
- alias of - RegisteredExtension
 - fields: Mapping[str, Union[WebAPIResourceFieldInfo, Mapping[str, Any]]] = {'author': {'description': 'The author of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'author_url': {'description': "The author's website.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'can_disable': {'description': 'Whether or not the extension can be disabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'can_enable': {'description': 'Whether or not the extension can be enabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'class_name': {'description': 'The class name for the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'enabled': {'description': 'Whether or not the extension is enabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'installed': {'description': 'Whether or not the extension is installed.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'load_error': {'description': 'If the extension could not be loaded, this will contain any errors captured while trying to load.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'loadable': {'description': 'Whether or not the extension is currently loadable. An extension may be installed but missing or may be broken due to a bug.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'name': {'description': 'The name of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'summary': {'description': "A summary of the extension's functionality.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'version': {'description': 'The installed version of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}}[source]¶
- A mapping of field names to definitions for any serialized objects. - Each key should be a field name either present in - modelor defined as a- serialize_<fieldname>_fieldmethod.- Type:
 
 - uri_object_key: Optional[str] = 'extension_name'[source]¶
- The key to populate with the ID of an object in an item resource. - Type:
 
 - uri_object_key_regex: str = '[.A-Za-z0-9_-]+'[source]¶
- A regex for mapping keys for an object in an item resource. - By default, this matches integers. Subclasses can override this to match IDs with other values. - Type:
 
 - model_object_key: str = 'class_name'[source]¶
- The key on the provided model for matching an object key. - This is used when - modelis set, allowing API resources to automatically query for a model instance matching this model key to the value in the URL corresponding to- uri_object_key.- Type:
 
 - allowed_methods: Sequence[str] = ('GET', 'PUT')[source]¶
- A list of HTTP methods that are allowed on this resource. - Subclasses must have resource handlers defined for each allowed HTTP method. 
 - __init__(extension_manager)[source]¶
- Initialize the API resource. - This will register the resource and set up state required for processing API requests. 
 - get_list(request, *args, **kwargs)[source]¶
- Returns the list of known extensions. - Each extension in the list has been installed, but may not be enabled. 
 - get_links(resources=[], obj=None, request=None, *args, **kwargs)[source]¶
- Return a dictionary of links coming off this resource. - The resulting links will point to the resources passed in - resources, and will also provide special resources for- self(which points back to the official location for this resource) and one per HTTP method/operation allowed on this resource.- Parameters:
- resources ( - listof- WebAPIResource, optional) – A list of resources for which to generate additional links.
- obj ( - object, optional) – The object being serialized, for use as a base for resource URLs.
- *args ( - tuple) – Additional positional arguments passed to the view.
- request ( - django.http.HttpRequest) – The HTTP request from the client.
- **kwargs ( - dict) – Keyword arguments representing values captured from the URL.
 
- Returns:
- A dictionary of link names to link information. 
- Return type:
 
 - update(request, *args, **kwargs)[source]¶
- Updates the state of the extension. - If - enabledis true, then the extension will be enabled, if it is not already. If false, it will be disabled.
 - get_url_patterns()[source]¶
- Return the Django URL patterns for this object and its children. - This is used to automatically build up the URL hierarchy for all objects. Projects should call this for top-level resources and return them in the - urls.pyfiles.- Returns:
- The list of URL patterns. 
- Return type:
 
 - Returns links to the resources provided by the extension. - The result should be a dictionary of link names to a dictionary of information. The information should contain: - ‘method’ - The HTTP method 
- ‘href’ - The URL 
- ‘title’ - The title of the link (optional) 
- ‘resource’ - The WebAPIResource instance 
- ‘list-resource’ - True if this links to a list resource (optional) 
 
 - __annotations__ = {'_parent_resource': 'Optional[WebAPIResource]', '_prefetch_related_fields': 'List[str]', '_select_related_fields': 'List[str]', 'allowed_methods': 'Sequence[str]', 'allowed_mimetypes': 'Sequence[AllowedMimetypeEntry]', 'autogenerate_etags': 'bool', 'etag_field': 'Optional[str]', 'fields': 'Mapping[str, Union[WebAPIResourceFieldInfo, Mapping[str, Any]]]', 'is_webapi_handler': 'Final[bool]', 'item_child_resources': 'Sequence[WebAPIResource]', 'last_modified_field': 'Optional[str]', 'list_child_resources': 'Sequence[WebAPIResource]', 'method_mapping': 'Mapping[str, str]', 'mimetype_item_resource_name': 'Optional[str]', 'mimetype_list_resource_name': 'Optional[str]', 'mimetype_vendor': 'Optional[str]', 'model': 'Optional[Type[Model]]', 'model_object_key': 'str', 'model_parent_key': 'Optional[str]', 'paginated_cls': 'Type[WebAPIResponsePaginated]', 'singleton': 'bool', 'uri_object_key': 'Optional[str]', 'uri_object_key_regex': 'str'}¶
 
- class ExtensionRootResourceMixin(*args, **kwargs)[source]¶
- Bases: - object- Mixin for Root Resources making use of Extension Resources. - As extensions are able to provide their own API resources, this mixin allows a root resource to generate URI templates for non built-in resources. - See also 
