qcs_api_client.client._configuration#
Submodules#
Package Contents#
Classes#
A user's settings and secrets along with a specified profile name. |
|
The user's full set of QCS secrets. |
|
A set of credentials containing a |
|
TokenPayload represents a response from the OAuth2 POST /token endpoint. |
|
Generic enumeration. |
|
Specifies an OAuth2 authorization server against which to refresh tokens. |
|
A fully parsed settings configuration file. |
|
Specifies the authorization server, credentials, and API URL. |
|
Section of a profile specifying per-application settings. |
|
- class qcs_api_client.client._configuration.QCSClientConfiguration#
Bases:
pydantic.main.BaseModelA user’s settings and secrets along with a specified profile name.
This class contains a full representation of user specified
QCSClientConfigurationSecretsandQCSClientConfigurationSettings, as well as aprofile_namewhich indicates whichQCSClientConfigurationSettingsProfileto access withinQCSClientConfigurationSettings.profiles.Typically, clients will simply call
QCSClientConfiguration.load, to initialize this class from the specified secrets and settings paths.- profile_name :str#
- secrets :qcs_api_client.client._configuration.secrets.QCSClientConfigurationSecrets#
- settings :qcs_api_client.client._configuration.settings.QCSClientConfigurationSettings#
- property auth_server qcs_api_client.client._configuration.settings.QCSAuthServer#
Returns the configured authorization server.
self.profile.auth_server_nameserves as key toQCSClientConfigurationSettings.auth_servers.- Returns
The specified
QCSAuthServer.- Raises
QCSClientConfigurationError – If
QCSClientConfigurationSettings.auth_serversdoes not have a value for the authorization server name.
- property credentials qcs_api_client.client._configuration.secrets.QCSClientConfigurationSecretsCredentials#
Returns the configured
QCSClientConfigurationSecretsCredentialsself.profile.credentials_nameserves as key toQCSClientConfigurationSecrets.credentials.- Returns
The specified
QCSClientConfigurationSecretsCredentials.- Raises
QCSClientConfigurationError – If
QCSClientConfigurationSettings.credentialsdoes not have a value for the specified credentials name.
- property profile qcs_api_client.client._configuration.settings.QCSClientConfigurationSettingsProfile#
Returns the configured
QCSClientConfigurationSettingsProfile.self.profile_name serves as key to
QCSClientConfigurationSettingsProfile.profiles.- Returns
The specified
QCSClientConfigurationSettingsProfile.- Raises
QCSClientConfigurationError – If
QCSClientConfigurationSettings.profilesdoes not have a value for the specified profile name.
- classmethod load(profile_name: Optional[str] = None, settings_file_path: Optional[os.PathLike] = None, secrets_file_path: Optional[os.PathLike] = None) QCSClientConfiguration#
Loads a fully specified
QCSClientConfigurationfrom file.It evaluates attribute values according to the following precedence: argument value > environment variable > default value.
- Parameters
profile_name – [env: QCS_PROFILE_NAME] The name of the profile referenced in the fully parsed
QCSClientConfigurationSettings.profiles. If the profile name does not exist onQCSClientConfigurationSettings,QCSClientConfiguration.profilewill raise an error. The default value is “default”, which may be overridden byQCSClientConfigurationSettings.default_profile_name.settings_file_path – [env: QCS_SETTINGS_FILE_PATH] The file path from which to parse
QCSClientConfigurationSettings. This file must exist in TOML format. The default value is~/.qcs/settings.toml.secrets_file_path – [env: QCS_SECRETS_FILE_PATH] The file path from which to parse
QCSClientConfigurationSecrets. This file must exist in TOML format. The default value is~/.qcs/secrets.toml.
- Returns
A fully specified
QCSClientConfiguration, whichQCSAuthmay use for adding refreshed OAuth2 access tokens to outgoing HTTP requests.
- exception qcs_api_client.client._configuration.QCSClientConfigurationError#
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class qcs_api_client.client._configuration.QCSClientConfigurationSecrets#
Bases:
qcs_api_client.client._configuration.file.QCSClientConfigurationFileThe user’s full set of QCS secrets.
This class maps
QCSClientConfigurationSecretsCredentialsby user specified names. Each set of credentials, in turn, contains aTokenPayload.- credentials :Dict[str, QCSClientConfigurationSecretsCredentials]#
- update_token(*, credentials_name: str, token: TokenPayload) None#
Update the value of a token payload in memory and (if appropriate) on disk.
- class qcs_api_client.client._configuration.QCSClientConfigurationSecretsCredentials#
Bases:
pydantic.BaseModelA set of credentials containing a
TokenPayload.- token_payload :Optional[TokenPayload]#
- property access_token Optional[str]#
- property refresh_token Optional[str]#
- class qcs_api_client.client._configuration.TokenPayload#
Bases:
pydantic.BaseModelTokenPayload represents a response from the OAuth2 POST /token endpoint.
It contains an access_token which may be set as a Bearer token in the Authorization header on HTTP requests to the QCS API.
QCSAuthwill use therefresh_tokento refresh theaccess_tokenif the token expires.- refresh_token :Optional[str]#
- access_token :Optional[str]#
- scope :Optional[str]#
- expires_in :Optional[int]#
- id_token :Optional[str]#
- token_type :Optional[str]#
- get_access_token_claims(key: Union[None, bytes, str] = None)#
Return the claims within the encoded access token.
If a JWK is provided as
key, verify the claims as well. If no key is provided, be aware that the returned claims might be forged or invalid.
- property access_token_expires_at Optional[datetime.datetime]#
Return the datetime that the token expires (if any).
- should_refresh() bool#
Return True if the token is past or nearing expiration and should be refreshed.
- class qcs_api_client.client._configuration.QCSAccountType#
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- user = user#
- group = group#
- class qcs_api_client.client._configuration.QCSAuthServer#
Bases:
pydantic.BaseModelSpecifies an OAuth2 authorization server against which to refresh tokens.
- client_id :str#
- issuer :str#
- authorize_url()#
- token_url()#
- static scopes()#
- class qcs_api_client.client._configuration.QCSClientConfigurationSettings#
Bases:
qcs_api_client.client._configuration.file.QCSClientConfigurationFileA fully parsed settings configuration file.
This contains all of the user’s configured authorization servers and profiles. It may optionally contain a
default_profile_nameto use to override the “default” value.QCSClientConfigurationkeys into these configured values when instantiated.- default_profile_name :str = default#
Which profile to select settings from when none is specified.
See
QCSClientConfiguration.load.
- profiles :Dict[str, QCSClientConfigurationSettingsProfile]#
All available configuration profiles, keyed by name
- auth_servers :Dict[str, QCSAuthServer]#
All available authorization servers, keyed by name
- class qcs_api_client.client._configuration.QCSClientConfigurationSettingsProfile#
Bases:
qcs_api_client.client._configuration.environment.EnvironmentModelSpecifies the authorization server, credentials, and API URL.
The attributes of this class can be used to initialize an
httpx.Clientwith the correct base URL and theQCSAuthmiddleware for making authenticated API calls against the QCS API.QCSClientConfigurationSettingsmay contain several profiles, whichQCSClientConfiguration.profile_namemay key into.- api_url :pydantic.networks.HttpUrl = https://api.qcs.rigetti.com#
URL of the QCS API to use for all API calls
- auth_server_name :str = default#
Which of the configured
QCSClientConfigurationSettings.auth_serversto use
- applications :QCSClientConfigurationSettingsApplications#
Application-specific configuration values
- credentials_name :str = default#
Which of the configured
QCSClientConfigurationSecrets.credentialsto use and update
- account_id :Optional[str]#
Account ID on behalf of which to make requests. If set to
None, QCS services will use your personal user account. Clients may also set this to a QCS group name for which they are authorized to make requests.
- account_type :Optional[QCSAccountType]#
Account type on behalf of which to make requests. When setting the
account_idto a group name, this must be set toAccountType.group.
- class qcs_api_client.client._configuration.QCSClientConfigurationSettingsApplications#
Bases:
pydantic.BaseModelSection of a profile specifying per-application settings.
- cli :QCSClientConfigurationSettingsApplicationsCLI#
- pyquil :QCSClientConfigurationSettingsApplicationsPyquil#
- class qcs_api_client.client._configuration.QCSClientConfigurationSettingsApplicationsCLI#
Bases:
qcs_api_client.client._configuration.environment.EnvironmentModel- verbosity :str =#