sedai.optimizations

class ResourceConfig:

The configuration of a resource monitored by Sedai.

class WorkloadConfig(sedai.optimizations.ResourceConfig):

Configuration for a Kubernetes workload.

replicas: int

Replica count for this workload.

class KubeContainerConfig(sedai.optimizations.ResourceConfig):

Container configuration of a Kubernetes resource monitored by Sedai.

memory_request: Optional[types.SimpleNamespace]

Minimum memory requested for the container if set.

memory_limit: Optional[types.SimpleNamespace]

Maximum memory allowed for the container if set.

cpu_request: Optional[types.SimpleNamespace]

Minimum CPU units requested for the container if set.

cpu_limit: Optional[types.SimpleNamespace]

Maximum CPU units allowed for the container if set.

class NodegroupDetails:

Details of a single nodegroup for hosting a cluster.

name: str

Name of the node group.

instance_type: str

Instance type for this node group.

memory_bytes: float

Memory for this node group.

vcpus: int

VCPUs for this node group.

num_nodes: int

Number of nodes in this node group.

min_num_nodes: int

Minimum number of nodes in this node group.

max_num_nodes: int

Maximum number of nodes in this node group.

class NodegroupConfig(sedai.optimizations.ResourceConfig):

The nodegroup configuration for hosting a cluster.

nodegroups: List[NodegroupDetails]

List of nodegroups for this cluster.

class S3IntelligentTieringConfig:

Configuration for S3 intelligent tiering.

config_id: str

The ID of the configuration.

prefix: str

The prefix for the configuration.

tags: Dict[str, str]

The tags for the configuration.

archive_threshold_days: Dict[str, int]

The archive threshold in days for the configuration.

class S3LifecycleRule:

Configuration for S3 lifecycle rules.

rule_id: str

The ID of the rule.

enabled: bool

Whether the rule is enabled.

transitions: List[Dict[str, Any]]

The transitions for the rule.

class S3BucketConfig:

Configuration for an S3 bucket.

bucket_name: str

The name of the bucket.

intelligent_tiering_configs: List[S3IntelligentTieringConfig]

The intelligent tiering configurations for the bucket.

lifecycle_rules: List[S3LifecycleRule]

The lifecycle rules for the bucket.

class EBSVolumeConfig:

Configuration for an EBS volume.

volume_type: str

The type of the volume.

size_gb: int

The size of the volume in GB.

iops: int

The IOPS of the volume.

throughput: int

The throughput of the volume.

class ECSContainerConfig:

Configuration for an ECS container.

container_name: str

The name of the container.

container_image: str

The image of the container.

memory_soft_limit: int

The soft memory limit of the container.

memory_hard_limit: int

The hard memory limit of the container.

cpu_soft_limit: int

The soft CPU limit of the container.

class ECSResourceConfig:

Configuration for an ECS resource.

desired_count: int

The desired count of the resource.

running_count: int

The running count of the resource.

task_cpu_hard_limit_units: Optional[float]

The hard CPU limit of the task.

task_memory_hard_limit_mib: Optional[float]

The hard memory limit of the task.

container_configs: List[ECSContainerConfig]

The container configurations for the resource.

class KubeResourceConfig:

Configuration for a Kubernetes resource.

container_configs
replicas
class LambdaResourceConfig:

Configuration for a Serverless Lambda resource.

memory_size: int

The memory size configured for the Lambda function.

timeout: int

The timeout configured for the Lambda function.

reserved_concurrency: Optional[int]

The reserved concurrency of the Lambda function if configured.

provisioned_concurrency: Optional[int]

The provisioned concurrency of the Lambda function if configured.

class ClusterOpportunity(sedai.optimizations.ResourceOpportunity):

Details of all potential optimization opportunities for a cluster.

cost_projection_summary: types.SimpleNamespace

Summary of the estimated cost projection for this cluster.

nodegroup_optimization: NodegroupOptimization

