sedai.account

CLOUD_PROVIDERS = ['AWS', 'AZURE', 'GCP', 'KUBERNETES']
INTEGRATION_TYPES = ['AGENTLESS', 'AGENT_BASED']
CLUSTER_PROVIDERS = ['AWS', 'AZURE', 'GCP', 'SELF_MANAGED']
def get_all_accounts():

Get all accounts that are integrated with Sedai

Returns

A list of accounts Each account is an object with the following fields:

  • id - the account id in Sedai
  • name - the name of the account as specified by the user
  • providerAccountId - the account id in the cloud provider
  • accountDetails.cloudProvider - the cloud provider of the account. Values are: AWS, AZURE, GCP, KUBERNETES, VMWARE
  • accountDetails.integrationType - the type of integration. Values are: AGENTLESS, AGENT_BASED

Sample code:

models.to_json(account.get_all_accounts())

Output:

[
    {
        "id": "5f4f5d3a-9c6e-4b3e-8a5a-1e4b6b5b2a7e",
        "name": "test env",
        "accountDetails": {
            "cloudProvider": "AWS",
            "integrationType": "AGENTLESS"
        }
    }
]
def get_all_accounts_lite():

Get a lightweight list of all accounts integrated with Sedai. Faster than get_all_accounts() as it returns a reduced set of fields. Use this when you only need basic account info such as id, name, cloudProvider.

Returns

A list of accounts with the following fields:

  • id - the account id in Sedai
  • name - the name of the account
  • cloudProvider - the cloud provider. Values are: AWS, AZURE, GCP, KUBERNETES
  • serviceProvider - the underlying service provider for Kubernetes clusters. Values are: AWS, AZURE, GCP
  • enabled - whether the account is enabled
def search_accounts_by_provider_account_id(provider_account_id):

Search for all accounts that are integrated with Sedai that match the given provider account id

Parameters
  • provider_account_id: The providerAccountId of the account to search for
Returns

A list of accounts that match the given providerAccountId. Output is in the same structure as get_all_accounts()

def search_accounts_by_name(name):

Search for all accounts that are integrated with Sedai that match the given name

Parameters
  • name: The name of the account to search for
Returns

A list of accounts that match the given name. Output is in the same structure as get_all_accounts_lite()

def search_accounts_by_id(id):

Search for all accounts that are integrated with Sedai that match the given id

Parameters
  • id: The accountId of the account to search for
Returns

A list of accounts that match the given id. Output is in the same structure as get_all_accounts()

def create_account( name: str, cloud_provider: str, credentials: sedai.credentials.SedaiCredentials, integration_type: str, cluster_provider: str | None = None, cluster_url: str | None = None, ca_certificate: str | None = None, project_id: str | None = None):

Create an account in Sedai

Parameters
  • name: The name of the account
  • cloud_provider: Cloud provider of the account. Valid values are: AWS, AZURE, GCP, KUBERNETES
  • credentials: Credentials for the account. See :ref: credentials for more details
  • integration_type: Type of integration for Kubernetes accounts. Valid values are: AGENTLESS, AGENT_BASED
  • cluster_provider: Cluster provider for Kubernetes accounts. Required when adding Kubernetes clusters. Valid values are: AWS, AZURE, GCP, SELF_MANAGED
  • cluster_url: URL of the Kubernetes cluster. Required when adding agentless Kubernetes clusters.
  • ca_certificate: Optional Certifying Authority Certificate for connecting agentlessly to Kubernetes clusters.
  • project_id: The GCP project id. Required when adding GCP accounts.
Returns

True if the account was created successfully, False otherwise

def update_account( id: str, name: str | None = None, cloud_provider: str | None = None, credentials: sedai.credentials.SedaiCredentials | None = None, integration_type: str | None = None, cluster_provider: str | None = None, cluster_url: str | None = None, ca_certificate: str | None = None, project_id: str | None = None, subscription_id: str | None = None, tenant_id: str | None = None):

Update an account in Sedai

Parameters
  • id: The id of the account
  • name: The name of the account
  • cloud_provider: Cloud provider of the account. Valid values are: AWS, AZURE, GCP, KUBERNETES
  • credentials: Credentials for the account. See :ref: credentials for more details
  • integration_type: Type of integration for Kubernetes accounts. Valid values are: AGENTLESS, AGENT_BASED
  • cluster_provider: Cluster provider for Kubernetes accounts. Required when adding Kubernetes clusters. Valid values are: AWS, AZURE, GCP, SELF_MANAGED
  • cluster_url: URL of the Kubernetes cluster. Required when adding agentless Kubernetes clusters.
  • ca_certificate: Optional Certifying Authority Certificate for connecting agentlessly to Kubernetes clusters.
  • project_id: The GCP project id. Required when adding GCP accounts.
  • subscription_id: The Azure subscription id. Required when adding Azure accounts.
  • tenant_id: The Azure tenant id. Required when adding Azure accounts.
Returns

True if the account was updated successfully, False otherwise

def delete_account(name):

Delete an account in Sedai, looked up by name.

Account names are not unique in Sedai. If the name matches more than one account this raises rather than deleting an arbitrary one - use delete_account_by_id() instead.

Parameters
  • name: Name of the account to delete
Returns

True if the account was deleted successfully, False otherwise

Raises
  • ValueError: If no account is found with the given name
  • RuntimeError: If more than one account is found with the given name
def delete_account_by_id(id):

Delete an account in Sedai

Parameters
  • id: Id of the account to delete
Returns

True if the account was deleted successfully, False otherwise

def test_connection(account_id):

Test the connection to the account

Parameters
  • account_id: The Sedai account id
Returns

True if the connection was successful, False otherwise

def get_agent_installation_command(name):

Get the agent installation command for the given account

Parameters
  • name: Name of the account
Returns

The agent installation command details Contains the following fields:

  • accountId - The Sedai account id
  • apiKey - The Sedai API key used for the command
  • kubeInstallCmd - The kubectl command to install the agent on Kubernetes clusters
  • helmInstallCmd - The helm command to install the agent on Kubernetes clusters

Output:

{
    "accountId": "n9dngzfd",
    "apiKey": "eyJhbGciOiJSUzI1NiJ9...[Truncated]",
    "kubeInstallCmd": "kubectl apply -f “https://[Truncated. URL for the YAML file]“",
    "helmInstallCmd": "helm upgrade --install sedai-smart-agent-abc oci://[...] --version 1.21.36 -f “https://[Truncated. URL for the YAML file]“]"
}
Raises
  • ValueError: If no account is found with the given name
  • RuntimeError: If more than one account is found with the given name
def get_agent_installation_command_by_id(account_id):

Get the agent installation command for the given account id

Parameters
  • account_id: The Sedai account id
Returns

The agent installation command details, or None if the request failed Contains the following fields:

  • accountId - The Sedai account id
  • apiKey - The Sedai API key used for the command
  • kubeInstallCmd - The kubectl command to install the agent on Kubernetes clusters
  • helmInstallCmd - The helm command to install the agent on Kubernetes clusters

Output:

{
    "accountId": "n9dngzfd",
    "apiKey": "eyJhbGciOiJSUzI1NiJ9...[Truncated]",
    "kubeInstallCmd": "kubectl apply -f “https://[Truncated. URL for the YAML file]“",
    "helmInstallCmd": "helm upgrade --install sedai-smart-agent-abc oci://[...] --version 1.21.36 -f “https://[Truncated. URL for the YAML file]“]"
}