Source code for botocraft.services.application_autoscaling

# This file is automatically generated by botocraft.  Do not edit directly.
# mypy: disable-error-code="index, override, assignment, union-attr, misc"
from functools import cached_property
from pydantic import Field
from .abstract import (
    Boto3Model,
    ReadonlyBoto3Model,
    PrimaryBoto3Model,
    ReadonlyPrimaryBoto3Model,
    Boto3ModelManager,
    ReadonlyBoto3ModelManager,
)
from botocraft.mixins.application_autoscaling import ScalableTargetModelMixin
from collections import OrderedDict
from typing import ClassVar, Literal, Any, cast
from .abstract import PrimaryBoto3ModelQuerySet
from botocraft.mixins.application_autoscaling import scalable_target_only
from botocraft.mixins.tags import TagsDictMixin
from datetime import datetime
import builtins
from botocraft.mixins.application_autoscaling import scaling_policy_only

# ===============
# Managers
# ===============


[docs]class ScalingPolicyManager(Boto3ModelManager): service_name: str = "application-autoscaling"
[docs] @scaling_policy_only def create(self, model: "ScalingPolicy") -> "PutScalingPolicyResponse": """ Creates or updates a scaling policy for an Application Auto Scaling scalable target. Args: model: The :py:class:`ScalingPolicy` to create. """ data = model.model_dump(exclude_none=True, by_alias=True) args = dict( PolicyName=data.get("PolicyName"), ServiceNamespace=data.get("ServiceNamespace"), ResourceId=data.get("ResourceId"), ScalableDimension=data.get("ScalableDimension"), PolicyType=data.get("PolicyType"), StepScalingPolicyConfiguration=data.get("StepScalingPolicyConfiguration"), TargetTrackingScalingPolicyConfiguration=data.get( "TargetTrackingScalingPolicyConfiguration" ), PredictiveScalingPolicyConfiguration=data.get( "PredictiveScalingPolicyConfiguration" ), ) _response = self.client.put_scaling_policy( **{k: v for k, v in args.items() if v is not None} ) response = PutScalingPolicyResponse(**_response) self.sessionize(response) return cast("PutScalingPolicyResponse", response)
[docs] def delete( self, PolicyName: str, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], ResourceId: str, ScalableDimension: Literal[ "ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", "elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", "dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", "dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits", "rds:cluster:ReadReplicaCount", "sagemaker:variant:DesiredInstanceCount", "custom-resource:ResourceType:Property", "comprehend:document-classifier-endpoint:DesiredInferenceUnits", "comprehend:entity-recognizer-endpoint:DesiredInferenceUnits", "lambda:function:ProvisionedConcurrency", "cassandra:table:ReadCapacityUnits", "cassandra:table:WriteCapacityUnits", "kafka:broker-storage:VolumeSize", "elasticache:cache-cluster:Nodes", "elasticache:replication-group:NodeGroups", "elasticache:replication-group:Replicas", "neptune:cluster:ReadReplicaCount", "sagemaker:variant:DesiredProvisionedConcurrency", "sagemaker:inference-component:DesiredCopyCount", "workspaces:workspacespool:DesiredUserSessions", ], ) -> None: """ Deletes the specified scaling policy for an Application Auto Scaling scalable target. Args: PolicyName: The name of the scaling policy. ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. ResourceId: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. """ args: dict[str, Any] = dict( PolicyName=self.serialize(PolicyName), ServiceNamespace=self.serialize(ServiceNamespace), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) self.client.delete_scaling_policy( **{k: v for k, v in args.items() if v is not None} )
[docs] def list( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, PolicyNames: "builtins.list[str] | None" = None, ResourceId: "str | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> PrimaryBoto3ModelQuerySet: """ Describes the Application Auto Scaling scaling policies for the specified service namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: PolicyNames: The names of the scaling policies to describe. ResourceId: The identifier of the resource associated with the scaling policy. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ paginator = self.client.get_paginator("describe_scaling_policies") args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), PolicyNames=self.serialize(PolicyNames), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) response_iterator = paginator.paginate( **{k: v for k, v in args.items() if v is not None} ) results = [] for _response in response_iterator: if list(_response.keys()) == ["ResponseMetadata"]: break if "ResponseMetadata" in _response: del _response["ResponseMetadata"] response = DescribeScalingPoliciesResponse(**_response) if response.ScalingPolicies: results.extend(response.ScalingPolicies) else: if getattr(response, "NextToken", None): continue break self.sessionize(results) if results and isinstance(results[0], Boto3Model): return PrimaryBoto3ModelQuerySet(results) return results
[docs] @scaling_policy_only def update(self, model: "ScalingPolicy") -> "PutScalingPolicyResponse": """ Creates or updates a scaling policy for an Application Auto Scaling scalable target. Args: model: The :py:class:`ScalingPolicy` to update. """ data = model.model_dump(exclude_none=True, by_alias=True) args = dict( PolicyName=data.get("PolicyName"), ServiceNamespace=data.get("ServiceNamespace"), ResourceId=data.get("ResourceId"), ScalableDimension=data.get("ScalableDimension"), PolicyType=data.get("PolicyType"), StepScalingPolicyConfiguration=data.get("StepScalingPolicyConfiguration"), TargetTrackingScalingPolicyConfiguration=data.get( "TargetTrackingScalingPolicyConfiguration" ), PredictiveScalingPolicyConfiguration=data.get( "PredictiveScalingPolicyConfiguration" ), ) _response = self.client.put_scaling_policy( **{k: v for k, v in args.items() if v is not None} ) response = PutScalingPolicyResponse(**_response) self.sessionize(response) return cast("PutScalingPolicyResponse", response)
[docs] def get( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, PolicyNames: "builtins.list[str] | None" = None, ResourceId: "str | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> "ScalingPolicy | None": """ Describes the Application Auto Scaling scaling policies for the specified service namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: PolicyNames: The names of the scaling policies to describe. ResourceId: The identifier of the resource associated with the scaling policy. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), PolicyNames=self.serialize(PolicyNames), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) _response = self.client.describe_scaling_policies( **{k: v for k, v in args.items() if v is not None} ) response = DescribeScalingPoliciesResponse(**_response) if response and response.ScalingPolicies: self.sessionize(response.ScalingPolicies[0]) return response.ScalingPolicies[0] return None
[docs]class ScalableTargetManager(Boto3ModelManager): service_name: str = "application-autoscaling"
[docs] @scalable_target_only def create( self, model: "ScalableTarget", Tags: "dict[str, str] | None" = None ) -> "RegisterScalableTargetResponse": """ Registers or updates a scalable target, which is the resource that you want to scale. Args: model: The :py:class:`ScalableTarget` to create. Keyword Args: Tags: Assigns one or more tags to the scalable target. Use this parameter to tag the scalable target when it is created. To tag an existing scalable target, use the TagResource operation. """ data = model.model_dump(exclude_none=True, by_alias=True) args = dict( ServiceNamespace=data.get("ServiceNamespace"), ResourceId=data.get("ResourceId"), ScalableDimension=data.get("ScalableDimension"), MinCapacity=data.get("MinCapacity"), MaxCapacity=data.get("MaxCapacity"), RoleARN=data.get("RoleARN"), SuspendedState=data.get("SuspendedState"), Tags=self.serialize(Tags), ) _response = self.client.register_scalable_target( **{k: v for k, v in args.items() if v is not None} ) response = RegisterScalableTargetResponse(**_response) self.sessionize(response) return cast("RegisterScalableTargetResponse", response)
[docs] def delete( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], ResourceId: str, ScalableDimension: Literal[ "ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", "elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", "dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", "dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits", "rds:cluster:ReadReplicaCount", "sagemaker:variant:DesiredInstanceCount", "custom-resource:ResourceType:Property", "comprehend:document-classifier-endpoint:DesiredInferenceUnits", "comprehend:entity-recognizer-endpoint:DesiredInferenceUnits", "lambda:function:ProvisionedConcurrency", "cassandra:table:ReadCapacityUnits", "cassandra:table:WriteCapacityUnits", "kafka:broker-storage:VolumeSize", "elasticache:cache-cluster:Nodes", "elasticache:replication-group:NodeGroups", "elasticache:replication-group:Replicas", "neptune:cluster:ReadReplicaCount", "sagemaker:variant:DesiredProvisionedConcurrency", "sagemaker:inference-component:DesiredCopyCount", "workspaces:workspacespool:DesiredUserSessions", ], ) -> None: """ Deregisters an Application Auto Scaling scalable target when you have finished using it. To see which resources have been registered, use `DescribeScalableTargets <https://docs.aws.amazon.com/autoscaling/application/APIReference/API_Desc ribeScalableTargets.html>`_. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. ResourceId: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property. """ args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) self.client.deregister_scalable_target( **{k: v for k, v in args.items() if v is not None} )
[docs] def list( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, ResourceIds: "builtins.list[str] | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> PrimaryBoto3ModelQuerySet: """ Gets information about the scalable targets in the specified namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: ResourceIds: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ paginator = self.client.get_paginator("describe_scalable_targets") args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ResourceIds=self.serialize(ResourceIds), ScalableDimension=self.serialize(ScalableDimension), ) response_iterator = paginator.paginate( **{k: v for k, v in args.items() if v is not None} ) results = [] for _response in response_iterator: if list(_response.keys()) == ["ResponseMetadata"]: break if "ResponseMetadata" in _response: del _response["ResponseMetadata"] response = DescribeScalableTargetsResponse(**_response) if response.ScalableTargets: results.extend(response.ScalableTargets) else: if getattr(response, "NextToken", None): continue break self.sessionize(results) if results and isinstance(results[0], Boto3Model): return PrimaryBoto3ModelQuerySet(results) return results
[docs] def get( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, ResourceIds: "builtins.list[str] | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> "ScalableTarget | None": """ Gets information about the scalable targets in the specified namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: ResourceIds: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ResourceIds=self.serialize(ResourceIds), ScalableDimension=self.serialize(ScalableDimension), ) _response = self.client.describe_scalable_targets( **{k: v for k, v in args.items() if v is not None} ) response = DescribeScalableTargetsResponse(**_response) if response and response.ScalableTargets: self.sessionize(response.ScalableTargets[0]) return response.ScalableTargets[0] return None
[docs]class ScheduledActionManager(Boto3ModelManager): service_name: str = "application-autoscaling"
[docs] def create(self, model: "ScheduledAction") -> None: """ Creates or updates a scheduled action for an Application Auto Scaling scalable target. Args: model: The :py:class:`ScheduledAction` to create. """ data = model.model_dump(exclude_none=True, by_alias=True) args = dict( ServiceNamespace=data.get("ServiceNamespace"), ScheduledActionName=data.get("ScheduledActionName"), ResourceId=data.get("ResourceId"), ScalableDimension=data.get("ScalableDimension"), Schedule=data.get("Schedule"), Timezone=data.get("Timezone"), StartTime=data.get("StartTime"), EndTime=data.get("EndTime"), ScalableTargetAction=data.get("ScalableTargetAction"), ) self.client.put_scheduled_action( **{k: v for k, v in args.items() if v is not None} )
[docs] def update(self, model: "ScheduledAction") -> None: """ Creates or updates a scheduled action for an Application Auto Scaling scalable target. Args: model: The :py:class:`ScheduledAction` to update. """ data = model.model_dump(exclude_none=True, by_alias=True) args = dict( ServiceNamespace=data.get("ServiceNamespace"), ScheduledActionName=data.get("ScheduledActionName"), ResourceId=data.get("ResourceId"), ScalableDimension=data.get("ScalableDimension"), Schedule=data.get("Schedule"), Timezone=data.get("Timezone"), StartTime=data.get("StartTime"), EndTime=data.get("EndTime"), ScalableTargetAction=data.get("ScalableTargetAction"), ) self.client.put_scheduled_action( **{k: v for k, v in args.items() if v is not None} )
[docs] def delete( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], ScheduledActionName: str, ResourceId: str, ScalableDimension: Literal[ "ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", "elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", "dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", "dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits", "rds:cluster:ReadReplicaCount", "sagemaker:variant:DesiredInstanceCount", "custom-resource:ResourceType:Property", "comprehend:document-classifier-endpoint:DesiredInferenceUnits", "comprehend:entity-recognizer-endpoint:DesiredInferenceUnits", "lambda:function:ProvisionedConcurrency", "cassandra:table:ReadCapacityUnits", "cassandra:table:WriteCapacityUnits", "kafka:broker-storage:VolumeSize", "elasticache:cache-cluster:Nodes", "elasticache:replication-group:NodeGroups", "elasticache:replication-group:Replicas", "neptune:cluster:ReadReplicaCount", "sagemaker:variant:DesiredProvisionedConcurrency", "sagemaker:inference-component:DesiredCopyCount", "workspaces:workspacespool:DesiredUserSessions", ], ) -> None: """ Deletes the specified scheduled action for an Application Auto Scaling scalable target. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. ScheduledActionName: The name of the scheduled action. ResourceId: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. """ args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ScheduledActionName=self.serialize(ScheduledActionName), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) self.client.delete_scheduled_action( **{k: v for k, v in args.items() if v is not None} )
[docs] def list( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, ScheduledActionNames: "builtins.list[str] | None" = None, ResourceId: "str | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> PrimaryBoto3ModelQuerySet: """ Describes the Application Auto Scaling scheduled actions for the specified service namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: ScheduledActionNames: The names of the scheduled actions to describe. ResourceId: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ paginator = self.client.get_paginator("describe_scheduled_actions") args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ScheduledActionNames=self.serialize(ScheduledActionNames), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) response_iterator = paginator.paginate( **{k: v for k, v in args.items() if v is not None} ) results = [] for _response in response_iterator: if list(_response.keys()) == ["ResponseMetadata"]: break if "ResponseMetadata" in _response: del _response["ResponseMetadata"] response = DescribeScheduledActionsResponse(**_response) if response.ScheduledActions: results.extend(response.ScheduledActions) else: if getattr(response, "NextToken", None): continue break self.sessionize(results) if results and isinstance(results[0], Boto3Model): return PrimaryBoto3ModelQuerySet(results) return results
[docs] def get( self, ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ], *, ScheduledActionNames: "builtins.list[str] | None" = None, ResourceId: "str | None" = None, ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None, ) -> "ScheduledAction | None": """ Describes the Application Auto Scaling scheduled actions for the specified service namespace. Args: ServiceNamespace: The namespace of the Amazon Web Services service that provides the resource. For a resource provided by your own application or service, use ``custom-resource`` instead. Keyword Args: ScheduledActionNames: The names of the scheduled actions to describe. ResourceId: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier. ScalableDimension: The scalable dimension. This string consists of the service namespace, resource type, and scaling property. If you specify a scalable dimension, you must also specify a resource ID. """ args: dict[str, Any] = dict( ServiceNamespace=self.serialize(ServiceNamespace), ScheduledActionNames=self.serialize(ScheduledActionNames), ResourceId=self.serialize(ResourceId), ScalableDimension=self.serialize(ScalableDimension), ) _response = self.client.describe_scheduled_actions( **{k: v for k, v in args.items() if v is not None} ) response = DescribeScheduledActionsResponse(**_response) if response and response.ScheduledActions: self.sessionize(response.ScheduledActions[0]) return response.ScheduledActions[0] return None
# ============== # Service Models # ==============
[docs]class StepAdjustment(Boto3Model): """Represents a step adjustment for a `StepScalingPolicyConfiguration <https://docs.aws.amazon.com/autoscaling/application/ APIReference/API_StepScalingPolicyConfiguration.html>`_. Describes an adjustment based on the difference between the value of the aggregated CloudWatch metric and the breach threshold that you've defined for the alarm. For the following examples, suppose that you have an alarm with a breach threshold of 50: * To initiate the adjustment when the metric is greater than or equal to 50 and less than 60, specify a lower bound of ``0`` and an upper bound of ``10``. * To initiate the adjustment when the metric is greater than 40 and less than or equal to 50, specify a lower bound of ``-10`` and an upper bound of ``0``. There are a few rules for the step adjustments for your step policy: * The ranges of your step adjustments can't overlap or have a gap. * At most one step adjustment can have a null lower bound. If one step adjustment has a negative lower bound, then there must be a step adjustment with a null lower bound. * At most one step adjustment can have a null upper bound. If one step adjustment has a positive upper bound, then there must be a step adjustment with a null upper bound. * The upper and lower bound can't be null in the same step adjustment. """ MetricIntervalLowerBound: "float | None" = None """ The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the lower bound is inclusive (the metric must be greater than or equal to the threshold plus the lower bound). Otherwise, it's exclusive (the metric must be greater than the threshold plus the lower bound). A null value indicates negative infinity. """ MetricIntervalUpperBound: "float | None" = None """ The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the upper bound is exclusive (the metric must be less than the threshold plus the upper bound). Otherwise, it's inclusive (the metric must be less than or equal to the threshold plus the upper bound). A null value indicates positive infinity. """ ScalingAdjustment: int """ The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a non-negative value. """
[docs]class ApplicationAutoscalingStepScalingPolicyConfiguration(Boto3Model): """ Represents a step scaling policy configuration to use with Application Auto Scaling. For more information, see `Step scaling policies <https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-step-scaling- policies.html>`_ in the *Application Auto Scaling User Guide*. """ AdjustmentType: "Literal['ChangeInCapacity', 'PercentChangeInCapacity', 'ExactCapacity'] | None" = None """ Specifies how the ``ScalingAdjustment`` value in a `StepAdjustment <https://docs.aws.amazon.com/autoscaling/application/APIReference/API_StepAdjustment.html>`_ is interpreted (for example, an absolute number or a percentage). The valid values are ``ChangeInCapacity``, ``ExactCapacity``, and ``PercentChangeInCapacity``. """ StepAdjustments: "builtins.list[StepAdjustment] | None" = Field( default_factory=list ) """ A set of adjustments that enable you to scale based on the size of the alarm breach. """ MinAdjustmentMagnitude: "int | None" = None """ The minimum value to scale by when the adjustment type is ``PercentChangeInCapacity``. For example, suppose that you create a step scaling policy to scale out an Amazon ECS service by 25 percent and you specify a ``MinAdjustmentMagnitude`` of 2. If the service has 4 tasks and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a ``MinAdjustmentMagnitude`` of 2, Application Auto Scaling scales out the service by 2 tasks. """ Cooldown: "int | None" = None """ The amount of time, in seconds, to wait for a previous scaling activity to take effect. If not specified, the default value is 300. For more information, see `Cooldown period <https://docs.aws.amazon.com/autoscaling/application/userguide/step-scaling-policy-overview.html#step-scaling- cooldown>`_ in the *Application Auto Scaling User Guide*. """ MetricAggregationType: "Literal['Average', 'Minimum', 'Maximum'] | None" = None """ The aggregation type for the CloudWatch metrics. Valid values are ``Minimum``, ``Maximum``, and ``Average``. If the aggregation type is null, the value is treated as ``Average``. """
[docs]class ApplicationAutoscalingPredefinedMetricSpecification(Boto3Model): """ Represents a predefined metric for a target tracking scaling policy to use with Application Auto Scaling. For more information, `Predefined metrics for target tracking scaling policies <https://docs.aws.amazon.com/autoscaling/application/userguide/monitoring-cloudwatch.html#predefined-metrics>`_ in the *Application Auto Scaling User Guide*. """ PredefinedMetricType: Literal[ "DynamoDBReadCapacityUtilization", "DynamoDBWriteCapacityUtilization", "ALBRequestCountPerTarget", "RDSReaderAverageCPUUtilization", "RDSReaderAverageDatabaseConnections", "EC2SpotFleetRequestAverageCPUUtilization", "EC2SpotFleetRequestAverageNetworkIn", "EC2SpotFleetRequestAverageNetworkOut", "SageMakerVariantInvocationsPerInstance", "ECSServiceAverageCPUUtilization", "ECSServiceAverageMemoryUtilization", "AppStreamAverageCapacityUtilization", "ComprehendInferenceUtilization", "LambdaProvisionedConcurrencyUtilization", "CassandraReadCapacityUtilization", "CassandraWriteCapacityUtilization", "KafkaBrokerStorageUtilization", "ElastiCacheEngineCPUUtilization", "ElastiCacheDatabaseMemoryUsagePercentage", "ElastiCachePrimaryEngineCPUUtilization", "ElastiCacheReplicaEngineCPUUtilization", "ElastiCacheDatabaseMemoryUsageCountedForEvictPercentage", "NeptuneReaderAverageCPUUtilization", "SageMakerVariantProvisionedConcurrencyUtilization", "ElastiCacheDatabaseCapacityUsageCountedForEvictPercentage", "SageMakerInferenceComponentInvocationsPerCopy", "WorkSpacesAverageUserSessionsCapacityUtilization", "SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution", "SageMakerVariantConcurrentRequestsPerModelHighResolution", ] """ The metric type. The ``ALBRequestCountPerTarget`` metric type applies only to Spot Fleets and ECS services. """ ResourceLabel: "str | None" = None """ Identifies the resource associated with the metric type. You can't specify a resource label unless the metric type is ``ALBRequestCountPerTarget`` and there is a target group attached to the Spot Fleet or ECS service. """
[docs]class MetricDimension(Boto3Model): """ Describes the dimension names and values associated with a metric. """ Name: str """ The name of the dimension. """ Value: str """ The value of the dimension. """
[docs]class TargetTrackingMetricDimension(Boto3Model): """ Describes the dimension of a metric. """ Name: str """ The name of the dimension. """ Value: str """ The value of the dimension. """
[docs]class TargetTrackingMetric(Boto3Model): """ Represents a specific metric. Metric is a property of the TargetTrackingMetricStat object. """ Dimensions: "builtins.list[TargetTrackingMetricDimension] | None" = Field( default_factory=list ) """ The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in `Amazon Web Services services that publish CloudWatch metrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html>`_ in the *Amazon CloudWatch User Guide*. """ MetricName: "str | None" = None """ The name of the metric. """ Namespace: "str | None" = None """ The namespace of the metric. For more information, see the table in `Amazon Web Services services that publish CloudWatch metrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html>`_ in the *Amazon CloudWatch User Guide*. """
[docs]class TargetTrackingMetricStat(Boto3Model): """ This structure defines the CloudWatch metric to return, along with the statistic and unit. For more information about the CloudWatch terminology below, see `Amazon CloudWatch concepts <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html>`_ in the *Amazon CloudWatch User Guide*. """ Metric: TargetTrackingMetric """ The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the `Metric <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html>`_ object that is returned by a call to `ListMetrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html>`_. """ Stat: str """ The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in `Statistics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic>`_ in the *Amazon CloudWatch User Guide*. """ Unit: "str | None" = None """ The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the `MetricDatum <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html>`_ data type in the *Amazon CloudWatch API Reference*. """
[docs]class TargetTrackingMetricDataQuery(Boto3Model): """ The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp. For more information and examples, see `Create a target tracking scaling policy for Application Auto Scaling using metric math <https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking- metric-math.html>`_ in the *Application Auto Scaling User Guide*. """ Expression: "str | None" = None """ The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the ``Id`` of the other metrics to refer to those metrics, and can also use the ``Id`` of other expressions to use the result of those expressions. """ Id: str """ A short name that identifies the object's results in the response. This name must be unique among all ``MetricDataQuery`` objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter. """ Label: "str | None" = None """ A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents. """ MetricStat: "TargetTrackingMetricStat | None" = None """ Information about the metric data to return. """ ReturnData: "bool | None" = None """ Indicates whether to return the timestamps and raw data values of this metric. """
[docs]class ApplicationAutoscalingCustomizedMetricSpecification(Boto3Model): """ Represents a CloudWatch metric of your choosing for a target tracking scaling policy to use with Application Auto Scaling. For information about the available metrics for a service, see `Amazon Web Services services that publish CloudWatch metrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html>`_ in the *Amazon CloudWatch User Guide*. To create your customized metric specification: * Add values for each required parameter from CloudWatch. You can use an existing metric, or a new metric that you create. To use your own metric, you must first publish the metric to CloudWatch. For more information, see `Publish custom metrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html>`_ in the *Amazon CloudWatch User Guide*. * Choose a metric that changes proportionally with capacity. The value of the metric should increase or decrease in inverse proportion to the number of capacity units. That is, the value of the metric should decrease when capacity increases, and increase when capacity decreases. For more information about the CloudWatch terminology below, see `Amazon CloudWatch concepts <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html>`_ in the *Amazon CloudWatch User Guide*. """ MetricName: "str | None" = None """ The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the `Metric <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html>`_ object that's returned by a call to `ListMetrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html>`_. """ Namespace: "str | None" = None """ The namespace of the metric. """ Dimensions: "builtins.list[MetricDimension] | None" = Field(default_factory=list) """ The dimensions of the metric. """ Statistic: "Literal['Average', 'Minimum', 'Maximum', 'SampleCount', 'Sum'] | None" = None """ The statistic of the metric. """ Unit: "str | None" = None """ The unit of the metric. For a complete list of the units that CloudWatch supports, see the `MetricDatum <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html>`_ data type in the *Amazon CloudWatch API Reference*. """ Metrics: "builtins.list[TargetTrackingMetricDataQuery] | None" = Field( default_factory=list ) """ The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions. """
[docs]class ApplicationAutoscalingTargetTrackingScalingPolicyConfiguration(Boto3Model): """ Represents a target tracking scaling policy configuration to use with Application Auto Scaling. For more information, see `Target tracking scaling policies <https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html>`_ in the *Application Auto Scaling User Guide*. """ TargetValue: float """ The target value for the metric. Although this property accepts numbers of type Double, it won't accept values that are either too small or too large. Values must be in the range of -2^360 to 2^360. The value must be a valid number based on the choice of metric. For example, if the metric is CPU utilization, then the target value is a percent value that represents how much of the CPU can be used before scaling out. """ PredefinedMetricSpecification: "ApplicationAutoscalingPredefinedMetricSpecification | None" = None """ A predefined metric. You can specify either a predefined metric or a customized metric. """ CustomizedMetricSpecification: "ApplicationAutoscalingCustomizedMetricSpecification | None" = None """ A customized metric. You can specify either a predefined metric or a customized metric. """ ScaleOutCooldown: "int | None" = None """ The amount of time, in seconds, to wait for a previous scale-out activity to take effect. For more information and for default values, see `Define cooldown periods <https://docs.aws.amazon.com/autoscaling/application/userguide/target- tracking-scaling-policy-overview.html#target-tracking-cooldown>`_ in the *Application Auto Scaling User Guide*. """ ScaleInCooldown: "int | None" = None """ The amount of time, in seconds, after a scale-in activity completes before another scale-in activity can start. For more information and for default values, see `Define cooldown periods <https://docs.aws.amazon.com/autoscaling/application/userguide/target-tracking-scaling-policy- overview.html#target-tracking-cooldown>`_ in the *Application Auto Scaling User Guide*. """ DisableScaleIn: "bool | None" = None """ Indicates whether scale in by the target tracking scaling policy is disabled. If the value is ``true``, scale in is disabled and the target tracking scaling policy won't remove capacity from the scalable target. Otherwise, scale in is enabled and the target tracking scaling policy can remove capacity from the scalable target. The default value is ``false``. """
[docs]class PredictiveScalingPredefinedMetricPairSpecification(Boto3Model): """ Represents a metric pair for a predictive scaling policy. The following predefined metrics are available for predictive scaling: * ``ECSServiceAverageCPUUtilization`` * ``ECSServiceAverageMemoryUtilization`` * ``ECSServiceCPUUtilization`` * ``ECSServiceMemoryUtilization`` * ``ECSServiceTotalCPUUtilization`` * ``ECSServiceTotalMemoryUtilization`` * ``ALBRequestCount`` * ``ALBRequestCountPerTarget`` * ``TotalALBRequestCount`` """ PredefinedMetricType: str """ Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. """ ResourceLabel: "str | None" = None """ A label that uniquely identifies a specific target group from which to determine the total and average request count. """
[docs]class PredictiveScalingPredefinedScalingMetricSpecification(Boto3Model): """ Describes a scaling metric for a predictive scaling policy. When returned in the output of ``DescribePolicies``, it indicates that a predictive scaling policy uses individually specified load and scaling metrics instead of a metric pair. The following predefined metrics are available for predictive scaling: * ``ECSServiceAverageCPUUtilization`` * ``ECSServiceAverageMemoryUtilization`` * ``ECSServiceCPUUtilization`` * ``ECSServiceMemoryUtilization`` * ``ECSServiceTotalCPUUtilization`` * ``ECSServiceTotalMemoryUtilization`` * ``ALBRequestCount`` * ``ALBRequestCountPerTarget`` * ``TotalALBRequestCount`` """ PredefinedMetricType: str """ The metric type. """ ResourceLabel: "str | None" = None """ A label that uniquely identifies a specific target group from which to determine the average request count. """
[docs]class PredictiveScalingPredefinedLoadMetricSpecification(Boto3Model): """ Describes a load metric for a predictive scaling policy. When returned in the output of ``DescribePolicies``, it indicates that a predictive scaling policy uses individually specified load and scaling metrics instead of a metric pair. The following predefined metrics are available for predictive scaling: * ``ECSServiceAverageCPUUtilization`` * ``ECSServiceAverageMemoryUtilization`` * ``ECSServiceCPUUtilization`` * ``ECSServiceMemoryUtilization`` * ``ECSServiceTotalCPUUtilization`` * ``ECSServiceTotalMemoryUtilization`` * ``ALBRequestCount`` * ``ALBRequestCountPerTarget`` * ``TotalALBRequestCount`` """ PredefinedMetricType: str """ The metric type. """ ResourceLabel: "str | None" = None """ A label that uniquely identifies a target group. """
[docs]class PredictiveScalingMetricDimension(Boto3Model): """ Describes the dimension of a metric. """ Name: str """ The name of the dimension. """ Value: str """ The value of the dimension. """
[docs]class PredictiveScalingMetric(Boto3Model): """ Describes the scaling metric. """ Dimensions: "builtins.list[PredictiveScalingMetricDimension] | None" = Field( default_factory=list ) """ Describes the dimensions of the metric. """ MetricName: "str | None" = None """ The name of the metric. """ Namespace: "str | None" = None """ The namespace of the metric. """
[docs]class PredictiveScalingMetricStat(Boto3Model): """ This structure defines the CloudWatch metric to return, along with the statistic and unit. """ Metric: PredictiveScalingMetric """ The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the `Metric <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html>`_ object that is returned by a call to `ListMetrics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html>`_. """ Stat: str """ The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in `Statistics <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic>`_ in the *Amazon CloudWatch User Guide*. """ Unit: "str | None" = None """ The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the `MetricDatum <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html>`_ data type in the *Amazon CloudWatch API Reference*. """
[docs]class PredictiveScalingMetricDataQuery(Boto3Model): """ The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp. """ Id: str """ A short name that identifies the object's results in the response. This name must be unique among all ``MetricDataQuery`` objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter. """ Expression: "str | None" = None """ The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the ``Id`` of the other metrics to refer to those metrics, and can also use the ``Id`` of other expressions to use the result of those expressions. """ MetricStat: "PredictiveScalingMetricStat | None" = None """ Information about the metric data to return. """ Label: "str | None" = None """ A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents. """ ReturnData: "bool | None" = None """ Indicates whether to return the timestamps and raw data values of this metric. """
[docs]class PredictiveScalingCustomizedMetricSpecification(Boto3Model): """ Represents a CloudWatch metric of your choosing for a predictive scaling policy. """ MetricDataQueries: "builtins.list[PredictiveScalingMetricDataQuery]" """ One or more metric data queries to provide data points for a metric specification. """
[docs]class PredictiveScalingMetricSpecification(Boto3Model): """ This structure specifies the metrics and target utilization settings for a predictive scaling policy. You must specify either a metric pair, or a load metric and a scaling metric individually. Specifying a metric pair instead of individual metrics provides a simpler way to configure metrics for a scaling policy. You choose the metric pair, and the policy automatically knows the correct sum and average statistics to use for the load metric and the scaling metric. """ TargetValue: float """ Specifies the target utilization. """ PredefinedMetricPairSpecification: "PredictiveScalingPredefinedMetricPairSpecification | None" = None """ The predefined metric pair specification that determines the appropriate scaling metric and load metric to use. """ PredefinedScalingMetricSpecification: "PredictiveScalingPredefinedScalingMetricSpecification | None" = None """ The predefined scaling metric specification. """ PredefinedLoadMetricSpecification: "PredictiveScalingPredefinedLoadMetricSpecification | None" = None """ The predefined load metric specification. """ CustomizedScalingMetricSpecification: "PredictiveScalingCustomizedMetricSpecification | None" = None """ The customized scaling metric specification. """ CustomizedLoadMetricSpecification: "PredictiveScalingCustomizedMetricSpecification | None" = None """ The customized load metric specification. """ CustomizedCapacityMetricSpecification: "PredictiveScalingCustomizedMetricSpecification | None" = None """ The customized capacity metric specification. """
[docs]class ApplicationAutoscalingPredictiveScalingPolicyConfiguration(Boto3Model): """ Represents a predictive scaling policy configuration. Predictive scaling is supported on Amazon ECS services. """ MetricSpecifications: "builtins.list[PredictiveScalingMetricSpecification]" """ This structure includes the metrics and target utilization to use for predictive scaling. """ Mode: "Literal['ForecastOnly', 'ForecastAndScale'] | None" = None """ The predictive scaling mode. Defaults to ``ForecastOnly`` if not specified. """ SchedulingBufferTime: "int | None" = None """ The amount of time, in seconds, that the start time can be advanced. """ MaxCapacityBreachBehavior: "Literal['HonorMaxCapacity', 'IncreaseMaxCapacity'] | None" = None """ Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity. Defaults to ``HonorMaxCapacity`` if not specified. """ MaxCapacityBuffer: "int | None" = None """ The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55. """
[docs]class Alarm(Boto3Model): """ Represents a CloudWatch alarm associated with a scaling policy. """ AlarmName: str """ The name of the alarm. """ AlarmARN: str """ The Amazon Resource Name (ARN) of the alarm. """
[docs]class ScalingPolicy(PrimaryBoto3Model): """ Represents a scaling policy to use with Application Auto Scaling. For more information about configuring scaling policies for a specific service, see `Amazon Web Services services that you can use with Application Auto Scaling <https://docs.aws.amazon.com/autoscaling/application/userguide/integrated- services-list.html>`_ in the *Application Auto Scaling User Guide*. """ manager_class: ClassVar[type[Boto3ModelManager]] = ScalingPolicyManager PolicyARN: str """ The Amazon Resource Name (ARN) of the scaling policy. """ PolicyName: str """ The name of the scaling policy. """ ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ] """ The namespace of the Amazon Web Services service that provides the resource, or a ``custom-resource``. """ ResourceId: str """ The identifier of the resource associated with the scaling policy. This string consists of the resource type and unique identifier. """ ScalableDimension: Literal[ "ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", "elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", "dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", "dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits", "rds:cluster:ReadReplicaCount", "sagemaker:variant:DesiredInstanceCount", "custom-resource:ResourceType:Property", "comprehend:document-classifier-endpoint:DesiredInferenceUnits", "comprehend:entity-recognizer-endpoint:DesiredInferenceUnits", "lambda:function:ProvisionedConcurrency", "cassandra:table:ReadCapacityUnits", "cassandra:table:WriteCapacityUnits", "kafka:broker-storage:VolumeSize", "elasticache:cache-cluster:Nodes", "elasticache:replication-group:NodeGroups", "elasticache:replication-group:Replicas", "neptune:cluster:ReadReplicaCount", "sagemaker:variant:DesiredProvisionedConcurrency", "sagemaker:inference-component:DesiredCopyCount", "workspaces:workspacespool:DesiredUserSessions", ] """ The scalable dimension. This string consists of the service namespace, resource type, and scaling property. """ PolicyType: Literal["StepScaling", "TargetTrackingScaling", "PredictiveScaling"] """ The scaling policy type. """ StepScalingPolicyConfiguration: "ApplicationAutoscalingStepScalingPolicyConfiguration | None" = None """ A step scaling policy. """ TargetTrackingScalingPolicyConfiguration: "ApplicationAutoscalingTargetTrackingScalingPolicyConfiguration | None" = None """ A target tracking scaling policy. """ PredictiveScalingPolicyConfiguration: "ApplicationAutoscalingPredictiveScalingPolicyConfiguration | None" = None """ The predictive scaling policy configuration. """ Alarms: "builtins.list[Alarm] | None" = Field(default_factory=list) """ The CloudWatch alarms associated with the scaling policy. """ CreationTime: datetime """ The Unix timestamp for when the scaling policy was created. """ @property def arn(self) -> str | None: """ Return the ARN of the model. This is the value of the :py:attr:`PolicyARN` attribute. Returns: The ARN of the model instance. """ return self.PolicyARN @property def name(self) -> str | None: """ Return the name of the model. This is the value of the :py:attr:`PolicyName` attribute. Returns: The name of the model instance. """ return self.PolicyName @property def pk(self) -> OrderedDict[str, Any]: """ The primary key of the scaling policy. This can be used to get the scaling policy with the :py:meth:`botocraft.services.application_autoscaling.ScalingPolicyManager.get` method, or to do :py:meth:`botocraft.services.application_autoscaling.ScalingPolicyManager.delete`. """ return OrderedDict( { "PolicyName": self.PolicyName, "ServiceNamespace": self.ServiceNamespace, } ) @cached_property def scalable_target(self) -> "ScalableTarget | None": """ Return the :py:class:`ScalableTarget` object that this scaling policy applies to. .. note:: The output of this property is cached on the model instance, so calling this multiple times will not result in multiple calls to the AWS API. If you need a fresh copy of the data, you can re-get the model instance from the manager. """ try: pk = OrderedDict( { "ResourceId": self.ResourceId, "ScalableDimension": self.ScalableDimension, "ServiceNamespace": self.ServiceNamespace, } ) except AttributeError: return None return ScalableTarget.objects.using(self.session).get(**pk) # type: ignore[arg-type]
[docs]class ApplicationAutoscalingSuspendedState(Boto3Model): """ Specifies whether the scaling activities for a scalable target are in a suspended state. """ DynamicScalingInSuspended: "bool | None" = None """ Whether scale in by a target tracking scaling policy or a step scaling policy is suspended. Set the value to ``true`` if you don't want Application Auto Scaling to remove capacity when a scaling policy is triggered. The default is ``false``. """ DynamicScalingOutSuspended: "bool | None" = None """ Whether scale out by a target tracking scaling policy or a step scaling policy is suspended. Set the value to ``true`` if you don't want Application Auto Scaling to add capacity when a scaling policy is triggered. The default is ``false``. """ ScheduledScalingSuspended: "bool | None" = None """ Whether scheduled scaling is suspended. Set the value to ``true`` if you don't want Application Auto Scaling to add or remove capacity by initiating scheduled actions. The default is ``false``. """
[docs]class ScalableTarget(ScalableTargetModelMixin, PrimaryBoto3Model): """ Represents a scalable target. """ manager_class: ClassVar[type[Boto3ModelManager]] = ScalableTargetManager ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ] """ The namespace of the Amazon Web Services service that provides the resource, or a ``custom-resource``. """ ResourceId: str """ The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. """ ScalableDimension: Literal[ "ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", "elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", "dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", "dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits", "rds:cluster:ReadReplicaCount", "sagemaker:variant:DesiredInstanceCount", "custom-resource:ResourceType:Property", "comprehend:document-classifier-endpoint:DesiredInferenceUnits", "comprehend:entity-recognizer-endpoint:DesiredInferenceUnits", "lambda:function:ProvisionedConcurrency", "cassandra:table:ReadCapacityUnits", "cassandra:table:WriteCapacityUnits", "kafka:broker-storage:VolumeSize", "elasticache:cache-cluster:Nodes", "elasticache:replication-group:NodeGroups", "elasticache:replication-group:Replicas", "neptune:cluster:ReadReplicaCount", "sagemaker:variant:DesiredProvisionedConcurrency", "sagemaker:inference-component:DesiredCopyCount", "workspaces:workspacespool:DesiredUserSessions", ] """ The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property. """ MinCapacity: int """ The minimum value to scale to in response to a scale-in activity. """ MaxCapacity: int """ The maximum value to scale to in response to a scale-out activity. """ PredictedCapacity: int = Field(default=None, frozen=True) """ The predicted capacity of the scalable target. """ RoleARN: str """ The ARN of an IAM role that allows Application Auto Scaling to modify the scalable target on your behalf. """ CreationTime: datetime = Field(frozen=True) """ The Unix timestamp for when the scalable target was created. """ SuspendedState: "ApplicationAutoscalingSuspendedState | None" = None """ Specifies whether the scaling activities for a scalable target are in a suspended state. """ ScalableTargetARN: str = Field(default=None, frozen=True) """ The ARN of the scalable target. """ @property def arn(self) -> str | None: """ Return the ARN of the model. This is the value of the :py:attr:`ScalableTargetARN` attribute. Returns: The ARN of the model instance. """ return self.ScalableTargetARN @property def name(self) -> str | None: """ Return the name of the model. This is the value of the :py:attr:`ResourceId` attribute. Returns: The name of the model instance. """ return self.ResourceId @property def pk(self) -> OrderedDict[str, Any]: """ The primary key of the scalable target. This can be used do :py:meth:`botocraft.services.application_autoscaling.ScalableTargetManager.delete`. """ return OrderedDict( { "ServiceNamespace": self.ServiceNamespace, "ResourceIds": [self.ResourceId], "ScalableDimension": self.ScalableDimension, } ) @cached_property def scaling_policies(self) -> "list[ScalingPolicy] | None": """ Return the :py:class:`ScalingPolicy` objects that this scalable target has. .. note:: The output of this property is cached on the model instance, so calling this multiple times will not result in multiple calls to the AWS API. If you need a fresh copy of the data, you can re-get the model instance from the manager. """ try: pk = OrderedDict( { "ServiceNamespace": self.ServiceNamespace, "ResourceIds": [self.ResourceId], "ScalableDimension": self.ScalableDimension, } ) except AttributeError: return [] return ScalingPolicy.objects.using(self.session).list(**pk) # type: ignore[arg-type] @cached_property def scheduled_action(self) -> "ScheduledAction | None": """ Return the :py:class:`ScheduledAction` objects that this scalable target has. .. note:: The output of this property is cached on the model instance, so calling this multiple times will not result in multiple calls to the AWS API. If you need a fresh copy of the data, you can re-get the model instance from the manager. """ try: pk = OrderedDict( { "ServiceNamespace": self.ServiceNamespace, "ResourceId": self.ResourceId, "ScalableDimension": self.ScalableDimension, } ) except AttributeError: return None return ScheduledAction.objects.using(self.session).get(**pk) # type: ignore[arg-type]
[docs]class ApplicationAutoscalingScalableTargetAction(Boto3Model): """ Represents the minimum and maximum capacity for a scheduled action. """ MinCapacity: "int | None" = None """ The minimum capacity. """ MaxCapacity: "int | None" = None """ The maximum capacity. """
[docs]class ScheduledAction(PrimaryBoto3Model): """ Represents a scheduled action. """ manager_class: ClassVar[type[Boto3ModelManager]] = ScheduledActionManager ScheduledActionName: str """ The name of the scheduled action. """ ScheduledActionARN: str """ The Amazon Resource Name (ARN) of the scheduled action. """ ServiceNamespace: Literal[ "ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb", "rds", "sagemaker", "custom-resource", "comprehend", "lambda", "cassandra", "kafka", "elasticache", "neptune", "workspaces", ] """ The namespace of the Amazon Web Services service that provides the resource, or a ``custom-resource``. """ Schedule: str """ The schedule for this action. The following formats are supported: """ Timezone: "str | None" = None """ The time zone used when referring to the date and time of a scheduled action, when the scheduled action uses an at or cron expression. """ ResourceId: str """ The identifier of the resource associated with the scaling policy. This string consists of the resource type and unique identifier. """ ScalableDimension: "Literal['ecs:service:DesiredCount', 'ec2:spot-fleet-request:TargetCapacity', 'elasticmapreduce:instancegroup:InstanceCount', 'appstream:fleet:DesiredCapacity', 'dynamodb:table:ReadCapacityUnits', 'dynamodb:table:WriteCapacityUnits', 'dynamodb:index:ReadCapacityUnits', 'dynamodb:index:WriteCapacityUnits', 'rds:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredInstanceCount', 'custom-resource:ResourceType:Property', 'comprehend:document-classifier-endpoint:DesiredInferenceUnits', 'comprehend:entity-recognizer-endpoint:DesiredInferenceUnits', 'lambda:function:ProvisionedConcurrency', 'cassandra:table:ReadCapacityUnits', 'cassandra:table:WriteCapacityUnits', 'kafka:broker-storage:VolumeSize', 'elasticache:cache-cluster:Nodes', 'elasticache:replication-group:NodeGroups', 'elasticache:replication-group:Replicas', 'neptune:cluster:ReadReplicaCount', 'sagemaker:variant:DesiredProvisionedConcurrency', 'sagemaker:inference-component:DesiredCopyCount', 'workspaces:workspacespool:DesiredUserSessions'] | None" = None """ The scalable dimension. This string consists of the service namespace, resource type, and scaling property. """ StartTime: "datetime | None" = None """ The date and time that the action is scheduled to begin, in UTC. """ EndTime: "datetime | None" = None """ The date and time that the action is scheduled to end, in UTC. """ ScalableTargetAction: "ApplicationAutoscalingScalableTargetAction | None" = None """ The new minimum and maximum capacity. You can set both values or just one. At the scheduled time, if the current capacity is below the minimum capacity, Application Auto Scaling scales out to the minimum capacity. If the current capacity is above the maximum capacity, Application Auto Scaling scales in to the maximum capacity. """ CreationTime: datetime """ The date and time that the scheduled action was created. """ @property def arn(self) -> str | None: """ Return the ARN of the model. This is the value of the :py:attr:`ScheduledActionARN` attribute. Returns: The ARN of the model instance. """ return self.ScheduledActionARN @property def name(self) -> str | None: """ Return the name of the model. This is the value of the :py:attr:`ScheduledActionName` attribute. Returns: The name of the model instance. """ return self.ScheduledActionName @property def pk(self) -> OrderedDict[str, Any]: """ The primary key of the scheduled action. This can be used to get the scheduled action with the :py:meth:`botocraft.services.application_autoscaling.ScheduledActionManager.get` method, or to do :py:meth:`botocraft.services.application_autoscaling.ScheduledActionManager.delete`. """ return OrderedDict( { "ServiceNamespace": self.ServiceNamespace, "ScheduledActionNames": [self.ScheduledActionName], } ) @cached_property def scalable_target(self) -> "ScalableTarget | None": """ Return the :py:class:`ScalableTarget` object that this scheduled action applies to. .. note:: The output of this property is cached on the model instance, so calling this multiple times will not result in multiple calls to the AWS API. If you need a fresh copy of the data, you can re-get the model instance from the manager. """ try: pk = OrderedDict( { "ServiceNamespace": self.ServiceNamespace, "ResourceIds": [self.ResourceId], "ScalableDimension": self.ScalableDimension, } ) except AttributeError: return None return ScalableTarget.objects.using(self.session).get(**pk) # type: ignore[arg-type]
# ======================= # Request/Response Models # =======================
[docs]class PutScalingPolicyResponse(Boto3Model): PolicyARN: str """ The Amazon Resource Name (ARN) of the resulting scaling policy. """ Alarms: "builtins.list[Alarm] | None" = Field(default_factory=list) """ The CloudWatch alarms created for the target tracking scaling policy. """
[docs]class DeleteScalingPolicyResponse(Boto3Model): pass
[docs]class DescribeScalingPoliciesResponse(Boto3Model): ScalingPolicies: "builtins.list[ScalingPolicy] | None" = Field(default_factory=list) """ Information about the scaling policies. """ NextToken: "str | None" = None """ The token required to get the next set of results. This value is ``null`` if there are no more results to return. """
[docs]class RegisterScalableTargetResponse(Boto3Model): ScalableTargetARN: "str | None" = None """ The ARN of the scalable target. """
[docs]class DeregisterScalableTargetResponse(Boto3Model): pass
[docs]class DescribeScalableTargetsResponse(Boto3Model): ScalableTargets: "builtins.list[ScalableTarget] | None" = Field( default_factory=list ) """ The scalable targets that match the request parameters. """ NextToken: "str | None" = None """ The token required to get the next set of results. This value is ``null`` if there are no more results to return. """
[docs]class DeleteScheduledActionResponse(Boto3Model): pass
[docs]class DescribeScheduledActionsResponse(Boto3Model): ScheduledActions: "builtins.list[ScheduledAction] | None" = Field( default_factory=list ) """ Information about the scheduled actions. """ NextToken: "str | None" = None """ The token required to get the next set of results. This value is ``null`` if there are no more results to return. """