keystoneauth1.identity.v3.base module¶
- class keystoneauth1.identity.v3.base.Any(*args, **kwargs)
Bases:
objectSpecial type indicating an unconstrained type.
Any is assignable to every type.
Any assumed to have all methods and attributes.
All values are assignable to Any.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any cannot be used with instance checks.
- __annotations_cache__ = {}
- __dict__ = mappingproxy({'__module__': 'typing', '__firstlineno__': 588, '__doc__': 'Special type indicating an unconstrained type.\n\n- Any is assignable to every type.\n- Any assumed to have all methods and attributes.\n- All values are assignable to Any.\n\nNote that all the above statements are true from the point of view of\nstatic type checkers. At runtime, Any cannot be used with instance\nchecks.\n', '__new__': <staticmethod(<function Any.__new__>)>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'Any' objects>, '__weakref__': <attribute '__weakref__' of 'Any' objects>, '__annotations_cache__': {}})
- __doc__ = 'Special type indicating an unconstrained type.\n\n- Any is assignable to every type.\n- Any assumed to have all methods and attributes.\n- All values are assignable to Any.\n\nNote that all the above statements are true from the point of view of\nstatic type checkers. At runtime, Any cannot be used with instance\nchecks.\n'
- __firstlineno__ = 588
- __module__ = 'typing'
- static __new__(cls, *args, **kwargs)
- __static_attributes__ = ()
- __weakref__
list of weak references to the object
- class keystoneauth1.identity.v3.base.Auth(auth_url: str, auth_methods: list[AuthMethod], *, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
Bases:
BaseAuthIdentity V3 Authentication Plugin.
- Parameters:
auth_url – Identity service endpoint for authentication.
auth_methods – A collection of methods to authenticate with.
trust_id – Trust ID for trust scoping.
domain_id – Domain ID for domain scoping.
domain_name – Domain name for domain scoping.
project_id – Project ID for project scoping.
project_name – Project name for project scoping.
project_domain_id – Project’s domain ID for project.
project_domain_name – Project’s domain name for project.
reauthenticate – Allow fetching a new token if the current one is going to expire. (optional) default True
include_catalog – Include the service catalog in the returned token. (optional) default True.
unscoped – Force the return of an unscoped token. This will make the keystone server return an unscoped token even if a default_project_id is set for this user.
- __abstractmethods__ = frozenset({})
- __annotate_func__ = None
- __annotations_cache__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': 'str', 'interactive_unscoped_auth': 'ClassVar[bool]', 'reauthenticate': 'bool'}
- __doc__ = "Identity V3 Authentication Plugin.\n\n:param auth_url: Identity service endpoint for authentication.\n:param auth_methods: A collection of methods to authenticate with.\n:param trust_id: Trust ID for trust scoping.\n:param domain_id: Domain ID for domain scoping.\n:param domain_name: Domain name for domain scoping.\n:param project_id: Project ID for project scoping.\n:param project_name: Project name for project scoping.\n:param project_domain_id: Project's domain ID for project.\n:param project_domain_name: Project's domain name for project.\n:param reauthenticate: Allow fetching a new token if the current one is\n going to expire. (optional) default True\n:param include_catalog: Include the service catalog in the returned token.\n (optional) default True.\n:param unscoped: Force the return of an unscoped token. This will make the\n keystone server return an unscoped token even if a default_project_id\n is set for this user.\n"
- __firstlineno__ = 111
- __init__(auth_url: str, auth_methods: list[AuthMethod], *, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
- __module__ = 'keystoneauth1.identity.v3.base'
- __static_attributes__ = ('auth_methods', 'unscoped')
- _abc_impl = <_abc._abc_data object>
- _discovery_cache: dict[str, discover.Discover]
- add_method(method: AuthMethod) None
Add an additional initialized AuthMethod instance.
- auth_ref: access.AccessInfo | None
- auth_url: str
- get_auth_ref(session: Session) AccessInfoV3
Obtain a token from an OpenStack Identity Service.
This method is overridden by the various token version plugins.
This function should not be called independently and is expected to be invoked via the do_authenticate function.
This function will be invoked if the AcessInfo object cached by the plugin is not valid. Thus plugins should always fetch a new AccessInfo when invoked. If you are looking to just retrieve the current auth data then you should use get_access.
- Parameters:
session – A session object that can be used for communication.
- Raises:
keystoneauth1.exceptions.response.InvalidResponse – The response returned wasn’t appropriate.
keystoneauth1.exceptions.http.HttpError – An error from an invalid HTTP response.
- Returns:
Token access information.
- get_cache_id_elements() dict[str, str | None]
Get the elements for this auth plugin that make it unique.
As part of the get_cache_id requirement we need to determine what aspects of this plugin and its values that make up the unique elements.
This should be overridden by plugins that wish to allow caching.
- Returns:
A flat dict with a str key and str or None value. This is required as we feed these values into a hash. Pairs where the value is None are ignored in the hashed id.
- reauthenticate: bool
- class keystoneauth1.identity.v3.base.AuthConstructor(auth_url: str, *args: Any, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True, **kwargs: Any)
Bases:
AuthAbstract base class for creating an Auth Plugin.
The Auth Plugin created contains only one authentication method. This is generally the required usage.
An AuthConstructor creates an AuthMethod based on the method’s arguments and the auth_method_class defined by the plugin. It then creates the auth plugin with only that authentication method.
- __abstractmethods__ = frozenset({})
- __annotations_cache__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]], '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': 'str', 'interactive_unscoped_auth': 'ClassVar[bool]', 'reauthenticate': 'bool'}
- __doc__ = "Abstract base class for creating an Auth Plugin.\n\nThe Auth Plugin created contains only one authentication method. This\nis generally the required usage.\n\nAn AuthConstructor creates an AuthMethod based on the method's\narguments and the auth_method_class defined by the plugin. It then\ncreates the auth plugin with only that authentication method.\n"
- __firstlineno__ = 375
- __init__(auth_url: str, *args: Any, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True, **kwargs: Any)
- __module__ = 'keystoneauth1.identity.v3.base'
- __static_attributes__ = ()
- _abc_impl = <_abc._abc_data object>
- _auth_method_class: ClassVar[type[AuthMethod]]
- _discovery_cache: dict[str, discover.Discover]
- auth_ref: access.AccessInfo | None
- auth_url: str
- reauthenticate: bool
- class keystoneauth1.identity.v3.base.AuthMethod(**kwargs: object)
Bases:
objectOne part of a V3 Authentication strategy.
The v3 ‘/tokens’ API allow multiple methods to be presented when authentication against the server. Each one of these methods is implemented by an AuthMethod.
Note: When implementing an AuthMethod use keyword arguments to ensure they are supported by the MultiFactor auth plugin.
- __abstractmethods__ = frozenset({'get_auth_data'})
- __annotations_cache__ = {'_method_parameters': list[str] | None}
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__firstlineno__': 295, '__doc__': "One part of a V3 Authentication strategy.\n\nThe v3 '/tokens' API allow multiple methods to be presented when\nauthentication against the server. Each one of these methods is implemented\nby an AuthMethod.\n\nNote: When implementing an AuthMethod use keyword arguments to ensure they\nare supported by the MultiFactor auth plugin.\n", '_method_parameters': None, '__init__': <function AuthMethod.__init__>, '_extract_kwargs': <classmethod(<function AuthMethod._extract_kwargs>)>, 'get_auth_data': <function AuthMethod.get_auth_data>, 'get_cache_id_elements': <function AuthMethod.get_cache_id_elements>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'AuthMethod' objects>, '__weakref__': <attribute '__weakref__' of 'AuthMethod' objects>, '__abstractmethods__': frozenset({'get_auth_data'}), '_abc_impl': <_abc._abc_data object>, '__annotations_cache__': {'_method_parameters': list[str] | None}})
- __doc__ = "One part of a V3 Authentication strategy.\n\nThe v3 '/tokens' API allow multiple methods to be presented when\nauthentication against the server. Each one of these methods is implemented\nby an AuthMethod.\n\nNote: When implementing an AuthMethod use keyword arguments to ensure they\nare supported by the MultiFactor auth plugin.\n"
- __firstlineno__ = 295
- __init__(**kwargs: object)
- __module__ = 'keystoneauth1.identity.v3.base'
- __static_attributes__ = ()
- __weakref__
list of weak references to the object
- _abc_impl = <_abc._abc_data object>
- classmethod _extract_kwargs(kwargs: dict[str, object]) dict[str, object]
Remove parameters related to this method from other kwargs.
- _method_parameters: list[str] | None = None
Deprecated parameter for defining the parameters supported by the plugin. These should now be defined by typed class attributes.
- abstractmethod get_auth_data(session: Session, auth: Auth, headers: dict[str, str], request_kwargs: dict[str, object]) tuple[None, None] | tuple[str, Mapping[str, object]]
Return the authentication section of an auth plugin.
- Parameters:
session – The communication session.
auth – The auth plugin calling the method.
headers – The headers that will be sent with the auth request if a plugin needs to add to them.
- Returns:
The identifier of this plugin and a dict of authentication data for the auth type.
- get_cache_id_elements() dict[str, str | None]
Get the elements for this auth method that make it unique.
These elements will be used as part of the
keystoneauth1.plugin.BaseIdentityPlugin.get_cache_id()to allow caching of the auth plugin.Plugins should override this if they want to allow caching of their state.
To avoid collision or overrides the keys of the returned dictionary should be prefixed with the plugin identifier. For example the password plugin returns its username value as ‘password_username’.
- class keystoneauth1.identity.v3.base.BaseAuth(auth_url: str, *, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
Bases:
BaseIdentityPluginIdentity V3 Authentication Plugin.
- Parameters:
auth_url – Identity service endpoint for authentication.
trust_id – Trust ID for trust scoping.
system_scope – System information to scope to.
domain_id – Domain ID for domain scoping.
domain_name – Domain name for domain scoping.
project_id – Project ID for project scoping.
project_name – Project name for project scoping.
project_domain_id – Project’s domain ID for project.
project_domain_name – Project’s domain name for project.
reauthenticate – Allow fetching a new token if the current one is going to expire. (optional) default True
include_catalog – Include the service catalog in the returned token. (optional) default True.
- __abstractmethods__ = frozenset({'get_auth_ref'})
- __annotations_cache__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': <class 'str'>, 'interactive_unscoped_auth': 'ClassVar[bool]', 'reauthenticate': 'bool'}
- __doc__ = "Identity V3 Authentication Plugin.\n\n:param auth_url: Identity service endpoint for authentication.\n:param trust_id: Trust ID for trust scoping.\n:param system_scope: System information to scope to.\n:param domain_id: Domain ID for domain scoping.\n:param domain_name: Domain name for domain scoping.\n:param project_id: Project ID for project scoping.\n:param project_name: Project name for project scoping.\n:param project_domain_id: Project's domain ID for project.\n:param project_domain_name: Project's domain name for project.\n:param reauthenticate: Allow fetching a new token if the current one is\n going to expire. (optional) default True\n:param include_catalog: Include the service catalog in the returned token.\n (optional) default True.\n"
- __firstlineno__ = 37
- __init__(auth_url: str, *, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
- __module__ = 'keystoneauth1.identity.v3.base'
- __static_attributes__ = ('domain_id', 'domain_name', 'include_catalog', 'project_domain_id', 'project_domain_name', 'project_id', 'project_name', 'system_scope', 'trust_id')
- _abc_impl = <_abc._abc_data object>
- _discovery_cache: dict[str, discover.Discover]
- auth_ref: access.AccessInfo | None
- auth_url: str
- property has_scope_parameters: bool
Return true if parameters can be used to create a scoped token.
- reauthenticate: bool
- property token_url: str
The full URL where we will send authentication data.
- class keystoneauth1.identity.v3.base.Mapping
Bases:
CollectionA Mapping is a generic container for associating key/value pairs.
This class provides concrete generic implementations of all methods except for __getitem__, __iter__, and __len__.
- __abstractmethods__ = frozenset({'__getitem__', '__iter__', '__len__'})
- __annotations_cache__ = {}
- __contains__(key)
- __doc__ = 'A Mapping is a generic container for associating key/value\npairs.\n\nThis class provides concrete generic implementations of all\nmethods except for __getitem__, __iter__, and __len__.\n'
- __eq__(other)
Return self==value.
- __firstlineno__ = 775
- abstractmethod __getitem__(key)
- __hash__ = None
- __module__ = 'collections.abc'
- __reversed__ = None
- __slots__ = ()
- __static_attributes__ = ()
- _abc_impl = <_abc._abc_data object>
- get(k[, d]) D[k] if k in D, else d. d defaults to None.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- values() an object providing a view on D's values
- class keystoneauth1.identity.v3.base.Protocol
Bases:
GenericBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- __abstractmethods__ = frozenset({})
- __annotate_func__ = None
- __annotations_cache__ = {}
- __doc__ = 'Base class for protocol classes.\n\nProtocol classes are defined as::\n\n class Proto(Protocol):\n def meth(self) -> int:\n ...\n\nSuch classes are primarily used with static type checkers that recognize\nstructural subtyping (static duck-typing).\n\nFor example::\n\n class C:\n def meth(self) -> int:\n return 0\n\n def func(x: Proto) -> int:\n return x.meth()\n\n func(C()) # Passes static type check\n\nSee PEP 544 for details. Protocol classes decorated with\n@typing.runtime_checkable act as simple-minded runtime protocols that check\nonly the presence of given attributes, ignoring their type signatures.\nProtocol classes can be generic, they are defined as::\n\n class GenProto[T](Protocol):\n def meth(self) -> T:\n ...\n'
- __firstlineno__ = 2099
- classmethod __init_subclass__(*args, **kwargs)
Function to initialize subclasses.
- __module__ = 'typing'
- __parameters__ = ()
- __protocol_attrs__ = {}
- __slots__ = ()
- __static_attributes__ = ()
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- _is_runtime_protocol = False
- class keystoneauth1.identity.v3.base.SupportsMultiFactor(*args, **kwargs)
Bases:
Protocol- __abstractmethods__ = frozenset({})
- __annotate_func__()
The type of the None singleton.
- __annotations_cache__ = {'_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]]}
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__firstlineno__': 370, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'SupportsMultiFactor' objects>, '__weakref__': <attribute '__weakref__' of 'SupportsMultiFactor' objects>, '__doc__': None, '__parameters__': (), '_is_protocol': True, '__subclasshook__': <classmethod(<function _proto_hook>)>, '__init__': <function _no_init_or_replace_init>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations_cache__': {'_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]]}, '__protocol_attrs__': {'_auth_method_class'}, '_is_runtime_protocol': True, '__non_callable_proto_members__': {'_auth_method_class'}})
- __doc__ = None
- __firstlineno__ = 370
- __init__(*args, **kwargs)
- __module__ = 'keystoneauth1.identity.v3.base'
- __non_callable_proto_members__ = {'_auth_method_class'}
- __parameters__ = ()
- __protocol_attrs__ = {'_auth_method_class'}
- __static_attributes__ = ()
- classmethod __subclasshook__(other)
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- __weakref__
list of weak references to the object
- _abc_impl = <_abc._abc_data object>
- _auth_method_class: ClassVar[type[AuthMethod]]
- _is_protocol = True
- _is_runtime_protocol = True
- keystoneauth1.identity.v3.base.TypedDict(typename, fields=<sentinel>, /, *, total=True)
A simple typed namespace. At runtime it is equivalent to a plain dict.
TypedDict creates a dictionary type such that a type checker will expect all instances to have a certain set of keys, where each key is associated with a value of a consistent type. This expectation is not checked at runtime.
Usage:
>>> class Point2D(TypedDict): ... x: int ... y: int ... label: str ... >>> a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK >>> b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check >>> Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') True
The type info can be accessed by calling annotationlib.get_annotations(Point2D), and via the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets. TypedDict supports an additional equivalent form:
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
By default, all keys must be present in a TypedDict. It is possible to override this by using the NotRequired and Required special forms:
class Point2D(TypedDict): x: int # the "x" key must always be present (Required is the default) y: NotRequired[int] # the "y" key can be omitted
This means that a Point2D TypedDict can have the “y” key omitted, but the “x” key must be present. Items are required by default, so the Required special form is not necessary in this example. In addition, the total argument to the TypedDict function can be used to make all items not required:
class Point2D(TypedDict, total=False): x: int y: int
This means that a Point2D TypedDict can have any of the keys omitted. A type checker is only expected to support a literal False or True as the value of the total argument. True is the default, and makes all items defined in the class body be required. The Required special form can be used to mark individual keys as required in a total=False TypedDict.
The ReadOnly special form can be used to mark individual keys as immutable for type checkers:
class DatabaseUser(TypedDict): id: ReadOnly[int] # the "id" key must not be modified username: str # the "username" key can be changed
See PEPs 589, 655, and 705 for more information.
- class keystoneauth1.identity.v3.base._AuthBody
Bases:
TypedDict- __annotate_func__()
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__firstlineno__': 107, '__static_attributes__': (), '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of '_AuthBody' objects>, '__weakref__': <attribute '__weakref__' of '_AuthBody' objects>, '__doc__': None, '__required_keys__': frozenset({'auth'}), '__optional_keys__': frozenset(), '__readonly_keys__': frozenset(), '__mutable_keys__': frozenset({'auth'}), '__total__': True, '__annotations_cache__': {'auth': <class 'keystoneauth1.identity.v3.base._AuthIdentity'>}})
- __doc__ = None
- __firstlineno__ = 107
- __module__ = 'keystoneauth1.identity.v3.base'
- __mutable_keys__ = frozenset({'auth'})
- __optional_keys__ = frozenset({})
- __orig_bases__ = (<function TypedDict>,)
- __readonly_keys__ = frozenset({})
- __required_keys__ = frozenset({'auth'})
- __static_attributes__ = ()
- __total__ = True
- __weakref__
list of weak references to the object
- auth: _AuthIdentity
- class keystoneauth1.identity.v3.base._AuthIdentity
Bases:
TypedDict- __annotate_func__()
- __dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__firstlineno__': 102, '__static_attributes__': (), '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of '_AuthIdentity' objects>, '__weakref__': <attribute '__weakref__' of '_AuthIdentity' objects>, '__doc__': None, '__required_keys__': frozenset({'identity'}), '__optional_keys__': frozenset({'scope'}), '__readonly_keys__': frozenset(), '__mutable_keys__': frozenset({'identity', 'scope'}), '__total__': True, '__annotations_cache__': {'identity': dict[str, typing.Any], 'scope': typing.NotRequired[dict[str, typing.Any] | str]}})
- __doc__ = None
- __firstlineno__ = 102
- __module__ = 'keystoneauth1.identity.v3.base'
- __mutable_keys__ = frozenset({'identity', 'scope'})
- __optional_keys__ = frozenset({'scope'})
- __orig_bases__ = (<function TypedDict>,)
- __readonly_keys__ = frozenset({})
- __required_keys__ = frozenset({'identity'})
- __static_attributes__ = ()
- __total__ = True
- __weakref__
list of weak references to the object
- identity: dict[str, Any]
- scope: NotRequired[dict[str, Any] | str]
- keystoneauth1.identity.v3.base.runtime_checkable(cls)
Mark a protocol class as a runtime protocol.
Such protocol can be used with isinstance() and issubclass(). Raise TypeError if applied to a non-protocol class. This allows a simple-minded structural check very similar to one-trick ponies in collections.abc such as Iterable.
For example:
@runtime_checkable class Closable(Protocol): def close(self): ... assert isinstance(open('/some/file'), Closable)
Warning: this will check only the presence of the required methods, not their type signatures!