djblets.webapi.resources.user¶
Built-in resource representing the User model.
- class UserResource[source]¶
Bases:
WebAPIResource
A default resource for representing a Django User model.
- fields: Mapping[str, Union[WebAPIResourceFieldInfo, Mapping[str, Any]]] = {'email': {'description': "The user's e-mail address", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'first_name': {'description': "The user's first name.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'fullname': {'description': "The user's full name (first and last).", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'id': {'description': 'The numeric ID of the user.', 'type': <class 'djblets.webapi.fields.IntFieldType'>}, 'last_name': {'description': "The user's last name.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'url': {'description': "The URL to the user's page on the site. This is deprecated and will be removed in a future version.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'username': {'description': "The user's username.", '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
model
or defined as aserialize_<fieldname>_field
method.- Type:
- uri_object_key: Optional[str] = 'username'[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 = 'username'[source]¶
The key on the provided model for matching an object key.
This is used when
model
is set, allowing API resources to automatically query for a model instance matching this model key to the value in the URL corresponding touri_object_key
.- Type:
- autogenerate_etags: bool = True[source]¶
Whether to auto-generate ETags for responses.
If set, and an ETag is not otherwise provided, one will be generated based on the response payload.
- Type:
- allowed_methods: Sequence[str] = ('GET',)[source]¶
A list of HTTP methods that are allowed on this resource.
Subclasses must have resource handlers defined for each allowed HTTP method.
- has_modify_permissions(request, user, *args, **kwargs)[source]¶
Return whether or not the user can modify this object.
- __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'}¶