djblets.webapi.models¶
- class BaseWebAPIToken(*args, **kwargs)¶
Bases:
Model
Base class for an access token used for authenticating with the API.
Each token can be used to authenticate the token’s owner with the API, without requiring a username or password to be provided. Tokens can be revoked, and new tokens added.
Tokens can store policy information, which will later be used for restricting access to the API.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- token¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- token_generator_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- time_added¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_updated¶
A descriptor for tracking the modification of a value.
- last_used¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- expires¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- valid¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- invalid_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- invalid_reason¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- note¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- policy¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- extra_data¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_accessible_by(user)¶
- is_mutable_by(user)¶
- is_deletable_by(user)¶
- is_deprecated() bool ¶
Return whether the token is deprecated or not.
This will be
True
if the token was generated by a deprecated token generator.New in version 3.1.
- Returns:
Whether the token is deprecated.
- Return type:
- is_expired() bool ¶
Return whether the token is expired or not.
This will be
False
if there is no expiration date set.New in version 3.0.
- Returns:
Whether the token is expired.
- Return type:
- __str__()¶
Return str(self).
- save(*args, **kwargs)¶
Save the token.
If the token is being updated, the
webapi_token_updated
signal will be emitted.
- classmethod get_root_resource()¶
- classmethod validate_policy(policy)¶
Validate an API policy.
This will check to ensure that the policy is in a suitable format and contains the information required in a format that can be parsed.
If a failure is found, a ValidationError will be raised describing the error and where it was found.
- class Meta¶
Bases:
object
- abstract = False¶
- verbose_name = 'Web API token'¶
- verbose_name_plural = 'Web API tokens'¶
- __annotations__ = {}¶
- get_extra_data_json()¶
- get_next_by_last_updated(*, field=<djblets.db.fields.modification_timestamp_field.ModificationTimestampField: last_updated>, is_next=True, **kwargs)¶
- get_next_by_time_added(*, field=<django.db.models.fields.DateTimeField: time_added>, is_next=True, **kwargs)¶
- get_policy_json()¶
- get_previous_by_last_updated(*, field=<djblets.db.fields.modification_timestamp_field.ModificationTimestampField: last_updated>, is_next=False, **kwargs)¶
- get_previous_by_time_added(*, field=<django.db.models.fields.DateTimeField: time_added>, is_next=False, **kwargs)¶
- set_extra_data_json(json)¶
- set_policy_json(json)¶
- user_id¶