127 lines
4.9 KiB
Python
127 lines
4.9 KiB
Python
from typing import Dict
|
|
|
|
from atst.models.user import User
|
|
from atst.models.environment import Environment
|
|
from atst.models.environment_role import EnvironmentRole
|
|
|
|
|
|
class CloudProviderInterface:
|
|
def set_secret(self, secret_key: str, secret_value: str):
|
|
raise NotImplementedError()
|
|
|
|
def get_secret(self, secret_key: str):
|
|
raise NotImplementedError()
|
|
|
|
def root_creds(self) -> Dict:
|
|
raise NotImplementedError()
|
|
|
|
def create_environment(
|
|
self, auth_credentials: Dict, user: User, environment: Environment
|
|
) -> str:
|
|
"""Create a new environment in the CSP.
|
|
|
|
Arguments:
|
|
auth_credentials -- Object containing CSP account credentials
|
|
user -- ATAT user authorizing the environment creation
|
|
environment -- ATAT Environment model
|
|
|
|
Returns:
|
|
string: ID of created environment
|
|
|
|
Raises:
|
|
AuthenticationException: Problem with the credentials
|
|
AuthorizationException: Credentials not authorized for current action(s)
|
|
ConnectionException: Issue with the CSP API connection
|
|
UnknownServerException: Unknown issue on the CSP side
|
|
EnvironmentExistsException: Environment already exists and has been created
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def create_atat_admin_user(
|
|
self, auth_credentials: Dict, csp_environment_id: str
|
|
) -> Dict:
|
|
"""Creates a new, programmatic user in the CSP. Grants this user full permissions to administer
|
|
the CSP.
|
|
|
|
Arguments:
|
|
auth_credentials -- Object containing CSP account credentials
|
|
csp_environment_id -- ID of the CSP Environment the admin user should be created in
|
|
|
|
Returns:
|
|
object: Object representing new remote admin user, including credentials
|
|
Something like:
|
|
{
|
|
"user_id": string,
|
|
"credentials": dict, # structure TBD based on csp
|
|
}
|
|
|
|
Raises:
|
|
AuthenticationException: Problem with the credentials
|
|
AuthorizationException: Credentials not authorized for current action(s)
|
|
ConnectionException: Issue with the CSP API connection
|
|
UnknownServerException: Unknown issue on the CSP side
|
|
UserProvisioningException: Problem creating the root user
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def create_or_update_user(
|
|
self, auth_credentials: Dict, user_info: EnvironmentRole, csp_role_id: str
|
|
) -> str:
|
|
"""Creates a user or updates an existing user's role.
|
|
|
|
Arguments:
|
|
auth_credentials -- Object containing CSP account credentials
|
|
user_info -- instance of EnvironmentRole containing user data
|
|
if it has a csp_user_id it will try to update that user
|
|
csp_role_id -- The id of the role the user should be given in the CSP
|
|
|
|
Returns:
|
|
string: Returns the interal csp_user_id of the created/updated user account
|
|
|
|
Raises:
|
|
AuthenticationException: Problem with the credentials
|
|
AuthorizationException: Credentials not authorized for current action(s)
|
|
ConnectionException: Issue with the CSP API connection
|
|
UnknownServerException: Unknown issue on the CSP side
|
|
UserProvisioningException: User couldn't be created or modified
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def disable_user(self, auth_credentials: Dict, csp_user_id: str) -> bool:
|
|
"""Revoke all privileges for a user. Used to prevent user access while a full
|
|
delete is being processed.
|
|
|
|
Arguments:
|
|
auth_credentials -- Object containing CSP account credentials
|
|
csp_user_id -- CSP internal user identifier
|
|
|
|
Returns:
|
|
bool -- True on success
|
|
|
|
Raises:
|
|
AuthenticationException: Problem with the credentials
|
|
AuthorizationException: Credentials not authorized for current action(s)
|
|
ConnectionException: Issue with the CSP API connection
|
|
UnknownServerException: Unknown issue on the CSP side
|
|
UserRemovalException: User couldn't be suspended
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def get_calculator_url(self) -> str:
|
|
"""Returns the calculator url for the CSP.
|
|
This will likely be a static property elsewhere once a CSP is chosen.
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def get_environment_login_url(self, environment) -> str:
|
|
"""Returns the login url for a given environment
|
|
This may move to be a computed property on the Environment domain object
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def create_subscription(self, environment):
|
|
"""Returns True if a new subscription has been created or raises an
|
|
exception if an error occurs while creating a subscription.
|
|
"""
|
|
raise NotImplementedError()
|