text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: application_auto_scaling
using AWS.Compat
using AWS.UUIDs

"""
    DeleteScalingPolicy()

Deletes the specified scaling policy for an Application Auto Scaling scalable target. Deleting a step scaling policy deletes the underlying alarm action, but does not delete the CloudWatch alarm associated with the scaling policy, even if it no longer has an associated action. For more information, see Delete a Step Scaling Policy and Delete a Target Tracking Scaling Policy in the Application Auto Scaling User Guide.

# Required Parameters
- `PolicyName`: The name of the scaling policy.
- `ResourceId`: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

"""
delete_scaling_policy(PolicyName, ResourceId, ScalableDimension, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeleteScalingPolicy", Dict{String, Any}("PolicyName"=>PolicyName, "ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
delete_scaling_policy(PolicyName, ResourceId, ScalableDimension, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeleteScalingPolicy", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("PolicyName"=>PolicyName, "ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DeleteScheduledAction()

Deletes the specified scheduled action for an Application Auto Scaling scalable target. For more information, see Delete a Scheduled Action in the Application Auto Scaling User Guide.

# Required Parameters
- `ResourceId`: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ScheduledActionName`: The name of the scheduled action.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

"""
delete_scheduled_action(ResourceId, ScalableDimension, ScheduledActionName, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeleteScheduledAction", Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ScheduledActionName"=>ScheduledActionName, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
delete_scheduled_action(ResourceId, ScalableDimension, ScheduledActionName, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeleteScheduledAction", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ScheduledActionName"=>ScheduledActionName, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DeregisterScalableTarget()

Deregisters an Application Auto Scaling scalable target when you have finished using it. To see which resources have been registered, use DescribeScalableTargets.   Deregistering a scalable target deletes the scaling policies and the scheduled actions that are associated with it.

# Required Parameters
- `ResourceId`: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

"""
deregister_scalable_target(ResourceId, ScalableDimension, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeregisterScalableTarget", Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
deregister_scalable_target(ResourceId, ScalableDimension, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DeregisterScalableTarget", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DescribeScalableTargets()

Gets information about the scalable targets in the specified namespace. You can filter the results using ResourceIds and ScalableDimension.

# Required Parameters
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `MaxResults`: The maximum number of scalable targets. This value can be between 1 and 50. The default value is 50. If this parameter is used, the operation returns up to MaxResults results at a time, along with a NextToken value. To get the next set of results, include the NextToken value in a subsequent call. If this parameter is not used, the operation returns up to 50 results and a NextToken value, if applicable.
- `NextToken`: The token for the next set of results.
- `ResourceIds`: The identifier of the resource associated with the scalable target. This string consists of the resource type and unique identifier. If you specify a scalable dimension, you must also specify a resource ID.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `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.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
"""
describe_scalable_targets(ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalableTargets", Dict{String, Any}("ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
describe_scalable_targets(ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalableTargets", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DescribeScalingActivities()

Provides descriptive information about the scaling activities in the specified namespace from the previous six weeks. You can filter the results using ResourceId and ScalableDimension.

# Required Parameters
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `MaxResults`: The maximum number of scalable targets. This value can be between 1 and 50. The default value is 50. If this parameter is used, the operation returns up to MaxResults results at a time, along with a NextToken value. To get the next set of results, include the NextToken value in a subsequent call. If this parameter is not used, the operation returns up to 50 results and a NextToken value, if applicable.
- `NextToken`: The token for the next set of results.
- `ResourceId`: The identifier of the resource associated with the scaling activity. This string consists of the resource type and unique identifier. If you specify a scalable dimension, you must also specify a resource ID.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `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.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
"""
describe_scaling_activities(ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalingActivities", Dict{String, Any}("ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
describe_scaling_activities(ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalingActivities", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DescribeScalingPolicies()

Describes the Application Auto Scaling scaling policies for the specified service namespace. You can filter the results using ResourceId, ScalableDimension, and PolicyNames. For more information, see Target Tracking Scaling Policies and Step Scaling Policies in the Application Auto Scaling User Guide.

# Required Parameters
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `MaxResults`: The maximum number of scalable targets. This value can be between 1 and 50. The default value is 50. If this parameter is used, the operation returns up to MaxResults results at a time, along with a NextToken value. To get the next set of results, include the NextToken value in a subsequent call. If this parameter is not used, the operation returns up to 50 results and a NextToken value, if applicable.
- `NextToken`: The token for the next set of results.
- `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. If you specify a scalable dimension, you must also specify a resource ID.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `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.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
"""
describe_scaling_policies(ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalingPolicies", Dict{String, Any}("ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
describe_scaling_policies(ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScalingPolicies", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    DescribeScheduledActions()

Describes the Application Auto Scaling scheduled actions for the specified service namespace. You can filter the results using the ResourceId, ScalableDimension, and ScheduledActionNames parameters. For more information, see Scheduled Scaling in the Application Auto Scaling User Guide.

# Required Parameters
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `MaxResults`: The maximum number of scheduled action results. This value can be between 1 and 50. The default value is 50. If this parameter is used, the operation returns up to MaxResults results at a time, along with a NextToken value. To get the next set of results, include the NextToken value in a subsequent call. If this parameter is not used, the operation returns up to 50 results and a NextToken value, if applicable.
- `NextToken`: The token for the next set of results.
- `ResourceId`: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier. If you specify a scalable dimension, you must also specify a resource ID.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `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.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ScheduledActionNames`: The names of the scheduled actions to describe.
"""
describe_scheduled_actions(ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScheduledActions", Dict{String, Any}("ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
describe_scheduled_actions(ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("DescribeScheduledActions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    PutScalingPolicy()

Creates or updates a scaling policy for an Application Auto Scaling scalable target. Each scalable target is identified by a service namespace, resource ID, and scalable dimension. A scaling policy applies to the scalable target identified by those three attributes. You cannot create a scaling policy until you have registered the resource as a scalable target. Multiple scaling policies can be in force at the same time for the same scalable target. You can have one or more target tracking scaling policies, one or more step scaling policies, or both. However, there is a chance that multiple policies could conflict, instructing the scalable target to scale out or in at the same time. Application Auto Scaling gives precedence to the policy that provides the largest capacity for both scale out and scale in. For example, if one policy increases capacity by 3, another policy increases capacity by 200 percent, and the current capacity is 10, Application Auto Scaling uses the policy with the highest calculated capacity (200% of 10 = 20) and scales out to 30.  We recommend caution, however, when using target tracking scaling policies with step scaling policies because conflicts between these policies can cause undesirable behavior. For example, if the step scaling policy initiates a scale-in activity before the target tracking policy is ready to scale in, the scale-in activity will not be blocked. After the scale-in activity completes, the target tracking policy could instruct the scalable target to scale out again.  For more information, see Target Tracking Scaling Policies and Step Scaling Policies in the Application Auto Scaling User Guide.  If a scalable target is deregistered, the scalable target is no longer available to execute scaling policies. Any scaling policies that were specified for the scalable target are deleted.

# Required Parameters
- `PolicyName`: The name of the scaling policy.
- `ResourceId`: The identifier of the resource associated with the scaling policy. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `PolicyType`: The policy type. This parameter is required if you are creating a scaling policy. The following policy types are supported:   TargetTrackingScaling—Not supported for Amazon EMR  StepScaling—Not supported for DynamoDB, Amazon Comprehend, Lambda, Amazon Keyspaces (for Apache Cassandra), or Amazon MSK. For more information, see Target Tracking Scaling Policies and Step Scaling Policies in the Application Auto Scaling User Guide.
- `StepScalingPolicyConfiguration`: A step scaling policy. This parameter is required if you are creating a policy and the policy type is StepScaling.
- `TargetTrackingScalingPolicyConfiguration`: A target tracking scaling policy. Includes support for predefined or customized metrics. This parameter is required if you are creating a policy and the policy type is TargetTrackingScaling.
"""
put_scaling_policy(PolicyName, ResourceId, ScalableDimension, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("PutScalingPolicy", Dict{String, Any}("PolicyName"=>PolicyName, "ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
put_scaling_policy(PolicyName, ResourceId, ScalableDimension, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("PutScalingPolicy", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("PolicyName"=>PolicyName, "ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    PutScheduledAction()

Creates or updates a scheduled action for an Application Auto Scaling scalable target. Each scalable target is identified by a service namespace, resource ID, and scalable dimension. A scheduled action applies to the scalable target identified by those three attributes. You cannot create a scheduled action until you have registered the resource as a scalable target. When start and end times are specified with a recurring schedule using a cron expression or rates, they form the boundaries of when the recurring action starts and stops. To update a scheduled action, specify the parameters that you want to change. If you don't specify start and end times, the old values are deleted. For more information, see Scheduled Scaling in the Application Auto Scaling User Guide.  If a scalable target is deregistered, the scalable target is no longer available to run scheduled actions. Any scheduled actions that were specified for the scalable target are deleted.

# Required Parameters
- `ResourceId`: The identifier of the resource associated with the scheduled action. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ScheduledActionName`: The name of the scheduled action. This name must be unique among all other scheduled actions on the specified scalable target.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `EndTime`: The date and time for the recurring schedule to end.
- `ScalableTargetAction`: 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.
- `Schedule`: The schedule for this action. The following formats are supported:   At expressions - \"at(yyyy-mm-ddThh:mm:ss)\"   Rate expressions - \"rate(value unit)\"   Cron expressions - \"cron(fields)\"   At expressions are useful for one-time schedules. Specify the time in UTC. For rate expressions, value is a positive integer and unit is minute | minutes | hour | hours | day | days. For more information about cron expressions, see Cron Expressions in the Amazon CloudWatch Events User Guide. For examples of using these expressions, see Scheduled Scaling in the Application Auto Scaling User Guide.
- `StartTime`: The date and time for this scheduled action to start.
"""
put_scheduled_action(ResourceId, ScalableDimension, ScheduledActionName, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("PutScheduledAction", Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ScheduledActionName"=>ScheduledActionName, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
put_scheduled_action(ResourceId, ScalableDimension, ScheduledActionName, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("PutScheduledAction", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ScheduledActionName"=>ScheduledActionName, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)

"""
    RegisterScalableTarget()

Registers or updates a scalable target.  A scalable target is a resource that Application Auto Scaling can scale out and scale in. Scalable targets are uniquely identified by the combination of resource ID, scalable dimension, and namespace.  When you register a new scalable target, you must specify values for minimum and maximum capacity. Current capacity will be adjusted within the specified range when scaling starts. Application Auto Scaling scaling policies will not scale capacity to values that are outside of this range. After you register a scalable target, you do not need to register it again to use other Application Auto Scaling operations. To see which resources have been registered, use DescribeScalableTargets. You can also view the scaling policies for a service namespace by using DescribeScalableTargets. If you no longer need a scalable target, you can deregister it by using DeregisterScalableTarget. To update a scalable target, specify the parameters that you want to change. Include the parameters that identify the scalable target: resource ID, scalable dimension, and namespace. Any parameters that you don't specify are not changed by this update request.

# Required Parameters
- `ResourceId`: The identifier of the resource that is associated with the scalable target. This string consists of the resource type and unique identifier.   ECS service - The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp.   Spot Fleet request - The resource type is spot-fleet-request and the unique identifier is the Spot Fleet request ID. Example: spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE.   EMR cluster - The resource type is instancegroup and the unique identifier is the cluster ID and instance group ID. Example: instancegroup/j-2EEZNYKUA1NTV/ig-1791Y4E1L8YI0.   AppStream 2.0 fleet - The resource type is fleet and the unique identifier is the fleet name. Example: fleet/sample-fleet.   DynamoDB table - The resource type is table and the unique identifier is the table name. Example: table/my-table.   DynamoDB global secondary index - The resource type is index and the unique identifier is the index name. Example: table/my-table/index/my-table-index.   Aurora DB cluster - The resource type is cluster and the unique identifier is the cluster name. Example: cluster:my-db-cluster.   Amazon SageMaker endpoint variant - The resource type is variant and the unique identifier is the resource ID. Example: endpoint/my-end-point/variant/KMeansClustering.   Custom resources are not supported with a resource type. This parameter must specify the OutputValue from the CloudFormation template stack used to access the resources. The unique identifier is defined by the service provider. More information is available in our GitHub repository.   Amazon Comprehend document classification endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:document-classifier-endpoint/EXAMPLE.   Amazon Comprehend entity recognizer endpoint - The resource type and unique identifier are specified using the endpoint ARN. Example: arn:aws:comprehend:us-west-2:123456789012:entity-recognizer-endpoint/EXAMPLE.   Lambda provisioned concurrency - The resource type is function and the unique identifier is the function name with a function version or alias name suffix that is not LATEST. Example: function:my-function:prod or function:my-function:1.   Amazon Keyspaces table - The resource type is table and the unique identifier is the table name. Example: keyspace/mykeyspace/table/mytable.   Amazon MSK cluster - The resource type and unique identifier are specified using the cluster ARN. Example: arn:aws:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5.
- `ScalableDimension`: The scalable dimension associated with the scalable target. This string consists of the service namespace, resource type, and scaling property.    ecs:service:DesiredCount - The desired task count of an ECS service.    ec2:spot-fleet-request:TargetCapacity - The target capacity of a Spot Fleet request.    elasticmapreduce:instancegroup:InstanceCount - The instance count of an EMR Instance Group.    appstream:fleet:DesiredCapacity - The desired capacity of an AppStream 2.0 fleet.    dynamodb:table:ReadCapacityUnits - The provisioned read capacity for a DynamoDB table.    dynamodb:table:WriteCapacityUnits - The provisioned write capacity for a DynamoDB table.    dynamodb:index:ReadCapacityUnits - The provisioned read capacity for a DynamoDB global secondary index.    dynamodb:index:WriteCapacityUnits - The provisioned write capacity for a DynamoDB global secondary index.    rds:cluster:ReadReplicaCount - The count of Aurora Replicas in an Aurora DB cluster. Available for Aurora MySQL-compatible edition and Aurora PostgreSQL-compatible edition.    sagemaker:variant:DesiredInstanceCount - The number of EC2 instances for an Amazon SageMaker model endpoint variant.    custom-resource:ResourceType:Property - The scalable dimension for a custom resource provided by your own application or service.    comprehend:document-classifier-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend document classification endpoint.    comprehend:entity-recognizer-endpoint:DesiredInferenceUnits - The number of inference units for an Amazon Comprehend entity recognizer endpoint.    lambda:function:ProvisionedConcurrency - The provisioned concurrency for a Lambda function.    cassandra:table:ReadCapacityUnits - The provisioned read capacity for an Amazon Keyspaces table.    cassandra:table:WriteCapacityUnits - The provisioned write capacity for an Amazon Keyspaces table.    kafka:broker-storage:VolumeSize - The provisioned volume size (in GiB) for brokers in an Amazon MSK cluster.
- `ServiceNamespace`: The namespace of the AWS service that provides the resource. For a resource provided by your own application or service, use custom-resource instead.

# Optional Parameters
- `MaxCapacity`: The maximum value that you plan to scale out to. When a scaling policy is in effect, Application Auto Scaling can scale out (expand) as needed to the maximum capacity limit in response to changing demand.  This parameter is required if you are registering a scalable target. Although you can specify a large maximum capacity, note that service quotas may impose lower limits. Each service has its own default quotas for the maximum capacity of the resource. If you want to specify a higher limit, you can request an increase. For more information, consult the documentation for that service. For information about the default quotas for each service, see Service Endpoints and Quotas in the Amazon Web Services General Reference.
- `MinCapacity`: The minimum value that you plan to scale in to. When a scaling policy is in effect, Application Auto Scaling can scale in (contract) as needed to the minimum capacity limit in response to changing demand.  This parameter is required if you are registering a scalable target. For certain resources, the minimum value allowed is 0. This includes Lambda provisioned concurrency, Spot Fleet, ECS services, Aurora DB clusters, EMR clusters, and custom resources. For all other resources, the minimum value allowed is 1.
- `RoleARN`: This parameter is required for services that do not support service-linked roles (such as Amazon EMR), and it must specify the ARN of an IAM role that allows Application Auto Scaling to modify the scalable target on your behalf.  If the service supports service-linked roles, Application Auto Scaling uses a service-linked role, which it creates if it does not yet exist. For more information, see Application Auto Scaling IAM Roles.
- `SuspendedState`: An embedded object that contains attributes and attribute values that are used to suspend and resume automatic scaling. Setting the value of an attribute to true suspends the specified scaling activities. Setting it to false (default) resumes the specified scaling activities.   Suspension Outcomes    For DynamicScalingInSuspended, while a suspension is in effect, all scale-in activities that are triggered by a scaling policy are suspended.   For DynamicScalingOutSuspended, while a suspension is in effect, all scale-out activities that are triggered by a scaling policy are suspended.   For ScheduledScalingSuspended, while a suspension is in effect, all scaling activities that involve scheduled actions are suspended.    For more information, see Suspending and Resuming Scaling in the Application Auto Scaling User Guide.
"""
register_scalable_target(ResourceId, ScalableDimension, ServiceNamespace; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("RegisterScalableTarget", Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace); aws_config=aws_config)
register_scalable_target(ResourceId, ScalableDimension, ServiceNamespace, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = application_auto_scaling("RegisterScalableTarget", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceId"=>ResourceId, "ScalableDimension"=>ScalableDimension, "ServiceNamespace"=>ServiceNamespace), args)); aws_config=aws_config)


text:
using ConstrainedDynamics

# Parameters
joint_axis = [1.0;0.0;0.0]

length1 = 0.5
width, depth = 0.5, 0.5

corners = [
    [[length1 / 2;length1 / 2;-length1 / 2]]
    [[length1 / 2;-length1 / 2;-length1 / 2]]
    [[-length1 / 2;length1 / 2;-length1 / 2]]
    [[-length1 / 2;-length1 / 2;-length1 / 2]]
    [[length1 / 2;length1 / 2;length1 / 2]]
    [[length1 / 2;-length1 / 2;length1 / 2]]
    [[-length1 / 2;length1 / 2;length1 / 2]]
    [[-length1 / 2;-length1 / 2;length1 / 2]]
]

# Links
origin = Origin{Float64}()

link1 = Box(width, depth, length1, 1., color = RGBA(1., 1., 0.))
links = [link1]

# Constraints
ineqcs = [InequalityConstraint(Impact(link1, [0;0;1.0], p = corners[i])) for i = 1:8]

eqcs = [EqualityConstraint(Floating(origin, link1))]

mech = Mechanism(origin, links, eqcs, ineqcs)
setPosition!(link1,x = [0.;-2;1.5])

setVelocity!(link1,v = [0;3;7.],ω = [0.1;0.1;0.1])

ext: jl


text:
# To run this script, `cd` to the `./test/fixtures` directory and then, from the Julia terminal, `include("./runner.jl")`.

import JSON

function gen( x, name )
	len = length( x );

	frac = Array( Float64, len );
	exp = Array( Float64, len );
	v = Array( Float64, len );

	for i in eachindex(x)
		out = frexp( x[i] );
		frac[ i ] = out[ 1 ];
		exp[ i ] = out[ 2 ];
		v[ i ] = ldexp( out[1], out[2] );
	end

	data = Dict([
		("frac", frac),
		("exp", exp),
		("expected", v)
	]);

	outfile = open( name, "w" );
	write( outfile, JSON.json(data) );
	close( outfile );
end

# Small values:
x = linspace( 1e-200, 1e-308, 1007 );
name = "small.json";
gen( x, name );

# Medium values:
x = linspace( -1e3, 1e3, 1007 );
name = "medium.json";
gen( x, name );

# Large values:
x = linspace( 1e200, 1e308, 1007 );
name = "large.json";
gen( x, name );

# Subnormal values:
x = linspace( 1e-310, 5e-324, 1007 );
name = "subnormal.json";
gen( x, name );

max_stars_repo_name: math-io/ldexp

max_issues_repo_name: math-io/ldexp


text:
using MLStyle
# import SimplePosets
using NestedTuples
using NestedTuples: LazyMerge

expr(x) = :(identity($x))

# like `something`, but doesn't throw an error
maybesomething() = nothing
maybesomething(x::Nothing, y...) = maybesomething(y...)
maybesomething(x::Some, y...) = x.value
maybesomething(x::Any, y...) = x

export argtuple
argtuple(m) = arguments(m) |> astuple

astuple(x) = Expr(:tuple,x...)
astuple(x::Symbol) = Expr(:tuple,x)

export arguments
arguments(m::AbstractModel) = model(m).args

export parameters
parameters(m::AbstractModel) = parameters(m.body)

function parameters(ast)
    leaf(x) = Set{Symbol}()
    @inline function branch(f, head, args)
        default() = mapreduce(f, union, args)
        head == :call || return default()
        first(args) == :~ || return default()
        length(args) == 3 || return default()

        # If we get here, we know we're working with something like `lhs ~ rhs`
        lhs = args[2]
        rhs = args[3]

        lhs′ = @match lhs begin
            :(($(x::Symbol), $o)) => return Set{Symbol}((x,))
            :(($(x::Var), $o)) => return Set{Symbol}((x,))
            _ => begin
                (x, o) = unescape.(Accessors.parse_obj_optic(lhs))
                return Set{Symbol}((x,))
            end
        end

    end

    foldast(leaf, branch)(ast)
end

export variables
variables(m::AbstractModel) = union(arguments(m), parameters(m))

function variables(expr :: Expr)
    leaf(s::Symbol) = begin
        [s]
    end
    leaf(x) = []
    branch(head, newargs) = begin
        union(newargs...)
    end
    foldall(leaf, branch)(expr)
end

variables(s::Symbol) = [s]
variables(x) = []

export foldast

function foldast(leaf, branch; kwargs...)
    @inline function f(ast::Expr; kwargs...)
        MLStyle.@match ast begin
            Expr(head, args...) => branch(f, head, args; kwargs...)
        end
    end
    f(x; kwargs...) = leaf(x; kwargs...)

    return f
end

export foldall
function foldall(leaf, branch; kwargs...)
    function go(ast)
        MLStyle.@match ast begin
            Expr(head, args...) => branch(head, map(go, args); kwargs...)
            x                   => leaf(x; kwargs...)
        end
    end

    return go
end

export foldall1
function foldall1(leaf, branch; kwargs...)
    function go(ast)
        MLStyle.@match ast begin
            Expr(head, arg1, args...) => branch(head, arg1, map(go, args); kwargs...)
            x                         => leaf(x; kwargs...)
        end
    end

    return go
end

import MacroTools: striplines, @q

# function arguments(model::DAGModel)
#     model.args
# end

allequal(xs) = all(xs[1] .== xs)

# # fold example usage:
# # ------------------
# # function leafCount(ast)
# #     leaf(x) = 1
# #     expr(head, arg1, newargs) = sum(newargs)
# #     fold(leaf, expr)(ast)
# # end

# # leaves = begin
# #     leaf(x) = [x]
# #     expr(head, arg1, newargs) = union(newargs...)
# #     fold(leaf, expr)
# # end

# # ast = :(f(x + 3y))

# # leaves(ast)

# # Example of Tamas Papp's `as` combinator:
# # julia> as((;s=as(Array, as𝕀,4), a=asℝ))(randn(5))
# # (s = [0.545324, 0.281332, 0.418541, 0.485946], a = 2.217762640580984)

# From https://github.com/thautwarm/MLStyle.jl/issues/66
@active LamExpr(x) begin
           @match x begin
               :($a -> begin $(bs...) end) =>
                 let exprs = filter(x -> !(x isa LineNumberNode), bs)
                   if length(exprs) == 1
                     (a, exprs[1])
                   else
                     (a, Expr(:block, bs...))
                     end
               end
                _  => nothing
           end
       end

# using BenchmarkTools
# f(;kwargs...) = kwargs[:a] + kwargs[:b]

# @btime invokefrozen(f, Int; a=3,b=4)  # 3.466 ns (0 allocations: 0 bytes)
# @btime f(;a=3,b=4)                    # 1.152 ns (0 allocations: 0 bytes)

# @isdefined
# Base.@locals
# @__MODULE__
# names

# getprototype(::Type{NamedTuple{(),Tuple{}}}) = NamedTuple()
getprototype(::Type{NamedTuple{N,T} where {T <: Tuple} } ) where {N} = NamedTuple{N}
getprototype(::NamedTuple{N,T} where {T<: Tuple} ) where N = NamedTuple{N}

function loadvals(argstype, obstype)
    args = getntkeys(argstype)
    obs = getntkeys(obstype)
    loader = @q begin
    end

    for k in args
        push!(loader.args, :($k = _args.$k))
    end
    for k in obs
        push!(loader.args, :($k = _obs.$k))
    end

    src -> (@q begin
        $loader
        $src
    end) |> MacroTools.flatten
end

function loadvals(argstype, datatype, parstype)
    args = schema(argstype)
    data = schema(datatype)
    pars = schema(parstype)

    loader = @q begin

    end

    for k in keys(args)
        T = getproperty(args, k)
        push!(loader.args, :($k::$T = _args.$k))
    end
    for k in setdiff(keys(data), keys(pars))
        T = getproperty(data, k)
        push!(loader.args, :($k::$T = _data.$k))
    end

    for k in setdiff(keys(pars), keys(data))
        T = getproperty(pars, k)
        push!(loader.args, :($k::$T = _pars.$k))
    end

    for k in keys(pars) ∩ keys(data)
        qk = QuoteNode(k)
        if typejoin(getproperty(pars, k), getproperty(data, k)) <: NamedTuple
            push!(loader.args, :($k = Tilde.NestedTuples.lazymerge(_data.$k, _pars.$k)))
        else
            T = getproperty(pars, k)
            push!(loader.args, quote
                _k = $qk
                @warn "Duplicate key, ignoring $_k in data"
                $k::$T = _pars.$k
            end)
        end
    end

    src -> (@q begin
        $loader
        $src
    end) |> MacroTools.flatten
end

getntkeys(::NamedTuple{A,B}) where {A,B} = A
getntkeys(::Type{NamedTuple{A,B}}) where {A,B} = A
getntkeys(::Type{NamedTuple{A}}) where {A} = A
getntkeys(::Type{LazyMerge{X,Y}}) where {X,Y} = Tuple(getntkeys(X) ∪ getntkeys(Y))

# This is just handy for REPLing, no direct connection to Tilde

# julia> tower(Int)
# 6-element Array{DataType,1}:
#  Int64
#  Signed
#  Integer
#  Real
#  Number
#  Any

const TypeLevel = GeneralizedGenerated.TypeLevel

export drop_return

function drop_return(m::Model)
    Model(getmodule(m), arguments(m), drop_return(body(m)))
end

function drop_return(ast)
    leaf(x) = x
    function branch(f, head, args)
        head === :return && return nothing
        return Expr(head, map(f, args)...)
    end
    foldast(leaf, branch)(ast)
end

export unVal
export val2nt

unVal(::Type{V}) where {T, V <: Val{T}} = T
unVal(::Val{T}) where {T} = T

function val2nt(v,x)
    k = Tilde.unVal(v)
    NamedTuple{(k,)}((x,))
end

function detilde(ast)
    q = MLStyle.@match ast begin
            :($x ~ $rhs)        => :($x = __SAMPLE__($rhs))
            Expr(head, args...) => Expr(head, map(detilde, args)...)
            x                   => x
    end

    MacroTools.flatten(q)
end

retilde(s::Symbol) = s
retilde(s::Number) = s

function retilde(v::JuliaVariables.Var)
    ifelse(v.name == :__SAMPLE__, :__SAMPLE__, v)
end

function retilde(ast)
    MLStyle.@match ast begin
            :($x = $v($rhs))        => begin
                    rx = retilde(x)
                    rv = retilde(v)
                    rrhs = retilde(rhs)
                    if rv == :__SAMPLE__
                        return :($rx ~ $rrhs)
                    else
                        return :($rx = $rv($rrhs))
                    end
            end
            Expr(head, args...) => Expr(head, map(retilde, args)...)
            x                   => x
    end
end

asfun(m::AbstractModel) = :(($(arguments(m)...),) -> $(Tilde.body(m)) )

function solve_scope(m::AbstractModel)
    solve_scope(asfun(m))
end

function solve_scope(ex::Expr)
    ex |> detilde |> simplify_ex  |> MacroTools.flatten  |> solve_from_local |> retilde
end

function locally_bound(ex, optic)
    isolated = solve_scope(optic(ex))
    in_context = optic(solve_scope(ex))

    setdiff(globals(isolated), globals(in_context))
end

"""
Given a JuliaVariables "solved" expression, convert back to a standard expression
"""
function unsolve(ex)
    ex = unwrap_scoped(ex)
    @match ex begin
        v::JuliaVariables.Var => v.name
        Expr(head, args...) => Expr(head, map(unsolve, args)...)
        x => x
    end
end

"""
Return the set of local variable names from a *solved* expression (using JuliaVariables)
"""
function locals(ex)
    go(ex) = @match ex begin
        v::JuliaVariables.Var => ifelse(v.is_global, Set{Symbol}(), Set((v.name,)))
        Expr(head, args...) => union(map(go, args)...)
        x => Set{Symbol}()
    end

    Tuple(go(ex))
end

# make_closure(funexpr)

# @gg function make_closure(__vars::NamedTuple{N,T}, funexpr) where {N,T}
#     funexpr =
#     fdict = MacroTools.splitdef(funexpr)
#     for v in N
#         qv = QuoteNode(v)
#         pushfirst!(fdict[:body], :($v = getproperty(__vars, $qv)))
#     end

#     fdict[:args] = Any[:__ctx, Expr(:tuple, fdict[:args]...)]

# f(ctx) = Base.Fix1(ctx) do ctx, j
#     p = ctx.p
#     Bernoulli(p/j)
# end

struct ReturnNow{T}
    value::T
end


text:
push!(LOAD_PATH, joinpath(expanduser("~/repos/InsarTimeseries.jl/src/")))
# import InsarTimeseries
# using InsarTimeseries: PHASE_TO_CM, STACK_FLAT_SHIFTED_DSET, STACK_FLAT_DSET, STACK_DSET, CC_FILENAME, UNW_FILENAME
import Polynomials
import Glob
using HDF5
using PyCall
using Printf: @printf
try
    using MapImages
catch
end

# gps = InsarTimeseries.gps
latlon = pyimport("apertools.latlon")
gps = pyimport("apertools.gps")

reloadpython(modname) = pyimport("importlib")."reload"(modname)
reloadpython(gps)

LOS_MAP_FILE = "los_enu.tif"

# PATH 78
station_name_list78 = [
    "NMHB",
    "TXAD",
    "TXBG",
    "TXBL",
    "TXCE",
    "TXFS",
    "TXKM",
    "TXL2",
    "TXMC",
    "TXMH",
    "TXOE",
    "TXOZ",
    "TXS3",
    "TXSO",
]
#
# PATH 85
station_name_list85 = ["TXKM", "TXMH", "TXFS", "NMHB", "TXAD", "TXS3"]
# Take out TXAL cuz it's not in crop
# BAD station reasons: MDO1 (nothing 2014-2017), TXVH (started 2018), TXPC (ended 2017)

all_stations = sort(unique([station_name_list78; station_name_list85]))

# Functions for error evaluation
rms(arr::AbstractArray{T,1}) where {T <: Any} = sqrt(mean(filter(!isnan, arr.^2)))
# rms(arr::AbstractArray{T, 2}) where {T <: Any} = [rms(arr[i, :]) for i in 1:size(arr, 1)]
maxabs(x) = maximum(abs.(filter(!isnan, x)))

# Function to take a velocity file and calculate the GPS errors at one station
function get_gps_error(
    insar_fname::String,
    station_name::String;
    dset="velos",
    window=5,
    ref_station=nothing,
    verbose=false,
    shift=0.0,
    negate=false,
)
    # If it's a file with LOS flipped:
    flip_sign = negate ? -1 : 1

    # insar derived solution in a small patch
    slope_insar_mm_yr =
        flip_sign * _get_val_at_station(insar_fname, station_name, dset=dset, window=window) + shift
    slope_insar_mm_yr -= isnothing(ref_station) ? 0 :
        (
        flip_sign * _get_val_at_station(insar_fname, ref_station, dset=dset, window=window) + shift
    )

    start_date, end_date = _get_date_range(insar_fname, dset)
    slope_gps_mm_yr = solve_gps_ts(
        station_name,
        ref_station,
        start_date=start_date,
        end_date=end_date,
        los_map_file=joinpath(dirname(insar_fname), LOS_MAP_FILE),
    )

    if verbose
        @show station_name
        println("GPS velocity (mm / year): $slope_gps_mm_yr")
        println("InSAR linear velocity (mm / year): $slope_insar_mm_yr")
        println("==="^10)
    end

    return slope_insar_mm_yr - slope_gps_mm_yr
end
get_gps_error(fname::String, station_list::Array{String}; kwargs...) =
    get_gps_error.(fname, station_list; kwargs...)
# ! note: dot broadcasting is same as [get_gps_error.(fname, stat; kwargs...) for stat in station_list]

_get_date_range(fname::AbstractString) = extrema(Sario.load_geolist_from_h5(fname))
_get_date_range(fname::AbstractString, dset::AbstractString) =
    extrema(Sario.load_geolist_from_h5(fname, dset))

function _get_station_rowcol(station_name, directory=".")
    demrsc = Sario.load(joinpath(directory, "dem.rsc"))
    return map(x -> convert(Int, x), MapImages.station_rowcol(station_name, demrsc))
end

"""Load the insar data in a small patch around the pixel"""
function _get_val_at_station(
    insar_fname,
    station_name;
    dset="velos",
    window=5,
    kwargs...,
)
    # Note: swapping row and col due to julia/hdf5 transposes
    row, col = _get_station_rowcol(station_name, dirname(insar_fname))
    halfwin = div(window, 2)
    try
        patch =
            h5read(insar_fname, dset, (col - halfwin:col + halfwin, row - halfwin:row + halfwin))
        return mean(patch)
    catch e
        println(e)
        return NaN
    end
end

get_station_values(fname, station_list::Array{String}; kwargs...) =
    [_get_val_at_station(fname, stat; kwargs...) for stat in station_list]

"""Given a list of errors from insar-gps, find the const to add
to the insar solution image to minimize these errors
(converts the gps from relative to absolute)"""
function minimize_errors(error_list, search_range=-5:0.1:5)
    best_rms, best_maxabs = 100, 100
    c_rms, c_maxabs = 0, 0
    for c in search_range
        cur_rms = rms(c .+ error_list)
        cur_maxabs = maxabs(c .+ error_list)
        if cur_rms < best_rms
            c_rms = c
            best_rms = cur_rms
        end

        if cur_maxabs < best_maxabs
            c_maxabs = c
            best_maxabs = cur_maxabs
        end
    end
    return c_rms, c_maxabs, best_rms, best_maxabs
end

function print_errors(
    errors78::AbstractArray{<:AbstractFloat},
    errors85::AbstractArray{<:AbstractFloat},
    station_name_list::AbstractArray{<:AbstractString},
)
    println("Name | error 78 | error 85 ")
    println("============================")
    for (err78, err85, name) in zip(errors78, errors85, station_name_list)
        # println("$name RESULTS:")
        @printf("%s |  %.2f | %.2f \n", name, err78, err85)
    end
    println("==============")
    println("RMS 78 | Max-abs 78 | RMS 85 | Max-abs 85")
    @printf(
        "%.2f |  %.2f | %.2f |  %.2f  \n",
        rms(errors78),
        maxabs(errors78),
        rms(errors85),
        maxabs(errors85)
    )
end

function compare_solutions_with_gps(geolist, intlist, unw_vals, station_name, linear=true)
    B = prepB(geolist, intlist, constant_velocity=linear)

    l1_diffs = Array{Float32,1}(undef, length(geolist))
    lstsq_diffs = similar(l1_diffs)

    slope_gps_mm_yr = solve_gps_ts(station_name, nothing)

    # First, solve with a dummy date so nothing is removed
    base_l1, base_lstsq = solve_without(Date(2000, 1, 1), intlist, unw_vals, B)
    base_l1_error = base_l1 - slope_gps_mm_yr
    base_lstsq_error = base_lstsq - slope_gps_mm_yr
    println("Base L1 error for $station_name = $base_l1_error")

    for (idx, d) in enumerate(geolist)
        l1, lstsq = solve_without(d, intlist, unw_vals, B)
        l1d = l1 - slope_gps_mm_yr
        lstsqd = lstsq - slope_gps_mm_yr

        # Note: if base is larger, the diff will be positive (an improvement)
        l1_diffs[idx] = abs(base_l1_error) - abs(l1d)
        lstsq_diffs[idx] = abs(base_lstsq_error) - abs(lstsqd)
    end
    return l1_diffs, lstsq_diffs, base_l1_error
end

############################
# GPS FUNCTIONS
############################
function get_gps_los(
    station_name;
    los_map_file=LOS_MAP_FILE,
    reference_station=nothing,
    start_date=Date(2014, 11, 1),
    end_date=Date(2019, 1, 1),
    days_smooth=0,
)
    dts, gps_los_data = gps.load_gps_los_data(
        days_smooth=days_smooth,
        los_map_file=los_map_file,
        station_name=station_name,
        start_date=start_date,
        end_date=end_date,
        zero_mean=true,
        reference_station=reference_station,
    )

    return [convert(Date, d) for d in dts], gps_los_data
end

function get_gps_enu(station_name)
    dts, enu_df = gps.load_station_enu(
        station_name,
        start_date=Date(2014, 11, 1),
        end_date=Date(2019, 1, 1),
        zero_mean=true,
    )

    # Convert from PyObjects to Arrays
    dts = [convert(Date, d) for d in dts]
    east = [r for r in enu_df.east]
    north = [r for r in enu_df.north]
    up = [r for r in enu_df.up]
    return dts, east, north, up
end

"""Find the linear fit of MM per year of the gps station"""
function solve_gps_ts(
    station_name,
    reference_station=nothing;
    start_date=Date(2014, 11, 1),
    end_date=Date(2019, 1, 1),
    los_map_file=LOS_MAP_FILE,
)
    dts, gps_los_data = get_gps_los(
        station_name,
        reference_station=reference_station,
        start_date=start_date,
        end_date=end_date,
        los_map_file=los_map_file,
    )
    # If we wanna compare with GPS subtracted too, do this:
    # dts, gps_los_data = get_gps_los(station_name, reference_station=reference_station)

    # Convert to "days since start" for line fitting
    gps_poly = fit_line(dts, gps_los_data)
    slope = length(gps_poly) == 2 ? Polynomials.coeffs(gps_poly)[2] :
        Polynomials.coeffs(gps_poly)[1]
    # offset, slope = Polynomials.coeffs(gps_poly)
    slope_gps_mm_yr = 365 * 10 * slope
    return slope_gps_mm_yr
end

function fit_line(dts, data)
    day_nums = InsarTimeseries._get_day_nums(dts)
    p = Polynomials.polyfit(day_nums, data, 1)
    # p(day_nums[end])
    return p
end

function shift_from(src::HDF5Dataset, shift::Real)
    tmp = src .+ shift
    tmp[src .== 0] .= 0
    return tmp
end

function shift_dset(shift, fname, src::String="velos/1", dest="velos_shifted/1")
    h5open(fname, "r+") do f
        out = shift_from(f[src], shift)
        f[dest] = out
    end
    h5writeattr(fname, dest, h5readattr(fname, src))
    return
end

function scale_dset!(scale, fname, src::String="velos/1")
    a = h5readattr(fname, src)
    h5open(fname, "cw") do f
        tmp = scale * read(f, src)
        o_delete(f, src)
        f[src] = tmp
    end
    h5writeattr(fname, src, a)
    return
end

function get_shift(fname, src::String="velos/1", dest="velos_shifted/1")
    h5open(fname, "r+") do f
        return f[dest][div(end, 2), div(end, 2)] - f[src][div(end, 2), div(end, 2)]
    end
    end

function save_as_unw(fname, dset="velos/1")
    amp = abs.(Sario.load(Glob.glob("*.int")[1]))
    img = Sario.load(fname, dset_name=dset)
    outname = replace(fname, ".h5" => ".unw")
    Sario.save(outname, cat(amp, Float32.(img ./ 10), dims=3))
end


text:
using FeedbackParticleFilters, Random, Statistics, LinearAlgebra

println("Testing KBF.jl:")

@testset "KBF.jl" begin

    A = randn(2,2)
    B = randn(2,3)
    C = randn(4,2)

    BB = B*B'
    CC = C'*C

    m = zeros(2)
    P = zeros(2,2)

    print("  inner constructor for KBState")
    init = KBState(MultivariateGaussian(m,P))
    print(".")
    @test typeof(init) == KBState{MultivariateGaussian{Float64,Array{Float64,1},Array{Float64,2}}}
    println("DONE.")

    print("  inner constructor for KBF")
    kbf = KBF(A, BB, C, CC, init)
    print(".")
    @test typeof(kbf) == KBF{Array{Float64,2},Array{Float64,2},Array{Float64,2},Array{Float64,2},KBState{MultivariateGaussian{Float64,Array{Float64,1},Array{Float64,2}}}}
    print(".")
    @test_throws DimensionMismatch KBF(randn(1,2), BB, C, CC, init)
    println("DONE.")

    print("  method initial_condition")
    print(".")
    @test initial_condition(kbf) == kbf.init
    println("DONE.")

    print("  method for Statistics.mean")
    print(".")
    @test Statistics.mean(init) == init.gauss.mean
    println("DONE.")

    print("  method for Statistics.cov")
    print(".")
    @test Statistics.cov(init) == init.gauss.cov
    println("DONE.")

    print("  method for Statistics.var")
    print(".")
    @test Statistics.var(init) == LinearAlgebra.diag(init.gauss.cov)
    println("DONE.")

    print("  outer constructors for KBState")
    init2 = KBState(m, P)
    print(".")
    @test init2 == init
    init3 = KBState(3)
    print(".")
    @test init3.gauss.mean == [0.0, 0.0, 0.0]
    print(".")
    @test init3.gauss.cov == [0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]

    A      = [0. 1.; -0.7 -0.3]
    B      = zeros(2,1)
    B[2,1] = sqrt(2.)
    C      = [1. 2. ; 2. 3. ; 3. 4.]
    BB = B*B'
    CC = C'*C
    st_mod = LinearDiffusionStateModel(A, B)
    ob_mod = LinearDiffusionObservationModel(C)
    f_prob = FilteringProblem(st_mod, ob_mod)

    init4  = KBState(f_prob)
    print(".")
    @test init4.gauss.mean == [0.0, 0.0]
    print(".")
    @test init4.gauss.cov == [4.746796851882334 -5.543824348282954e-5; -5.543824348282954e-5 3.3192089048776765]
    println("DONE.")

    print("  outer constructors for KBF")
    kbf2 = KBF(A, B, C, init)
    print(".")
    @test kbf2.BB == BB
    print(".")
    @test kbf2.CC == CC
    print(".")
    @test kbf2.init == init

    kbf3 = KBF(A, B, C)
    print(".")
    @test typeof(kbf3) == KBF{Array{Float64,2},Array{Float64,2},Array{Float64,2},Array{Float64,2},KBState{MultivariateGaussian{Float64,Array{Float64,1},Array{Float64,2}}}}
    print(".")
    @test kbf3.BB == BB
    print(".")
    @test kbf3.CC == CC
    print(".")
    @test kbf3.init.gauss.mean == [0.0, 0.0]
    print(".")
    @test kbf3.init.gauss.cov == [4.746796851882334 -5.543824348282954e-5; -5.543824348282954e-5 3.3192089048776765]

    kbf4 = KBF(f_prob)
    print(".")
    @test typeof(kbf4) == KBF{Array{Float64,2},Array{Float64,2},Array{Float64,2},Array{Float64,2},KBState{MultivariateGaussian{Float64,Array{Float64,1},Array{Float64,2}}}}
    print(".")
    @test kbf4.BB == BB
    print(".")
    @test kbf4.CC == CC
    print(".")
    @test kbf4.init.gauss.mean == [0.0, 0.0]
    print(".")
    @test kbf4.init.gauss.cov == [4.746796851882334 -5.543824348282954e-5; -5.543824348282954e-5 3.3192089048776765]
    println("DONE.")

    print("  method initialize")
    init5 = initialize(kbf4)
    print(".")
    @test init5 == kbf4.init
    println("DONE.")

    print("  method update!")
    print(".")
    state = deepcopy(kbf3.init)
    update!(state, kbf3, [0.1, 0.2, 0.3], 0.01)
    print(".")
    @test state.gauss.mean == [6.6454047161483025, 6.638340196214477 ]
    print(".")
    @test state.gauss.cov == [1.5924097544324285 -3.151122632746998; -3.151122632746998 0.12439518287453177]
    println("DONE.")

end; #KBF.jl


text:
using InteractiveUtils,LinearAlgebra,BenchmarkTools,Printf,Statistics;
USING

BenchmarkTools.DEFAULT_PARAMETERS.samples=10; # NOF SAMPLES

versioninfo(verbose=true);
# Check CPU-turbo state.
# from https://askubuntu.com/questions/619875/disabling-intel-turbo-boost-in-ubuntu
# Disable:
# $ sudo -s
# # echo "1" > /sys/devices/system/cpu/intel_pstate/no_turbo
# Enable:
# $ sudo -s
# # echo "0" > /sys/devices/system/cpu/intel_pstate/no_turbo
turbo_disabled=NaN
if (isfile("/sys/devices/system/cpu/intel_pstate/no_turbo"))
    if readlines("/sys/devices/system/cpu/intel_pstate/no_turbo")[1] == "1"
        turbo_disabled=true;
    end
    if readlines("/sys/devices/system/cpu/intel_pstate/no_turbo")[1] == "0"
        turbo_disabled=false;
    end
end

if (turbo_disabled == false)
    @warn("CPU turbo is enabled. Timing likely unreliable.")
elseif (turbo_disabled == true)
    println("CPU turbo is disabled. Good!")
else
    println("CPU turbo state unknown.")
end

n=MATSIZE;
A0=zeros(n,n);
for i=1:n
    for j=1:n
        if (i!=j)
            A0[i,j]=1/sqrt(abs(i-j));
        end
    end
end
A0[n,1] += 0.0001;
# opnorm(A0,1)=123.57039475388511
A0_basic=A0/opnorm(A0,1);

println("Matrix norm: $(opnorm(A0,1))");
println("Matrix size: ", n ," x ", n);
if (!isdefined(BLAS,:get_config))
    println("BLAS vendor: ",BLAS.vendor())
else
    println("BLAS config: ",BLAS.get_config())
end

### START REPEATED CODE
# Code to run: NAME *******
print(@sprintf("%20.20s: ","NAME"));
A=MATNORM*A0_basic;
INCLUDE
bb=@benchmark FUNCTION($A) samples=5 seconds=20;
mm=median(bb.times)*1e-9;
stdval=std(bb.times)*1e-9
println("$(mm) ± $stdval mem: $(bb.memory)");
print("                       ")
@show bb.times
GC.gc();
sleep(3);

### END REPEATED CODE

println("DONE!");

max_stars_repo_name: matrixfunctions/GraphMatFunData

max_issues_repo_name: matrixfunctions/GraphMatFunData

max_forks_repo_name: matrixfunctions/GraphMatFunData


text:
#
println("Ca) Test of the Einstein module with ASF from an internally generated multiplet.")
#
setDefaults("print summary: open", "zzz-Einstein.sum")
wa = Atomic.Computation("xx",  Nuclear.Model(26.); properties=[JAC.EinsteinX],
                        configs=[Configuration("[Ne] 3s 3p^6"), Configuration("[Ne] 3s^2 3p^4 3d"), Configuration("[Ne] 3s^2 3p^5")],
                        einsteinSettings=Einstein.Settings([E1, M1, E2], true,
                        false, Tuple{Int64,Int64}[], 0., 0., 10000. ) )

wb = perform(wa; output=true)
setDefaults("print summary: close", "")


text:
# Step 4: Select a package.
function select(::HTTP.Request)
    body = render_from_file(
               SELECT_TPL,
               route_status=ROUTES[:STATUS],
               route_register=ROUTES[:REGISTER],
               enable_release_notes=REGISTRY[].enable_release_notes,
           )
    return html(body)
end


text:
function getclass(T::UIkit, arg, typ...)
    length(typ) > 0 && last(typ) == "label" && return ""

    if arg == :input
        typ==() && return "uk-input"
        typ[1]=="checkbox" && return "uk-checkbox"
        typ[1]=="radio" && return "uk-radio"
        typ[1]=="toggle" && return ""
        typ[1]=="range" && return "uk-range"

        if typ[1]=="file"
            typ[2:end]==("icon",) && return "fas fa-upload"
            typ[2:end]==("span",) && return "uk-button"
            return ""
        end

        return "uk-input"
    elseif arg == :button
        typ==("primary",) && return "uk-button-primary"
        typ==("active",) && return "uk-button-primary"
        typ==("fullwidth",) && return "uk-width-1-1"
        return "uk-button"
    elseif arg==:tab
        typ==("active",) && return "uk-active"
        return "not-active"
    elseif arg == :textarea
        return "uk-textarea"
    elseif arg==:wdglabel
        return ""
    elseif arg==:dropdown
        return "uk-select"
    elseif arg==:div
        return "uk-margin"
    elseif arg==:togglebuttons
        return "uk-button-group uk-width-1-1"
    elseif arg==:tabs
        return "uk-tab"
    elseif arg==:radiobuttons
        return "uk-margin uk-grid-small uk-child-width-auto uk-grid"
    else
        return ""
    end
end