awsapilib.console package

Submodules

awsapilib.console.console module

Main code for console.

class awsapilib.console.console.AccountManager(email, password, region, mfa_serial=None, solver=<class 'awsapilib.captcha.captcha.Terminal'>)[source]

Bases: BaseConsoleInterface

Models basic communication with the server for account and password management.

property account_id

IAM.

property iam

IAM.

property mfa

Retrieves an MFA manager.

Returns:

The mfa manager object

Return type:

mfa_manager (MfaManager)

terminate_account()[source]

Terminates the account matching the info provided.

Returns:

True on success, False otherwise.

update_account_email(new_account_email)[source]

Updates the name of an account to the new one provided.

Parameters:

new_account_email – The new account name.

Returns:

True on success.

Raises:

ServerError, UnableToUpdateAccount – On Failure with the corresponding message from the backend service.

update_account_name(new_account_name)[source]

Updates the email of an account to the new one provided.

Parameters:

new_account_name – The new account email.

Returns:

True on success.

Raises:

ServerError, UnableToUpdateAccount – On Failure with the corresponding message from the backend service.

class awsapilib.console.console.BaseConsoleInterface(solver=<class 'awsapilib.captcha.captcha.Terminal'>)[source]

Bases: LoggerMixin

Manages accounts password filecycles and can provide a root console session.

get_mfa_type(email)[source]

Gets the MFA type of the account.

Parameters:

email – The email of the account to check for MFA settings.

Returns:

The type of MFA set (only “SW” currently supported) None if no MFA is set.

class awsapilib.console.console.Captcha(url: str, token: str, obfuscation_token: str)[source]

Bases: object

Models a Captcha.

obfuscation_token: str
token: str
url: str
class awsapilib.console.console.IamAccess(billing_session)[source]

Bases: LoggerMixin

Models the iam access settings and implements the interaction with them.

property billing_console_access

Billing console access setting.

class awsapilib.console.console.MFA(_data: dict)[source]

Bases: object

Models the MFA device.

property enabled_date

Timestamp of enabled day.

property id

Id.

property serial_number

The serial number of the device.

property user_name

The user name set on the device.

class awsapilib.console.console.MfaManager(iam_session)[source]

Bases: LoggerMixin

Models interaction with the api for mfa management.

create_virtual_device(name='root-account-mfa-device')[source]

Creates a virtual MFA device with the provided name.

Parameters:

name – The name of the virtual MFA device, defaults to “root-account-mfa-device”

Returns:

The secret seed of the virtual MFA device. This needs to be saved in a safe place!!

Return type:

seed (str)

Raises:

VirtualMFADeviceExists, UnableToCreateVirtualMFA, UnableToEnableVirtualMFA on respective failures.

delete_virtual_device(serial_number)[source]

Deletes a virtual MFA with the provided serial number.

Parameters:

serial_number – The serial number of the virtual MFA device to delete.

Returns:

True on success

Raises:

UnableToDisableVirtualMFA on failure.

get_virtual_device()[source]

Retrieves the virtual MFA device if set.

Returns:

The set virtual MFA device if any else, None.

Return type:

mfa_device (MFA)

class awsapilib.console.console.Oidc(client_id: str, code_challenge: str, code_challenge_method: str, redirect_url: str)[source]

Bases: object

Models an OIDC response.

client_id: str
code_challenge: str
code_challenge_method: str
redirect_url: str
class awsapilib.console.console.PasswordManager(solver=<class 'awsapilib.captcha.captcha.Terminal'>)[source]

Bases: BaseConsoleInterface

Models interaction for account password reset.

request_password_reset(email)[source]

Requests a password reset for an account by it’s email.

Parameters:

email – The email of the account to request the password reset.

Returns:

True on success, False otherwise.

Raises:

UnableToRequestResetPassword if unsuccessful

reset_password(reset_url, password)[source]

Resets password of an aws account.

Parameters:
  • reset_url – The reset url provided by aws thought the reset password workflow.

  • password – The new password to set to the account.

Returns:

True on success, False otherwise.

Raises:

UnableToResetPassword on failure

class awsapilib.console.console.RootAuthenticator(session, region)[source]

Bases: BaseAuthenticator

Interacts with the console to retrieve console and billing page sessions.

get_billing_root_session(redirect_url, unfiltered_session=False)[source]

Retreives a billing session, filtered with specific cookies or not depending on the usage.

Parameters:
  • redirect_url (str) – The redirect url provided to initiate the authentication flow after the captcha.

  • unfiltered_session (bool) – Returns a full session if unfiltered, or a filtered session with xsrf token if set to True. Defaults to False.

Returns:

A valid session.

Return type:

session (Session)

get_iam_root_session(redirect_url)[source]

Retrieves an iam console session, filtered with specific cookies or not depending on the usage.

Parameters:

redirect_url (str) – The redirect url provided to initiate the authentication flow after the captcha.

Returns:

A valid session.

Return type:

session (Session)

class awsapilib.console.console.VirtualMFADevice(seed: str, serial: str)[source]

Bases: object

Models the active MFA device.

seed: str
serial: str

awsapilib.console.consoleexceptions module

Custom exception code for console.

exception awsapilib.console.consoleexceptions.InvalidAuthentication[source]

Bases: Exception

The authentication did not succeed.

exception awsapilib.console.consoleexceptions.NoMFAProvided[source]

Bases: Exception

The account is MFA provided but no MFA serial was provided.

exception awsapilib.console.consoleexceptions.NotSolverInstance[source]

Bases: Exception

The object provided was not of Solver type.

exception awsapilib.console.consoleexceptions.ServerError[source]

Bases: Exception

Unknown server error occured.

exception awsapilib.console.consoleexceptions.UnableToCreateVirtualMFA[source]

Bases: Exception

The attempt to create a virtual mfa failed.

exception awsapilib.console.consoleexceptions.UnableToDisableVirtualMFA[source]

Bases: Exception

The attempt to disable a virtual mfa failed.

exception awsapilib.console.consoleexceptions.UnableToEnableVirtualMFA[source]

Bases: Exception

The attempt to create a virtual mfa failed.

exception awsapilib.console.consoleexceptions.UnableToGetVirtualMFA[source]

Bases: Exception

The attempt to list a virtual mfa failed.

exception awsapilib.console.consoleexceptions.UnableToQueryMFA[source]

Bases: Exception

Unable to query the account MFA info.

exception awsapilib.console.consoleexceptions.UnableToRequestResetPassword[source]

Bases: Exception

The request to reset password did not work.

exception awsapilib.console.consoleexceptions.UnableToResetPassword[source]

Bases: Exception

The reset password request did not work.

exception awsapilib.console.consoleexceptions.UnableToResolveAccount[source]

Bases: Exception

Unable to resolve the account type.

exception awsapilib.console.consoleexceptions.UnableToUpdateAccount[source]

Bases: Exception

Unable to update the account info.

exception awsapilib.console.consoleexceptions.UnsupportedMFA[source]

Bases: Exception

The MFA enabled is not supported.

exception awsapilib.console.consoleexceptions.VirtualMFADeviceExists[source]

Bases: Exception

The device already exists.

Module contents

console package.

Import all parts from console here