djblets.webapi.resources.user¶
Built-in resource representing the User model.
- class UserResource[source]¶
Bases:
WebAPIResourceA default resource for representing a Django User model.
- fields: ClassVar[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
modelor defined as aserialize_<fieldname>_fieldmethod.- Type:
- uri_object_key: ClassVar[str | None] = 'username'[source]¶
The key to populate with the ID of an object in an item resource.
- Type:
- uri_object_key_regex: ClassVar[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: ClassVar[str] = 'username'[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 touri_object_key.- Type:
- autogenerate_etags: ClassVar[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: ClassVar[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.
- get_list(request: HttpRequest, *args, api_format: str | None, **kwargs) WebAPIResourceHandlerResult[source]¶
Retrieve the list of users on the site.
- __annotations__ = {'_parent_resource': 'WebAPIResource | None', '_prefetch_related_fields': 'list[str]', '_select_related_fields': 'list[str]', 'allowed_methods': 'ClassVar[Sequence[str]]', 'allowed_mimetypes': 'ClassVar[Sequence[AllowedMimetypeEntry]]', 'autogenerate_etags': 'ClassVar[bool]', 'etag_field': 'ClassVar[str | None]', 'fields': 'ClassVar[Mapping[str, Union[WebAPIResourceFieldInfo, Mapping[str, Any]]]]', 'is_webapi_handler': 'Final[bool]', 'item_child_resources': 'ClassVar[Sequence[WebAPIResource]]', 'last_modified_field': 'ClassVar[str | None]', 'list_child_resources': 'ClassVar[Sequence[WebAPIResource]]', 'method_mapping': 'ClassVar[Mapping[str, str]]', 'mimetype_item_resource_name': 'ClassVar[str | None]', 'mimetype_list_resource_name': 'ClassVar[str | None]', 'mimetype_vendor': 'ClassVar[str | None]', 'model': 'ClassVar[type[Model] | None]', 'model_object_key': 'ClassVar[str]', 'model_parent_key': 'ClassVar[str | None]', 'paginated_cls': 'ClassVar[type[WebAPIResponsePaginated]]', 'singleton': 'ClassVar[bool]', 'uri_object_key': 'ClassVar[str | None]', 'uri_object_key_regex': 'ClassVar[str]'}¶