django-esi¶
The django-esi package provides an interface for easy access to the ESI.
Location: esi
This is an external package. Please also see here for it’s official documentation.
clients¶
-
esi_client_factory
(token=None, datasource: Optional[str] = None, spec_file: Optional[str] = None, version: Optional[str] = None, app_info_text: Optional[str] = None, **kwargs) → bravado.client.SwaggerClient¶ Generate a new ESI client.
- Parameters
token (esi.models.Token) – used to access authenticated endpoints.
datasource – Name of the ESI datasource to access.
spec_file – Absolute path to a swagger spec file to load.
version – Base ESI API version. Accepted values are ‘legacy’, ‘latest’,
app_info_text – Text identifying the application using ESI which will be included in the User-Agent header. Should contain name and version of the application using ESI. e.g. “my-app v1.0.0”. Note that spaces are used as delimiter.
kwargs – Explicit resource versions to build, in the form Character=’v4’. Same values accepted as version.
If a spec_file is specified, specific versioning is not available. Meaning the version and resource version kwargs are ignored in favour of the versions available in the spec_file.
- Returns
New ESI client
decorators¶
-
single_use_token
(scopes='', new=False)¶ Decorator for views which supplies a single use token granted via sso login regardless of login state. Same parameters as tokens_required.
-
token_required
(scopes='', new=False)¶ Decorator for views which supplies a single, user-selected token for the view to process. Same parameters as tokens_required.
-
tokens_required
(scopes='', new=False)¶ Decorator for views to request an ESI Token. Accepts required scopes as a space-delimited string or list of strings of scope names. Can require a new token to be retrieved by SSO. Returns a QueryDict of Tokens.
errors¶
-
exception
DjangoEsiException
¶
-
exception
IncompleteResponseError
¶
-
exception
NotRefreshableTokenError
¶
-
exception
TokenError
¶
-
exception
TokenExpiredError
¶
-
exception
TokenInvalidError
¶
models¶
-
class
Scope
(*args, **kwargs)¶ Represents an access scope granted by SSO.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
property
friendly_name
¶
-
help_text
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
token_set
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
exception
-
class
Token
(*args, **kwargs)¶ EVE Swagger Interface Access Token
Contains information about the authenticating character and scopes granted to this token. Contains the access token required for ESI authentication as well as refreshing.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
access_token
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
callbackredirect_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
property
can_refresh
¶ Determine if this token can be refreshed upon expiry.
-
character_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
character_name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
character_owner_hash
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
corpstats_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
created
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
property
expired
¶ Determines if this token has expired.
-
property
expires
¶ Determines when this token expires.
- Returns
Date & time when this token expires
-
get_esi_client
(**kwargs) → bravado.client.SwaggerClient¶ Creates an authenticated ESI client with this token.
- Parameters
**kwargs – Extra spec versioning as per
esi.clients.esi_client_factory
- Returns
New ESI client
-
get_next_by_created
(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)¶
-
get_previous_by_created
(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)¶
-
classmethod
get_token
(character_id: int, scopes: list) → esi.models.Token¶ Helper method to get a token for a specific character with specific scopes.
- Parameters
character_id – Character to filter on.
scopes – array of ESI scope strings to search for.
- Returns
Matching token or False when token is not found
-
classmethod
get_token_data
(access_token)¶
-
get_token_type_display
(*, field=<django.db.models.fields.CharField: token_type>)¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
refresh
(session: Optional[requests_oauthlib.oauth2_session.OAuth2Session] = None, auth: Optional[requests.auth.HTTPBasicAuth] = None) → None¶ Refresh this token.
- Parameters
session – session for refreshing token with
auth – ESI authentication
-
refresh_token
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
scopes
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
sso_version
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
token_type
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
update_token_data
(commit=True)¶
-
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.
-
user_id
¶
-
valid_access_token
() → str¶ Refresh and return access token to be used in an authed ESI call.
Example
# fetch medals for a character medals = esi.client.Character.get_characters_character_id_medals( # required parameter for endpoint character_id = token.character_id, # provide a valid access token, which will be refreshed if required token = token.valid_access_token() ).results()
- Returns
Valid access token
- Raises
TokenExpiredError – When token can not be refreshed
-
exception