Details of nodegroup optimizations recommended for this cluster.

workload_optimizations: List[ResourceOptimization]

Details of workload optimizations recommended for this cluster.

class ResourceOpportunity:

Details of potential resource optimization opportunities. This may also include opportunities for resources that are set to autonomous.

account_id: str

Account ID of the resource for which the optimization was proposed.

resource_name: str

Name of the resource for which the optimization was proposed.

src
def get_opportunities(level, id):

Retrieves recommendations from the Sedai API.

Returns: dict: A dictionary containing the recommendation data.

def get_cluster_opportunities( cluster_id: str, optimization_targets: List[str] = None) -> ClusterOpportunity:

Returns details of available optimization opportunities for a cluster.

Parameters
  • cluster_id: ID of the cluster to retrieve opportunities for.
  • optimization_targets: Optimization targets to consider. Possible options are NODE, WORK_LOAD and PURCHASE_OPTION.
Returns

Details of potential optimization opportunities for the given cluster.

class NodegroupOptimization:

Optimizations for the nodegroup configuration of a cluster.

original_nodegroup_config: NodegroupConfig

The original nodegroup configuration for this cluster.

recommended_nodegroup_config_original: NodegroupConfig

Recommendations for the original nodegroup configuration for this cluster.

recommended_nodegroup_config_optimal: NodegroupConfig

Recommended optimal nodegroup configuration for this cluster.

class ResourceOptimization:

Details of an optimization proposed for a resource.

resource_name: str

Name of the resource for which the optimization was proposed.

resource_id: str

ID of the resource for which the optimization was proposed.

account_id: str

Account ID of the resource for which the optimization was proposed.

optimization_time: Optional[datetime.datetime]

Time at which the optimization was performed for completed optimizations.

class KubeResourceOptimization(sedai.optimizations.ResourceOptimization):

Details of an optimization proposed for a Kubernetes resource.

original_container_config: Dict[str, KubeContainerConfig]

The original container configuration of the Kubernetes resource.

recommended_container_config: Dict[str, KubeContainerConfig]

Optimized container configuration recommended by Sedai.

original_workload_config: WorkloadConfig

The original workload configuration of the Kubernetes resource.

recommended_workload_config: WorkloadConfig

Optimized workload configuration recommended by Sedai.

def get_resource_optimizations( account_id: str = None, resource_id: str = None, starttime: datetime.datetime = None, endtime: datetime.datetime = None, sort_by: str = None, sort_dir: str = None) -> List[ResourceOptimization]:

Get details of completed optimizations.

Parameters
  • account_id: Optional account ID to query for optimizations recommended for the given account.
  • resource_id: Optional resource ID to query for optimizations recommended for the given resource.
  • starttime: Retrieve optimizations performed after the given starttime.
  • endtime: Retrieve optimizations performed before the given endtime.
  • sort_by: Attribute to sort the retrieved optimizations by. Possible options are
    • optimization_time: The time at which the optimization was performed.
    • cpu_change_core: Change in CPU cores.
    • cpu_change_vcpu: Change in VCPUs.
    • memory_change_mib: Change in memory in MiBs.
    • storage_change_gib: Change in storage size in GiBs.
  • sort_dir: Sort direction for retrieving optimizations. Possible options are ASC and DESC.
class Operation:

Base class for all operations.

action: str

The action that the operation is performing.

class KubeNodePoolOperation(sedai.optimizations.Operation):

Represents a Kubernetes node pool operation.

current_state: NodegroupDetails

The current configuration of the node pool.

proposed_state: NodegroupDetails

The proposed configuration of the node pool.

class S3BucketOperation(sedai.optimizations.Operation):

Represents an S3 bucket operation.

bucket_name: str

The name of the S3 bucket.

current_state: S3BucketConfig

The current configuration of the S3 bucket.

proposed_state: S3BucketConfig

The proposed configuration of the S3 bucket.

class EBSTypeTuningOperation(sedai.optimizations.Operation):

