mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +00:00
Upgrade AWS SDK to the latest version
This commit is contained in:
+755
-102
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package applicationautoscalingiface provides an interface to enable mocking the Application Auto Scaling service client
|
||||
// for testing your code.
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
//
|
||||
// The best way to use this interface is so the SDK's service client's calls
|
||||
// can be stubbed out for unit testing your code with the SDK without needing
|
||||
// to inject custom request handlers into the the SDK's request pipeline.
|
||||
// to inject custom request handlers into the SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // Application Auto Scaling.
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package applicationautoscaling provides the client and types for making API
|
||||
// requests to Application Auto Scaling.
|
||||
//
|
||||
// With Application Auto Scaling, you can automatically scale your AWS resources.
|
||||
// The experience similar to that of Auto Scaling (https://aws.amazon.com/autoscaling/).
|
||||
// You can use Application Auto Scaling to accomplish the following tasks:
|
||||
//
|
||||
// * Define scaling policies to automatically scale your AWS resources
|
||||
//
|
||||
// * Scale your resources in response to CloudWatch alarms
|
||||
//
|
||||
// * View the history of your scaling events
|
||||
//
|
||||
// Application Auto Scaling can scale the following AWS resources:
|
||||
//
|
||||
// * Amazon ECS services. For more information, see Service Auto Scaling
|
||||
// (http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html)
|
||||
// in the Amazon EC2 Container Service Developer Guide.
|
||||
//
|
||||
// * Amazon EC2 Spot fleets. For more information, see Automatic Scaling
|
||||
// for Spot Fleet (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/fleet-auto-scaling.html)
|
||||
// in the Amazon EC2 User Guide.
|
||||
//
|
||||
// * Amazon EMR clusters. For more information, see Using Automatic Scaling
|
||||
// in Amazon EMR (http://docs.aws.amazon.com/ElasticMapReduce/latest/ManagementGuide/emr-automatic-scaling.html)
|
||||
// in the Amazon EMR Management Guide.
|
||||
//
|
||||
// * AppStream 2.0 fleets. For more information, see Fleet Auto Scaling for
|
||||
// Amazon AppStream 2.0 (http://docs.aws.amazon.com/appstream2/latest/developerguide/autoscaling.html)
|
||||
// in the Amazon AppStream 2.0 Developer Guide.
|
||||
//
|
||||
// * Provisioned read and write capacity for Amazon DynamoDB tables and global
|
||||
// secondary indexes. For more information, see Managing Throughput Capacity
|
||||
// Automatically with DynamoDB Auto Scaling (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.html)
|
||||
// in the Amazon DynamoDB Developer Guide.
|
||||
//
|
||||
// For a list of supported regions, see AWS Regions and Endpoints: Application
|
||||
// Auto Scaling (http://docs.aws.amazon.com/general/latest/gr/rande.html#as-app_region)
|
||||
// in the AWS General Reference.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/application-autoscaling-2016-02-06 for more information on this service.
|
||||
//
|
||||
// See applicationautoscaling package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/applicationautoscaling/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To Application Auto Scaling with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the Application Auto Scaling client ApplicationAutoScaling for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/applicationautoscaling/#New
|
||||
package applicationautoscaling
|
||||
+6
-7
@@ -1,4 +1,4 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package applicationautoscaling
|
||||
|
||||
@@ -14,12 +14,11 @@ const (
|
||||
// ErrCodeFailedResourceAccessException for service response error code
|
||||
// "FailedResourceAccessException".
|
||||
//
|
||||
// Failed access to resources caused an exception. This exception currently
|
||||
// only applies to DescribeScalingPolicies. It is thrown when Application Auto
|
||||
// Scaling is unable to retrieve the alarms associated with a scaling policy
|
||||
// due to a client error, for example, if the role ARN specified for a scalable
|
||||
// target does not have the proper permissions to call the CloudWatch DescribeAlarms
|
||||
// (http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html)
|
||||
// Failed access to resources caused an exception. This exception is thrown
|
||||
// when Application Auto Scaling is unable to retrieve the alarms associated
|
||||
// with a scaling policy due to a client error, for example, if the role ARN
|
||||
// specified for a scalable target does not have permission to call the CloudWatch
|
||||
// DescribeAlarms (http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html)
|
||||
// API operation on behalf of your account.
|
||||
ErrCodeFailedResourceAccessException = "FailedResourceAccessException"
|
||||
|
||||
|
||||
+332
-135
@@ -1,210 +1,407 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package applicationautoscaling_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
|
||||
)
|
||||
|
||||
var _ time.Duration
|
||||
var _ bytes.Buffer
|
||||
|
||||
func ExampleApplicationAutoScaling_DeleteScalingPolicy() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.DeleteScalingPolicyInput{
|
||||
PolicyName: aws.String("ResourceIdMaxLen1600"), // Required
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
|
||||
ScalableDimension: aws.String("ScalableDimension"), // Required
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
}
|
||||
resp, err := svc.DeleteScalingPolicy(params)
|
||||
var _ strings.Reader
|
||||
var _ aws.Config
|
||||
|
||||
func parseTime(layout, value string) *time.Time {
|
||||
t, err := time.Parse(layout, value)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
panic(err)
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
// To delete a scaling policy
|
||||
//
|
||||
// This example deletes a scaling policy for the Amazon ECS service called web-app,
|
||||
// which is running in the default cluster.
|
||||
func ExampleApplicationAutoScaling_DeleteScalingPolicy_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.DeleteScalingPolicyInput{
|
||||
PolicyName: aws.String("web-app-cpu-lt-25"),
|
||||
ResourceId: aws.String("service/default/web-app"),
|
||||
ScalableDimension: aws.String("ecs:service:DesiredCount"),
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
|
||||
result, err := svc.DeleteScalingPolicy(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeObjectNotFoundException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeObjectNotFoundException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_DeregisterScalableTarget() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.DeregisterScalableTargetInput{
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
|
||||
ScalableDimension: aws.String("ScalableDimension"), // Required
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
// To deregister a scalable target
|
||||
//
|
||||
// This example deregisters a scalable target for an Amazon ECS service called web-app
|
||||
// that is running in the default cluster.
|
||||
func ExampleApplicationAutoScaling_DeregisterScalableTarget_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.DeregisterScalableTargetInput{
|
||||
ResourceId: aws.String("service/default/web-app"),
|
||||
ScalableDimension: aws.String("ecs:service:DesiredCount"),
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
resp, err := svc.DeregisterScalableTarget(params)
|
||||
|
||||
result, err := svc.DeregisterScalableTarget(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeObjectNotFoundException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeObjectNotFoundException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_DescribeScalableTargets() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.DescribeScalableTargetsInput{
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
MaxResults: aws.Int64(1),
|
||||
NextToken: aws.String("XmlString"),
|
||||
ResourceIds: []*string{
|
||||
aws.String("ResourceIdMaxLen1600"), // Required
|
||||
// More values...
|
||||
},
|
||||
ScalableDimension: aws.String("ScalableDimension"),
|
||||
// To describe scalable targets
|
||||
//
|
||||
// This example describes the scalable targets for the ecs service namespace.
|
||||
func ExampleApplicationAutoScaling_DescribeScalableTargets_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.DescribeScalableTargetsInput{
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
resp, err := svc.DescribeScalableTargets(params)
|
||||
|
||||
result, err := svc.DescribeScalableTargets(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInvalidNextTokenException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInvalidNextTokenException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_DescribeScalingActivities() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.DescribeScalingActivitiesInput{
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
MaxResults: aws.Int64(1),
|
||||
NextToken: aws.String("XmlString"),
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"),
|
||||
ScalableDimension: aws.String("ScalableDimension"),
|
||||
// To describe scaling activities for a scalable target
|
||||
//
|
||||
// This example describes the scaling activities for an Amazon ECS service called web-app
|
||||
// that is running in the default cluster.
|
||||
func ExampleApplicationAutoScaling_DescribeScalingActivities_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.DescribeScalingActivitiesInput{
|
||||
ResourceId: aws.String("service/default/web-app"),
|
||||
ScalableDimension: aws.String("ecs:service:DesiredCount"),
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
resp, err := svc.DescribeScalingActivities(params)
|
||||
|
||||
result, err := svc.DescribeScalingActivities(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInvalidNextTokenException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInvalidNextTokenException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_DescribeScalingPolicies() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.DescribeScalingPoliciesInput{
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
MaxResults: aws.Int64(1),
|
||||
NextToken: aws.String("XmlString"),
|
||||
PolicyNames: []*string{
|
||||
aws.String("ResourceIdMaxLen1600"), // Required
|
||||
// More values...
|
||||
},
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"),
|
||||
ScalableDimension: aws.String("ScalableDimension"),
|
||||
// To describe scaling policies
|
||||
//
|
||||
// This example describes the scaling policies for the ecs service namespace.
|
||||
func ExampleApplicationAutoScaling_DescribeScalingPolicies_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.DescribeScalingPoliciesInput{
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
resp, err := svc.DescribeScalingPolicies(params)
|
||||
|
||||
result, err := svc.DescribeScalingPolicies(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeFailedResourceAccessException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeFailedResourceAccessException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInvalidNextTokenException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInvalidNextTokenException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_PutScalingPolicy() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
|
||||
params := &applicationautoscaling.PutScalingPolicyInput{
|
||||
PolicyName: aws.String("PolicyName"), // Required
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
|
||||
ScalableDimension: aws.String("ScalableDimension"), // Required
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
PolicyType: aws.String("PolicyType"),
|
||||
// To apply a scaling policy to an Amazon ECS service
|
||||
//
|
||||
// This example applies a scaling policy to an Amazon ECS service called web-app in
|
||||
// the default cluster. The policy increases the desired count of the service by 200%,
|
||||
// with a cool down period of 60 seconds.
|
||||
func ExampleApplicationAutoScaling_PutScalingPolicy_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.PutScalingPolicyInput{
|
||||
PolicyName: aws.String("web-app-cpu-gt-75"),
|
||||
PolicyType: aws.String("StepScaling"),
|
||||
ResourceId: aws.String("service/default/web-app"),
|
||||
ScalableDimension: aws.String("ecs:service:DesiredCount"),
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
StepScalingPolicyConfiguration: &applicationautoscaling.StepScalingPolicyConfiguration{
|
||||
AdjustmentType: aws.String("AdjustmentType"),
|
||||
Cooldown: aws.Int64(1),
|
||||
MetricAggregationType: aws.String("MetricAggregationType"),
|
||||
MinAdjustmentMagnitude: aws.Int64(1),
|
||||
AdjustmentType: aws.String("PercentChangeInCapacity"),
|
||||
Cooldown: aws.Int64(60),
|
||||
StepAdjustments: []*applicationautoscaling.StepAdjustment{
|
||||
{ // Required
|
||||
ScalingAdjustment: aws.Int64(1), // Required
|
||||
MetricIntervalLowerBound: aws.Float64(1.0),
|
||||
MetricIntervalUpperBound: aws.Float64(1.0),
|
||||
{
|
||||
MetricIntervalLowerBound: aws.Float64(0.000000),
|
||||
ScalingAdjustment: aws.Int64(200),
|
||||
},
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
}
|
||||
resp, err := svc.PutScalingPolicy(params)
|
||||
|
||||
result, err := svc.PutScalingPolicy(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeLimitExceededException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeLimitExceededException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeObjectNotFoundException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeObjectNotFoundException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeFailedResourceAccessException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeFailedResourceAccessException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func ExampleApplicationAutoScaling_RegisterScalableTarget() {
|
||||
sess := session.Must(session.NewSession())
|
||||
// To apply a scaling policy to an Amazon EC2 Spot fleet
|
||||
//
|
||||
// This example applies a scaling policy to an Amazon EC2 Spot fleet. The policy increases
|
||||
// the target capacity of the spot fleet by 200%, with a cool down period of 180 seconds.",
|
||||
//
|
||||
//
|
||||
func ExampleApplicationAutoScaling_PutScalingPolicy_shared01() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.PutScalingPolicyInput{
|
||||
PolicyName: aws.String("fleet-cpu-gt-75"),
|
||||
PolicyType: aws.String("StepScaling"),
|
||||
ResourceId: aws.String("spot-fleet-request/sfr-45e69d8a-be48-4539-bbf3-3464e99c50c3"),
|
||||
ScalableDimension: aws.String("ec2:spot-fleet-request:TargetCapacity"),
|
||||
ServiceNamespace: aws.String("ec2"),
|
||||
StepScalingPolicyConfiguration: &applicationautoscaling.StepScalingPolicyConfiguration{
|
||||
AdjustmentType: aws.String("PercentChangeInCapacity"),
|
||||
Cooldown: aws.Int64(180),
|
||||
StepAdjustments: []*applicationautoscaling.StepAdjustment{
|
||||
{
|
||||
MetricIntervalLowerBound: aws.Float64(0.000000),
|
||||
ScalingAdjustment: aws.Int64(200),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
svc := applicationautoscaling.New(sess)
|
||||
result, err := svc.PutScalingPolicy(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeLimitExceededException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeLimitExceededException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeObjectNotFoundException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeObjectNotFoundException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeFailedResourceAccessException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeFailedResourceAccessException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
params := &applicationautoscaling.RegisterScalableTargetInput{
|
||||
ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
|
||||
ScalableDimension: aws.String("ScalableDimension"), // Required
|
||||
ServiceNamespace: aws.String("ServiceNamespace"), // Required
|
||||
MaxCapacity: aws.Int64(1),
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To register an ECS service as a scalable target
|
||||
//
|
||||
// This example registers a scalable target from an Amazon ECS service called web-app
|
||||
// that is running on the default cluster, with a minimum desired count of 1 task and
|
||||
// a maximum desired count of 10 tasks.
|
||||
func ExampleApplicationAutoScaling_RegisterScalableTarget_shared00() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.RegisterScalableTargetInput{
|
||||
MaxCapacity: aws.Int64(10),
|
||||
MinCapacity: aws.Int64(1),
|
||||
RoleARN: aws.String("ResourceIdMaxLen1600"),
|
||||
ResourceId: aws.String("service/default/web-app"),
|
||||
RoleARN: aws.String("arn:aws:iam::012345678910:role/ApplicationAutoscalingECSRole"),
|
||||
ScalableDimension: aws.String("ecs:service:DesiredCount"),
|
||||
ServiceNamespace: aws.String("ecs"),
|
||||
}
|
||||
resp, err := svc.RegisterScalableTarget(params)
|
||||
|
||||
result, err := svc.RegisterScalableTarget(input)
|
||||
if err != nil {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeLimitExceededException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeLimitExceededException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pretty-print the response data.
|
||||
fmt.Println(resp)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To register an EC2 Spot fleet as a scalable target
|
||||
//
|
||||
// This example registers a scalable target from an Amazon EC2 Spot fleet with a minimum
|
||||
// target capacity of 1 and a maximum of 10.
|
||||
func ExampleApplicationAutoScaling_RegisterScalableTarget_shared01() {
|
||||
svc := applicationautoscaling.New(session.New())
|
||||
input := &applicationautoscaling.RegisterScalableTargetInput{
|
||||
MaxCapacity: aws.Int64(10),
|
||||
MinCapacity: aws.Int64(1),
|
||||
ResourceId: aws.String("spot-fleet-request/sfr-45e69d8a-be48-4539-bbf3-3464e99c50c3"),
|
||||
RoleARN: aws.String("arn:aws:iam::012345678910:role/ApplicationAutoscalingSpotRole"),
|
||||
ScalableDimension: aws.String("ec2:spot-fleet-request:TargetCapacity"),
|
||||
ServiceNamespace: aws.String("ec2"),
|
||||
}
|
||||
|
||||
result, err := svc.RegisterScalableTarget(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case applicationautoscaling.ErrCodeValidationException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeValidationException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeLimitExceededException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeLimitExceededException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeConcurrentUpdateException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeConcurrentUpdateException, aerr.Error())
|
||||
case applicationautoscaling.ErrCodeInternalServiceException:
|
||||
fmt.Println(applicationautoscaling.ErrCodeInternalServiceException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
+6
-30
@@ -1,4 +1,4 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package applicationautoscaling
|
||||
|
||||
@@ -11,36 +11,12 @@ import (
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
)
|
||||
|
||||
// With Application Auto Scaling, you can automatically scale your AWS resources.
|
||||
// The experience similar to that of Auto Scaling (https://aws.amazon.com/autoscaling/).
|
||||
// You can use Application Auto Scaling to accomplish the following tasks:
|
||||
// ApplicationAutoScaling provides the API operation methods for making requests to
|
||||
// Application Auto Scaling. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// * Define scaling policies to automatically scale your AWS resources
|
||||
//
|
||||
// * Scale your resources in response to CloudWatch alarms
|
||||
//
|
||||
// * View the history of your scaling events
|
||||
//
|
||||
// Application Auto Scaling can scale the following AWS resources:
|
||||
//
|
||||
// * Amazon ECS services. For more information, see Service Auto Scaling
|
||||
// (http://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html)
|
||||
// in the Amazon EC2 Container Service Developer Guide.
|
||||
//
|
||||
// * Amazon EC2 Spot fleets. For more information, see Automatic Scaling
|
||||
// for Spot Fleet (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/fleet-auto-scaling.html)
|
||||
// in the Amazon EC2 User Guide.
|
||||
//
|
||||
// * Amazon EMR clusters. For more information, see Using Automatic Scaling
|
||||
// in Amazon EMR (http://docs.aws.amazon.com/ElasticMapReduce/latest/ManagementGuide/emr-automatic-scaling.html)
|
||||
// in the Amazon EMR Management Guide.
|
||||
//
|
||||
// For a list of supported regions, see AWS Regions and Endpoints: Application
|
||||
// Auto Scaling (http://docs.aws.amazon.com/general/latest/gr/rande.html#as-app_region)
|
||||
// in the AWS General Reference.
|
||||
// The service client's operations are safe to be used concurrently.
|
||||
// It is not safe to mutate any of the client's properties though.
|
||||
// Please also see https://docs.aws.amazon.com/goto/WebAPI/application-autoscaling-2016-02-06
|
||||
// ApplicationAutoScaling methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type ApplicationAutoScaling struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user