# api.APIKey ## Model Info | Key | Value | |---|-----| | Model Name | APIKey | | Verbose Name | api key | | Verbose Name Plural | api keys | | Docstring | <p>A developer's key/secret pair to access the API.</p> | | Is Abstract | False | | Is Proxy | False | | Is Managed | True | | Ordering | [] | | Permissions | [] | | Default Permissions | ('add', 'change', 'delete', 'view') | | Indexes | [<Index: fields=['user'] name='api_key_user_id'>] | | Constraints | [<UniqueConstraint: fields=('user', 'is_active') name='user_id'>] | | Database Table | api_key | | Base Manager | None | | Default Manager | None | | File | /data/olympia/src/olympia/api/models.py | | Starting Line Number | 30 | | Method Resolution Order | (<class 'olympia.api.models.APIKey'>, <class 'olympia.amo.models.ModelBase'>, <class 'olympia.amo.models.SaveUpdateMixin'>, <class 'django.db.models.base.Model'>, <class 'django.db.models.utils.AltersData'>, <class 'object'>) | ## Fields | Field Name | Field Type | Database Column | Database Type | Verbose Name | |----------|----------|---------------|-------------|------------| | `created` | DateTimeField | created | datetime(6) | created | | `id (pk)` | PositiveAutoField | id | integer UNSIGNED AUTO_INCREMENT | id | | `is_active` | BooleanField | is_active | bool | is active | | `key` | CharField | key | varchar(255) | key | | `modified` | DateTimeField | modified | datetime(6) | modified | | `secret` | AESField | secret | longtext | secret | | `type` | PositiveIntegerField | type | integer UNSIGNED | type | | `user` | ForeignKey | user_id | integer | user | ## Relations | Field Name | Field Type | Database Column | Database Type | Related Model | Related Name | |----------|----------|---------------|-------------|-------------|------------| | `user` | ForeignKey | user_id | integer | users.UserProfile | api_keys | fields_reverse_relation=[] ## Methods ### Other Methods | Method Name | Signature | |-----------|---------| | `generate_secret` | `(byte_length)` | | `get_admin_absolute_url` | `(self)` | | `get_admin_url_path` | `(self)` | | `get_jwt_key` | `(**kwargs)` | | `get_next_by_created` | `(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)` | | `get_next_by_modified` | `(self, *, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)` | | `get_previous_by_created` | `(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)` | | `get_previous_by_modified` | `(self, *, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)` | | `get_type_display` | `(self, *, field=<django.db.models.fields.PositiveIntegerField: type>)` | | `get_unfiltered_manager` | `()` | | `get_unique_key` | `(prefix, try_count=1, max_tries=1000)` | | `new_jwt_credentials` | `(user)` | | `reload` | `(self)` | | `serializable_reference` | `(self)` | | `update` | `(self, **kw)` | ### Private Methods | Method Name | Signature | |-----------|---------| | `_get_field_value_map` | `(self, meta, exclude=None)` | ## Custom Managers ### default **Class:** `ManagerBase` *Base for all managers in AMO. Returns BaseQuerySets. If a model has translated fields, they'll be attached through a transform function.* #### Custom Methods ##### `transform(self, fn)` #### Custom QuerySet **Class:** `BaseQuerySet` *Represent a lazy database lookup for a set of objects.* ##### Custom Methods ###### `no_transforms(self)` ###### `only_translations(self)` *Remove all transforms except translations.* ###### `optimized_count(self)` *Slightly optimized count() for cases where there is a DISTINCT in the queryset. When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That's tracked in https://code.djangoproject.com/ticket/30685. We can't easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.* ###### `pop_transforms(self)` ###### `transform(self, fn)` ### objects **Class:** `ManagerBase` *Base for all managers in AMO. Returns BaseQuerySets. If a model has translated fields, they'll be attached through a transform function.* #### Custom Methods ##### `transform(self, fn)` #### Custom QuerySet **Class:** `BaseQuerySet` *Represent a lazy database lookup for a set of objects.* ##### Custom Methods ###### `no_transforms(self)` ###### `only_translations(self)` *Remove all transforms except translations.* ###### `optimized_count(self)` *Slightly optimized count() for cases where there is a DISTINCT in the queryset. When a count() call is made on a queryset that has a distinct, that causes django to run the full SELECT (including all fields, distinct, ordering etc) in a subquery and then COUNT() on the result of that subquery, which is costly/innefficient. That's tracked in https://code.djangoproject.com/ticket/30685. We can't easily fix the fact that there is a subquery, but we can avoid selecting all fields and ordering in that subquery needlessly.* ###### `pop_transforms(self)` ###### `transform(self, fn)` --- !!! THIS DOCUMENT WAS *AUTOGENERATED* ON 2025-07-29 !!!