Represents an EBS volume type tuning operation.

current_state: EBSVolumeConfig

The current configuration of the EBS volume.

proposed_state: EBSVolumeConfig

The proposed configuration of the EBS volume.

class VMStorageRightSizingOperation(sedai.optimizations.Operation):

Represents a VM storage right sizing operation.

resource_name: str

The name of the resource.

current_disk_size_gb: int

The current disk size in GB.

proposed_disk_size_gb: int

The proposed disk size in GB.

class ECSClusterOperation(sedai.optimizations.Operation):

Represents an ECS cluster operation.

current_nodegroups: List[NodegroupDetails]

The current node groups in the ECS cluster.

proposed_nodegroups: List[NodegroupDetails]

The proposed node groups in the ECS cluster.

class ECSAppOperation(sedai.optimizations.Operation):

Represents an ECS app operation.

current_state: ECSResourceConfig

The current configuration of the ECS app.

proposed_state: ECSResourceConfig

The proposed configuration of the ECS app.

class KubeAppOperation(sedai.optimizations.Operation):

Represents a Kubernetes app operation.

original_config: KubeResourceConfig

The original configuration of the Kubernetes app.

proposed_config: KubeResourceConfig

The proposed configuration of the Kubernetes app.

class ServerlessFunctionOperation(sedai.optimizations.Operation):

An operation on a serverless function.

function_name: str

The name of the serverless function.

original_config: LambdaResourceConfig

The original configuration of the serverless function.

proposed_config: LambdaResourceConfig

The proposed configuration of the serverless function.

An operation on a serverless function to scale memory.

initial_memory: int

The initial memory of the Lambda function.

new_memory: int

The new memory of the Lambda function.

class ScaleDownMemoryOperation(sedai.optimizations.MemoryOperation):

Represents a scale down memory operation.

class ScaleUpMemoryOperation(sedai.optimizations.MemoryOperation):

Represents a scale up memory operation.

An operation on a serverless function to scale timeout.

initial_timeout: int

The initial timeout of the Lambda function.

new_timeout: int

The new timeout of the Lambda function.

class IncreaseTimeoutOperation(sedai.optimizations.TimeoutOperation):

Represents an increase timeout operation.

class DecreaseTimeoutOperation(sedai.optimizations.TimeoutOperation):

Represents a decrease timeout operation.

class IncreaseReservedConcurrencyOperation(sedai.optimizations.ServerlessFunctionOperation):

An operation to increase the reserved concurrency of a Lambda function.

initial_reserved_concurrency: int

The initial reserved concurrency of the Lambda function.

new_reserved_concurrency: Optional[int]

The new reserved concurrency of the Lambda function.

class DecreaseReservedConcurrencyOperation(sedai.optimizations.ServerlessFunctionOperation):

Represents a decrease reserved concurrency operation.

initial_reserved_concurrency: int

The initial reserved concurrency of the Lambda function.

new_reserved_concurrency: Optional[int]

The new reserved concurrency of the Lambda function.

class IncreaseProvisionedConcurrencyOperation(sedai.optimizations.ServerlessFunctionOperation):

An operation to increase the provisioned concurrency of a Lambda function.

initial_provisioned_concurrency: int

The initial provisioned concurrency of the Lambda function.

new_provisioned_concurrency: Optional[int]

The new provisioned concurrency of the Lambda function.

function_version: str

The version of the Lambda function.

class DecreaseProvisionedConcurrencyOperation(sedai.optimizations.ServerlessFunctionOperation):

Represents a decrease provisioned concurrency operation.

initial_provisioned_concurrency: int

The initial provisioned concurrency of the Lambda function.

new_provisioned_concurrency: Optional[int]

The new provisioned concurrency of the Lambda function.

function_version: str

The version of the Lambda function.

class Recommendation:

Represents a recommendation generated in Sedai.

resource_id: str

The Sedai ID of the resource for which the recommendation is generated.

