examples_test.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package applicationautoscaling_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/applicationautoscaling"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleApplicationAutoScaling_DeleteScalingPolicy() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := applicationautoscaling.New(sess)
  20. params := &applicationautoscaling.DeleteScalingPolicyInput{
  21. PolicyName: aws.String("ResourceIdMaxLen1600"), // Required
  22. ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
  23. ScalableDimension: aws.String("ScalableDimension"), // Required
  24. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  25. }
  26. resp, err := svc.DeleteScalingPolicy(params)
  27. if err != nil {
  28. // Print the error, cast err to awserr.Error to get the Code and
  29. // Message from an error.
  30. fmt.Println(err.Error())
  31. return
  32. }
  33. // Pretty-print the response data.
  34. fmt.Println(resp)
  35. }
  36. func ExampleApplicationAutoScaling_DeregisterScalableTarget() {
  37. sess, err := session.NewSession()
  38. if err != nil {
  39. fmt.Println("failed to create session,", err)
  40. return
  41. }
  42. svc := applicationautoscaling.New(sess)
  43. params := &applicationautoscaling.DeregisterScalableTargetInput{
  44. ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
  45. ScalableDimension: aws.String("ScalableDimension"), // Required
  46. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  47. }
  48. resp, err := svc.DeregisterScalableTarget(params)
  49. if err != nil {
  50. // Print the error, cast err to awserr.Error to get the Code and
  51. // Message from an error.
  52. fmt.Println(err.Error())
  53. return
  54. }
  55. // Pretty-print the response data.
  56. fmt.Println(resp)
  57. }
  58. func ExampleApplicationAutoScaling_DescribeScalableTargets() {
  59. sess, err := session.NewSession()
  60. if err != nil {
  61. fmt.Println("failed to create session,", err)
  62. return
  63. }
  64. svc := applicationautoscaling.New(sess)
  65. params := &applicationautoscaling.DescribeScalableTargetsInput{
  66. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  67. MaxResults: aws.Int64(1),
  68. NextToken: aws.String("XmlString"),
  69. ResourceIds: []*string{
  70. aws.String("ResourceIdMaxLen1600"), // Required
  71. // More values...
  72. },
  73. ScalableDimension: aws.String("ScalableDimension"),
  74. }
  75. resp, err := svc.DescribeScalableTargets(params)
  76. if err != nil {
  77. // Print the error, cast err to awserr.Error to get the Code and
  78. // Message from an error.
  79. fmt.Println(err.Error())
  80. return
  81. }
  82. // Pretty-print the response data.
  83. fmt.Println(resp)
  84. }
  85. func ExampleApplicationAutoScaling_DescribeScalingActivities() {
  86. sess, err := session.NewSession()
  87. if err != nil {
  88. fmt.Println("failed to create session,", err)
  89. return
  90. }
  91. svc := applicationautoscaling.New(sess)
  92. params := &applicationautoscaling.DescribeScalingActivitiesInput{
  93. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  94. MaxResults: aws.Int64(1),
  95. NextToken: aws.String("XmlString"),
  96. ResourceId: aws.String("ResourceIdMaxLen1600"),
  97. ScalableDimension: aws.String("ScalableDimension"),
  98. }
  99. resp, err := svc.DescribeScalingActivities(params)
  100. if err != nil {
  101. // Print the error, cast err to awserr.Error to get the Code and
  102. // Message from an error.
  103. fmt.Println(err.Error())
  104. return
  105. }
  106. // Pretty-print the response data.
  107. fmt.Println(resp)
  108. }
  109. func ExampleApplicationAutoScaling_DescribeScalingPolicies() {
  110. sess, err := session.NewSession()
  111. if err != nil {
  112. fmt.Println("failed to create session,", err)
  113. return
  114. }
  115. svc := applicationautoscaling.New(sess)
  116. params := &applicationautoscaling.DescribeScalingPoliciesInput{
  117. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  118. MaxResults: aws.Int64(1),
  119. NextToken: aws.String("XmlString"),
  120. PolicyNames: []*string{
  121. aws.String("ResourceIdMaxLen1600"), // Required
  122. // More values...
  123. },
  124. ResourceId: aws.String("ResourceIdMaxLen1600"),
  125. ScalableDimension: aws.String("ScalableDimension"),
  126. }
  127. resp, err := svc.DescribeScalingPolicies(params)
  128. if err != nil {
  129. // Print the error, cast err to awserr.Error to get the Code and
  130. // Message from an error.
  131. fmt.Println(err.Error())
  132. return
  133. }
  134. // Pretty-print the response data.
  135. fmt.Println(resp)
  136. }
  137. func ExampleApplicationAutoScaling_PutScalingPolicy() {
  138. sess, err := session.NewSession()
  139. if err != nil {
  140. fmt.Println("failed to create session,", err)
  141. return
  142. }
  143. svc := applicationautoscaling.New(sess)
  144. params := &applicationautoscaling.PutScalingPolicyInput{
  145. PolicyName: aws.String("PolicyName"), // Required
  146. ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
  147. ScalableDimension: aws.String("ScalableDimension"), // Required
  148. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  149. PolicyType: aws.String("PolicyType"),
  150. StepScalingPolicyConfiguration: &applicationautoscaling.StepScalingPolicyConfiguration{
  151. AdjustmentType: aws.String("AdjustmentType"),
  152. Cooldown: aws.Int64(1),
  153. MetricAggregationType: aws.String("MetricAggregationType"),
  154. MinAdjustmentMagnitude: aws.Int64(1),
  155. StepAdjustments: []*applicationautoscaling.StepAdjustment{
  156. { // Required
  157. ScalingAdjustment: aws.Int64(1), // Required
  158. MetricIntervalLowerBound: aws.Float64(1.0),
  159. MetricIntervalUpperBound: aws.Float64(1.0),
  160. },
  161. // More values...
  162. },
  163. },
  164. }
  165. resp, err := svc.PutScalingPolicy(params)
  166. if err != nil {
  167. // Print the error, cast err to awserr.Error to get the Code and
  168. // Message from an error.
  169. fmt.Println(err.Error())
  170. return
  171. }
  172. // Pretty-print the response data.
  173. fmt.Println(resp)
  174. }
  175. func ExampleApplicationAutoScaling_RegisterScalableTarget() {
  176. sess, err := session.NewSession()
  177. if err != nil {
  178. fmt.Println("failed to create session,", err)
  179. return
  180. }
  181. svc := applicationautoscaling.New(sess)
  182. params := &applicationautoscaling.RegisterScalableTargetInput{
  183. ResourceId: aws.String("ResourceIdMaxLen1600"), // Required
  184. ScalableDimension: aws.String("ScalableDimension"), // Required
  185. ServiceNamespace: aws.String("ServiceNamespace"), // Required
  186. MaxCapacity: aws.Int64(1),
  187. MinCapacity: aws.Int64(1),
  188. RoleARN: aws.String("ResourceIdMaxLen1600"),
  189. }
  190. resp, err := svc.RegisterScalableTarget(params)
  191. if err != nil {
  192. // Print the error, cast err to awserr.Error to get the Code and
  193. // Message from an error.
  194. fmt.Println(err.Error())
  195. return
  196. }
  197. // Pretty-print the response data.
  198. fmt.Println(resp)
  199. }