resource_name: str

The name of the resource for which the recommendation is generated.

recommendation_type: str

The type of recommendation. This could be

  • AVAILABILITY: A recommendation to resolve availability issues.
  • EFFICIENCY: A recommendation to optimize the resource for cost or performance.
action_name: str

The recommended action to be taken.

account_id: str

The Sedai ID of the account to which the resource belongs.

account_name: str

The name of the account to which the resource belongs.

region_id: str

The ID of the region in which the resource is located.

created_time: datetime.datetime

The time at which the recommendation was generated.

expiry_time: datetime.datetime

The time at which the recommendation expires.

status: str

The status of the recommendation. This could be one of the following:

  • EXECUTING: The recommendation is currently being executed.
  • PROPOSED: The recommendation is proposed.
  • EXPIRED: The recommendation has expired.
  • FAILED: The recommendation execution has failed.
  • USER_REJECTED: The user has rejected the recommendation.
  • UNSAFE_TO_ACT: The recommendation is unsafe to act on.
  • SUCCESSFUL: The recommendation execution has been successful.
  • PAUSED: The recommendation execution has been paused.
operation: Optional[Operation]

Details of the operation associated with this recommendation. This field is only populated if the include_operation_details parameter is set to True in the get_recommendations function.

def get_recommendations( account_ids: Optional[List[str]] = None, resource_id: Optional[str] = None, starttime: Optional[datetime.datetime] = None, endtime: Optional[datetime.datetime] = None, recommendation_status: Optional[List[str]] = None, recommendation_types: Optional[List[str]] = None, pagination_config: Optional[sedai.pagination.PaginationConfig] = None, include_operation_details: Optional[bool] = False, action_name: Optional[str] = None) -> sedai.pagination.PageIterator[Recommendation]:

Returns a sedai.pagination.PageIterator of all recommendations available in Sedai.

Parameters
  • account_ids: Optional list of Sedai account IDs for which recommendations are to be fetched. If None, recommendations for all accounts are fetched.
  • resource_id: The Sedai ID of the resource for which recommendations are to be fetched. If None, recommendations for all resources are fetched.
  • starttime: Optional start time for the recommendations to be fetched.
  • endtime: Optional end time for the recommendations to be fetched. If None, the current time is considered as the end time.
  • recommendation_status: Optional list of recommendation statuses to filter the recommendations by. Possible values are

    • EXECUTING: The recommendation is currently being executed.
    • PROPOSED: The recommendation is proposed.
    • EXPIRED: The recommendation has expired.
    • FAILED: The recommendation execution has failed.
    • USER_REJECTED: The user has rejected the recommendation.
    • UNSAFE_TO_ACT: The recommendation is unsafe to act on.
    • SUCCESSFUL: The recommendation execution has been successful.
    • PAUSED: The recommendation execution has been paused.

    If no status is provided, all recommendations are fetched.

  • recommendation_types: Optional list of recommendation types to filter the recommendations by. Possible values are

    • AVAILABILITY: A recommendation to resolve availability issues.
    • EFFICIENCY: A recommendation to optimize the resource for cost or performance.

    If no recommendation type is provided, all recommendation types are fetched.

  • pagination_config: The pagination configuration for fetching recommendations. Refer to sedai.pagination.PaginationConfig for more details about the available options. If None, the first page of recommendations is fetched, and the function returns a list of recommendations as dictionaries instead of a sedai.pagination.PageIterator object. For default pagination configuration, use sedai.pagination.DEFAULT_PAGINATION_CONFIG.
  • include_operation_details: Optional boolean flag to indicate whether to include details of the operation associated with the recommendation. If set to True, the operation details are included in the operation field of the Recommendation object. Default is False.
  • action_name: Optional name of the action for which recommendations are to be fetched. If None, recommendations for all actions are fetched.
Returns

A sedai.pagination.PageIterator of Recommendation objects representing the recommendations.