diff --git a/private/model/api/example.go b/private/model/api/example.go index 673e4f0b867..d711c81a912 100644 --- a/private/model/api/example.go +++ b/private/model/api/example.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "os" + "reflect" "sort" "strings" "text/template" @@ -141,6 +142,8 @@ func generateTypes(ex Example) string { // buildShape will recursively build the referenced shape based on the json object // provided. +// isMap will dictate how the field name is specified. If isMap is true, we will expect +// the member name to be quotes like "Foo". func buildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string { order := make([]string, len(shapes)) for k := range shapes { @@ -161,12 +164,13 @@ func buildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string memName := name if isMap { memName = fmt.Sprintf("%q", memName) - } else if ref != nil { } switch v := shape.(type) { case map[string]interface{}: ret += buildComplex(name, memName, ref, v) + case []interface{}: + ret += buildList(ref, name, memName, v) default: ret += buildScalar(name, memName, ref, v) } @@ -174,32 +178,128 @@ func buildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string return ret } +func buildList(ref *ShapeRef, name, memName string, v []interface{}) string { + ret := "" + + if len(v) == 0 || ref == nil { + return "" + } + + t := "" + format := "" + isComplex := false + passRef := ref + + switch v[0].(type) { + case string: + t = "string" + format = "%s" + case bool: + t = "bool" + format = "%t" + case int: + t = "int64" + format = "%d" + case float64: + t = "float64" + format = "%f" + default: + pkgPrefix := ref.API.PackageName() + "." + if ref.Shape.MemberRefs[name] != nil { + t = pkgPrefix + ref.Shape.MemberRefs[name].Shape.ShapeName + passRef = ref.Shape.MemberRefs[name] + } else { + t = pkgPrefix + ref.Shape.MemberRef.Shape.ShapeName + passRef = &ref.Shape.MemberRef + } + isComplex = true + } + ret += fmt.Sprintf("%s: []*%s {\n", memName, t) + for _, elem := range v { + if isComplex { + ret += fmt.Sprintf("{\n%s\n},\n", buildShape(passRef, elem.(map[string]interface{}), false)) + } else { + ret += fmt.Sprintf("%s,\n", getValue(t, fmt.Sprintf(format, elem))) + } + } + ret += "},\n" + return ret +} + func buildScalar(name, memName string, ref *ShapeRef, shape interface{}) string { + if ref == nil || ref.Shape == nil || ref.Shape.MemberRefs[name] == nil { + return correctType(memName, shape) + } + switch v := shape.(type) { case bool: - return fmt.Sprintf("%s: aws.Bool(%t),\n", memName, v) + return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%t", v)) case int: if ref.Shape.MemberRefs[name].Shape.Type == "timestamp" { return parseTimeString(ref, memName, fmt.Sprintf("%d", v)) } else { - return fmt.Sprintf("%s: aws.Int64(%d),\n", memName, v) + return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%d", v)) } + case float64: + return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%f", v)) case string: - if ref != nil && ref.Shape.MemberRefs[name] != nil && ref.Shape.MemberRefs[name].Shape.Type == "timestamp" { + t := ref.Shape.MemberRefs[name].Shape.Type + switch t { + case "timestamp": return parseTimeString(ref, memName, fmt.Sprintf("%s", v)) - } else if ref != nil && ref.Shape.MemberRefs[name] != nil && ref.Shape.MemberRefs[name].Shape.Type == "blob" { + case "blob": if (ref.Shape.MemberRefs[name].Streaming || ref.Shape.MemberRefs[name].Shape.Streaming) && ref.Shape.Payload == name { return fmt.Sprintf("%s: aws.ReadSeekCloser(bytes.NewBuffer([]byte(%q))),\n", memName, v) } else { return fmt.Sprintf("%s: []byte(%q),\n", memName, v) } - } else { - return fmt.Sprintf("%s: aws.String(%q),\n", memName, v) + default: + return convertToCorrectType(memName, t, v) } + default: + panic(fmt.Errorf("Unsupported scalar type: %v", reflect.TypeOf(v))) } return "" } +func correctType(memName string, value interface{}) string { + if value == nil { + return "" + } + + switch v := value.(type) { + case string: + return convertToCorrectType(memName, "string", v) + case int: + return convertToCorrectType(memName, "integer", fmt.Sprintf("%d", v)) + case float64: + return convertToCorrectType(memName, "float", fmt.Sprintf("%f", v)) + case bool: + return convertToCorrectType(memName, "boolean", fmt.Sprintf("%t", v)) + default: + panic(fmt.Sprintf("Unsupported type: %v", v)) + } +} + +func convertToCorrectType(memName, t, v string) string { + return fmt.Sprintf("%s: %s,\n", memName, getValue(t, v)) +} + +func getValue(t, v string) string { + switch t { + case "string": + return fmt.Sprintf("aws.String(%q)", v) + case "integer", "long": + return fmt.Sprintf("aws.Int64(%s)", v) + case "float", "float64": + return fmt.Sprintf("aws.Float64(%s)", v) + case "boolean": + return fmt.Sprintf("aws.Bool(%s)", v) + default: + panic("Unsupported type: " + t) + } +} + func buildComplex(name, memName string, ref *ShapeRef, v map[string]interface{}) string { shapeName, t := "", "" member := ref.Shape.MemberRefs[name] @@ -232,6 +332,8 @@ func buildComplex(name, memName string, ref *ShapeRef, v map[string]interface{}) // AttachExamples will create a new ExamplesDefinition from the examples file // and reference the API object. func (a *API) AttachExamples(filename string) { + a.Setup() + a.customizationPasses() p := ExamplesDefinition{API: a} f, err := os.Open(filename) @@ -274,8 +376,8 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/{{ .PackageName }}" ) @@ -332,7 +434,7 @@ func getNestedType(shape *Shape) string { case "structure": return fmt.Sprintf("*%s.%s", shape.API.PackageName(), shape.ShapeName) default: - panic("Unsupported shape " + shape.ValueRef.Shape.Type) + panic("Unsupported shape " + shape.Type) } } diff --git a/private/model/api/example_test.go b/private/model/api/example_test.go index cd6593b4e90..8ab153ab604 100644 --- a/private/model/api/example_test.go +++ b/private/model/api/example_test.go @@ -1,4 +1,4 @@ -// +build codegen +// +build 1.6,codegen package api @@ -13,6 +13,7 @@ func buildAPI() *API { stringShape := &Shape{ API: a, ShapeName: "string", + Type: "string", } stringShapeRef := &ShapeRef{ API: a, @@ -23,6 +24,7 @@ func buildAPI() *API { intShape := &Shape{ API: a, ShapeName: "int", + Type: "int", } intShapeRef := &ShapeRef{ API: a, @@ -114,24 +116,40 @@ func TestExampleGeneration(t *testing.T) { def.API = a def.setup() - expected := `import ( -"fmt" -"github.com/aws/aws-sdk-go/aws" -"github.com/aws/aws-sdk-go/aws/request" -"github.com/aws/aws-sdk-go/service/fooservice" + expected := ` +import ( + "fmt" + "bytes" + "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/fooservice" ) + +var _ time.Duration +var _ bytes.Buffer +var _ aws.Config + +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} + // I pity the foo // // Foo bar baz qux -func ExampleFooService_Foo() { +func ExampleFooService_Foo_shared00() { svc := fooservice.New(session.New()) - - input := FooInput{ - BarShape: "Hello world", + input := &fooservice.FooInput{ + BarShape: aws.String("Hello world"), } result, err := svc.Foo(input) - if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { @@ -150,7 +168,9 @@ func ExampleFooService_Foo() { } ` if expected != a.ExamplesGoCode() { - t.Errorf("Expected:\n%s\n\nReceived:\n%s\n", expected, a.ExamplesGoCode()) + t.Log([]byte(expected)) + t.Log([]byte(a.ExamplesGoCode())) + t.Errorf("Expected:\n%s\nReceived:\n%s\n", expected, a.ExamplesGoCode()) } } @@ -164,13 +184,13 @@ func TestBuildShape(t *testing.T) { defs: map[string]interface{}{ "barShape": "Hello World", }, - expected: "BarShape: \"Hello World\",\n", + expected: "BarShape: aws.String(\"Hello World\"),\n", }, { defs: map[string]interface{}{ "BarShape": "Hello World", }, - expected: "BarShape: \"Hello World\",\n", + expected: "BarShape: aws.String(\"Hello World\"),\n", }, } diff --git a/service/acm/examples_test.go b/service/acm/examples_test.go deleted file mode 100644 index 5b07c8b476f..00000000000 --- a/service/acm/examples_test.go +++ /dev/null @@ -1,262 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package acm_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/acm" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleACM_AddTagsToCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.AddTagsToCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - Tags: []*acm.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.AddTagsToCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_DeleteCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.DeleteCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_DescribeCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.DescribeCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - } - resp, err := svc.DescribeCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_GetCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.GetCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - } - resp, err := svc.GetCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_ImportCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.ImportCertificateInput{ - Certificate: []byte("PAYLOAD"), // Required - PrivateKey: []byte("PAYLOAD"), // Required - CertificateArn: aws.String("Arn"), - CertificateChain: []byte("PAYLOAD"), - } - resp, err := svc.ImportCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_ListCertificates() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.ListCertificatesInput{ - CertificateStatuses: []*string{ - aws.String("CertificateStatus"), // Required - // More values... - }, - MaxItems: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListCertificates(params) - - if err != nil { - // 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) -} - -func ExampleACM_ListTagsForCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.ListTagsForCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - } - resp, err := svc.ListTagsForCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_RemoveTagsFromCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.RemoveTagsFromCertificateInput{ - CertificateArn: aws.String("Arn"), // Required - Tags: []*acm.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.RemoveTagsFromCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_RequestCertificate() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.RequestCertificateInput{ - DomainName: aws.String("DomainNameString"), // Required - DomainValidationOptions: []*acm.DomainValidationOption{ - { // Required - DomainName: aws.String("DomainNameString"), // Required - ValidationDomain: aws.String("DomainNameString"), // Required - }, - // More values... - }, - IdempotencyToken: aws.String("IdempotencyToken"), - SubjectAlternativeNames: []*string{ - aws.String("DomainNameString"), // Required - // More values... - }, - } - resp, err := svc.RequestCertificate(params) - - if err != nil { - // 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) -} - -func ExampleACM_ResendValidationEmail() { - sess := session.Must(session.NewSession()) - - svc := acm.New(sess) - - params := &acm.ResendValidationEmailInput{ - CertificateArn: aws.String("Arn"), // Required - Domain: aws.String("DomainNameString"), // Required - ValidationDomain: aws.String("DomainNameString"), // Required - } - resp, err := svc.ResendValidationEmail(params) - - if err != nil { - // 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) -} diff --git a/service/apigateway/examples_test.go b/service/apigateway/examples_test.go deleted file mode 100644 index 17882ea77b3..00000000000 --- a/service/apigateway/examples_test.go +++ /dev/null @@ -1,2770 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package apigateway_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/apigateway" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleAPIGateway_CreateApiKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateApiKeyInput{ - CustomerId: aws.String("String"), - Description: aws.String("String"), - Enabled: aws.Bool(true), - GenerateDistinctId: aws.Bool(true), - Name: aws.String("String"), - StageKeys: []*apigateway.StageKey{ - { // Required - RestApiId: aws.String("String"), - StageName: aws.String("String"), - }, - // More values... - }, - Value: aws.String("String"), - } - resp, err := svc.CreateApiKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateAuthorizer() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateAuthorizerInput{ - IdentitySource: aws.String("String"), // Required - Name: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Type: aws.String("AuthorizerType"), // Required - AuthType: aws.String("String"), - AuthorizerCredentials: aws.String("String"), - AuthorizerResultTtlInSeconds: aws.Int64(1), - AuthorizerUri: aws.String("String"), - IdentityValidationExpression: aws.String("String"), - ProviderARNs: []*string{ - aws.String("ProviderARN"), // Required - // More values... - }, - } - resp, err := svc.CreateAuthorizer(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateBasePathMapping() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateBasePathMappingInput{ - DomainName: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - BasePath: aws.String("String"), - Stage: aws.String("String"), - } - resp, err := svc.CreateBasePathMapping(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateDeployment() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateDeploymentInput{ - RestApiId: aws.String("String"), // Required - CacheClusterEnabled: aws.Bool(true), - CacheClusterSize: aws.String("CacheClusterSize"), - Description: aws.String("String"), - StageDescription: aws.String("String"), - StageName: aws.String("String"), - Variables: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateDeployment(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateDocumentationPart() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateDocumentationPartInput{ - Location: &apigateway.DocumentationPartLocation{ // Required - Type: aws.String("DocumentationPartType"), // Required - Method: aws.String("String"), - Name: aws.String("String"), - Path: aws.String("String"), - StatusCode: aws.String("DocumentationPartLocationStatusCode"), - }, - Properties: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.CreateDocumentationPart(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateDocumentationVersion() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateDocumentationVersionInput{ - DocumentationVersion: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Description: aws.String("String"), - StageName: aws.String("String"), - } - resp, err := svc.CreateDocumentationVersion(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateDomainName() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateDomainNameInput{ - DomainName: aws.String("String"), // Required - CertificateArn: aws.String("String"), - CertificateBody: aws.String("String"), - CertificateChain: aws.String("String"), - CertificateName: aws.String("String"), - CertificatePrivateKey: aws.String("String"), - } - resp, err := svc.CreateDomainName(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateModel() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateModelInput{ - ContentType: aws.String("String"), // Required - Name: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Description: aws.String("String"), - Schema: aws.String("String"), - } - resp, err := svc.CreateModel(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateRequestValidator() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateRequestValidatorInput{ - RestApiId: aws.String("String"), // Required - Name: aws.String("String"), - ValidateRequestBody: aws.Bool(true), - ValidateRequestParameters: aws.Bool(true), - } - resp, err := svc.CreateRequestValidator(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateResource() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateResourceInput{ - ParentId: aws.String("String"), // Required - PathPart: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.CreateResource(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateRestApiInput{ - Name: aws.String("String"), // Required - BinaryMediaTypes: []*string{ - aws.String("String"), // Required - // More values... - }, - CloneFrom: aws.String("String"), - Description: aws.String("String"), - Version: aws.String("String"), - } - resp, err := svc.CreateRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateStage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateStageInput{ - DeploymentId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - CacheClusterEnabled: aws.Bool(true), - CacheClusterSize: aws.String("CacheClusterSize"), - Description: aws.String("String"), - DocumentationVersion: aws.String("String"), - Variables: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateStage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateUsagePlan() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateUsagePlanInput{ - Name: aws.String("String"), // Required - ApiStages: []*apigateway.ApiStage{ - { // Required - ApiId: aws.String("String"), - Stage: aws.String("String"), - }, - // More values... - }, - Description: aws.String("String"), - Quota: &apigateway.QuotaSettings{ - Limit: aws.Int64(1), - Offset: aws.Int64(1), - Period: aws.String("QuotaPeriodType"), - }, - Throttle: &apigateway.ThrottleSettings{ - BurstLimit: aws.Int64(1), - RateLimit: aws.Float64(1.0), - }, - } - resp, err := svc.CreateUsagePlan(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_CreateUsagePlanKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.CreateUsagePlanKeyInput{ - KeyId: aws.String("String"), // Required - KeyType: aws.String("String"), // Required - UsagePlanId: aws.String("String"), // Required - } - resp, err := svc.CreateUsagePlanKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteApiKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteApiKeyInput{ - ApiKey: aws.String("String"), // Required - } - resp, err := svc.DeleteApiKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteAuthorizer() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteAuthorizerInput{ - AuthorizerId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteAuthorizer(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteBasePathMapping() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteBasePathMappingInput{ - BasePath: aws.String("String"), // Required - DomainName: aws.String("String"), // Required - } - resp, err := svc.DeleteBasePathMapping(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteClientCertificateInput{ - ClientCertificateId: aws.String("String"), // Required - } - resp, err := svc.DeleteClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteDeployment() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteDeploymentInput{ - DeploymentId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteDeployment(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteDocumentationPart() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteDocumentationPartInput{ - DocumentationPartId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteDocumentationPart(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteDocumentationVersion() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteDocumentationVersionInput{ - DocumentationVersion: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteDocumentationVersion(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteDomainName() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteDomainNameInput{ - DomainName: aws.String("String"), // Required - } - resp, err := svc.DeleteDomainName(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteIntegration() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteIntegrationInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteIntegration(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteIntegrationResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteIntegrationResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - } - resp, err := svc.DeleteIntegrationResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteMethod() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteMethodInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteMethod(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteMethodResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteMethodResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - } - resp, err := svc.DeleteMethodResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteModel() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteModelInput{ - ModelName: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteModel(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteRequestValidator() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteRequestValidatorInput{ - RequestValidatorId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteRequestValidator(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteResource() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteResourceInput{ - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteResource(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteRestApiInput{ - RestApiId: aws.String("String"), // Required - } - resp, err := svc.DeleteRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteStage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteStageInput{ - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - } - resp, err := svc.DeleteStage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteUsagePlan() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteUsagePlanInput{ - UsagePlanId: aws.String("String"), // Required - } - resp, err := svc.DeleteUsagePlan(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_DeleteUsagePlanKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.DeleteUsagePlanKeyInput{ - KeyId: aws.String("String"), // Required - UsagePlanId: aws.String("String"), // Required - } - resp, err := svc.DeleteUsagePlanKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_FlushStageAuthorizersCache() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.FlushStageAuthorizersCacheInput{ - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - } - resp, err := svc.FlushStageAuthorizersCache(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_FlushStageCache() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.FlushStageCacheInput{ - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - } - resp, err := svc.FlushStageCache(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GenerateClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GenerateClientCertificateInput{ - Description: aws.String("String"), - } - resp, err := svc.GenerateClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetAccount() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - var params *apigateway.GetAccountInput - resp, err := svc.GetAccount(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetApiKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetApiKeyInput{ - ApiKey: aws.String("String"), // Required - IncludeValue: aws.Bool(true), - } - resp, err := svc.GetApiKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetApiKeys() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetApiKeysInput{ - CustomerId: aws.String("String"), - IncludeValues: aws.Bool(true), - Limit: aws.Int64(1), - NameQuery: aws.String("String"), - Position: aws.String("String"), - } - resp, err := svc.GetApiKeys(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetAuthorizer() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetAuthorizerInput{ - AuthorizerId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetAuthorizer(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetAuthorizers() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetAuthorizersInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetAuthorizers(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetBasePathMapping() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetBasePathMappingInput{ - BasePath: aws.String("String"), // Required - DomainName: aws.String("String"), // Required - } - resp, err := svc.GetBasePathMapping(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetBasePathMappings() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetBasePathMappingsInput{ - DomainName: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetBasePathMappings(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetClientCertificateInput{ - ClientCertificateId: aws.String("String"), // Required - } - resp, err := svc.GetClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetClientCertificates() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetClientCertificatesInput{ - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetClientCertificates(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDeployment() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDeploymentInput{ - DeploymentId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Embed: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.GetDeployment(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDeployments() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDeploymentsInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetDeployments(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDocumentationPart() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDocumentationPartInput{ - DocumentationPartId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetDocumentationPart(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDocumentationParts() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDocumentationPartsInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - NameQuery: aws.String("String"), - Path: aws.String("String"), - Position: aws.String("String"), - Type: aws.String("DocumentationPartType"), - } - resp, err := svc.GetDocumentationParts(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDocumentationVersion() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDocumentationVersionInput{ - DocumentationVersion: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetDocumentationVersion(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDocumentationVersions() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDocumentationVersionsInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetDocumentationVersions(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDomainName() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDomainNameInput{ - DomainName: aws.String("String"), // Required - } - resp, err := svc.GetDomainName(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetDomainNames() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetDomainNamesInput{ - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetDomainNames(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetExport() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetExportInput{ - ExportType: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - Accepts: aws.String("String"), - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.GetExport(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetIntegration() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetIntegrationInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetIntegration(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetIntegrationResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetIntegrationResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - } - resp, err := svc.GetIntegrationResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetMethod() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetMethodInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetMethod(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetMethodResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetMethodResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - } - resp, err := svc.GetMethodResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetModel() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetModelInput{ - ModelName: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Flatten: aws.Bool(true), - } - resp, err := svc.GetModel(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetModelTemplate() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetModelTemplateInput{ - ModelName: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetModelTemplate(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetModels() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetModelsInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetModels(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetRequestValidator() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetRequestValidatorInput{ - RequestValidatorId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetRequestValidator(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetRequestValidators() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetRequestValidatorsInput{ - RestApiId: aws.String("String"), // Required - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetRequestValidators(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetResource() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetResourceInput{ - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Embed: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.GetResource(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetResources() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetResourcesInput{ - RestApiId: aws.String("String"), // Required - Embed: []*string{ - aws.String("String"), // Required - // More values... - }, - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetResources(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetRestApiInput{ - RestApiId: aws.String("String"), // Required - } - resp, err := svc.GetRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetRestApis() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetRestApisInput{ - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetRestApis(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetSdk() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetSdkInput{ - RestApiId: aws.String("String"), // Required - SdkType: aws.String("String"), // Required - StageName: aws.String("String"), // Required - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.GetSdk(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetSdkType() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetSdkTypeInput{ - Id: aws.String("String"), // Required - } - resp, err := svc.GetSdkType(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetSdkTypes() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetSdkTypesInput{ - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetSdkTypes(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetStage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetStageInput{ - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - } - resp, err := svc.GetStage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetStages() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetStagesInput{ - RestApiId: aws.String("String"), // Required - DeploymentId: aws.String("String"), - } - resp, err := svc.GetStages(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetUsage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetUsageInput{ - EndDate: aws.String("String"), // Required - StartDate: aws.String("String"), // Required - UsagePlanId: aws.String("String"), // Required - KeyId: aws.String("String"), - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetUsage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetUsagePlan() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetUsagePlanInput{ - UsagePlanId: aws.String("String"), // Required - } - resp, err := svc.GetUsagePlan(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetUsagePlanKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetUsagePlanKeyInput{ - KeyId: aws.String("String"), // Required - UsagePlanId: aws.String("String"), // Required - } - resp, err := svc.GetUsagePlanKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetUsagePlanKeys() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetUsagePlanKeysInput{ - UsagePlanId: aws.String("String"), // Required - Limit: aws.Int64(1), - NameQuery: aws.String("String"), - Position: aws.String("String"), - } - resp, err := svc.GetUsagePlanKeys(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_GetUsagePlans() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.GetUsagePlansInput{ - KeyId: aws.String("String"), - Limit: aws.Int64(1), - Position: aws.String("String"), - } - resp, err := svc.GetUsagePlans(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_ImportApiKeys() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.ImportApiKeysInput{ - Body: []byte("PAYLOAD"), // Required - Format: aws.String("ApiKeysFormat"), // Required - FailOnWarnings: aws.Bool(true), - } - resp, err := svc.ImportApiKeys(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_ImportDocumentationParts() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.ImportDocumentationPartsInput{ - Body: []byte("PAYLOAD"), // Required - RestApiId: aws.String("String"), // Required - FailOnWarnings: aws.Bool(true), - Mode: aws.String("PutMode"), - } - resp, err := svc.ImportDocumentationParts(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_ImportRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.ImportRestApiInput{ - Body: []byte("PAYLOAD"), // Required - FailOnWarnings: aws.Bool(true), - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ImportRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_PutIntegration() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.PutIntegrationInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Type: aws.String("IntegrationType"), // Required - CacheKeyParameters: []*string{ - aws.String("String"), // Required - // More values... - }, - CacheNamespace: aws.String("String"), - ContentHandling: aws.String("ContentHandlingStrategy"), - Credentials: aws.String("String"), - IntegrationHttpMethod: aws.String("String"), - PassthroughBehavior: aws.String("String"), - RequestParameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - RequestTemplates: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - Uri: aws.String("String"), - } - resp, err := svc.PutIntegration(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_PutIntegrationResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.PutIntegrationResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - ContentHandling: aws.String("ContentHandlingStrategy"), - ResponseParameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - ResponseTemplates: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - SelectionPattern: aws.String("String"), - } - resp, err := svc.PutIntegrationResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_PutMethod() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.PutMethodInput{ - AuthorizationType: aws.String("String"), // Required - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - ApiKeyRequired: aws.Bool(true), - AuthorizerId: aws.String("String"), - OperationName: aws.String("String"), - RequestModels: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - RequestParameters: map[string]*bool{ - "Key": aws.Bool(true), // Required - // More values... - }, - RequestValidatorId: aws.String("String"), - } - resp, err := svc.PutMethod(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_PutMethodResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.PutMethodResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - ResponseModels: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - ResponseParameters: map[string]*bool{ - "Key": aws.Bool(true), // Required - // More values... - }, - } - resp, err := svc.PutMethodResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_PutRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.PutRestApiInput{ - Body: []byte("PAYLOAD"), // Required - RestApiId: aws.String("String"), // Required - FailOnWarnings: aws.Bool(true), - Mode: aws.String("PutMode"), - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.PutRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_TestInvokeAuthorizer() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.TestInvokeAuthorizerInput{ - AuthorizerId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - AdditionalContext: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - Body: aws.String("String"), - Headers: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - PathWithQueryString: aws.String("String"), - StageVariables: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.TestInvokeAuthorizer(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_TestInvokeMethod() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.TestInvokeMethodInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - Body: aws.String("String"), - ClientCertificateId: aws.String("String"), - Headers: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - PathWithQueryString: aws.String("String"), - StageVariables: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.TestInvokeMethod(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateAccount() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateAccountInput{ - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateAccount(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateApiKey() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateApiKeyInput{ - ApiKey: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateApiKey(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateAuthorizer() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateAuthorizerInput{ - AuthorizerId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateAuthorizer(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateBasePathMapping() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateBasePathMappingInput{ - BasePath: aws.String("String"), // Required - DomainName: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateBasePathMapping(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateClientCertificateInput{ - ClientCertificateId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateDeployment() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateDeploymentInput{ - DeploymentId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateDeployment(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateDocumentationPart() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateDocumentationPartInput{ - DocumentationPartId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateDocumentationPart(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateDocumentationVersion() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateDocumentationVersionInput{ - DocumentationVersion: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateDocumentationVersion(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateDomainName() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateDomainNameInput{ - DomainName: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateDomainName(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateIntegration() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateIntegrationInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateIntegration(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateIntegrationResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateIntegrationResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateIntegrationResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateMethod() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateMethodInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateMethod(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateMethodResponse() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateMethodResponseInput{ - HttpMethod: aws.String("String"), // Required - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - StatusCode: aws.String("StatusCode"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateMethodResponse(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateModel() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateModelInput{ - ModelName: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateModel(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateRequestValidator() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateRequestValidatorInput{ - RequestValidatorId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateRequestValidator(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateResource() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateResourceInput{ - ResourceId: aws.String("String"), // Required - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateResource(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateRestApi() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateRestApiInput{ - RestApiId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateRestApi(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateStage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateStageInput{ - RestApiId: aws.String("String"), // Required - StageName: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateStage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateUsage() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateUsageInput{ - KeyId: aws.String("String"), // Required - UsagePlanId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateUsage(params) - - if err != nil { - // 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) -} - -func ExampleAPIGateway_UpdateUsagePlan() { - sess := session.Must(session.NewSession()) - - svc := apigateway.New(sess) - - params := &apigateway.UpdateUsagePlanInput{ - UsagePlanId: aws.String("String"), // Required - PatchOperations: []*apigateway.PatchOperation{ - { // Required - From: aws.String("String"), - Op: aws.String("Op"), - Path: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateUsagePlan(params) - - if err != nil { - // 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) -} diff --git a/service/applicationautoscaling/examples_test.go b/service/applicationautoscaling/examples_test.go deleted file mode 100644 index 377d28db0c0..00000000000 --- a/service/applicationautoscaling/examples_test.go +++ /dev/null @@ -1,210 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package applicationautoscaling_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "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) - - if err != nil { - // 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) -} - -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 - } - resp, err := svc.DeregisterScalableTarget(params) - - if err != nil { - // 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) -} - -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"), - } - resp, err := svc.DescribeScalableTargets(params) - - if err != nil { - // 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) -} - -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"), - } - resp, err := svc.DescribeScalingActivities(params) - - if err != nil { - // 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) -} - -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"), - } - resp, err := svc.DescribeScalingPolicies(params) - - if err != nil { - // 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) -} - -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"), - StepScalingPolicyConfiguration: &applicationautoscaling.StepScalingPolicyConfiguration{ - AdjustmentType: aws.String("AdjustmentType"), - Cooldown: aws.Int64(1), - MetricAggregationType: aws.String("MetricAggregationType"), - MinAdjustmentMagnitude: aws.Int64(1), - StepAdjustments: []*applicationautoscaling.StepAdjustment{ - { // Required - ScalingAdjustment: aws.Int64(1), // Required - MetricIntervalLowerBound: aws.Float64(1.0), - MetricIntervalUpperBound: aws.Float64(1.0), - }, - // More values... - }, - }, - } - resp, err := svc.PutScalingPolicy(params) - - if err != nil { - // 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) -} - -func ExampleApplicationAutoScaling_RegisterScalableTarget() { - sess := session.Must(session.NewSession()) - - svc := applicationautoscaling.New(sess) - - params := &applicationautoscaling.RegisterScalableTargetInput{ - ResourceId: aws.String("ResourceIdMaxLen1600"), // Required - ScalableDimension: aws.String("ScalableDimension"), // Required - ServiceNamespace: aws.String("ServiceNamespace"), // Required - MaxCapacity: aws.Int64(1), - MinCapacity: aws.Int64(1), - RoleARN: aws.String("ResourceIdMaxLen1600"), - } - resp, err := svc.RegisterScalableTarget(params) - - if err != nil { - // 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) -} diff --git a/service/applicationdiscoveryservice/examples_test.go b/service/applicationdiscoveryservice/examples_test.go deleted file mode 100644 index 0493cbd5c12..00000000000 --- a/service/applicationdiscoveryservice/examples_test.go +++ /dev/null @@ -1,521 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package applicationdiscoveryservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/applicationdiscoveryservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleApplicationDiscoveryService_AssociateConfigurationItemsToApplication() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.AssociateConfigurationItemsToApplicationInput{ - ApplicationConfigurationId: aws.String("ApplicationId"), // Required - ConfigurationIds: []*string{ // Required - aws.String("ConfigurationId"), // Required - // More values... - }, - } - resp, err := svc.AssociateConfigurationItemsToApplication(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_CreateApplication() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.CreateApplicationInput{ - Name: aws.String("String"), // Required - Description: aws.String("String"), - } - resp, err := svc.CreateApplication(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_CreateTags() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.CreateTagsInput{ - ConfigurationIds: []*string{ // Required - aws.String("ConfigurationId"), // Required - // More values... - }, - Tags: []*applicationdiscoveryservice.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.CreateTags(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DeleteApplications() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DeleteApplicationsInput{ - ConfigurationIds: []*string{ // Required - aws.String("ApplicationId"), // Required - // More values... - }, - } - resp, err := svc.DeleteApplications(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DeleteTagsInput{ - ConfigurationIds: []*string{ // Required - aws.String("ConfigurationId"), // Required - // More values... - }, - Tags: []*applicationdiscoveryservice.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.DeleteTags(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DescribeAgents() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DescribeAgentsInput{ - AgentIds: []*string{ - aws.String("AgentId"), // Required - // More values... - }, - Filters: []*applicationdiscoveryservice.Filter{ - { // Required - Condition: aws.String("Condition"), // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("FilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeAgents(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DescribeConfigurations() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DescribeConfigurationsInput{ - ConfigurationIds: []*string{ // Required - aws.String("ConfigurationId"), // Required - // More values... - }, - } - resp, err := svc.DescribeConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DescribeExportConfigurations() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DescribeExportConfigurationsInput{ - ExportIds: []*string{ - aws.String("ConfigurationsExportId"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeExportConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DescribeExportTasks() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DescribeExportTasksInput{ - ExportIds: []*string{ - aws.String("ConfigurationsExportId"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeExportTasks(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DescribeTagsInput{ - Filters: []*applicationdiscoveryservice.TagFilter{ - { // Required - Name: aws.String("FilterName"), // Required - Values: []*string{ // Required - aws.String("FilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_DisassociateConfigurationItemsFromApplication() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.DisassociateConfigurationItemsFromApplicationInput{ - ApplicationConfigurationId: aws.String("ApplicationId"), // Required - ConfigurationIds: []*string{ // Required - aws.String("ConfigurationId"), // Required - // More values... - }, - } - resp, err := svc.DisassociateConfigurationItemsFromApplication(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_ExportConfigurations() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - var params *applicationdiscoveryservice.ExportConfigurationsInput - resp, err := svc.ExportConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_GetDiscoverySummary() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - var params *applicationdiscoveryservice.GetDiscoverySummaryInput - resp, err := svc.GetDiscoverySummary(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_ListConfigurations() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.ListConfigurationsInput{ - ConfigurationType: aws.String("ConfigurationItemType"), // Required - Filters: []*applicationdiscoveryservice.Filter{ - { // Required - Condition: aws.String("Condition"), // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("FilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - OrderBy: []*applicationdiscoveryservice.OrderByElement{ - { // Required - FieldName: aws.String("String"), // Required - SortOrder: aws.String("orderString"), - }, - // More values... - }, - } - resp, err := svc.ListConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_ListServerNeighbors() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.ListServerNeighborsInput{ - ConfigurationId: aws.String("ConfigurationId"), // Required - MaxResults: aws.Int64(1), - NeighborConfigurationIds: []*string{ - aws.String("ConfigurationId"), // Required - // More values... - }, - NextToken: aws.String("String"), - PortInformationNeeded: aws.Bool(true), - } - resp, err := svc.ListServerNeighbors(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_StartDataCollectionByAgentIds() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.StartDataCollectionByAgentIdsInput{ - AgentIds: []*string{ // Required - aws.String("AgentId"), // Required - // More values... - }, - } - resp, err := svc.StartDataCollectionByAgentIds(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_StartExportTask() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.StartExportTaskInput{ - ExportDataFormat: []*string{ - aws.String("ExportDataFormat"), // Required - // More values... - }, - } - resp, err := svc.StartExportTask(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_StopDataCollectionByAgentIds() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.StopDataCollectionByAgentIdsInput{ - AgentIds: []*string{ // Required - aws.String("AgentId"), // Required - // More values... - }, - } - resp, err := svc.StopDataCollectionByAgentIds(params) - - if err != nil { - // 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) -} - -func ExampleApplicationDiscoveryService_UpdateApplication() { - sess := session.Must(session.NewSession()) - - svc := applicationdiscoveryservice.New(sess) - - params := &applicationdiscoveryservice.UpdateApplicationInput{ - ConfigurationId: aws.String("ApplicationId"), // Required - Description: aws.String("String"), - Name: aws.String("String"), - } - resp, err := svc.UpdateApplication(params) - - if err != nil { - // 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) -} diff --git a/service/appstream/examples_test.go b/service/appstream/examples_test.go deleted file mode 100644 index 6e97d87ac9f..00000000000 --- a/service/appstream/examples_test.go +++ /dev/null @@ -1,471 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package appstream_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/appstream" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleAppStream_AssociateFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.AssociateFleetInput{ - FleetName: aws.String("String"), // Required - StackName: aws.String("String"), // Required - } - resp, err := svc.AssociateFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_CreateFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.CreateFleetInput{ - ComputeCapacity: &appstream.ComputeCapacity{ // Required - DesiredInstances: aws.Int64(1), // Required - }, - ImageName: aws.String("String"), // Required - InstanceType: aws.String("String"), // Required - Name: aws.String("Name"), // Required - Description: aws.String("Description"), - DisconnectTimeoutInSeconds: aws.Int64(1), - DisplayName: aws.String("DisplayName"), - EnableDefaultInternetAccess: aws.Bool(true), - MaxUserDurationInSeconds: aws.Int64(1), - VpcConfig: &appstream.VpcConfig{ - SubnetIds: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - } - resp, err := svc.CreateFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_CreateStack() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.CreateStackInput{ - Name: aws.String("String"), // Required - Description: aws.String("Description"), - DisplayName: aws.String("DisplayName"), - StorageConnectors: []*appstream.StorageConnector{ - { // Required - ConnectorType: aws.String("StorageConnectorType"), // Required - ResourceIdentifier: aws.String("ResourceIdentifier"), - }, - // More values... - }, - } - resp, err := svc.CreateStack(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_CreateStreamingURL() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.CreateStreamingURLInput{ - FleetName: aws.String("String"), // Required - StackName: aws.String("String"), // Required - UserId: aws.String("UserId"), // Required - ApplicationId: aws.String("String"), - SessionContext: aws.String("String"), - Validity: aws.Int64(1), - } - resp, err := svc.CreateStreamingURL(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DeleteFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DeleteFleetInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.DeleteFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DeleteStack() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DeleteStackInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.DeleteStack(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DescribeFleets() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DescribeFleetsInput{ - Names: []*string{ - aws.String("String"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.DescribeFleets(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DescribeImages() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DescribeImagesInput{ - Names: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeImages(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DescribeSessions() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DescribeSessionsInput{ - FleetName: aws.String("String"), // Required - StackName: aws.String("String"), // Required - AuthenticationType: aws.String("AuthenticationType"), - Limit: aws.Int64(1), - NextToken: aws.String("String"), - UserId: aws.String("UserId"), - } - resp, err := svc.DescribeSessions(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DescribeStacks() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DescribeStacksInput{ - Names: []*string{ - aws.String("String"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.DescribeStacks(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_DisassociateFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.DisassociateFleetInput{ - FleetName: aws.String("String"), // Required - StackName: aws.String("String"), // Required - } - resp, err := svc.DisassociateFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_ExpireSession() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.ExpireSessionInput{ - SessionId: aws.String("String"), // Required - } - resp, err := svc.ExpireSession(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_ListAssociatedFleets() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.ListAssociatedFleetsInput{ - StackName: aws.String("String"), // Required - NextToken: aws.String("String"), - } - resp, err := svc.ListAssociatedFleets(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_ListAssociatedStacks() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.ListAssociatedStacksInput{ - FleetName: aws.String("String"), // Required - NextToken: aws.String("String"), - } - resp, err := svc.ListAssociatedStacks(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_StartFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.StartFleetInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.StartFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_StopFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.StopFleetInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.StopFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_UpdateFleet() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.UpdateFleetInput{ - Name: aws.String("String"), // Required - ComputeCapacity: &appstream.ComputeCapacity{ - DesiredInstances: aws.Int64(1), // Required - }, - DeleteVpcConfig: aws.Bool(true), - Description: aws.String("Description"), - DisconnectTimeoutInSeconds: aws.Int64(1), - DisplayName: aws.String("DisplayName"), - EnableDefaultInternetAccess: aws.Bool(true), - ImageName: aws.String("String"), - InstanceType: aws.String("String"), - MaxUserDurationInSeconds: aws.Int64(1), - VpcConfig: &appstream.VpcConfig{ - SubnetIds: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - } - resp, err := svc.UpdateFleet(params) - - if err != nil { - // 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) -} - -func ExampleAppStream_UpdateStack() { - sess := session.Must(session.NewSession()) - - svc := appstream.New(sess) - - params := &appstream.UpdateStackInput{ - Name: aws.String("String"), // Required - DeleteStorageConnectors: aws.Bool(true), - Description: aws.String("Description"), - DisplayName: aws.String("DisplayName"), - StorageConnectors: []*appstream.StorageConnector{ - { // Required - ConnectorType: aws.String("StorageConnectorType"), // Required - ResourceIdentifier: aws.String("ResourceIdentifier"), - }, - // More values... - }, - } - resp, err := svc.UpdateStack(params) - - if err != nil { - // 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) -} diff --git a/service/athena/examples_test.go b/service/athena/examples_test.go deleted file mode 100644 index 8ec43cdcbc6..00000000000 --- a/service/athena/examples_test.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package athena_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/athena" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleAthena_BatchGetNamedQuery() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.BatchGetNamedQueryInput{ - NamedQueryIds: []*string{ // Required - aws.String("NamedQueryId"), // Required - // More values... - }, - } - resp, err := svc.BatchGetNamedQuery(params) - - if err != nil { - // 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) -} - -func ExampleAthena_BatchGetQueryExecution() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.BatchGetQueryExecutionInput{ - QueryExecutionIds: []*string{ // Required - aws.String("QueryExecutionId"), // Required - // More values... - }, - } - resp, err := svc.BatchGetQueryExecution(params) - - if err != nil { - // 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) -} - -func ExampleAthena_CreateNamedQuery() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.CreateNamedQueryInput{ - Database: aws.String("DatabaseString"), // Required - Name: aws.String("NameString"), // Required - QueryString: aws.String("QueryString"), // Required - ClientRequestToken: aws.String("IdempotencyToken"), - Description: aws.String("DescriptionString"), - } - resp, err := svc.CreateNamedQuery(params) - - if err != nil { - // 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) -} - -func ExampleAthena_DeleteNamedQuery() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.DeleteNamedQueryInput{ - NamedQueryId: aws.String("NamedQueryId"), // Required - } - resp, err := svc.DeleteNamedQuery(params) - - if err != nil { - // 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) -} - -func ExampleAthena_GetNamedQuery() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.GetNamedQueryInput{ - NamedQueryId: aws.String("NamedQueryId"), // Required - } - resp, err := svc.GetNamedQuery(params) - - if err != nil { - // 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) -} - -func ExampleAthena_GetQueryExecution() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.GetQueryExecutionInput{ - QueryExecutionId: aws.String("QueryExecutionId"), // Required - } - resp, err := svc.GetQueryExecution(params) - - if err != nil { - // 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) -} - -func ExampleAthena_GetQueryResults() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.GetQueryResultsInput{ - QueryExecutionId: aws.String("QueryExecutionId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("Token"), - } - resp, err := svc.GetQueryResults(params) - - if err != nil { - // 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) -} - -func ExampleAthena_ListNamedQueries() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.ListNamedQueriesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("Token"), - } - resp, err := svc.ListNamedQueries(params) - - if err != nil { - // 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) -} - -func ExampleAthena_ListQueryExecutions() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.ListQueryExecutionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("Token"), - } - resp, err := svc.ListQueryExecutions(params) - - if err != nil { - // 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) -} - -func ExampleAthena_StartQueryExecution() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.StartQueryExecutionInput{ - QueryString: aws.String("QueryString"), // Required - ResultConfiguration: &athena.ResultConfiguration{ // Required - OutputLocation: aws.String("String"), // Required - EncryptionConfiguration: &athena.EncryptionConfiguration{ - EncryptionOption: aws.String("EncryptionOption"), // Required - KmsKey: aws.String("String"), - }, - }, - ClientRequestToken: aws.String("IdempotencyToken"), - QueryExecutionContext: &athena.QueryExecutionContext{ - Database: aws.String("DatabaseString"), - }, - } - resp, err := svc.StartQueryExecution(params) - - if err != nil { - // 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) -} - -func ExampleAthena_StopQueryExecution() { - sess := session.Must(session.NewSession()) - - svc := athena.New(sess) - - params := &athena.StopQueryExecutionInput{ - QueryExecutionId: aws.String("QueryExecutionId"), // Required - } - resp, err := svc.StopQueryExecution(params) - - if err != nil { - // 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) -} diff --git a/service/autoscaling/api.go b/service/autoscaling/api.go index d20cf3c0494..ee90c8f82f5 100644 --- a/service/autoscaling/api.go +++ b/service/autoscaling/api.go @@ -9133,7 +9133,7 @@ type Group struct { HealthCheckType *string `min:"1" type:"string" required:"true"` // The EC2 instances associated with the group. - Instances []*Instance `type:"list"` + Instances []*InstanceDetails `type:"list"` // The name of the associated launch configuration. LaunchConfigurationName *string `min:"1" type:"string"` @@ -9247,7 +9247,7 @@ func (s *Group) SetHealthCheckType(v string) *Group { } // SetInstances sets the Instances field's value. -func (s *Group) SetInstances(v []*Instance) *Group { +func (s *Group) SetInstances(v []*InstanceDetails) *Group { s.Instances = v return s } diff --git a/service/autoscaling/examples_test.go b/service/autoscaling/examples_test.go index 6921ad4884f..6f5ab280e04 100644 --- a/service/autoscaling/examples_test.go +++ b/service/autoscaling/examples_test.go @@ -8,1377 +8,1926 @@ import ( "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/autoscaling" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleAutoScaling_AttachInstances() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &autoscaling.AttachInstancesInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To attach an instance to an Auto Scaling group +// +// This example attaches the specified instance to the specified Auto Scaling group. +func ExampleAutoScaling_AttachInstances_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.AttachInstancesInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), InstanceIds: []*string{ - aws.String("XmlStringMaxLen19"), // Required - // More values... + aws.String("i-93633f9b"), }, } - resp, err := svc.AttachInstances(params) + result, err := svc.AttachInstances(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_AttachLoadBalancerTargetGroups() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.AttachLoadBalancerTargetGroupsInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - TargetGroupARNs: []*string{ // Required - aws.String("XmlStringMaxLen511"), // Required - // More values... +// To attach a target group to an Auto Scaling group +// +// This example attaches the specified target group to the specified Auto Scaling group. +func ExampleAutoScaling_AttachLoadBalancerTargetGroups_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.AttachLoadBalancerTargetGroupsInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + TargetGroupARNs: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), }, } - resp, err := svc.AttachLoadBalancerTargetGroups(params) + result, err := svc.AttachLoadBalancerTargetGroups(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_AttachLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.AttachLoadBalancersInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LoadBalancerNames: []*string{ // Required - aws.String("XmlStringMaxLen255"), // Required - // More values... +// To attach a load balancer to an Auto Scaling group +// +// This example attaches the specified load balancer to the specified Auto Scaling group. +func ExampleAutoScaling_AttachLoadBalancers_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.AttachLoadBalancersInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LoadBalancerNames: []*string{ + aws.String("my-load-balancer"), }, } - resp, err := svc.AttachLoadBalancers(params) + result, err := svc.AttachLoadBalancers(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_CompleteLifecycleAction() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.CompleteLifecycleActionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LifecycleActionResult: aws.String("LifecycleActionResult"), // Required - LifecycleHookName: aws.String("AsciiStringMaxLen255"), // Required - InstanceId: aws.String("XmlStringMaxLen19"), - LifecycleActionToken: aws.String("LifecycleActionToken"), +// To complete the lifecycle action +// +// This example notifies Auto Scaling that the specified lifecycle action is complete +// so that it can finish launching or terminating the instance. +func ExampleAutoScaling_CompleteLifecycleAction_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CompleteLifecycleActionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LifecycleActionResult: aws.String("CONTINUE"), + LifecycleActionToken: aws.String("bcd2f1b8-9a78-44d3-8a7a-4dd07d7cf635"), + LifecycleHookName: aws.String("my-lifecycle-hook"), } - resp, err := svc.CompleteLifecycleAction(params) + result, err := svc.CompleteLifecycleAction(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_CreateAutoScalingGroup() { - sess := session.Must(session.NewSession()) +// To create an Auto Scaling group +// +// This example creates an Auto Scaling group. +func ExampleAutoScaling_CreateAutoScalingGroup_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CreateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LaunchConfigurationName: aws.String("my-launch-config"), + MaxSize: aws.Int64(3.000000), + MinSize: aws.Int64(1.000000), + VPCZoneIdentifier: aws.String("subnet-4176792c"), + } + + result, err := svc.CreateAutoScalingGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 + } - svc := autoscaling.New(sess) + fmt.Println(result) +} - params := &autoscaling.CreateAutoScalingGroupInput{ - AutoScalingGroupName: aws.String("XmlStringMaxLen255"), // Required - MaxSize: aws.Int64(1), // Required - MinSize: aws.Int64(1), // Required +// To create an Auto Scaling group with an attached load balancer +// +// This example creates an Auto Scaling group and attaches the specified Classic Load +// Balancer. +func ExampleAutoScaling_CreateAutoScalingGroup_shared01() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CreateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), AvailabilityZones: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... + aws.String("us-west-2c"), }, - DefaultCooldown: aws.Int64(1), - DesiredCapacity: aws.Int64(1), - HealthCheckGracePeriod: aws.Int64(1), - HealthCheckType: aws.String("XmlStringMaxLen32"), - InstanceId: aws.String("XmlStringMaxLen19"), - LaunchConfigurationName: aws.String("ResourceName"), + HealthCheckGracePeriod: aws.Int64(120.000000), + HealthCheckType: aws.String("ELB"), + LaunchConfigurationName: aws.String("my-launch-config"), LoadBalancerNames: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... - }, - NewInstancesProtectedFromScaleIn: aws.Bool(true), - PlacementGroup: aws.String("XmlStringMaxLen255"), - Tags: []*autoscaling.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - PropagateAtLaunch: aws.Bool(true), - ResourceId: aws.String("XmlString"), - ResourceType: aws.String("XmlString"), - Value: aws.String("TagValue"), - }, - // More values... + aws.String("my-load-balancer"), }, + MaxSize: aws.Int64(3.000000), + MinSize: aws.Int64(1.000000), + } + + result, err := svc.CreateAutoScalingGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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) +} + +// To create an Auto Scaling group with an attached target group +// +// This example creates an Auto Scaling group and attaches the specified target group. +func ExampleAutoScaling_CreateAutoScalingGroup_shared02() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CreateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + HealthCheckGracePeriod: aws.Int64(120.000000), + HealthCheckType: aws.String("ELB"), + LaunchConfigurationName: aws.String("my-launch-config"), + MaxSize: aws.Int64(3.000000), + MinSize: aws.Int64(1.000000), TargetGroupARNs: []*string{ - aws.String("XmlStringMaxLen511"), // Required - // More values... - }, - TerminationPolicies: []*string{ - aws.String("XmlStringMaxLen1600"), // Required - // More values... + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), }, - VPCZoneIdentifier: aws.String("XmlStringMaxLen2047"), + VPCZoneIdentifier: aws.String("subnet-4176792c, subnet-65ea5f08"), } - resp, err := svc.CreateAutoScalingGroup(params) + result, err := svc.CreateAutoScalingGroup(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 autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_CreateLaunchConfiguration() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.CreateLaunchConfigurationInput{ - LaunchConfigurationName: aws.String("XmlStringMaxLen255"), // Required - AssociatePublicIpAddress: aws.Bool(true), - BlockDeviceMappings: []*autoscaling.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("XmlStringMaxLen255"), // Required - Ebs: &autoscaling.Ebs{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("XmlStringMaxLen255"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("BlockDeviceEbsVolumeType"), - }, - NoDevice: aws.Bool(true), - VirtualName: aws.String("XmlStringMaxLen255"), - }, - // More values... - }, - ClassicLinkVPCId: aws.String("XmlStringMaxLen255"), - ClassicLinkVPCSecurityGroups: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... - }, - EbsOptimized: aws.Bool(true), - IamInstanceProfile: aws.String("XmlStringMaxLen1600"), - ImageId: aws.String("XmlStringMaxLen255"), - InstanceId: aws.String("XmlStringMaxLen19"), - InstanceMonitoring: &autoscaling.InstanceMonitoring{ - Enabled: aws.Bool(true), - }, - InstanceType: aws.String("XmlStringMaxLen255"), - KernelId: aws.String("XmlStringMaxLen255"), - KeyName: aws.String("XmlStringMaxLen255"), - PlacementTenancy: aws.String("XmlStringMaxLen64"), - RamdiskId: aws.String("XmlStringMaxLen255"), +// To create a launch configuration +// +// This example creates a launch configuration. +func ExampleAutoScaling_CreateLaunchConfiguration_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CreateLaunchConfigurationInput{ + IamInstanceProfile: aws.String("my-iam-role"), + ImageId: aws.String("ami-12345678"), + InstanceType: aws.String("m3.medium"), + LaunchConfigurationName: aws.String("my-launch-config"), SecurityGroups: []*string{ - aws.String("XmlString"), // Required - // More values... + aws.String("sg-eb2af88e"), }, - SpotPrice: aws.String("SpotPrice"), - UserData: aws.String("XmlStringUserData"), } - resp, err := svc.CreateLaunchConfiguration(params) + result, err := svc.CreateLaunchConfiguration(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 autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_CreateOrUpdateTags() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.CreateOrUpdateTagsInput{ - Tags: []*autoscaling.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required +// To create or update tags for an Auto Scaling group +// +// This example adds two tags to the specified Auto Scaling group. +func ExampleAutoScaling_CreateOrUpdateTags_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.CreateOrUpdateTagsInput{ + Tags: []*autoscaling.Tags{ + { + Key: aws.String("Role"), PropagateAtLaunch: aws.Bool(true), - ResourceId: aws.String("XmlString"), - ResourceType: aws.String("XmlString"), - Value: aws.String("TagValue"), + ResourceId: aws.String("my-auto-scaling-group"), + ResourceType: aws.String("auto-scaling-group"), + Value: aws.String("WebServer"), + }, + { + Key: aws.String("Dept"), + PropagateAtLaunch: aws.Bool(true), + ResourceId: aws.String("my-auto-scaling-group"), + ResourceType: aws.String("auto-scaling-group"), + Value: aws.String("Research"), }, - // More values... }, } - resp, err := svc.CreateOrUpdateTags(params) + result, err := svc.CreateOrUpdateTags(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 autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteAutoScalingGroup() { - sess := session.Must(session.NewSession()) +// To delete an Auto Scaling group +// +// This example deletes the specified Auto Scaling group. +func ExampleAutoScaling_DeleteAutoScalingGroup_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + } + + result, err := svc.DeleteAutoScalingGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceInUseFault: + fmt.Println(autoscaling.ErrCodeResourceInUseFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 + } - svc := autoscaling.New(sess) + fmt.Println(result) +} - params := &autoscaling.DeleteAutoScalingGroupInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To delete an Auto Scaling group and all its instances +// +// This example deletes the specified Auto Scaling group and all its instances. +func ExampleAutoScaling_DeleteAutoScalingGroup_shared01() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), ForceDelete: aws.Bool(true), } - resp, err := svc.DeleteAutoScalingGroup(params) + result, err := svc.DeleteAutoScalingGroup(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 autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceInUseFault: + fmt.Println(autoscaling.ErrCodeResourceInUseFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteLaunchConfiguration() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeleteLaunchConfigurationInput{ - LaunchConfigurationName: aws.String("ResourceName"), // Required +// To delete a launch configuration +// +// This example deletes the specified launch configuration. +func ExampleAutoScaling_DeleteLaunchConfiguration_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteLaunchConfigurationInput{ + LaunchConfigurationName: aws.String("my-launch-config"), } - resp, err := svc.DeleteLaunchConfiguration(params) + result, err := svc.DeleteLaunchConfiguration(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 autoscaling.ErrCodeResourceInUseFault: + fmt.Println(autoscaling.ErrCodeResourceInUseFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteLifecycleHook() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeleteLifecycleHookInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LifecycleHookName: aws.String("AsciiStringMaxLen255"), // Required +// To delete a lifecycle hook +// +// This example deletes the specified lifecycle hook. +func ExampleAutoScaling_DeleteLifecycleHook_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteLifecycleHookInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LifecycleHookName: aws.String("my-lifecycle-hook"), } - resp, err := svc.DeleteLifecycleHook(params) + result, err := svc.DeleteLifecycleHook(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteNotificationConfiguration() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeleteNotificationConfigurationInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - TopicARN: aws.String("ResourceName"), // Required +// To delete an Auto Scaling notification +// +// This example deletes the specified notification from the specified Auto Scaling group. +func ExampleAutoScaling_DeleteNotificationConfiguration_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteNotificationConfigurationInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + TopicARN: aws.String("arn:aws:sns:us-west-2:123456789012:my-sns-topic"), } - resp, err := svc.DeleteNotificationConfiguration(params) + result, err := svc.DeleteNotificationConfiguration(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeletePolicy() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeletePolicyInput{ - PolicyName: aws.String("ResourceName"), // Required - AutoScalingGroupName: aws.String("ResourceName"), +// To delete an Auto Scaling policy +// +// This example deletes the specified Auto Scaling policy. +func ExampleAutoScaling_DeletePolicy_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeletePolicyInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + PolicyName: aws.String("ScaleIn"), } - resp, err := svc.DeletePolicy(params) + result, err := svc.DeletePolicy(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteScheduledAction() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeleteScheduledActionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - ScheduledActionName: aws.String("ResourceName"), // Required +// To delete a scheduled action from an Auto Scaling group +// +// This example deletes the specified scheduled action from the specified Auto Scaling +// group. +func ExampleAutoScaling_DeleteScheduledAction_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteScheduledActionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + ScheduledActionName: aws.String("my-scheduled-action"), } - resp, err := svc.DeleteScheduledAction(params) + result, err := svc.DeleteScheduledAction(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DeleteTagsInput{ - Tags: []*autoscaling.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - PropagateAtLaunch: aws.Bool(true), - ResourceId: aws.String("XmlString"), - ResourceType: aws.String("XmlString"), - Value: aws.String("TagValue"), +// To delete a tag from an Auto Scaling group +// +// This example deletes the specified tag from the specified Auto Scaling group. +func ExampleAutoScaling_DeleteTags_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DeleteTagsInput{ + Tags: []*autoscaling.Tags{ + { + Key: aws.String("Dept"), + ResourceId: aws.String("my-auto-scaling-group"), + ResourceType: aws.String("auto-scaling-group"), + Value: aws.String("Research"), }, - // More values... }, } - resp, err := svc.DeleteTags(params) + result, err := svc.DeleteTags(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeAccountLimits() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeAccountLimitsInput - resp, err := svc.DescribeAccountLimits(params) +// To describe your Auto Scaling account limits +// +// This example describes the Auto Scaling limits for your AWS account. +func ExampleAutoScaling_DescribeAccountLimits_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeAccountLimitsInput{} + result, err := svc.DescribeAccountLimits(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeAdjustmentTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeAdjustmentTypesInput - resp, err := svc.DescribeAdjustmentTypes(params) +// To describe the Auto Scaling adjustment types +// +// This example describes the available adjustment types. +func ExampleAutoScaling_DescribeAdjustmentTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeAdjustmentTypesInput{} + result, err := svc.DescribeAdjustmentTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeAutoScalingGroups() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeAutoScalingGroupsInput{ +// To describe an Auto Scaling group +// +// This example describes the specified Auto Scaling group. +func ExampleAutoScaling_DescribeAutoScalingGroups_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeAutoScalingGroupsInput{ AutoScalingGroupNames: []*string{ - aws.String("ResourceName"), // Required - // More values... + aws.String("my-auto-scaling-group"), }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), } - resp, err := svc.DescribeAutoScalingGroups(params) + result, err := svc.DescribeAutoScalingGroups(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeAutoScalingInstances() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeAutoScalingInstancesInput{ +// To describe one or more Auto Scaling instances +// +// This example describes the specified Auto Scaling instance. +func ExampleAutoScaling_DescribeAutoScalingInstances_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeAutoScalingInstancesInput{ InstanceIds: []*string{ - aws.String("XmlStringMaxLen19"), // Required - // More values... + aws.String("i-4ba0837f"), }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), } - resp, err := svc.DescribeAutoScalingInstances(params) + result, err := svc.DescribeAutoScalingInstances(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeAutoScalingNotificationTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeAutoScalingNotificationTypesInput - resp, err := svc.DescribeAutoScalingNotificationTypes(params) +// To describe the Auto Scaling notification types +// +// This example describes the available notification types. +func ExampleAutoScaling_DescribeAutoScalingNotificationTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeAutoScalingNotificationTypesInput{} + result, err := svc.DescribeAutoScalingNotificationTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeLaunchConfigurations() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeLaunchConfigurationsInput{ +// To describe Auto Scaling launch configurations +// +// This example describes the specified launch configuration. +func ExampleAutoScaling_DescribeLaunchConfigurations_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeLaunchConfigurationsInput{ LaunchConfigurationNames: []*string{ - aws.String("ResourceName"), // Required - // More values... + aws.String("my-launch-config"), }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), } - resp, err := svc.DescribeLaunchConfigurations(params) + result, err := svc.DescribeLaunchConfigurations(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeLifecycleHookTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeLifecycleHookTypesInput - resp, err := svc.DescribeLifecycleHookTypes(params) +// To describe the available types of lifecycle hooks +// +// This example describes the available lifecycle hook types. +func ExampleAutoScaling_DescribeLifecycleHookTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeLifecycleHookTypesInput{} + result, err := svc.DescribeLifecycleHookTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeLifecycleHooks() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeLifecycleHooksInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LifecycleHookNames: []*string{ - aws.String("AsciiStringMaxLen255"), // Required - // More values... - }, +// To describe your lifecycle hooks +// +// This example describes the lifecycle hooks for the specified Auto Scaling group. +func ExampleAutoScaling_DescribeLifecycleHooks_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeLifecycleHooksInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - resp, err := svc.DescribeLifecycleHooks(params) + result, err := svc.DescribeLifecycleHooks(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeLoadBalancerTargetGroups() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeLoadBalancerTargetGroupsInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), +// To describe the target groups for an Auto Scaling group +// +// This example describes the target groups attached to the specified Auto Scaling group. +func ExampleAutoScaling_DescribeLoadBalancerTargetGroups_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeLoadBalancerTargetGroupsInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - resp, err := svc.DescribeLoadBalancerTargetGroups(params) + result, err := svc.DescribeLoadBalancerTargetGroups(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeLoadBalancersInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), +// To describe the load balancers for an Auto Scaling group +// +// This example describes the load balancers attached to the specified Auto Scaling +// group. +func ExampleAutoScaling_DescribeLoadBalancers_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeLoadBalancersInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - resp, err := svc.DescribeLoadBalancers(params) + result, err := svc.DescribeLoadBalancers(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeMetricCollectionTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeMetricCollectionTypesInput - resp, err := svc.DescribeMetricCollectionTypes(params) +// To describe the Auto Scaling metric collection types +// +// This example describes the available metric collection types. +func ExampleAutoScaling_DescribeMetricCollectionTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeMetricCollectionTypesInput{} + result, err := svc.DescribeMetricCollectionTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeNotificationConfigurations() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeNotificationConfigurationsInput{ +// To describe Auto Scaling notification configurations +// +// This example describes the notification configurations for the specified Auto Scaling +// group. +func ExampleAutoScaling_DescribeNotificationConfigurations_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeNotificationConfigurationsInput{ AutoScalingGroupNames: []*string{ - aws.String("ResourceName"), // Required - // More values... + aws.String("my-auto-scaling-group"), }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), } - resp, err := svc.DescribeNotificationConfigurations(params) + result, err := svc.DescribeNotificationConfigurations(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribePolicies() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribePoliciesInput{ - AutoScalingGroupName: aws.String("ResourceName"), - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), - PolicyNames: []*string{ - aws.String("ResourceName"), // Required - // More values... - }, - PolicyTypes: []*string{ - aws.String("XmlStringMaxLen64"), // Required - // More values... - }, +// To describe Auto Scaling policies +// +// This example describes the policies for the specified Auto Scaling group. +func ExampleAutoScaling_DescribePolicies_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribePoliciesInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - resp, err := svc.DescribePolicies(params) + result, err := svc.DescribePolicies(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeScalingActivities() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeScalingActivitiesInput{ - ActivityIds: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - AutoScalingGroupName: aws.String("ResourceName"), - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), +// To describe the scaling activities for an Auto Scaling group +// +// This example describes the scaling activities for the specified Auto Scaling group. +func ExampleAutoScaling_DescribeScalingActivities_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeScalingActivitiesInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - 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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeScalingProcessTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeScalingProcessTypesInput - resp, err := svc.DescribeScalingProcessTypes(params) +// To describe the Auto Scaling process types +// +// This example describes the Auto Scaling process types. +func ExampleAutoScaling_DescribeScalingProcessTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeScalingProcessTypesInput{} + result, err := svc.DescribeScalingProcessTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeScheduledActions() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeScheduledActionsInput{ - AutoScalingGroupName: aws.String("ResourceName"), - EndTime: aws.Time(time.Now()), - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), - ScheduledActionNames: []*string{ - aws.String("ResourceName"), // Required - // More values... - }, - StartTime: aws.Time(time.Now()), +// To describe scheduled actions +// +// This example describes the scheduled actions for the specified Auto Scaling group. +func ExampleAutoScaling_DescribeScheduledActions_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeScheduledActionsInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), } - resp, err := svc.DescribeScheduledActions(params) + result, err := svc.DescribeScheduledActions(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DescribeTagsInput{ - Filters: []*autoscaling.Filter{ - { // Required - Name: aws.String("XmlString"), +// To describe tags +// +// This example describes the tags for the specified Auto Scaling group. +func ExampleAutoScaling_DescribeTags_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeTagsInput{ + Filters: []*autoscaling.Filters{ + { + Name: aws.String("auto-scaling-group"), Values: []*string{ - aws.String("XmlString"), // Required - // More values... + aws.String("my-auto-scaling-group"), }, }, - // More values... }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("XmlString"), } - resp, err := svc.DescribeTags(params) + result, err := svc.DescribeTags(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 autoscaling.ErrCodeInvalidNextToken: + fmt.Println(autoscaling.ErrCodeInvalidNextToken, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DescribeTerminationPolicyTypes() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - var params *autoscaling.DescribeTerminationPolicyTypesInput - resp, err := svc.DescribeTerminationPolicyTypes(params) +// To describe termination policy types +// +// This example describes the available termination policy types. +func ExampleAutoScaling_DescribeTerminationPolicyTypes_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DescribeTerminationPolicyTypesInput{} + result, err := svc.DescribeTerminationPolicyTypes(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DetachInstances() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DetachInstancesInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - ShouldDecrementDesiredCapacity: aws.Bool(true), // Required +// To detach an instance from an Auto Scaling group +// +// This example detaches the specified instance from the specified Auto Scaling group. +func ExampleAutoScaling_DetachInstances_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DetachInstancesInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), InstanceIds: []*string{ - aws.String("XmlStringMaxLen19"), // Required - // More values... + aws.String("i-93633f9b"), }, + ShouldDecrementDesiredCapacity: aws.Bool(true), } - resp, err := svc.DetachInstances(params) + result, err := svc.DetachInstances(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DetachLoadBalancerTargetGroups() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DetachLoadBalancerTargetGroupsInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - TargetGroupARNs: []*string{ // Required - aws.String("XmlStringMaxLen511"), // Required - // More values... +// To detach a target group from an Auto Scaling group +// +// This example detaches the specified target group from the specified Auto Scaling +// group +func ExampleAutoScaling_DetachLoadBalancerTargetGroups_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DetachLoadBalancerTargetGroupsInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + TargetGroupARNs: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), }, } - resp, err := svc.DetachLoadBalancerTargetGroups(params) + result, err := svc.DetachLoadBalancerTargetGroups(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DetachLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DetachLoadBalancersInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LoadBalancerNames: []*string{ // Required - aws.String("XmlStringMaxLen255"), // Required - // More values... +// To detach a load balancer from an Auto Scaling group +// +// This example detaches the specified load balancer from the specified Auto Scaling +// group. +func ExampleAutoScaling_DetachLoadBalancers_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DetachLoadBalancersInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LoadBalancerNames: []*string{ + aws.String("my-load-balancer"), }, } - resp, err := svc.DetachLoadBalancers(params) + result, err := svc.DetachLoadBalancers(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_DisableMetricsCollection() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.DisableMetricsCollectionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To disable metrics collection for an Auto Scaling group +// +// This example disables collecting data for the GroupDesiredCapacity metric for the +// specified Auto Scaling group. +func ExampleAutoScaling_DisableMetricsCollection_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.DisableMetricsCollectionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), Metrics: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... + aws.String("GroupDesiredCapacity"), }, } - resp, err := svc.DisableMetricsCollection(params) + result, err := svc.DisableMetricsCollection(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_EnableMetricsCollection() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.EnableMetricsCollectionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - Granularity: aws.String("XmlStringMaxLen255"), // Required - Metrics: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... - }, +// To enable metrics collection for an Auto Scaling group +// +// This example enables data collection for the specified Auto Scaling group. +func ExampleAutoScaling_EnableMetricsCollection_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.EnableMetricsCollectionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + Granularity: aws.String("1Minute"), } - resp, err := svc.EnableMetricsCollection(params) + result, err := svc.EnableMetricsCollection(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_EnterStandby() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.EnterStandbyInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - ShouldDecrementDesiredCapacity: aws.Bool(true), // Required +// To move instances into standby mode +// +// This example puts the specified instance into standby mode. +func ExampleAutoScaling_EnterStandby_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.EnterStandbyInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), InstanceIds: []*string{ - aws.String("XmlStringMaxLen19"), // Required - // More values... + aws.String("i-93633f9b"), }, + ShouldDecrementDesiredCapacity: aws.Bool(true), } - resp, err := svc.EnterStandby(params) + result, err := svc.EnterStandby(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_ExecutePolicy() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.ExecutePolicyInput{ - PolicyName: aws.String("ResourceName"), // Required - AutoScalingGroupName: aws.String("ResourceName"), - BreachThreshold: aws.Float64(1.0), +// To execute an Auto Scaling policy +// +// This example executes the specified Auto Scaling policy for the specified Auto Scaling +// group. +func ExampleAutoScaling_ExecutePolicy_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.ExecutePolicyInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), HonorCooldown: aws.Bool(true), - MetricValue: aws.Float64(1.0), + PolicyName: aws.String("ScaleIn"), } - resp, err := svc.ExecutePolicy(params) + result, err := svc.ExecutePolicy(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 autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_ExitStandby() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.ExitStandbyInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To move instances out of standby mode +// +// This example moves the specified instance out of standby mode. +func ExampleAutoScaling_ExitStandby_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.ExitStandbyInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), InstanceIds: []*string{ - aws.String("XmlStringMaxLen19"), // Required - // More values... + aws.String("i-93633f9b"), }, } - resp, err := svc.ExitStandby(params) + result, err := svc.ExitStandby(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_PutLifecycleHook() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.PutLifecycleHookInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LifecycleHookName: aws.String("AsciiStringMaxLen255"), // Required - DefaultResult: aws.String("LifecycleActionResult"), - HeartbeatTimeout: aws.Int64(1), - LifecycleTransition: aws.String("LifecycleTransition"), - NotificationMetadata: aws.String("XmlStringMaxLen1023"), - NotificationTargetARN: aws.String("NotificationTargetResourceName"), - RoleARN: aws.String("ResourceName"), +// To create a lifecycle hook +// +// This example creates a lifecycle hook. +func ExampleAutoScaling_PutLifecycleHook_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.PutLifecycleHookInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LifecycleHookName: aws.String("my-lifecycle-hook"), + LifecycleTransition: aws.String("autoscaling:EC2_INSTANCE_LAUNCHING"), + NotificationTargetARN: aws.String("arn:aws:sns:us-west-2:123456789012:my-sns-topic --role-arn"), + RoleARN: aws.String("arn:aws:iam::123456789012:role/my-auto-scaling-role"), } - resp, err := svc.PutLifecycleHook(params) + result, err := svc.PutLifecycleHook(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 autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_PutNotificationConfiguration() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.PutNotificationConfigurationInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - NotificationTypes: []*string{ // Required - aws.String("XmlStringMaxLen255"), // Required - // More values... +// To add an Auto Scaling notification +// +// This example adds the specified notification to the specified Auto Scaling group. +func ExampleAutoScaling_PutNotificationConfiguration_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.PutNotificationConfigurationInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + NotificationTypes: []*string{ + aws.String("autoscaling:TEST_NOTIFICATION"), }, - TopicARN: aws.String("ResourceName"), // Required + TopicARN: aws.String("arn:aws:sns:us-west-2:123456789012:my-sns-topic"), } - resp, err := svc.PutNotificationConfiguration(params) + result, err := svc.PutNotificationConfiguration(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 autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_PutScalingPolicy() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.PutScalingPolicyInput{ - AdjustmentType: aws.String("XmlStringMaxLen255"), // Required - AutoScalingGroupName: aws.String("ResourceName"), // Required - PolicyName: aws.String("XmlStringMaxLen255"), // Required - Cooldown: aws.Int64(1), - EstimatedInstanceWarmup: aws.Int64(1), - MetricAggregationType: aws.String("XmlStringMaxLen32"), - MinAdjustmentMagnitude: aws.Int64(1), - MinAdjustmentStep: aws.Int64(1), - PolicyType: aws.String("XmlStringMaxLen64"), - ScalingAdjustment: aws.Int64(1), - StepAdjustments: []*autoscaling.StepAdjustment{ - { // Required - ScalingAdjustment: aws.Int64(1), // Required - MetricIntervalLowerBound: aws.Float64(1.0), - MetricIntervalUpperBound: aws.Float64(1.0), - }, - // More values... - }, +// To add a scaling policy to an Auto Scaling group +// +// This example adds the specified policy to the specified Auto Scaling group. +func ExampleAutoScaling_PutScalingPolicy_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.PutScalingPolicyInput{ + AdjustmentType: aws.String("ChangeInCapacity"), + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + PolicyName: aws.String("ScaleIn"), + ScalingAdjustment: aws.Int64(-1.000000), } - 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 autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_PutScheduledUpdateGroupAction() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.PutScheduledUpdateGroupActionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - ScheduledActionName: aws.String("XmlStringMaxLen255"), // Required - DesiredCapacity: aws.Int64(1), - EndTime: aws.Time(time.Now()), - MaxSize: aws.Int64(1), - MinSize: aws.Int64(1), - Recurrence: aws.String("XmlStringMaxLen255"), - StartTime: aws.Time(time.Now()), - Time: aws.Time(time.Now()), - } - resp, err := svc.PutScheduledUpdateGroupAction(params) - +// To add a scheduled action to an Auto Scaling group +// +// This example adds the specified scheduled action to the specified Auto Scaling group. +func ExampleAutoScaling_PutScheduledUpdateGroupAction_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.PutScheduledUpdateGroupActionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + DesiredCapacity: aws.Int64(4.000000), + EndTime: parseTime("2006-01-02T15:04:05Z", "2014-05-12T08:00:00Z"), + MaxSize: aws.Int64(6.000000), + MinSize: aws.Int64(2.000000), + ScheduledActionName: aws.String("my-scheduled-action"), + StartTime: parseTime("2006-01-02T15:04:05Z", "2014-05-12T08:00:00Z"), + } + + result, err := svc.PutScheduledUpdateGroupAction(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 autoscaling.ErrCodeAlreadyExistsFault: + fmt.Println(autoscaling.ErrCodeAlreadyExistsFault, aerr.Error()) + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_RecordLifecycleActionHeartbeat() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.RecordLifecycleActionHeartbeatInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - LifecycleHookName: aws.String("AsciiStringMaxLen255"), // Required - InstanceId: aws.String("XmlStringMaxLen19"), - LifecycleActionToken: aws.String("LifecycleActionToken"), +// To record a lifecycle action heartbeat +// +// This example records a lifecycle action heartbeat to keep the instance in a pending +// state. +func ExampleAutoScaling_RecordLifecycleActionHeartbeat_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.RecordLifecycleActionHeartbeatInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LifecycleActionToken: aws.String("bcd2f1b8-9a78-44d3-8a7a-4dd07d7cf635"), + LifecycleHookName: aws.String("my-lifecycle-hook"), } - resp, err := svc.RecordLifecycleActionHeartbeat(params) + result, err := svc.RecordLifecycleActionHeartbeat(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_ResumeProcesses() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.ScalingProcessQuery{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To resume Auto Scaling processes +// +// This example resumes the specified suspended scaling process for the specified Auto +// Scaling group. +func ExampleAutoScaling_ResumeProcesses_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.ScalingProcessQuery{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), ScalingProcesses: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... + aws.String("AlarmNotification"), }, } - resp, err := svc.ResumeProcesses(params) + result, err := svc.ResumeProcesses(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 autoscaling.ErrCodeResourceInUseFault: + fmt.Println(autoscaling.ErrCodeResourceInUseFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_SetDesiredCapacity() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.SetDesiredCapacityInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - DesiredCapacity: aws.Int64(1), // Required +// To set the desired capacity for an Auto Scaling group +// +// This example sets the desired capacity for the specified Auto Scaling group. +func ExampleAutoScaling_SetDesiredCapacity_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.SetDesiredCapacityInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + DesiredCapacity: aws.Int64(2.000000), HonorCooldown: aws.Bool(true), } - resp, err := svc.SetDesiredCapacity(params) + result, err := svc.SetDesiredCapacity(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 autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_SetInstanceHealth() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.SetInstanceHealthInput{ - HealthStatus: aws.String("XmlStringMaxLen32"), // Required - InstanceId: aws.String("XmlStringMaxLen19"), // Required - ShouldRespectGracePeriod: aws.Bool(true), +// To set the health status of an instance +// +// This example sets the health status of the specified instance to Unhealthy. +func ExampleAutoScaling_SetInstanceHealth_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.SetInstanceHealthInput{ + HealthStatus: aws.String("Unhealthy"), + InstanceId: aws.String("i-93633f9b"), } - resp, err := svc.SetInstanceHealth(params) + result, err := svc.SetInstanceHealth(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 autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_SetInstanceProtection() { - sess := session.Must(session.NewSession()) - - svc := autoscaling.New(sess) - - params := &autoscaling.SetInstanceProtectionInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - InstanceIds: []*string{ // Required - aws.String("XmlStringMaxLen19"), // Required - // More values... +// To enable instance protection for an instance +// +// This example enables instance protection for the specified instance. +func ExampleAutoScaling_SetInstanceProtection_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.SetInstanceProtectionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + InstanceIds: []*string{ + aws.String("i-93633f9b"), }, - ProtectedFromScaleIn: aws.Bool(true), // Required + ProtectedFromScaleIn: aws.Bool(true), } - resp, err := svc.SetInstanceProtection(params) + result, err := svc.SetInstanceProtection(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 autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_SuspendProcesses() { - sess := session.Must(session.NewSession()) +// To disable instance protection for an instance +// +// This example disables instance protection for the specified instance. +func ExampleAutoScaling_SetInstanceProtection_shared01() { + svc := autoscaling.New(session.New()) + input := &autoscaling.SetInstanceProtectionInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + InstanceIds: []*string{ + aws.String("i-93633f9b"), + }, + ProtectedFromScaleIn: aws.Bool(false), + } - svc := autoscaling.New(sess) + result, err := svc.SetInstanceProtection(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeLimitExceededFault: + fmt.Println(autoscaling.ErrCodeLimitExceededFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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) +} - params := &autoscaling.ScalingProcessQuery{ - AutoScalingGroupName: aws.String("ResourceName"), // Required +// To suspend Auto Scaling processes +// +// This example suspends the specified scaling process for the specified Auto Scaling +// group. +func ExampleAutoScaling_SuspendProcesses_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.ScalingProcessQuery{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), ScalingProcesses: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... + aws.String("AlarmNotification"), }, } - resp, err := svc.SuspendProcesses(params) + result, err := svc.SuspendProcesses(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 autoscaling.ErrCodeResourceInUseFault: + fmt.Println(autoscaling.ErrCodeResourceInUseFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_TerminateInstanceInAutoScalingGroup() { - sess := session.Must(session.NewSession()) +// To terminate an instance in an Auto Scaling group +// +// This example terminates the specified instance from the specified Auto Scaling group +// without updating the size of the group. Auto Scaling launches a replacement instance +// after the specified instance terminates. +func ExampleAutoScaling_TerminateInstanceInAutoScalingGroup_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.TerminateInstanceInAutoScalingGroupInput{ + InstanceId: aws.String("i-93633f9b"), + ShouldDecrementDesiredCapacity: aws.Bool(false), + } + + result, err := svc.TerminateInstanceInAutoScalingGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 + } - svc := autoscaling.New(sess) + fmt.Println(result) +} - params := &autoscaling.TerminateInstanceInAutoScalingGroupInput{ - InstanceId: aws.String("XmlStringMaxLen19"), // Required - ShouldDecrementDesiredCapacity: aws.Bool(true), // Required +// To update the launch configuration +// +// This example updates the launch configuration of the specified Auto Scaling group. +func ExampleAutoScaling_UpdateAutoScalingGroup_shared00() { + svc := autoscaling.New(session.New()) + input := &autoscaling.UpdateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + LaunchConfigurationName: aws.String("new-launch-config"), } - resp, err := svc.TerminateInstanceInAutoScalingGroup(params) + result, err := svc.UpdateAutoScalingGroup(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 autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 ExampleAutoScaling_UpdateAutoScalingGroup() { - sess := session.Must(session.NewSession()) +// To update the minimum and maximum size +// +// This example updates the minimum size and maximum size of the specified Auto Scaling +// group. +func ExampleAutoScaling_UpdateAutoScalingGroup_shared01() { + svc := autoscaling.New(session.New()) + input := &autoscaling.UpdateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), + MaxSize: aws.Int64(3.000000), + MinSize: aws.Int64(1.000000), + } + + result, err := svc.UpdateAutoScalingGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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 + } - svc := autoscaling.New(sess) + fmt.Println(result) +} - params := &autoscaling.UpdateAutoScalingGroupInput{ - AutoScalingGroupName: aws.String("ResourceName"), // Required - AvailabilityZones: []*string{ - aws.String("XmlStringMaxLen255"), // Required - // More values... - }, - DefaultCooldown: aws.Int64(1), - DesiredCapacity: aws.Int64(1), - HealthCheckGracePeriod: aws.Int64(1), - HealthCheckType: aws.String("XmlStringMaxLen32"), - LaunchConfigurationName: aws.String("ResourceName"), - MaxSize: aws.Int64(1), - MinSize: aws.Int64(1), +// To enable instance protection +// +// This example enables instance protection for the specified Auto Scaling group. +func ExampleAutoScaling_UpdateAutoScalingGroup_shared02() { + svc := autoscaling.New(session.New()) + input := &autoscaling.UpdateAutoScalingGroupInput{ + AutoScalingGroupName: aws.String("my-auto-scaling-group"), NewInstancesProtectedFromScaleIn: aws.Bool(true), - PlacementGroup: aws.String("XmlStringMaxLen255"), - TerminationPolicies: []*string{ - aws.String("XmlStringMaxLen1600"), // Required - // More values... - }, - VPCZoneIdentifier: aws.String("XmlStringMaxLen2047"), } - resp, err := svc.UpdateAutoScalingGroup(params) + result, err := svc.UpdateAutoScalingGroup(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 autoscaling.ErrCodeScalingActivityInProgressFault: + fmt.Println(autoscaling.ErrCodeScalingActivityInProgressFault, aerr.Error()) + case autoscaling.ErrCodeResourceContentionFault: + fmt.Println(autoscaling.ErrCodeResourceContentionFault, 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) } diff --git a/service/batch/examples_test.go b/service/batch/examples_test.go deleted file mode 100644 index 97a3ecbfd92..00000000000 --- a/service/batch/examples_test.go +++ /dev/null @@ -1,515 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package batch_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/batch" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleBatch_CancelJob() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.CancelJobInput{ - JobId: aws.String("String"), // Required - Reason: aws.String("String"), // Required - } - resp, err := svc.CancelJob(params) - - if err != nil { - // 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) -} - -func ExampleBatch_CreateComputeEnvironment() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.CreateComputeEnvironmentInput{ - ComputeEnvironmentName: aws.String("String"), // Required - ServiceRole: aws.String("String"), // Required - Type: aws.String("CEType"), // Required - ComputeResources: &batch.ComputeResource{ - InstanceRole: aws.String("String"), // Required - InstanceTypes: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - MaxvCpus: aws.Int64(1), // Required - MinvCpus: aws.Int64(1), // Required - SecurityGroupIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Subnets: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Type: aws.String("CRType"), // Required - BidPercentage: aws.Int64(1), - DesiredvCpus: aws.Int64(1), - Ec2KeyPair: aws.String("String"), - ImageId: aws.String("String"), - SpotIamFleetRole: aws.String("String"), - Tags: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - State: aws.String("CEState"), - } - resp, err := svc.CreateComputeEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleBatch_CreateJobQueue() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.CreateJobQueueInput{ - ComputeEnvironmentOrder: []*batch.ComputeEnvironmentOrder{ // Required - { // Required - ComputeEnvironment: aws.String("String"), // Required - Order: aws.Int64(1), // Required - }, - // More values... - }, - JobQueueName: aws.String("String"), // Required - Priority: aws.Int64(1), // Required - State: aws.String("JQState"), - } - resp, err := svc.CreateJobQueue(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DeleteComputeEnvironment() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DeleteComputeEnvironmentInput{ - ComputeEnvironment: aws.String("String"), // Required - } - resp, err := svc.DeleteComputeEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DeleteJobQueue() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DeleteJobQueueInput{ - JobQueue: aws.String("String"), // Required - } - resp, err := svc.DeleteJobQueue(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DeregisterJobDefinition() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DeregisterJobDefinitionInput{ - JobDefinition: aws.String("String"), // Required - } - resp, err := svc.DeregisterJobDefinition(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DescribeComputeEnvironments() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DescribeComputeEnvironmentsInput{ - ComputeEnvironments: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeComputeEnvironments(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DescribeJobDefinitions() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DescribeJobDefinitionsInput{ - JobDefinitionName: aws.String("String"), - JobDefinitions: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - Status: aws.String("String"), - } - resp, err := svc.DescribeJobDefinitions(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DescribeJobQueues() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DescribeJobQueuesInput{ - JobQueues: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeJobQueues(params) - - if err != nil { - // 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) -} - -func ExampleBatch_DescribeJobs() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.DescribeJobsInput{ - Jobs: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeJobs(params) - - if err != nil { - // 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) -} - -func ExampleBatch_ListJobs() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.ListJobsInput{ - JobQueue: aws.String("String"), // Required - JobStatus: aws.String("JobStatus"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListJobs(params) - - if err != nil { - // 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) -} - -func ExampleBatch_RegisterJobDefinition() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.RegisterJobDefinitionInput{ - JobDefinitionName: aws.String("String"), // Required - Type: aws.String("JobDefinitionType"), // Required - ContainerProperties: &batch.ContainerProperties{ - Image: aws.String("String"), // Required - Memory: aws.Int64(1), // Required - Vcpus: aws.Int64(1), // Required - Command: []*string{ - aws.String("String"), // Required - // More values... - }, - Environment: []*batch.KeyValuePair{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - JobRoleArn: aws.String("String"), - MountPoints: []*batch.MountPoint{ - { // Required - ContainerPath: aws.String("String"), - ReadOnly: aws.Bool(true), - SourceVolume: aws.String("String"), - }, - // More values... - }, - Privileged: aws.Bool(true), - ReadonlyRootFilesystem: aws.Bool(true), - Ulimits: []*batch.Ulimit{ - { // Required - HardLimit: aws.Int64(1), // Required - Name: aws.String("String"), // Required - SoftLimit: aws.Int64(1), // Required - }, - // More values... - }, - User: aws.String("String"), - Volumes: []*batch.Volume{ - { // Required - Host: &batch.Host{ - SourcePath: aws.String("String"), - }, - Name: aws.String("String"), - }, - // More values... - }, - }, - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - RetryStrategy: &batch.RetryStrategy{ - Attempts: aws.Int64(1), - }, - } - resp, err := svc.RegisterJobDefinition(params) - - if err != nil { - // 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) -} - -func ExampleBatch_SubmitJob() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.SubmitJobInput{ - JobDefinition: aws.String("String"), // Required - JobName: aws.String("String"), // Required - JobQueue: aws.String("String"), // Required - ContainerOverrides: &batch.ContainerOverrides{ - Command: []*string{ - aws.String("String"), // Required - // More values... - }, - Environment: []*batch.KeyValuePair{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - Memory: aws.Int64(1), - Vcpus: aws.Int64(1), - }, - DependsOn: []*batch.JobDependency{ - { // Required - JobId: aws.String("String"), - }, - // More values... - }, - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - RetryStrategy: &batch.RetryStrategy{ - Attempts: aws.Int64(1), - }, - } - resp, err := svc.SubmitJob(params) - - if err != nil { - // 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) -} - -func ExampleBatch_TerminateJob() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.TerminateJobInput{ - JobId: aws.String("String"), // Required - Reason: aws.String("String"), // Required - } - resp, err := svc.TerminateJob(params) - - if err != nil { - // 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) -} - -func ExampleBatch_UpdateComputeEnvironment() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.UpdateComputeEnvironmentInput{ - ComputeEnvironment: aws.String("String"), // Required - ComputeResources: &batch.ComputeResourceUpdate{ - DesiredvCpus: aws.Int64(1), - MaxvCpus: aws.Int64(1), - MinvCpus: aws.Int64(1), - }, - ServiceRole: aws.String("String"), - State: aws.String("CEState"), - } - resp, err := svc.UpdateComputeEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleBatch_UpdateJobQueue() { - sess := session.Must(session.NewSession()) - - svc := batch.New(sess) - - params := &batch.UpdateJobQueueInput{ - JobQueue: aws.String("String"), // Required - ComputeEnvironmentOrder: []*batch.ComputeEnvironmentOrder{ - { // Required - ComputeEnvironment: aws.String("String"), // Required - Order: aws.Int64(1), // Required - }, - // More values... - }, - Priority: aws.Int64(1), - State: aws.String("JQState"), - } - resp, err := svc.UpdateJobQueue(params) - - if err != nil { - // 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) -} diff --git a/service/budgets/examples_test.go b/service/budgets/examples_test.go deleted file mode 100644 index be5fcf4af52..00000000000 --- a/service/budgets/examples_test.go +++ /dev/null @@ -1,455 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package budgets_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/budgets" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleBudgets_CreateBudget() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.CreateBudgetInput{ - AccountId: aws.String("AccountId"), // Required - Budget: &budgets.Budget{ // Required - BudgetLimit: &budgets.Spend{ // Required - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - BudgetName: aws.String("BudgetName"), // Required - BudgetType: aws.String("BudgetType"), // Required - CostTypes: &budgets.CostTypes{ // Required - IncludeSubscription: aws.Bool(true), // Required - IncludeTax: aws.Bool(true), // Required - UseBlended: aws.Bool(true), // Required - }, - TimePeriod: &budgets.TimePeriod{ // Required - End: aws.Time(time.Now()), // Required - Start: aws.Time(time.Now()), // Required - }, - TimeUnit: aws.String("TimeUnit"), // Required - CalculatedSpend: &budgets.CalculatedSpend{ - ActualSpend: &budgets.Spend{ // Required - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - ForecastedSpend: &budgets.Spend{ - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - }, - CostFilters: map[string][]*string{ - "Key": { // Required - aws.String("GenericString"), // Required - // More values... - }, - // More values... - }, - }, - NotificationsWithSubscribers: []*budgets.NotificationWithSubscribers{ - { // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - Subscribers: []*budgets.Subscriber{ // Required - { // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.CreateBudget(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_CreateNotification() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.CreateNotificationInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - Subscribers: []*budgets.Subscriber{ // Required - { // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - // More values... - }, - } - resp, err := svc.CreateNotification(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_CreateSubscriber() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.CreateSubscriberInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - Subscriber: &budgets.Subscriber{ // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - } - resp, err := svc.CreateSubscriber(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DeleteBudget() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DeleteBudgetInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - } - resp, err := svc.DeleteBudget(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DeleteNotification() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DeleteNotificationInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - } - resp, err := svc.DeleteNotification(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DeleteSubscriber() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DeleteSubscriberInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - Subscriber: &budgets.Subscriber{ // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - } - resp, err := svc.DeleteSubscriber(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DescribeBudget() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DescribeBudgetInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - } - resp, err := svc.DescribeBudget(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DescribeBudgets() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DescribeBudgetsInput{ - AccountId: aws.String("AccountId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("GenericString"), - } - resp, err := svc.DescribeBudgets(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DescribeNotificationsForBudget() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DescribeNotificationsForBudgetInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("GenericString"), - } - resp, err := svc.DescribeNotificationsForBudget(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_DescribeSubscribersForNotification() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.DescribeSubscribersForNotificationInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("GenericString"), - } - resp, err := svc.DescribeSubscribersForNotification(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_UpdateBudget() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.UpdateBudgetInput{ - AccountId: aws.String("AccountId"), // Required - NewBudget: &budgets.Budget{ // Required - BudgetLimit: &budgets.Spend{ // Required - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - BudgetName: aws.String("BudgetName"), // Required - BudgetType: aws.String("BudgetType"), // Required - CostTypes: &budgets.CostTypes{ // Required - IncludeSubscription: aws.Bool(true), // Required - IncludeTax: aws.Bool(true), // Required - UseBlended: aws.Bool(true), // Required - }, - TimePeriod: &budgets.TimePeriod{ // Required - End: aws.Time(time.Now()), // Required - Start: aws.Time(time.Now()), // Required - }, - TimeUnit: aws.String("TimeUnit"), // Required - CalculatedSpend: &budgets.CalculatedSpend{ - ActualSpend: &budgets.Spend{ // Required - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - ForecastedSpend: &budgets.Spend{ - Amount: aws.String("NumericValue"), // Required - Unit: aws.String("GenericString"), // Required - }, - }, - CostFilters: map[string][]*string{ - "Key": { // Required - aws.String("GenericString"), // Required - // More values... - }, - // More values... - }, - }, - } - resp, err := svc.UpdateBudget(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_UpdateNotification() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.UpdateNotificationInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - NewNotification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - OldNotification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - } - resp, err := svc.UpdateNotification(params) - - if err != nil { - // 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) -} - -func ExampleBudgets_UpdateSubscriber() { - sess := session.Must(session.NewSession()) - - svc := budgets.New(sess) - - params := &budgets.UpdateSubscriberInput{ - AccountId: aws.String("AccountId"), // Required - BudgetName: aws.String("BudgetName"), // Required - NewSubscriber: &budgets.Subscriber{ // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - Notification: &budgets.Notification{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - NotificationType: aws.String("NotificationType"), // Required - Threshold: aws.Float64(1.0), // Required - }, - OldSubscriber: &budgets.Subscriber{ // Required - Address: aws.String("GenericString"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - }, - } - resp, err := svc.UpdateSubscriber(params) - - if err != nil { - // 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) -} diff --git a/service/clouddirectory/examples_test.go b/service/clouddirectory/examples_test.go deleted file mode 100644 index 4acf901c23a..00000000000 --- a/service/clouddirectory/examples_test.go +++ /dev/null @@ -1,1910 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package clouddirectory_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/clouddirectory" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudDirectory_AddFacetToObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.AddFacetToObjectInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - SchemaFacet: &clouddirectory.SchemaFacet{ // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - ObjectAttributeList: []*clouddirectory.AttributeKeyAndValue{ - { // Required - Key: &clouddirectory.AttributeKey{ // Required - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - } - resp, err := svc.AddFacetToObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ApplySchema() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ApplySchemaInput{ - DirectoryArn: aws.String("Arn"), // Required - PublishedSchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.ApplySchema(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_AttachObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.AttachObjectInput{ - ChildReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - DirectoryArn: aws.String("Arn"), // Required - LinkName: aws.String("LinkName"), // Required - ParentReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.AttachObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_AttachPolicy() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.AttachPolicyInput{ - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - PolicyReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - DirectoryArn: aws.String("Arn"), - } - resp, err := svc.AttachPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_AttachToIndex() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.AttachToIndexInput{ - DirectoryArn: aws.String("Arn"), // Required - IndexReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TargetReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.AttachToIndex(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_AttachTypedLink() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.AttachTypedLinkInput{ - Attributes: []*clouddirectory.AttributeNameAndValue{ // Required - { // Required - AttributeName: aws.String("AttributeName"), // Required - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - DirectoryArn: aws.String("Arn"), // Required - SourceObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TargetObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TypedLinkFacet: &clouddirectory.TypedLinkSchemaAndFacetName{ // Required - SchemaArn: aws.String("Arn"), // Required - TypedLinkName: aws.String("TypedLinkName"), // Required - }, - } - resp, err := svc.AttachTypedLink(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_BatchRead() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.BatchReadInput{ - DirectoryArn: aws.String("Arn"), // Required - Operations: []*clouddirectory.BatchReadOperation{ // Required - { // Required - ListObjectAttributes: &clouddirectory.BatchListObjectAttributes{ - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - FacetFilter: &clouddirectory.SchemaFacet{ - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - }, - ListObjectChildren: &clouddirectory.BatchListObjectChildren{ - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - }, - }, - // More values... - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - } - resp, err := svc.BatchRead(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_BatchWrite() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.BatchWriteInput{ - DirectoryArn: aws.String("Arn"), // Required - Operations: []*clouddirectory.BatchWriteOperation{ // Required - { // Required - AddFacetToObject: &clouddirectory.BatchAddFacetToObject{ - ObjectAttributeList: []*clouddirectory.AttributeKeyAndValue{ // Required - { // Required - Key: &clouddirectory.AttributeKey{ // Required - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - SchemaFacet: &clouddirectory.SchemaFacet{ // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - }, - AttachObject: &clouddirectory.BatchAttachObject{ - ChildReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - LinkName: aws.String("LinkName"), // Required - ParentReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - }, - CreateObject: &clouddirectory.BatchCreateObject{ - BatchReferenceName: aws.String("BatchReferenceName"), // Required - LinkName: aws.String("LinkName"), // Required - ObjectAttributeList: []*clouddirectory.AttributeKeyAndValue{ // Required - { // Required - Key: &clouddirectory.AttributeKey{ // Required - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - ParentReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - SchemaFacet: []*clouddirectory.SchemaFacet{ // Required - { // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - // More values... - }, - }, - DeleteObject: &clouddirectory.BatchDeleteObject{ - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - }, - DetachObject: &clouddirectory.BatchDetachObject{ - BatchReferenceName: aws.String("BatchReferenceName"), // Required - LinkName: aws.String("LinkName"), // Required - ParentReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - }, - RemoveFacetFromObject: &clouddirectory.BatchRemoveFacetFromObject{ - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - SchemaFacet: &clouddirectory.SchemaFacet{ // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - }, - UpdateObjectAttributes: &clouddirectory.BatchUpdateObjectAttributes{ - AttributeUpdates: []*clouddirectory.ObjectAttributeUpdate{ // Required - { // Required - ObjectAttributeAction: &clouddirectory.ObjectAttributeAction{ - ObjectAttributeActionType: aws.String("UpdateActionType"), - ObjectAttributeUpdateValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - ObjectAttributeKey: &clouddirectory.AttributeKey{ - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - }, - // More values... - }, - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - }, - }, - // More values... - }, - } - resp, err := svc.BatchWrite(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateDirectory() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateDirectoryInput{ - Name: aws.String("DirectoryName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.CreateDirectory(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateFacetInput{ - Name: aws.String("FacetName"), // Required - ObjectType: aws.String("ObjectType"), // Required - SchemaArn: aws.String("Arn"), // Required - Attributes: []*clouddirectory.FacetAttribute{ - { // Required - Name: aws.String("AttributeName"), // Required - AttributeDefinition: &clouddirectory.FacetAttributeDefinition{ - Type: aws.String("FacetAttributeType"), // Required - DefaultValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - IsImmutable: aws.Bool(true), - Rules: map[string]*clouddirectory.Rule{ - "Key": { // Required - Parameters: map[string]*string{ - "Key": aws.String("RuleParameterValue"), // Required - // More values... - }, - Type: aws.String("RuleType"), - }, - // More values... - }, - }, - AttributeReference: &clouddirectory.FacetAttributeReference{ - TargetAttributeName: aws.String("AttributeName"), // Required - TargetFacetName: aws.String("FacetName"), // Required - }, - RequiredBehavior: aws.String("RequiredAttributeBehavior"), - }, - // More values... - }, - } - resp, err := svc.CreateFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateIndex() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateIndexInput{ - DirectoryArn: aws.String("Arn"), // Required - IsUnique: aws.Bool(true), // Required - OrderedIndexedAttributeList: []*clouddirectory.AttributeKey{ // Required - { // Required - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - // More values... - }, - LinkName: aws.String("LinkName"), - ParentReference: &clouddirectory.ObjectReference{ - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.CreateIndex(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateObjectInput{ - DirectoryArn: aws.String("Arn"), // Required - SchemaFacets: []*clouddirectory.SchemaFacet{ // Required - { // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - // More values... - }, - LinkName: aws.String("LinkName"), - ObjectAttributeList: []*clouddirectory.AttributeKeyAndValue{ - { // Required - Key: &clouddirectory.AttributeKey{ // Required - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - ParentReference: &clouddirectory.ObjectReference{ - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.CreateObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateSchema() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateSchemaInput{ - Name: aws.String("SchemaName"), // Required - } - resp, err := svc.CreateSchema(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_CreateTypedLinkFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.CreateTypedLinkFacetInput{ - Facet: &clouddirectory.TypedLinkFacet{ // Required - Attributes: []*clouddirectory.TypedLinkAttributeDefinition{ // Required - { // Required - Name: aws.String("AttributeName"), // Required - RequiredBehavior: aws.String("RequiredAttributeBehavior"), // Required - Type: aws.String("FacetAttributeType"), // Required - DefaultValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - IsImmutable: aws.Bool(true), - Rules: map[string]*clouddirectory.Rule{ - "Key": { // Required - Parameters: map[string]*string{ - "Key": aws.String("RuleParameterValue"), // Required - // More values... - }, - Type: aws.String("RuleType"), - }, - // More values... - }, - }, - // More values... - }, - IdentityAttributeOrder: []*string{ // Required - aws.String("AttributeName"), // Required - // More values... - }, - Name: aws.String("TypedLinkName"), // Required - }, - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.CreateTypedLinkFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DeleteDirectory() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DeleteDirectoryInput{ - DirectoryArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteDirectory(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DeleteFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DeleteFacetInput{ - Name: aws.String("FacetName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DeleteObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DeleteObjectInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.DeleteObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DeleteSchema() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DeleteSchemaInput{ - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteSchema(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DeleteTypedLinkFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DeleteTypedLinkFacetInput{ - Name: aws.String("TypedLinkName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteTypedLinkFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DetachFromIndex() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DetachFromIndexInput{ - DirectoryArn: aws.String("Arn"), // Required - IndexReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TargetReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.DetachFromIndex(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DetachObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DetachObjectInput{ - DirectoryArn: aws.String("Arn"), // Required - LinkName: aws.String("LinkName"), // Required - ParentReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.DetachObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DetachPolicy() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DetachPolicyInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - PolicyReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.DetachPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DetachTypedLink() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DetachTypedLinkInput{ - DirectoryArn: aws.String("Arn"), // Required - TypedLinkSpecifier: &clouddirectory.TypedLinkSpecifier{ // Required - IdentityAttributeValues: []*clouddirectory.AttributeNameAndValue{ // Required - { // Required - AttributeName: aws.String("AttributeName"), // Required - Value: &clouddirectory.TypedAttributeValue{ // Required - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - // More values... - }, - SourceObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TargetObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - TypedLinkFacet: &clouddirectory.TypedLinkSchemaAndFacetName{ // Required - SchemaArn: aws.String("Arn"), // Required - TypedLinkName: aws.String("TypedLinkName"), // Required - }, - }, - } - resp, err := svc.DetachTypedLink(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_DisableDirectory() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.DisableDirectoryInput{ - DirectoryArn: aws.String("Arn"), // Required - } - resp, err := svc.DisableDirectory(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_EnableDirectory() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.EnableDirectoryInput{ - DirectoryArn: aws.String("Arn"), // Required - } - resp, err := svc.EnableDirectory(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_GetDirectory() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.GetDirectoryInput{ - DirectoryArn: aws.String("DirectoryArn"), // Required - } - resp, err := svc.GetDirectory(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_GetFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.GetFacetInput{ - Name: aws.String("FacetName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.GetFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_GetObjectInformation() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.GetObjectInformationInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - } - resp, err := svc.GetObjectInformation(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_GetSchemaAsJson() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.GetSchemaAsJsonInput{ - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.GetSchemaAsJson(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_GetTypedLinkFacetInformation() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.GetTypedLinkFacetInformationInput{ - Name: aws.String("TypedLinkName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.GetTypedLinkFacetInformation(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListAppliedSchemaArns() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListAppliedSchemaArnsInput{ - DirectoryArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListAppliedSchemaArns(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListAttachedIndices() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListAttachedIndicesInput{ - DirectoryArn: aws.String("Arn"), // Required - TargetReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListAttachedIndices(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListDevelopmentSchemaArns() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListDevelopmentSchemaArnsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDevelopmentSchemaArns(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListDirectories() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListDirectoriesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - State: aws.String("DirectoryState"), - } - resp, err := svc.ListDirectories(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListFacetAttributes() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListFacetAttributesInput{ - Name: aws.String("FacetName"), // Required - SchemaArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListFacetAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListFacetNames() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListFacetNamesInput{ - SchemaArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListFacetNames(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListIncomingTypedLinks() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListIncomingTypedLinksInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - FilterAttributeRanges: []*clouddirectory.TypedLinkAttributeRange{ - { // Required - Range: &clouddirectory.TypedAttributeValueRange{ // Required - EndMode: aws.String("RangeMode"), // Required - StartMode: aws.String("RangeMode"), // Required - EndValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - StartValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - AttributeName: aws.String("AttributeName"), - }, - // More values... - }, - FilterTypedLink: &clouddirectory.TypedLinkSchemaAndFacetName{ - SchemaArn: aws.String("Arn"), // Required - TypedLinkName: aws.String("TypedLinkName"), // Required - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListIncomingTypedLinks(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListIndex() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListIndexInput{ - DirectoryArn: aws.String("Arn"), // Required - IndexReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - RangesOnIndexedValues: []*clouddirectory.ObjectAttributeRange{ - { // Required - AttributeKey: &clouddirectory.AttributeKey{ - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - Range: &clouddirectory.TypedAttributeValueRange{ - EndMode: aws.String("RangeMode"), // Required - StartMode: aws.String("RangeMode"), // Required - EndValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - StartValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - }, - // More values... - }, - } - resp, err := svc.ListIndex(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListObjectAttributes() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListObjectAttributesInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - FacetFilter: &clouddirectory.SchemaFacet{ - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListObjectAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListObjectChildren() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListObjectChildrenInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListObjectChildren(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListObjectParentPaths() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListObjectParentPathsInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListObjectParentPaths(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListObjectParents() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListObjectParentsInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListObjectParents(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListObjectPolicies() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListObjectPoliciesInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListObjectPolicies(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListOutgoingTypedLinks() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListOutgoingTypedLinksInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - FilterAttributeRanges: []*clouddirectory.TypedLinkAttributeRange{ - { // Required - Range: &clouddirectory.TypedAttributeValueRange{ // Required - EndMode: aws.String("RangeMode"), // Required - StartMode: aws.String("RangeMode"), // Required - EndValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - StartValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - AttributeName: aws.String("AttributeName"), - }, - // More values... - }, - FilterTypedLink: &clouddirectory.TypedLinkSchemaAndFacetName{ - SchemaArn: aws.String("Arn"), // Required - TypedLinkName: aws.String("TypedLinkName"), // Required - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListOutgoingTypedLinks(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListPolicyAttachments() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListPolicyAttachmentsInput{ - DirectoryArn: aws.String("Arn"), // Required - PolicyReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - ConsistencyLevel: aws.String("ConsistencyLevel"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPolicyAttachments(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListPublishedSchemaArns() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListPublishedSchemaArnsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPublishedSchemaArns(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListTagsForResourceInput{ - ResourceArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListTypedLinkFacetAttributes() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListTypedLinkFacetAttributesInput{ - Name: aws.String("TypedLinkName"), // Required - SchemaArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTypedLinkFacetAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_ListTypedLinkFacetNames() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.ListTypedLinkFacetNamesInput{ - SchemaArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTypedLinkFacetNames(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_LookupPolicy() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.LookupPolicyInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.LookupPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_PublishSchema() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.PublishSchemaInput{ - DevelopmentSchemaArn: aws.String("Arn"), // Required - Version: aws.String("Version"), // Required - Name: aws.String("SchemaName"), - } - resp, err := svc.PublishSchema(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_PutSchemaFromJson() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.PutSchemaFromJsonInput{ - Document: aws.String("SchemaJsonDocument"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.PutSchemaFromJson(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_RemoveFacetFromObject() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.RemoveFacetFromObjectInput{ - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - SchemaFacet: &clouddirectory.SchemaFacet{ // Required - FacetName: aws.String("FacetName"), - SchemaArn: aws.String("Arn"), - }, - } - resp, err := svc.RemoveFacetFromObject(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_TagResource() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.TagResourceInput{ - ResourceArn: aws.String("Arn"), // Required - Tags: []*clouddirectory.Tag{ // Required - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.TagResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.UntagResourceInput{ - ResourceArn: aws.String("Arn"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UntagResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_UpdateFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.UpdateFacetInput{ - Name: aws.String("FacetName"), // Required - SchemaArn: aws.String("Arn"), // Required - AttributeUpdates: []*clouddirectory.FacetAttributeUpdate{ - { // Required - Action: aws.String("UpdateActionType"), - Attribute: &clouddirectory.FacetAttribute{ - Name: aws.String("AttributeName"), // Required - AttributeDefinition: &clouddirectory.FacetAttributeDefinition{ - Type: aws.String("FacetAttributeType"), // Required - DefaultValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - IsImmutable: aws.Bool(true), - Rules: map[string]*clouddirectory.Rule{ - "Key": { // Required - Parameters: map[string]*string{ - "Key": aws.String("RuleParameterValue"), // Required - // More values... - }, - Type: aws.String("RuleType"), - }, - // More values... - }, - }, - AttributeReference: &clouddirectory.FacetAttributeReference{ - TargetAttributeName: aws.String("AttributeName"), // Required - TargetFacetName: aws.String("FacetName"), // Required - }, - RequiredBehavior: aws.String("RequiredAttributeBehavior"), - }, - }, - // More values... - }, - ObjectType: aws.String("ObjectType"), - } - resp, err := svc.UpdateFacet(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_UpdateObjectAttributes() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.UpdateObjectAttributesInput{ - AttributeUpdates: []*clouddirectory.ObjectAttributeUpdate{ // Required - { // Required - ObjectAttributeAction: &clouddirectory.ObjectAttributeAction{ - ObjectAttributeActionType: aws.String("UpdateActionType"), - ObjectAttributeUpdateValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - }, - ObjectAttributeKey: &clouddirectory.AttributeKey{ - FacetName: aws.String("FacetName"), // Required - Name: aws.String("AttributeName"), // Required - SchemaArn: aws.String("Arn"), // Required - }, - }, - // More values... - }, - DirectoryArn: aws.String("Arn"), // Required - ObjectReference: &clouddirectory.ObjectReference{ // Required - Selector: aws.String("SelectorObjectReference"), - }, - } - resp, err := svc.UpdateObjectAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_UpdateSchema() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.UpdateSchemaInput{ - Name: aws.String("SchemaName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.UpdateSchema(params) - - if err != nil { - // 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) -} - -func ExampleCloudDirectory_UpdateTypedLinkFacet() { - sess := session.Must(session.NewSession()) - - svc := clouddirectory.New(sess) - - params := &clouddirectory.UpdateTypedLinkFacetInput{ - AttributeUpdates: []*clouddirectory.TypedLinkFacetAttributeUpdate{ // Required - { // Required - Action: aws.String("UpdateActionType"), // Required - Attribute: &clouddirectory.TypedLinkAttributeDefinition{ // Required - Name: aws.String("AttributeName"), // Required - RequiredBehavior: aws.String("RequiredAttributeBehavior"), // Required - Type: aws.String("FacetAttributeType"), // Required - DefaultValue: &clouddirectory.TypedAttributeValue{ - BinaryValue: []byte("PAYLOAD"), - BooleanValue: aws.Bool(true), - DatetimeValue: aws.Time(time.Now()), - NumberValue: aws.String("NumberAttributeValue"), - StringValue: aws.String("StringAttributeValue"), - }, - IsImmutable: aws.Bool(true), - Rules: map[string]*clouddirectory.Rule{ - "Key": { // Required - Parameters: map[string]*string{ - "Key": aws.String("RuleParameterValue"), // Required - // More values... - }, - Type: aws.String("RuleType"), - }, - // More values... - }, - }, - }, - // More values... - }, - IdentityAttributeOrder: []*string{ // Required - aws.String("AttributeName"), // Required - // More values... - }, - Name: aws.String("TypedLinkName"), // Required - SchemaArn: aws.String("Arn"), // Required - } - resp, err := svc.UpdateTypedLinkFacet(params) - - if err != nil { - // 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) -} diff --git a/service/cloudformation/examples_test.go b/service/cloudformation/examples_test.go deleted file mode 100644 index 8c4b221ae18..00000000000 --- a/service/cloudformation/examples_test.go +++ /dev/null @@ -1,718 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudformation_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudformation" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudFormation_CancelUpdateStack() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.CancelUpdateStackInput{ - StackName: aws.String("StackName"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - } - resp, err := svc.CancelUpdateStack(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ContinueUpdateRollback() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ContinueUpdateRollbackInput{ - StackName: aws.String("StackNameOrId"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - ResourcesToSkip: []*string{ - aws.String("ResourceToSkip"), // Required - // More values... - }, - RoleARN: aws.String("RoleARN"), - } - resp, err := svc.ContinueUpdateRollback(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_CreateChangeSet() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.CreateChangeSetInput{ - ChangeSetName: aws.String("ChangeSetName"), // Required - StackName: aws.String("StackNameOrId"), // Required - Capabilities: []*string{ - aws.String("Capability"), // Required - // More values... - }, - ChangeSetType: aws.String("ChangeSetType"), - ClientToken: aws.String("ClientToken"), - Description: aws.String("Description"), - NotificationARNs: []*string{ - aws.String("NotificationARN"), // Required - // More values... - }, - Parameters: []*cloudformation.Parameter{ - { // Required - ParameterKey: aws.String("ParameterKey"), - ParameterValue: aws.String("ParameterValue"), - UsePreviousValue: aws.Bool(true), - }, - // More values... - }, - ResourceTypes: []*string{ - aws.String("ResourceType"), // Required - // More values... - }, - RoleARN: aws.String("RoleARN"), - Tags: []*cloudformation.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - UsePreviousTemplate: aws.Bool(true), - } - resp, err := svc.CreateChangeSet(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_CreateStack() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.CreateStackInput{ - StackName: aws.String("StackName"), // Required - Capabilities: []*string{ - aws.String("Capability"), // Required - // More values... - }, - ClientRequestToken: aws.String("ClientRequestToken"), - DisableRollback: aws.Bool(true), - NotificationARNs: []*string{ - aws.String("NotificationARN"), // Required - // More values... - }, - OnFailure: aws.String("OnFailure"), - Parameters: []*cloudformation.Parameter{ - { // Required - ParameterKey: aws.String("ParameterKey"), - ParameterValue: aws.String("ParameterValue"), - UsePreviousValue: aws.Bool(true), - }, - // More values... - }, - ResourceTypes: []*string{ - aws.String("ResourceType"), // Required - // More values... - }, - RoleARN: aws.String("RoleARN"), - StackPolicyBody: aws.String("StackPolicyBody"), - StackPolicyURL: aws.String("StackPolicyURL"), - Tags: []*cloudformation.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - TimeoutInMinutes: aws.Int64(1), - } - resp, err := svc.CreateStack(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DeleteChangeSet() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DeleteChangeSetInput{ - ChangeSetName: aws.String("ChangeSetNameOrId"), // Required - StackName: aws.String("StackNameOrId"), - } - resp, err := svc.DeleteChangeSet(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DeleteStack() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DeleteStackInput{ - StackName: aws.String("StackName"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - RetainResources: []*string{ - aws.String("LogicalResourceId"), // Required - // More values... - }, - RoleARN: aws.String("RoleARN"), - } - resp, err := svc.DeleteStack(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeAccountLimits() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeAccountLimitsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeAccountLimits(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeChangeSet() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeChangeSetInput{ - ChangeSetName: aws.String("ChangeSetNameOrId"), // Required - NextToken: aws.String("NextToken"), - StackName: aws.String("StackNameOrId"), - } - resp, err := svc.DescribeChangeSet(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeStackEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeStackEventsInput{ - NextToken: aws.String("NextToken"), - StackName: aws.String("StackName"), - } - resp, err := svc.DescribeStackEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeStackResource() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeStackResourceInput{ - LogicalResourceId: aws.String("LogicalResourceId"), // Required - StackName: aws.String("StackName"), // Required - } - resp, err := svc.DescribeStackResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeStackResources() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeStackResourcesInput{ - LogicalResourceId: aws.String("LogicalResourceId"), - PhysicalResourceId: aws.String("PhysicalResourceId"), - StackName: aws.String("StackName"), - } - resp, err := svc.DescribeStackResources(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_DescribeStacks() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.DescribeStacksInput{ - NextToken: aws.String("NextToken"), - StackName: aws.String("StackName"), - } - resp, err := svc.DescribeStacks(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_EstimateTemplateCost() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.EstimateTemplateCostInput{ - Parameters: []*cloudformation.Parameter{ - { // Required - ParameterKey: aws.String("ParameterKey"), - ParameterValue: aws.String("ParameterValue"), - UsePreviousValue: aws.Bool(true), - }, - // More values... - }, - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - } - resp, err := svc.EstimateTemplateCost(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ExecuteChangeSet() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ExecuteChangeSetInput{ - ChangeSetName: aws.String("ChangeSetNameOrId"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - StackName: aws.String("StackNameOrId"), - } - resp, err := svc.ExecuteChangeSet(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_GetStackPolicy() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.GetStackPolicyInput{ - StackName: aws.String("StackName"), // Required - } - resp, err := svc.GetStackPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_GetTemplate() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.GetTemplateInput{ - ChangeSetName: aws.String("ChangeSetNameOrId"), - StackName: aws.String("StackName"), - TemplateStage: aws.String("TemplateStage"), - } - resp, err := svc.GetTemplate(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_GetTemplateSummary() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.GetTemplateSummaryInput{ - StackName: aws.String("StackNameOrId"), - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - } - resp, err := svc.GetTemplateSummary(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ListChangeSets() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ListChangeSetsInput{ - StackName: aws.String("StackNameOrId"), // Required - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListChangeSets(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ListExports() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ListExportsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListExports(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ListImports() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ListImportsInput{ - ExportName: aws.String("ExportName"), // Required - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListImports(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ListStackResources() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ListStackResourcesInput{ - StackName: aws.String("StackName"), // Required - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListStackResources(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ListStacks() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ListStacksInput{ - NextToken: aws.String("NextToken"), - StackStatusFilter: []*string{ - aws.String("StackStatus"), // Required - // More values... - }, - } - resp, err := svc.ListStacks(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_SetStackPolicy() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.SetStackPolicyInput{ - StackName: aws.String("StackName"), // Required - StackPolicyBody: aws.String("StackPolicyBody"), - StackPolicyURL: aws.String("StackPolicyURL"), - } - resp, err := svc.SetStackPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_SignalResource() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.SignalResourceInput{ - LogicalResourceId: aws.String("LogicalResourceId"), // Required - StackName: aws.String("StackNameOrId"), // Required - Status: aws.String("ResourceSignalStatus"), // Required - UniqueId: aws.String("ResourceSignalUniqueId"), // Required - } - resp, err := svc.SignalResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_UpdateStack() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.UpdateStackInput{ - StackName: aws.String("StackName"), // Required - Capabilities: []*string{ - aws.String("Capability"), // Required - // More values... - }, - ClientRequestToken: aws.String("ClientRequestToken"), - NotificationARNs: []*string{ - aws.String("NotificationARN"), // Required - // More values... - }, - Parameters: []*cloudformation.Parameter{ - { // Required - ParameterKey: aws.String("ParameterKey"), - ParameterValue: aws.String("ParameterValue"), - UsePreviousValue: aws.Bool(true), - }, - // More values... - }, - ResourceTypes: []*string{ - aws.String("ResourceType"), // Required - // More values... - }, - RoleARN: aws.String("RoleARN"), - StackPolicyBody: aws.String("StackPolicyBody"), - StackPolicyDuringUpdateBody: aws.String("StackPolicyDuringUpdateBody"), - StackPolicyDuringUpdateURL: aws.String("StackPolicyDuringUpdateURL"), - StackPolicyURL: aws.String("StackPolicyURL"), - Tags: []*cloudformation.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - UsePreviousTemplate: aws.Bool(true), - } - resp, err := svc.UpdateStack(params) - - if err != nil { - // 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) -} - -func ExampleCloudFormation_ValidateTemplate() { - sess := session.Must(session.NewSession()) - - svc := cloudformation.New(sess) - - params := &cloudformation.ValidateTemplateInput{ - TemplateBody: aws.String("TemplateBody"), - TemplateURL: aws.String("TemplateURL"), - } - resp, err := svc.ValidateTemplate(params) - - if err != nil { - // 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) -} diff --git a/service/cloudfront/examples_test.go b/service/cloudfront/examples_test.go index 4902d8573c9..9d2c910cb36 100644 --- a/service/cloudfront/examples_test.go +++ b/service/cloudfront/examples_test.go @@ -8,1435 +8,1075 @@ import ( "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/cloudfront" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleCloudFront_CreateCloudFrontOriginAccessIdentity() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateCloudFrontOriginAccessIdentityInput{ - CloudFrontOriginAccessIdentityConfig: &cloudfront.OriginAccessIdentityConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - }, - } - resp, err := svc.CreateCloudFrontOriginAccessIdentity(params) - +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()) - return + panic(err) } - - // Pretty-print the response data. - fmt.Println(resp) + return &t } -func ExampleCloudFront_CreateDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateDistributionInput{ - DistributionConfig: &cloudfront.DistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - Enabled: aws.Bool(true), // Required - Origins: &cloudfront.Origins{ // Required - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.Origin{ - { // Required - DomainName: aws.String("string"), // Required - Id: aws.String("string"), // Required - CustomHeaders: &cloudfront.CustomHeaders{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.OriginCustomHeader{ - { // Required - HeaderName: aws.String("string"), // Required - HeaderValue: aws.String("string"), // Required - }, - // More values... - }, - }, - CustomOriginConfig: &cloudfront.CustomOriginConfig{ - HTTPPort: aws.Int64(1), // Required - HTTPSPort: aws.Int64(1), // Required - OriginProtocolPolicy: aws.String("OriginProtocolPolicy"), // Required - OriginKeepaliveTimeout: aws.Int64(1), - OriginReadTimeout: aws.Int64(1), - OriginSslProtocols: &cloudfront.OriginSslProtocols{ - Items: []*string{ // Required - aws.String("SslProtocol"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - OriginPath: aws.String("string"), - S3OriginConfig: &cloudfront.S3OriginConfig{ - OriginAccessIdentity: aws.String("string"), // Required - }, - }, - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - CacheBehaviors: &cloudfront.CacheBehaviors{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CacheBehavior{ - { // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - PathPattern: aws.String("string"), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - // More values... - }, - }, - CustomErrorResponses: &cloudfront.CustomErrorResponses{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CustomErrorResponse{ - { // Required - ErrorCode: aws.Int64(1), // Required - ErrorCachingMinTTL: aws.Int64(1), - ResponseCode: aws.String("string"), - ResponsePagePath: aws.String("string"), - }, - // More values... - }, - }, - DefaultRootObject: aws.String("string"), - HttpVersion: aws.String("HttpVersion"), - IsIPV6Enabled: aws.Bool(true), - Logging: &cloudfront.LoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - IncludeCookies: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - Restrictions: &cloudfront.Restrictions{ - GeoRestriction: &cloudfront.GeoRestriction{ // Required - Quantity: aws.Int64(1), // Required - RestrictionType: aws.String("GeoRestrictionType"), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - ViewerCertificate: &cloudfront.ViewerCertificate{ - ACMCertificateArn: aws.String("string"), - Certificate: aws.String("string"), - CertificateSource: aws.String("CertificateSource"), - CloudFrontDefaultCertificate: aws.Bool(true), - IAMCertificateId: aws.String("string"), - MinimumProtocolVersion: aws.String("MinimumProtocolVersion"), - SSLSupportMethod: aws.String("SSLSupportMethod"), - }, - WebACLId: aws.String("string"), - }, - } - resp, err := svc.CreateDistribution(params) +// + +func ExampleCloudFront_CreateCloudFrontOriginAccessIdentity_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.CreateCloudFrontOriginAccessIdentityInput{} + result, err := svc.CreateCloudFrontOriginAccessIdentity(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 cloudfront.ErrCodeOriginAccessIdentityAlreadyExists: + fmt.Println(cloudfront.ErrCodeOriginAccessIdentityAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeTooManyCloudFrontOriginAccessIdentities: + fmt.Println(cloudfront.ErrCodeTooManyCloudFrontOriginAccessIdentities, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, 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 ExampleCloudFront_CreateDistributionWithTags() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateDistributionWithTagsInput{ - DistributionConfigWithTags: &cloudfront.DistributionConfigWithTags{ // Required - DistributionConfig: &cloudfront.DistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - Enabled: aws.Bool(true), // Required - Origins: &cloudfront.Origins{ // Required - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.Origin{ - { // Required - DomainName: aws.String("string"), // Required - Id: aws.String("string"), // Required - CustomHeaders: &cloudfront.CustomHeaders{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.OriginCustomHeader{ - { // Required - HeaderName: aws.String("string"), // Required - HeaderValue: aws.String("string"), // Required - }, - // More values... - }, - }, - CustomOriginConfig: &cloudfront.CustomOriginConfig{ - HTTPPort: aws.Int64(1), // Required - HTTPSPort: aws.Int64(1), // Required - OriginProtocolPolicy: aws.String("OriginProtocolPolicy"), // Required - OriginKeepaliveTimeout: aws.Int64(1), - OriginReadTimeout: aws.Int64(1), - OriginSslProtocols: &cloudfront.OriginSslProtocols{ - Items: []*string{ // Required - aws.String("SslProtocol"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - OriginPath: aws.String("string"), - S3OriginConfig: &cloudfront.S3OriginConfig{ - OriginAccessIdentity: aws.String("string"), // Required - }, - }, - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - CacheBehaviors: &cloudfront.CacheBehaviors{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CacheBehavior{ - { // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - PathPattern: aws.String("string"), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - // More values... - }, - }, - CustomErrorResponses: &cloudfront.CustomErrorResponses{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CustomErrorResponse{ - { // Required - ErrorCode: aws.Int64(1), // Required - ErrorCachingMinTTL: aws.Int64(1), - ResponseCode: aws.String("string"), - ResponsePagePath: aws.String("string"), - }, - // More values... - }, - }, - DefaultRootObject: aws.String("string"), - HttpVersion: aws.String("HttpVersion"), - IsIPV6Enabled: aws.Bool(true), - Logging: &cloudfront.LoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - IncludeCookies: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - Restrictions: &cloudfront.Restrictions{ - GeoRestriction: &cloudfront.GeoRestriction{ // Required - Quantity: aws.Int64(1), // Required - RestrictionType: aws.String("GeoRestrictionType"), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - ViewerCertificate: &cloudfront.ViewerCertificate{ - ACMCertificateArn: aws.String("string"), - Certificate: aws.String("string"), - CertificateSource: aws.String("CertificateSource"), - CloudFrontDefaultCertificate: aws.Bool(true), - IAMCertificateId: aws.String("string"), - MinimumProtocolVersion: aws.String("MinimumProtocolVersion"), - SSLSupportMethod: aws.String("SSLSupportMethod"), - }, - WebACLId: aws.String("string"), - }, - Tags: &cloudfront.Tags{ // Required - Items: []*cloudfront.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - }, - }, - } - resp, err := svc.CreateDistributionWithTags(params) +// + +func ExampleCloudFront_CreateDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.CreateDistributionInput{} + result, err := svc.CreateDistribution(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 cloudfront.ErrCodeCNAMEAlreadyExists: + fmt.Println(cloudfront.ErrCodeCNAMEAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeDistributionAlreadyExists: + fmt.Println(cloudfront.ErrCodeDistributionAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeInvalidOrigin: + fmt.Println(cloudfront.ErrCodeInvalidOrigin, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeInvalidOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeTooManyTrustedSigners: + fmt.Println(cloudfront.ErrCodeTooManyTrustedSigners, aerr.Error()) + case cloudfront.ErrCodeTrustedSignerDoesNotExist: + fmt.Println(cloudfront.ErrCodeTrustedSignerDoesNotExist, aerr.Error()) + case cloudfront.ErrCodeInvalidViewerCertificate: + fmt.Println(cloudfront.ErrCodeInvalidViewerCertificate, aerr.Error()) + case cloudfront.ErrCodeInvalidMinimumProtocolVersion: + fmt.Println(cloudfront.ErrCodeInvalidMinimumProtocolVersion, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionCNAMEs: + fmt.Println(cloudfront.ErrCodeTooManyDistributionCNAMEs, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributions: + fmt.Println(cloudfront.ErrCodeTooManyDistributions, aerr.Error()) + case cloudfront.ErrCodeInvalidDefaultRootObject: + fmt.Println(cloudfront.ErrCodeInvalidDefaultRootObject, aerr.Error()) + case cloudfront.ErrCodeInvalidRelativePath: + fmt.Println(cloudfront.ErrCodeInvalidRelativePath, aerr.Error()) + case cloudfront.ErrCodeInvalidErrorCode: + fmt.Println(cloudfront.ErrCodeInvalidErrorCode, aerr.Error()) + case cloudfront.ErrCodeInvalidResponseCode: + fmt.Println(cloudfront.ErrCodeInvalidResponseCode, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidRequiredProtocol: + fmt.Println(cloudfront.ErrCodeInvalidRequiredProtocol, aerr.Error()) + case cloudfront.ErrCodeNoSuchOrigin: + fmt.Println(cloudfront.ErrCodeNoSuchOrigin, aerr.Error()) + case cloudfront.ErrCodeTooManyOrigins: + fmt.Println(cloudfront.ErrCodeTooManyOrigins, aerr.Error()) + case cloudfront.ErrCodeTooManyCacheBehaviors: + fmt.Println(cloudfront.ErrCodeTooManyCacheBehaviors, aerr.Error()) + case cloudfront.ErrCodeTooManyCookieNamesInWhiteList: + fmt.Println(cloudfront.ErrCodeTooManyCookieNamesInWhiteList, aerr.Error()) + case cloudfront.ErrCodeInvalidForwardCookies: + fmt.Println(cloudfront.ErrCodeInvalidForwardCookies, aerr.Error()) + case cloudfront.ErrCodeTooManyHeadersInForwardedValues: + fmt.Println(cloudfront.ErrCodeTooManyHeadersInForwardedValues, aerr.Error()) + case cloudfront.ErrCodeInvalidHeadersForS3Origin: + fmt.Println(cloudfront.ErrCodeInvalidHeadersForS3Origin, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, aerr.Error()) + case cloudfront.ErrCodeTooManyCertificates: + fmt.Println(cloudfront.ErrCodeTooManyCertificates, aerr.Error()) + case cloudfront.ErrCodeInvalidLocationCode: + fmt.Println(cloudfront.ErrCodeInvalidLocationCode, aerr.Error()) + case cloudfront.ErrCodeInvalidGeoRestrictionParameter: + fmt.Println(cloudfront.ErrCodeInvalidGeoRestrictionParameter, aerr.Error()) + case cloudfront.ErrCodeInvalidProtocolSettings: + fmt.Println(cloudfront.ErrCodeInvalidProtocolSettings, aerr.Error()) + case cloudfront.ErrCodeInvalidTTLOrder: + fmt.Println(cloudfront.ErrCodeInvalidTTLOrder, aerr.Error()) + case cloudfront.ErrCodeInvalidWebACLId: + fmt.Println(cloudfront.ErrCodeInvalidWebACLId, aerr.Error()) + case cloudfront.ErrCodeTooManyOriginCustomHeaders: + fmt.Println(cloudfront.ErrCodeTooManyOriginCustomHeaders, aerr.Error()) + case cloudfront.ErrCodeTooManyQueryStringParameters: + fmt.Println(cloudfront.ErrCodeTooManyQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeInvalidQueryStringParameters: + fmt.Println(cloudfront.ErrCodeInvalidQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations: + fmt.Println(cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations, aerr.Error()) + case cloudfront.ErrCodeTooManyLambdaFunctionAssociations: + fmt.Println(cloudfront.ErrCodeTooManyLambdaFunctionAssociations, aerr.Error()) + case cloudfront.ErrCodeInvalidLambdaFunctionAssociation: + fmt.Println(cloudfront.ErrCodeInvalidLambdaFunctionAssociation, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginReadTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginReadTimeout, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginKeepaliveTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginKeepaliveTimeout, 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 ExampleCloudFront_CreateInvalidation() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateInvalidationInput{ - DistributionId: aws.String("string"), // Required - InvalidationBatch: &cloudfront.InvalidationBatch{ // Required - CallerReference: aws.String("string"), // Required - Paths: &cloudfront.Paths{ // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - } - resp, err := svc.CreateInvalidation(params) +// + +func ExampleCloudFront_CreateDistributionWithTags_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.CreateDistributionWithTagsInput{} + result, err := svc.CreateDistributionWithTags(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 cloudfront.ErrCodeCNAMEAlreadyExists: + fmt.Println(cloudfront.ErrCodeCNAMEAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeDistributionAlreadyExists: + fmt.Println(cloudfront.ErrCodeDistributionAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeInvalidOrigin: + fmt.Println(cloudfront.ErrCodeInvalidOrigin, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeInvalidOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeTooManyTrustedSigners: + fmt.Println(cloudfront.ErrCodeTooManyTrustedSigners, aerr.Error()) + case cloudfront.ErrCodeTrustedSignerDoesNotExist: + fmt.Println(cloudfront.ErrCodeTrustedSignerDoesNotExist, aerr.Error()) + case cloudfront.ErrCodeInvalidViewerCertificate: + fmt.Println(cloudfront.ErrCodeInvalidViewerCertificate, aerr.Error()) + case cloudfront.ErrCodeInvalidMinimumProtocolVersion: + fmt.Println(cloudfront.ErrCodeInvalidMinimumProtocolVersion, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionCNAMEs: + fmt.Println(cloudfront.ErrCodeTooManyDistributionCNAMEs, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributions: + fmt.Println(cloudfront.ErrCodeTooManyDistributions, aerr.Error()) + case cloudfront.ErrCodeInvalidDefaultRootObject: + fmt.Println(cloudfront.ErrCodeInvalidDefaultRootObject, aerr.Error()) + case cloudfront.ErrCodeInvalidRelativePath: + fmt.Println(cloudfront.ErrCodeInvalidRelativePath, aerr.Error()) + case cloudfront.ErrCodeInvalidErrorCode: + fmt.Println(cloudfront.ErrCodeInvalidErrorCode, aerr.Error()) + case cloudfront.ErrCodeInvalidResponseCode: + fmt.Println(cloudfront.ErrCodeInvalidResponseCode, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidRequiredProtocol: + fmt.Println(cloudfront.ErrCodeInvalidRequiredProtocol, aerr.Error()) + case cloudfront.ErrCodeNoSuchOrigin: + fmt.Println(cloudfront.ErrCodeNoSuchOrigin, aerr.Error()) + case cloudfront.ErrCodeTooManyOrigins: + fmt.Println(cloudfront.ErrCodeTooManyOrigins, aerr.Error()) + case cloudfront.ErrCodeTooManyCacheBehaviors: + fmt.Println(cloudfront.ErrCodeTooManyCacheBehaviors, aerr.Error()) + case cloudfront.ErrCodeTooManyCookieNamesInWhiteList: + fmt.Println(cloudfront.ErrCodeTooManyCookieNamesInWhiteList, aerr.Error()) + case cloudfront.ErrCodeInvalidForwardCookies: + fmt.Println(cloudfront.ErrCodeInvalidForwardCookies, aerr.Error()) + case cloudfront.ErrCodeTooManyHeadersInForwardedValues: + fmt.Println(cloudfront.ErrCodeTooManyHeadersInForwardedValues, aerr.Error()) + case cloudfront.ErrCodeInvalidHeadersForS3Origin: + fmt.Println(cloudfront.ErrCodeInvalidHeadersForS3Origin, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, aerr.Error()) + case cloudfront.ErrCodeTooManyCertificates: + fmt.Println(cloudfront.ErrCodeTooManyCertificates, aerr.Error()) + case cloudfront.ErrCodeInvalidLocationCode: + fmt.Println(cloudfront.ErrCodeInvalidLocationCode, aerr.Error()) + case cloudfront.ErrCodeInvalidGeoRestrictionParameter: + fmt.Println(cloudfront.ErrCodeInvalidGeoRestrictionParameter, aerr.Error()) + case cloudfront.ErrCodeInvalidProtocolSettings: + fmt.Println(cloudfront.ErrCodeInvalidProtocolSettings, aerr.Error()) + case cloudfront.ErrCodeInvalidTTLOrder: + fmt.Println(cloudfront.ErrCodeInvalidTTLOrder, aerr.Error()) + case cloudfront.ErrCodeInvalidWebACLId: + fmt.Println(cloudfront.ErrCodeInvalidWebACLId, aerr.Error()) + case cloudfront.ErrCodeTooManyOriginCustomHeaders: + fmt.Println(cloudfront.ErrCodeTooManyOriginCustomHeaders, aerr.Error()) + case cloudfront.ErrCodeInvalidTagging: + fmt.Println(cloudfront.ErrCodeInvalidTagging, aerr.Error()) + case cloudfront.ErrCodeTooManyQueryStringParameters: + fmt.Println(cloudfront.ErrCodeTooManyQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeInvalidQueryStringParameters: + fmt.Println(cloudfront.ErrCodeInvalidQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations: + fmt.Println(cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations, aerr.Error()) + case cloudfront.ErrCodeTooManyLambdaFunctionAssociations: + fmt.Println(cloudfront.ErrCodeTooManyLambdaFunctionAssociations, aerr.Error()) + case cloudfront.ErrCodeInvalidLambdaFunctionAssociation: + fmt.Println(cloudfront.ErrCodeInvalidLambdaFunctionAssociation, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginReadTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginReadTimeout, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginKeepaliveTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginKeepaliveTimeout, 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 ExampleCloudFront_CreateStreamingDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateStreamingDistributionInput{ - StreamingDistributionConfig: &cloudfront.StreamingDistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - S3Origin: &cloudfront.S3Origin{ // Required - DomainName: aws.String("string"), // Required - OriginAccessIdentity: aws.String("string"), // Required - }, - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Logging: &cloudfront.StreamingLoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - }, - } - resp, err := svc.CreateStreamingDistribution(params) +// + +func ExampleCloudFront_CreateInvalidation_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.CreateInvalidationInput{} + result, err := svc.CreateInvalidation(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodeBatchTooLarge: + fmt.Println(cloudfront.ErrCodeBatchTooLarge, aerr.Error()) + case cloudfront.ErrCodeTooManyInvalidationsInProgress: + fmt.Println(cloudfront.ErrCodeTooManyInvalidationsInProgress, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, 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 ExampleCloudFront_CreateStreamingDistributionWithTags() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.CreateStreamingDistributionWithTagsInput{ - StreamingDistributionConfigWithTags: &cloudfront.StreamingDistributionConfigWithTags{ // Required - StreamingDistributionConfig: &cloudfront.StreamingDistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - S3Origin: &cloudfront.S3Origin{ // Required - DomainName: aws.String("string"), // Required - OriginAccessIdentity: aws.String("string"), // Required - }, - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Logging: &cloudfront.StreamingLoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - }, - Tags: &cloudfront.Tags{ // Required - Items: []*cloudfront.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - }, - }, - } - resp, err := svc.CreateStreamingDistributionWithTags(params) +// +func ExampleCloudFront_CreateStreamingDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.CreateStreamingDistributionInput{} + + result, err := svc.CreateStreamingDistribution(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 cloudfront.ErrCodeCNAMEAlreadyExists: + fmt.Println(cloudfront.ErrCodeCNAMEAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeStreamingDistributionAlreadyExists: + fmt.Println(cloudfront.ErrCodeStreamingDistributionAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeInvalidOrigin: + fmt.Println(cloudfront.ErrCodeInvalidOrigin, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeInvalidOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeTooManyTrustedSigners: + fmt.Println(cloudfront.ErrCodeTooManyTrustedSigners, aerr.Error()) + case cloudfront.ErrCodeTrustedSignerDoesNotExist: + fmt.Println(cloudfront.ErrCodeTrustedSignerDoesNotExist, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeTooManyStreamingDistributionCNAMEs: + fmt.Println(cloudfront.ErrCodeTooManyStreamingDistributionCNAMEs, aerr.Error()) + case cloudfront.ErrCodeTooManyStreamingDistributions: + fmt.Println(cloudfront.ErrCodeTooManyStreamingDistributions, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, 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 ExampleCloudFront_DeleteCloudFrontOriginAccessIdentity() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.DeleteCloudFrontOriginAccessIdentityInput{ - Id: aws.String("string"), // Required - IfMatch: aws.String("string"), - } - resp, err := svc.DeleteCloudFrontOriginAccessIdentity(params) +func ExampleCloudFront_DeleteCloudFrontOriginAccessIdentity_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.DeleteCloudFrontOriginAccessIdentityInput{} + result, err := svc.DeleteCloudFrontOriginAccessIdentity(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, aerr.Error()) + case cloudfront.ErrCodeOriginAccessIdentityInUse: + fmt.Println(cloudfront.ErrCodeOriginAccessIdentityInUse, 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 ExampleCloudFront_DeleteDistribution() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.DeleteDistributionInput{ - Id: aws.String("string"), // Required - IfMatch: aws.String("string"), - } - resp, err := svc.DeleteDistribution(params) +func ExampleCloudFront_DeleteDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.DeleteDistributionInput{} + result, err := svc.DeleteDistribution(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeDistributionNotDisabled: + fmt.Println(cloudfront.ErrCodeDistributionNotDisabled, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, 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 ExampleCloudFront_DeleteStreamingDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.DeleteStreamingDistributionInput{ - Id: aws.String("string"), // Required - IfMatch: aws.String("string"), - } - resp, err := svc.DeleteStreamingDistribution(params) +func ExampleCloudFront_DeleteStreamingDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.DeleteStreamingDistributionInput{} + result, err := svc.DeleteStreamingDistribution(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeStreamingDistributionNotDisabled: + fmt.Println(cloudfront.ErrCodeStreamingDistributionNotDisabled, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeNoSuchStreamingDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchStreamingDistribution, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, 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 ExampleCloudFront_GetCloudFrontOriginAccessIdentity() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.GetCloudFrontOriginAccessIdentityInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetCloudFrontOriginAccessIdentity(params) +func ExampleCloudFront_GetCloudFrontOriginAccessIdentity_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetCloudFrontOriginAccessIdentityInput{} + result, err := svc.GetCloudFrontOriginAccessIdentity(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 cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetCloudFrontOriginAccessIdentityConfig() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.GetCloudFrontOriginAccessIdentityConfigInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetCloudFrontOriginAccessIdentityConfig(params) +func ExampleCloudFront_GetCloudFrontOriginAccessIdentityConfig_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetCloudFrontOriginAccessIdentityConfigInput{} + result, err := svc.GetCloudFrontOriginAccessIdentityConfig(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 cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetDistribution() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.GetDistributionInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetDistribution(params) +func ExampleCloudFront_GetDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetDistributionInput{} + result, err := svc.GetDistribution(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 cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetDistributionConfig() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.GetDistributionConfigInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetDistributionConfig(params) +func ExampleCloudFront_GetDistributionConfig_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetDistributionConfigInput{} + result, err := svc.GetDistributionConfig(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 cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetInvalidation() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.GetInvalidationInput{ - DistributionId: aws.String("string"), // Required - Id: aws.String("string"), // Required - } - resp, err := svc.GetInvalidation(params) +func ExampleCloudFront_GetInvalidation_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetInvalidationInput{} + result, err := svc.GetInvalidation(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 cloudfront.ErrCodeNoSuchInvalidation: + fmt.Println(cloudfront.ErrCodeNoSuchInvalidation, aerr.Error()) + case cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetStreamingDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.GetStreamingDistributionInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetStreamingDistribution(params) +func ExampleCloudFront_GetStreamingDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetStreamingDistributionInput{} + result, err := svc.GetStreamingDistribution(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 cloudfront.ErrCodeNoSuchStreamingDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchStreamingDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_GetStreamingDistributionConfig() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.GetStreamingDistributionConfigInput{ - Id: aws.String("string"), // Required - } - resp, err := svc.GetStreamingDistributionConfig(params) +func ExampleCloudFront_GetStreamingDistributionConfig_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.GetStreamingDistributionConfigInput{} + result, err := svc.GetStreamingDistributionConfig(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 cloudfront.ErrCodeNoSuchStreamingDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchStreamingDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_ListCloudFrontOriginAccessIdentities() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.ListCloudFrontOriginAccessIdentitiesInput{ - Marker: aws.String("string"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListCloudFrontOriginAccessIdentities(params) +func ExampleCloudFront_ListCloudFrontOriginAccessIdentities_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListCloudFrontOriginAccessIdentitiesInput{} + result, err := svc.ListCloudFrontOriginAccessIdentities(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 cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, 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 ExampleCloudFront_ListDistributions() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.ListDistributionsInput{ - Marker: aws.String("string"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListDistributions(params) +func ExampleCloudFront_ListDistributions_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListDistributionsInput{} + result, err := svc.ListDistributions(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 cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, 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 ExampleCloudFront_ListDistributionsByWebACLId() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.ListDistributionsByWebACLIdInput{ - WebACLId: aws.String("string"), // Required - Marker: aws.String("string"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListDistributionsByWebACLId(params) +func ExampleCloudFront_ListDistributionsByWebACLId_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListDistributionsByWebACLIdInput{} + result, err := svc.ListDistributionsByWebACLId(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 cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidWebACLId: + fmt.Println(cloudfront.ErrCodeInvalidWebACLId, 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 ExampleCloudFront_ListInvalidations() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.ListInvalidationsInput{ - DistributionId: aws.String("string"), // Required - Marker: aws.String("string"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListInvalidations(params) +func ExampleCloudFront_ListInvalidations_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListInvalidationsInput{} + result, err := svc.ListInvalidations(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 cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, 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 ExampleCloudFront_ListStreamingDistributions() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.ListStreamingDistributionsInput{ - Marker: aws.String("string"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListStreamingDistributions(params) +func ExampleCloudFront_ListStreamingDistributions_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListStreamingDistributionsInput{} + result, err := svc.ListStreamingDistributions(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 cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, 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 ExampleCloudFront_ListTagsForResource() { - sess := session.Must(session.NewSession()) +// - svc := cloudfront.New(sess) - - params := &cloudfront.ListTagsForResourceInput{ - Resource: aws.String("ResourceARN"), // Required - } - resp, err := svc.ListTagsForResource(params) +func ExampleCloudFront_ListTagsForResource_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.ListTagsForResourceInput{} + result, err := svc.ListTagsForResource(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidTagging: + fmt.Println(cloudfront.ErrCodeInvalidTagging, aerr.Error()) + case cloudfront.ErrCodeNoSuchResource: + fmt.Println(cloudfront.ErrCodeNoSuchResource, 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 ExampleCloudFront_TagResource() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.TagResourceInput{ - Resource: aws.String("ResourceARN"), // Required - Tags: &cloudfront.Tags{ // Required - Items: []*cloudfront.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - }, - } - resp, err := svc.TagResource(params) +// + +func ExampleCloudFront_TagResource_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.TagResourceInput{} + result, err := svc.TagResource(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidTagging: + fmt.Println(cloudfront.ErrCodeInvalidTagging, aerr.Error()) + case cloudfront.ErrCodeNoSuchResource: + fmt.Println(cloudfront.ErrCodeNoSuchResource, 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 ExampleCloudFront_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.UntagResourceInput{ - Resource: aws.String("ResourceARN"), // Required - TagKeys: &cloudfront.TagKeys{ // Required - Items: []*string{ - aws.String("TagKey"), // Required - // More values... - }, - }, - } - resp, err := svc.UntagResource(params) +func ExampleCloudFront_UntagResource_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.UntagResourceInput{} + result, err := svc.UntagResource(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidTagging: + fmt.Println(cloudfront.ErrCodeInvalidTagging, aerr.Error()) + case cloudfront.ErrCodeNoSuchResource: + fmt.Println(cloudfront.ErrCodeNoSuchResource, 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 ExampleCloudFront_UpdateCloudFrontOriginAccessIdentity() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) +// - params := &cloudfront.UpdateCloudFrontOriginAccessIdentityInput{ - CloudFrontOriginAccessIdentityConfig: &cloudfront.OriginAccessIdentityConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - }, - Id: aws.String("string"), // Required - IfMatch: aws.String("string"), - } - resp, err := svc.UpdateCloudFrontOriginAccessIdentity(params) +func ExampleCloudFront_UpdateCloudFrontOriginAccessIdentity_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.UpdateCloudFrontOriginAccessIdentityInput{} + result, err := svc.UpdateCloudFrontOriginAccessIdentity(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeIllegalUpdate: + fmt.Println(cloudfront.ErrCodeIllegalUpdate, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeNoSuchCloudFrontOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, 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 ExampleCloudFront_UpdateDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.UpdateDistributionInput{ - DistributionConfig: &cloudfront.DistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - Enabled: aws.Bool(true), // Required - Origins: &cloudfront.Origins{ // Required - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.Origin{ - { // Required - DomainName: aws.String("string"), // Required - Id: aws.String("string"), // Required - CustomHeaders: &cloudfront.CustomHeaders{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.OriginCustomHeader{ - { // Required - HeaderName: aws.String("string"), // Required - HeaderValue: aws.String("string"), // Required - }, - // More values... - }, - }, - CustomOriginConfig: &cloudfront.CustomOriginConfig{ - HTTPPort: aws.Int64(1), // Required - HTTPSPort: aws.Int64(1), // Required - OriginProtocolPolicy: aws.String("OriginProtocolPolicy"), // Required - OriginKeepaliveTimeout: aws.Int64(1), - OriginReadTimeout: aws.Int64(1), - OriginSslProtocols: &cloudfront.OriginSslProtocols{ - Items: []*string{ // Required - aws.String("SslProtocol"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - OriginPath: aws.String("string"), - S3OriginConfig: &cloudfront.S3OriginConfig{ - OriginAccessIdentity: aws.String("string"), // Required - }, - }, - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - CacheBehaviors: &cloudfront.CacheBehaviors{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CacheBehavior{ - { // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: aws.String("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - QueryStringCacheKeys: &cloudfront.QueryStringCacheKeys{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - MinTTL: aws.Int64(1), // Required - PathPattern: aws.String("string"), // Required - TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []*string{ // Required - aws.String("Method"), // Required - // More values... - }, - Quantity: aws.Int64(1), // Required - }, - }, - Compress: aws.Bool(true), - DefaultTTL: aws.Int64(1), - LambdaFunctionAssociations: &cloudfront.LambdaFunctionAssociations{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.LambdaFunctionAssociation{ - { // Required - EventType: aws.String("EventType"), - LambdaFunctionARN: aws.String("string"), - }, - // More values... - }, - }, - MaxTTL: aws.Int64(1), - SmoothStreaming: aws.Bool(true), - }, - // More values... - }, - }, - CustomErrorResponses: &cloudfront.CustomErrorResponses{ - Quantity: aws.Int64(1), // Required - Items: []*cloudfront.CustomErrorResponse{ - { // Required - ErrorCode: aws.Int64(1), // Required - ErrorCachingMinTTL: aws.Int64(1), - ResponseCode: aws.String("string"), - ResponsePagePath: aws.String("string"), - }, - // More values... - }, - }, - DefaultRootObject: aws.String("string"), - HttpVersion: aws.String("HttpVersion"), - IsIPV6Enabled: aws.Bool(true), - Logging: &cloudfront.LoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - IncludeCookies: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - Restrictions: &cloudfront.Restrictions{ - GeoRestriction: &cloudfront.GeoRestriction{ // Required - Quantity: aws.Int64(1), // Required - RestrictionType: aws.String("GeoRestrictionType"), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - ViewerCertificate: &cloudfront.ViewerCertificate{ - ACMCertificateArn: aws.String("string"), - Certificate: aws.String("string"), - CertificateSource: aws.String("CertificateSource"), - CloudFrontDefaultCertificate: aws.Bool(true), - IAMCertificateId: aws.String("string"), - MinimumProtocolVersion: aws.String("MinimumProtocolVersion"), - SSLSupportMethod: aws.String("SSLSupportMethod"), - }, - WebACLId: aws.String("string"), - }, - Id: aws.String("string"), // Required - IfMatch: aws.String("string"), - } - resp, err := svc.UpdateDistribution(params) +// +func ExampleCloudFront_UpdateDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.UpdateDistributionInput{} + + result, err := svc.UpdateDistribution(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeCNAMEAlreadyExists: + fmt.Println(cloudfront.ErrCodeCNAMEAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeIllegalUpdate: + fmt.Println(cloudfront.ErrCodeIllegalUpdate, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeNoSuchDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchDistribution, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionCNAMEs: + fmt.Println(cloudfront.ErrCodeTooManyDistributionCNAMEs, aerr.Error()) + case cloudfront.ErrCodeInvalidDefaultRootObject: + fmt.Println(cloudfront.ErrCodeInvalidDefaultRootObject, aerr.Error()) + case cloudfront.ErrCodeInvalidRelativePath: + fmt.Println(cloudfront.ErrCodeInvalidRelativePath, aerr.Error()) + case cloudfront.ErrCodeInvalidErrorCode: + fmt.Println(cloudfront.ErrCodeInvalidErrorCode, aerr.Error()) + case cloudfront.ErrCodeInvalidResponseCode: + fmt.Println(cloudfront.ErrCodeInvalidResponseCode, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeInvalidOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeTooManyTrustedSigners: + fmt.Println(cloudfront.ErrCodeTooManyTrustedSigners, aerr.Error()) + case cloudfront.ErrCodeTrustedSignerDoesNotExist: + fmt.Println(cloudfront.ErrCodeTrustedSignerDoesNotExist, aerr.Error()) + case cloudfront.ErrCodeInvalidViewerCertificate: + fmt.Println(cloudfront.ErrCodeInvalidViewerCertificate, aerr.Error()) + case cloudfront.ErrCodeInvalidMinimumProtocolVersion: + fmt.Println(cloudfront.ErrCodeInvalidMinimumProtocolVersion, aerr.Error()) + case cloudfront.ErrCodeInvalidRequiredProtocol: + fmt.Println(cloudfront.ErrCodeInvalidRequiredProtocol, aerr.Error()) + case cloudfront.ErrCodeNoSuchOrigin: + fmt.Println(cloudfront.ErrCodeNoSuchOrigin, aerr.Error()) + case cloudfront.ErrCodeTooManyOrigins: + fmt.Println(cloudfront.ErrCodeTooManyOrigins, aerr.Error()) + case cloudfront.ErrCodeTooManyCacheBehaviors: + fmt.Println(cloudfront.ErrCodeTooManyCacheBehaviors, aerr.Error()) + case cloudfront.ErrCodeTooManyCookieNamesInWhiteList: + fmt.Println(cloudfront.ErrCodeTooManyCookieNamesInWhiteList, aerr.Error()) + case cloudfront.ErrCodeInvalidForwardCookies: + fmt.Println(cloudfront.ErrCodeInvalidForwardCookies, aerr.Error()) + case cloudfront.ErrCodeTooManyHeadersInForwardedValues: + fmt.Println(cloudfront.ErrCodeTooManyHeadersInForwardedValues, aerr.Error()) + case cloudfront.ErrCodeInvalidHeadersForS3Origin: + fmt.Println(cloudfront.ErrCodeInvalidHeadersForS3Origin, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, aerr.Error()) + case cloudfront.ErrCodeTooManyCertificates: + fmt.Println(cloudfront.ErrCodeTooManyCertificates, aerr.Error()) + case cloudfront.ErrCodeInvalidLocationCode: + fmt.Println(cloudfront.ErrCodeInvalidLocationCode, aerr.Error()) + case cloudfront.ErrCodeInvalidGeoRestrictionParameter: + fmt.Println(cloudfront.ErrCodeInvalidGeoRestrictionParameter, aerr.Error()) + case cloudfront.ErrCodeInvalidTTLOrder: + fmt.Println(cloudfront.ErrCodeInvalidTTLOrder, aerr.Error()) + case cloudfront.ErrCodeInvalidWebACLId: + fmt.Println(cloudfront.ErrCodeInvalidWebACLId, aerr.Error()) + case cloudfront.ErrCodeTooManyOriginCustomHeaders: + fmt.Println(cloudfront.ErrCodeTooManyOriginCustomHeaders, aerr.Error()) + case cloudfront.ErrCodeTooManyQueryStringParameters: + fmt.Println(cloudfront.ErrCodeTooManyQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeInvalidQueryStringParameters: + fmt.Println(cloudfront.ErrCodeInvalidQueryStringParameters, aerr.Error()) + case cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations: + fmt.Println(cloudfront.ErrCodeTooManyDistributionsWithLambdaAssociations, aerr.Error()) + case cloudfront.ErrCodeTooManyLambdaFunctionAssociations: + fmt.Println(cloudfront.ErrCodeTooManyLambdaFunctionAssociations, aerr.Error()) + case cloudfront.ErrCodeInvalidLambdaFunctionAssociation: + fmt.Println(cloudfront.ErrCodeInvalidLambdaFunctionAssociation, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginReadTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginReadTimeout, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginKeepaliveTimeout: + fmt.Println(cloudfront.ErrCodeInvalidOriginKeepaliveTimeout, 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 ExampleCloudFront_UpdateStreamingDistribution() { - sess := session.Must(session.NewSession()) - - svc := cloudfront.New(sess) - - params := &cloudfront.UpdateStreamingDistributionInput{ - Id: aws.String("string"), // Required - StreamingDistributionConfig: &cloudfront.StreamingDistributionConfig{ // Required - CallerReference: aws.String("string"), // Required - Comment: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - S3Origin: &cloudfront.S3Origin{ // Required - DomainName: aws.String("string"), // Required - OriginAccessIdentity: aws.String("string"), // Required - }, - TrustedSigners: &cloudfront.TrustedSigners{ // Required - Enabled: aws.Bool(true), // Required - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Aliases: &cloudfront.Aliases{ - Quantity: aws.Int64(1), // Required - Items: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - Logging: &cloudfront.StreamingLoggingConfig{ - Bucket: aws.String("string"), // Required - Enabled: aws.Bool(true), // Required - Prefix: aws.String("string"), // Required - }, - PriceClass: aws.String("PriceClass"), - }, - IfMatch: aws.String("string"), - } - resp, err := svc.UpdateStreamingDistribution(params) +// + +func ExampleCloudFront_UpdateStreamingDistribution_shared00() { + svc := cloudfront.New(session.New()) + input := &cloudfront.UpdateStreamingDistributionInput{} + result, err := svc.UpdateStreamingDistribution(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 cloudfront.ErrCodeAccessDenied: + fmt.Println(cloudfront.ErrCodeAccessDenied, aerr.Error()) + case cloudfront.ErrCodeCNAMEAlreadyExists: + fmt.Println(cloudfront.ErrCodeCNAMEAlreadyExists, aerr.Error()) + case cloudfront.ErrCodeIllegalUpdate: + fmt.Println(cloudfront.ErrCodeIllegalUpdate, aerr.Error()) + case cloudfront.ErrCodeInvalidIfMatchVersion: + fmt.Println(cloudfront.ErrCodeInvalidIfMatchVersion, aerr.Error()) + case cloudfront.ErrCodeMissingBody: + fmt.Println(cloudfront.ErrCodeMissingBody, aerr.Error()) + case cloudfront.ErrCodeNoSuchStreamingDistribution: + fmt.Println(cloudfront.ErrCodeNoSuchStreamingDistribution, aerr.Error()) + case cloudfront.ErrCodePreconditionFailed: + fmt.Println(cloudfront.ErrCodePreconditionFailed, aerr.Error()) + case cloudfront.ErrCodeTooManyStreamingDistributionCNAMEs: + fmt.Println(cloudfront.ErrCodeTooManyStreamingDistributionCNAMEs, aerr.Error()) + case cloudfront.ErrCodeInvalidArgument: + fmt.Println(cloudfront.ErrCodeInvalidArgument, aerr.Error()) + case cloudfront.ErrCodeInvalidOriginAccessIdentity: + fmt.Println(cloudfront.ErrCodeInvalidOriginAccessIdentity, aerr.Error()) + case cloudfront.ErrCodeTooManyTrustedSigners: + fmt.Println(cloudfront.ErrCodeTooManyTrustedSigners, aerr.Error()) + case cloudfront.ErrCodeTrustedSignerDoesNotExist: + fmt.Println(cloudfront.ErrCodeTrustedSignerDoesNotExist, aerr.Error()) + case cloudfront.ErrCodeInconsistentQuantities: + fmt.Println(cloudfront.ErrCodeInconsistentQuantities, 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) } diff --git a/service/cloudhsm/examples_test.go b/service/cloudhsm/examples_test.go deleted file mode 100644 index e19fafb4557..00000000000 --- a/service/cloudhsm/examples_test.go +++ /dev/null @@ -1,471 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudhsm_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudhsm" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudHSM_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.AddTagsToResourceInput{ - ResourceArn: aws.String("String"), // Required - TagList: []*cloudhsm.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_CreateHapg() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.CreateHapgInput{ - Label: aws.String("Label"), // Required - } - resp, err := svc.CreateHapg(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_CreateHsm() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.CreateHsmInput{ - IamRoleArn: aws.String("IamRoleArn"), // Required - SshKey: aws.String("SshKey"), // Required - SubnetId: aws.String("SubnetId"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - ClientToken: aws.String("ClientToken"), - EniIp: aws.String("IpAddress"), - ExternalId: aws.String("ExternalId"), - SyslogIp: aws.String("IpAddress"), - } - resp, err := svc.CreateHsm(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_CreateLunaClient() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.CreateLunaClientInput{ - Certificate: aws.String("Certificate"), // Required - Label: aws.String("ClientLabel"), - } - resp, err := svc.CreateLunaClient(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DeleteHapg() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DeleteHapgInput{ - HapgArn: aws.String("HapgArn"), // Required - } - resp, err := svc.DeleteHapg(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DeleteHsm() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DeleteHsmInput{ - HsmArn: aws.String("HsmArn"), // Required - } - resp, err := svc.DeleteHsm(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DeleteLunaClient() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DeleteLunaClientInput{ - ClientArn: aws.String("ClientArn"), // Required - } - resp, err := svc.DeleteLunaClient(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DescribeHapg() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DescribeHapgInput{ - HapgArn: aws.String("HapgArn"), // Required - } - resp, err := svc.DescribeHapg(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DescribeHsm() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DescribeHsmInput{ - HsmArn: aws.String("HsmArn"), - HsmSerialNumber: aws.String("HsmSerialNumber"), - } - resp, err := svc.DescribeHsm(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_DescribeLunaClient() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.DescribeLunaClientInput{ - CertificateFingerprint: aws.String("CertificateFingerprint"), - ClientArn: aws.String("ClientArn"), - } - resp, err := svc.DescribeLunaClient(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_GetConfig() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.GetConfigInput{ - ClientArn: aws.String("ClientArn"), // Required - ClientVersion: aws.String("ClientVersion"), // Required - HapgList: []*string{ // Required - aws.String("HapgArn"), // Required - // More values... - }, - } - resp, err := svc.GetConfig(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ListAvailableZones() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - var params *cloudhsm.ListAvailableZonesInput - resp, err := svc.ListAvailableZones(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ListHapgs() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ListHapgsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListHapgs(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ListHsms() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ListHsmsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListHsms(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ListLunaClients() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ListLunaClientsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListLunaClients(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ListTagsForResourceInput{ - ResourceArn: aws.String("String"), // Required - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ModifyHapg() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ModifyHapgInput{ - HapgArn: aws.String("HapgArn"), // Required - Label: aws.String("Label"), - PartitionSerialList: []*string{ - aws.String("PartitionSerial"), // Required - // More values... - }, - } - resp, err := svc.ModifyHapg(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ModifyHsm() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ModifyHsmInput{ - HsmArn: aws.String("HsmArn"), // Required - EniIp: aws.String("IpAddress"), - ExternalId: aws.String("ExternalId"), - IamRoleArn: aws.String("IamRoleArn"), - SubnetId: aws.String("SubnetId"), - SyslogIp: aws.String("IpAddress"), - } - resp, err := svc.ModifyHsm(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_ModifyLunaClient() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.ModifyLunaClientInput{ - Certificate: aws.String("Certificate"), // Required - ClientArn: aws.String("ClientArn"), // Required - } - resp, err := svc.ModifyLunaClient(params) - - if err != nil { - // 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) -} - -func ExampleCloudHSM_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := cloudhsm.New(sess) - - params := &cloudhsm.RemoveTagsFromResourceInput{ - ResourceArn: aws.String("String"), // Required - TagKeyList: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromResource(params) - - if err != nil { - // 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) -} diff --git a/service/cloudsearch/examples_test.go b/service/cloudsearch/examples_test.go deleted file mode 100644 index ec979dc8888..00000000000 --- a/service/cloudsearch/examples_test.go +++ /dev/null @@ -1,664 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudsearch_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudsearch" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudSearch_BuildSuggesters() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.BuildSuggestersInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.BuildSuggesters(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_CreateDomain() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.CreateDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.CreateDomain(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DefineAnalysisScheme() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DefineAnalysisSchemeInput{ - AnalysisScheme: &cloudsearch.AnalysisScheme{ // Required - AnalysisSchemeLanguage: aws.String("AnalysisSchemeLanguage"), // Required - AnalysisSchemeName: aws.String("StandardName"), // Required - AnalysisOptions: &cloudsearch.AnalysisOptions{ - AlgorithmicStemming: aws.String("AlgorithmicStemming"), - JapaneseTokenizationDictionary: aws.String("String"), - StemmingDictionary: aws.String("String"), - Stopwords: aws.String("String"), - Synonyms: aws.String("String"), - }, - }, - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DefineAnalysisScheme(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DefineExpression() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DefineExpressionInput{ - DomainName: aws.String("DomainName"), // Required - Expression: &cloudsearch.Expression{ // Required - ExpressionName: aws.String("StandardName"), // Required - ExpressionValue: aws.String("ExpressionValue"), // Required - }, - } - resp, err := svc.DefineExpression(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DefineIndexField() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DefineIndexFieldInput{ - DomainName: aws.String("DomainName"), // Required - IndexField: &cloudsearch.IndexField{ // Required - IndexFieldName: aws.String("DynamicFieldName"), // Required - IndexFieldType: aws.String("IndexFieldType"), // Required - DateArrayOptions: &cloudsearch.DateArrayOptions{ - DefaultValue: aws.String("FieldValue"), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SourceFields: aws.String("FieldNameCommaList"), - }, - DateOptions: &cloudsearch.DateOptions{ - DefaultValue: aws.String("FieldValue"), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - DoubleArrayOptions: &cloudsearch.DoubleArrayOptions{ - DefaultValue: aws.Float64(1.0), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SourceFields: aws.String("FieldNameCommaList"), - }, - DoubleOptions: &cloudsearch.DoubleOptions{ - DefaultValue: aws.Float64(1.0), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - IntArrayOptions: &cloudsearch.IntArrayOptions{ - DefaultValue: aws.Int64(1), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SourceFields: aws.String("FieldNameCommaList"), - }, - IntOptions: &cloudsearch.IntOptions{ - DefaultValue: aws.Int64(1), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - LatLonOptions: &cloudsearch.LatLonOptions{ - DefaultValue: aws.String("FieldValue"), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - LiteralArrayOptions: &cloudsearch.LiteralArrayOptions{ - DefaultValue: aws.String("FieldValue"), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SourceFields: aws.String("FieldNameCommaList"), - }, - LiteralOptions: &cloudsearch.LiteralOptions{ - DefaultValue: aws.String("FieldValue"), - FacetEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SearchEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - TextArrayOptions: &cloudsearch.TextArrayOptions{ - AnalysisScheme: aws.String("Word"), - DefaultValue: aws.String("FieldValue"), - HighlightEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SourceFields: aws.String("FieldNameCommaList"), - }, - TextOptions: &cloudsearch.TextOptions{ - AnalysisScheme: aws.String("Word"), - DefaultValue: aws.String("FieldValue"), - HighlightEnabled: aws.Bool(true), - ReturnEnabled: aws.Bool(true), - SortEnabled: aws.Bool(true), - SourceField: aws.String("FieldName"), - }, - }, - } - resp, err := svc.DefineIndexField(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DefineSuggester() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DefineSuggesterInput{ - DomainName: aws.String("DomainName"), // Required - Suggester: &cloudsearch.Suggester{ // Required - DocumentSuggesterOptions: &cloudsearch.DocumentSuggesterOptions{ // Required - SourceField: aws.String("FieldName"), // Required - FuzzyMatching: aws.String("SuggesterFuzzyMatching"), - SortExpression: aws.String("String"), - }, - SuggesterName: aws.String("StandardName"), // Required - }, - } - resp, err := svc.DefineSuggester(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DeleteAnalysisScheme() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DeleteAnalysisSchemeInput{ - AnalysisSchemeName: aws.String("StandardName"), // Required - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DeleteAnalysisScheme(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DeleteDomain() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DeleteDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DeleteDomain(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DeleteExpression() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DeleteExpressionInput{ - DomainName: aws.String("DomainName"), // Required - ExpressionName: aws.String("StandardName"), // Required - } - resp, err := svc.DeleteExpression(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DeleteIndexField() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DeleteIndexFieldInput{ - DomainName: aws.String("DomainName"), // Required - IndexFieldName: aws.String("DynamicFieldName"), // Required - } - resp, err := svc.DeleteIndexField(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DeleteSuggester() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DeleteSuggesterInput{ - DomainName: aws.String("DomainName"), // Required - SuggesterName: aws.String("StandardName"), // Required - } - resp, err := svc.DeleteSuggester(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeAnalysisSchemes() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeAnalysisSchemesInput{ - DomainName: aws.String("DomainName"), // Required - AnalysisSchemeNames: []*string{ - aws.String("StandardName"), // Required - // More values... - }, - Deployed: aws.Bool(true), - } - resp, err := svc.DescribeAnalysisSchemes(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeAvailabilityOptions() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeAvailabilityOptionsInput{ - DomainName: aws.String("DomainName"), // Required - Deployed: aws.Bool(true), - } - resp, err := svc.DescribeAvailabilityOptions(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeDomains() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeDomainsInput{ - DomainNames: []*string{ - aws.String("DomainName"), // Required - // More values... - }, - } - resp, err := svc.DescribeDomains(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeExpressions() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeExpressionsInput{ - DomainName: aws.String("DomainName"), // Required - Deployed: aws.Bool(true), - ExpressionNames: []*string{ - aws.String("StandardName"), // Required - // More values... - }, - } - resp, err := svc.DescribeExpressions(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeIndexFields() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeIndexFieldsInput{ - DomainName: aws.String("DomainName"), // Required - Deployed: aws.Bool(true), - FieldNames: []*string{ - aws.String("DynamicFieldName"), // Required - // More values... - }, - } - resp, err := svc.DescribeIndexFields(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeScalingParameters() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeScalingParametersInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DescribeScalingParameters(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeServiceAccessPolicies() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeServiceAccessPoliciesInput{ - DomainName: aws.String("DomainName"), // Required - Deployed: aws.Bool(true), - } - resp, err := svc.DescribeServiceAccessPolicies(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_DescribeSuggesters() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.DescribeSuggestersInput{ - DomainName: aws.String("DomainName"), // Required - Deployed: aws.Bool(true), - SuggesterNames: []*string{ - aws.String("StandardName"), // Required - // More values... - }, - } - resp, err := svc.DescribeSuggesters(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_IndexDocuments() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.IndexDocumentsInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.IndexDocuments(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_ListDomainNames() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - var params *cloudsearch.ListDomainNamesInput - resp, err := svc.ListDomainNames(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_UpdateAvailabilityOptions() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.UpdateAvailabilityOptionsInput{ - DomainName: aws.String("DomainName"), // Required - MultiAZ: aws.Bool(true), // Required - } - resp, err := svc.UpdateAvailabilityOptions(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_UpdateScalingParameters() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.UpdateScalingParametersInput{ - DomainName: aws.String("DomainName"), // Required - ScalingParameters: &cloudsearch.ScalingParameters{ // Required - DesiredInstanceType: aws.String("PartitionInstanceType"), - DesiredPartitionCount: aws.Int64(1), - DesiredReplicationCount: aws.Int64(1), - }, - } - resp, err := svc.UpdateScalingParameters(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearch_UpdateServiceAccessPolicies() { - sess := session.Must(session.NewSession()) - - svc := cloudsearch.New(sess) - - params := &cloudsearch.UpdateServiceAccessPoliciesInput{ - AccessPolicies: aws.String("PolicyDocument"), // Required - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.UpdateServiceAccessPolicies(params) - - if err != nil { - // 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) -} diff --git a/service/cloudsearchdomain/examples_test.go b/service/cloudsearchdomain/examples_test.go deleted file mode 100644 index f199177aacb..00000000000 --- a/service/cloudsearchdomain/examples_test.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudsearchdomain_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudsearchdomain" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudSearchDomain_Search() { - sess := session.Must(session.NewSession()) - - svc := cloudsearchdomain.New(sess) - - params := &cloudsearchdomain.SearchInput{ - Query: aws.String("Query"), // Required - Cursor: aws.String("Cursor"), - Expr: aws.String("Expr"), - Facet: aws.String("Facet"), - FilterQuery: aws.String("FilterQuery"), - Highlight: aws.String("Highlight"), - Partial: aws.Bool(true), - QueryOptions: aws.String("QueryOptions"), - QueryParser: aws.String("QueryParser"), - Return: aws.String("Return"), - Size: aws.Int64(1), - Sort: aws.String("Sort"), - Start: aws.Int64(1), - Stats: aws.String("Stat"), - } - resp, err := svc.Search(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearchDomain_Suggest() { - sess := session.Must(session.NewSession()) - - svc := cloudsearchdomain.New(sess) - - params := &cloudsearchdomain.SuggestInput{ - Query: aws.String("Query"), // Required - Suggester: aws.String("Suggester"), // Required - Size: aws.Int64(1), - } - resp, err := svc.Suggest(params) - - if err != nil { - // 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) -} - -func ExampleCloudSearchDomain_UploadDocuments() { - sess := session.Must(session.NewSession()) - - svc := cloudsearchdomain.New(sess) - - params := &cloudsearchdomain.UploadDocumentsInput{ - ContentType: aws.String("ContentType"), // Required - Documents: bytes.NewReader([]byte("PAYLOAD")), // Required - } - resp, err := svc.UploadDocuments(params) - - if err != nil { - // 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) -} diff --git a/service/cloudtrail/examples_test.go b/service/cloudtrail/examples_test.go deleted file mode 100644 index af053f6336e..00000000000 --- a/service/cloudtrail/examples_test.go +++ /dev/null @@ -1,379 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudtrail_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudtrail" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudTrail_AddTags() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.AddTagsInput{ - ResourceId: aws.String("String"), // Required - TagsList: []*cloudtrail.Tag{ - { // Required - Key: aws.String("String"), // Required - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.AddTags(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_CreateTrail() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.CreateTrailInput{ - Name: aws.String("String"), // Required - S3BucketName: aws.String("String"), // Required - CloudWatchLogsLogGroupArn: aws.String("String"), - CloudWatchLogsRoleArn: aws.String("String"), - EnableLogFileValidation: aws.Bool(true), - IncludeGlobalServiceEvents: aws.Bool(true), - IsMultiRegionTrail: aws.Bool(true), - KmsKeyId: aws.String("String"), - S3KeyPrefix: aws.String("String"), - SnsTopicName: aws.String("String"), - } - resp, err := svc.CreateTrail(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_DeleteTrail() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.DeleteTrailInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.DeleteTrail(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_DescribeTrails() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.DescribeTrailsInput{ - IncludeShadowTrails: aws.Bool(true), - TrailNameList: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeTrails(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_GetEventSelectors() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.GetEventSelectorsInput{ - TrailName: aws.String("String"), // Required - } - resp, err := svc.GetEventSelectors(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_GetTrailStatus() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.GetTrailStatusInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.GetTrailStatus(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_ListPublicKeys() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.ListPublicKeysInput{ - EndTime: aws.Time(time.Now()), - NextToken: aws.String("String"), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.ListPublicKeys(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_ListTags() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.ListTagsInput{ - ResourceIdList: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.ListTags(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_LookupEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.LookupEventsInput{ - EndTime: aws.Time(time.Now()), - LookupAttributes: []*cloudtrail.LookupAttribute{ - { // Required - AttributeKey: aws.String("LookupAttributeKey"), // Required - AttributeValue: aws.String("String"), // Required - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.LookupEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_PutEventSelectors() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.PutEventSelectorsInput{ - EventSelectors: []*cloudtrail.EventSelector{ // Required - { // Required - DataResources: []*cloudtrail.DataResource{ - { // Required - Type: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - IncludeManagementEvents: aws.Bool(true), - ReadWriteType: aws.String("ReadWriteType"), - }, - // More values... - }, - TrailName: aws.String("String"), // Required - } - resp, err := svc.PutEventSelectors(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_RemoveTags() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.RemoveTagsInput{ - ResourceId: aws.String("String"), // Required - TagsList: []*cloudtrail.Tag{ - { // Required - Key: aws.String("String"), // Required - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.RemoveTags(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_StartLogging() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.StartLoggingInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.StartLogging(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_StopLogging() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.StopLoggingInput{ - Name: aws.String("String"), // Required - } - resp, err := svc.StopLogging(params) - - if err != nil { - // 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) -} - -func ExampleCloudTrail_UpdateTrail() { - sess := session.Must(session.NewSession()) - - svc := cloudtrail.New(sess) - - params := &cloudtrail.UpdateTrailInput{ - Name: aws.String("String"), // Required - CloudWatchLogsLogGroupArn: aws.String("String"), - CloudWatchLogsRoleArn: aws.String("String"), - EnableLogFileValidation: aws.Bool(true), - IncludeGlobalServiceEvents: aws.Bool(true), - IsMultiRegionTrail: aws.Bool(true), - KmsKeyId: aws.String("String"), - S3BucketName: aws.String("String"), - S3KeyPrefix: aws.String("String"), - SnsTopicName: aws.String("String"), - } - resp, err := svc.UpdateTrail(params) - - if err != nil { - // 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) -} diff --git a/service/cloudwatch/examples_test.go b/service/cloudwatch/examples_test.go deleted file mode 100644 index 7beb97beb0e..00000000000 --- a/service/cloudwatch/examples_test.go +++ /dev/null @@ -1,367 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudwatch_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudwatch" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudWatch_DeleteAlarms() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.DeleteAlarmsInput{ - AlarmNames: []*string{ // Required - aws.String("AlarmName"), // Required - // More values... - }, - } - resp, err := svc.DeleteAlarms(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_DescribeAlarmHistory() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.DescribeAlarmHistoryInput{ - AlarmName: aws.String("AlarmName"), - EndDate: aws.Time(time.Now()), - HistoryItemType: aws.String("HistoryItemType"), - MaxRecords: aws.Int64(1), - NextToken: aws.String("NextToken"), - StartDate: aws.Time(time.Now()), - } - resp, err := svc.DescribeAlarmHistory(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_DescribeAlarms() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.DescribeAlarmsInput{ - ActionPrefix: aws.String("ActionPrefix"), - AlarmNamePrefix: aws.String("AlarmNamePrefix"), - AlarmNames: []*string{ - aws.String("AlarmName"), // Required - // More values... - }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("NextToken"), - StateValue: aws.String("StateValue"), - } - resp, err := svc.DescribeAlarms(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_DescribeAlarmsForMetric() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.DescribeAlarmsForMetricInput{ - MetricName: aws.String("MetricName"), // Required - Namespace: aws.String("Namespace"), // Required - Dimensions: []*cloudwatch.Dimension{ - { // Required - Name: aws.String("DimensionName"), // Required - Value: aws.String("DimensionValue"), // Required - }, - // More values... - }, - ExtendedStatistic: aws.String("ExtendedStatistic"), - Period: aws.Int64(1), - Statistic: aws.String("Statistic"), - Unit: aws.String("StandardUnit"), - } - resp, err := svc.DescribeAlarmsForMetric(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_DisableAlarmActions() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.DisableAlarmActionsInput{ - AlarmNames: []*string{ // Required - aws.String("AlarmName"), // Required - // More values... - }, - } - resp, err := svc.DisableAlarmActions(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_EnableAlarmActions() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.EnableAlarmActionsInput{ - AlarmNames: []*string{ // Required - aws.String("AlarmName"), // Required - // More values... - }, - } - resp, err := svc.EnableAlarmActions(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_GetMetricStatistics() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.GetMetricStatisticsInput{ - EndTime: aws.Time(time.Now()), // Required - MetricName: aws.String("MetricName"), // Required - Namespace: aws.String("Namespace"), // Required - Period: aws.Int64(1), // Required - StartTime: aws.Time(time.Now()), // Required - Dimensions: []*cloudwatch.Dimension{ - { // Required - Name: aws.String("DimensionName"), // Required - Value: aws.String("DimensionValue"), // Required - }, - // More values... - }, - ExtendedStatistics: []*string{ - aws.String("ExtendedStatistic"), // Required - // More values... - }, - Statistics: []*string{ - aws.String("Statistic"), // Required - // More values... - }, - Unit: aws.String("StandardUnit"), - } - resp, err := svc.GetMetricStatistics(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_ListMetrics() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.ListMetricsInput{ - Dimensions: []*cloudwatch.DimensionFilter{ - { // Required - Name: aws.String("DimensionName"), // Required - Value: aws.String("DimensionValue"), - }, - // More values... - }, - MetricName: aws.String("MetricName"), - Namespace: aws.String("Namespace"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListMetrics(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_PutMetricAlarm() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.PutMetricAlarmInput{ - AlarmName: aws.String("AlarmName"), // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - EvaluationPeriods: aws.Int64(1), // Required - MetricName: aws.String("MetricName"), // Required - Namespace: aws.String("Namespace"), // Required - Period: aws.Int64(1), // Required - Threshold: aws.Float64(1.0), // Required - ActionsEnabled: aws.Bool(true), - AlarmActions: []*string{ - aws.String("ResourceName"), // Required - // More values... - }, - AlarmDescription: aws.String("AlarmDescription"), - Dimensions: []*cloudwatch.Dimension{ - { // Required - Name: aws.String("DimensionName"), // Required - Value: aws.String("DimensionValue"), // Required - }, - // More values... - }, - EvaluateLowSampleCountPercentile: aws.String("EvaluateLowSampleCountPercentile"), - ExtendedStatistic: aws.String("ExtendedStatistic"), - InsufficientDataActions: []*string{ - aws.String("ResourceName"), // Required - // More values... - }, - OKActions: []*string{ - aws.String("ResourceName"), // Required - // More values... - }, - Statistic: aws.String("Statistic"), - TreatMissingData: aws.String("TreatMissingData"), - Unit: aws.String("StandardUnit"), - } - resp, err := svc.PutMetricAlarm(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_PutMetricData() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.PutMetricDataInput{ - MetricData: []*cloudwatch.MetricDatum{ // Required - { // Required - MetricName: aws.String("MetricName"), // Required - Dimensions: []*cloudwatch.Dimension{ - { // Required - Name: aws.String("DimensionName"), // Required - Value: aws.String("DimensionValue"), // Required - }, - // More values... - }, - StatisticValues: &cloudwatch.StatisticSet{ - Maximum: aws.Float64(1.0), // Required - Minimum: aws.Float64(1.0), // Required - SampleCount: aws.Float64(1.0), // Required - Sum: aws.Float64(1.0), // Required - }, - Timestamp: aws.Time(time.Now()), - Unit: aws.String("StandardUnit"), - Value: aws.Float64(1.0), - }, - // More values... - }, - Namespace: aws.String("Namespace"), // Required - } - resp, err := svc.PutMetricData(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatch_SetAlarmState() { - sess := session.Must(session.NewSession()) - - svc := cloudwatch.New(sess) - - params := &cloudwatch.SetAlarmStateInput{ - AlarmName: aws.String("AlarmName"), // Required - StateReason: aws.String("StateReason"), // Required - StateValue: aws.String("StateValue"), // Required - StateReasonData: aws.String("StateReasonData"), - } - resp, err := svc.SetAlarmState(params) - - if err != nil { - // 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) -} diff --git a/service/cloudwatchevents/examples_test.go b/service/cloudwatchevents/examples_test.go deleted file mode 100644 index 0a3ccbfebb5..00000000000 --- a/service/cloudwatchevents/examples_test.go +++ /dev/null @@ -1,332 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudwatchevents_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudwatchevents" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudWatchEvents_DeleteRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.DeleteRuleInput{ - Name: aws.String("RuleName"), // Required - } - resp, err := svc.DeleteRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_DescribeRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.DescribeRuleInput{ - Name: aws.String("RuleName"), // Required - } - resp, err := svc.DescribeRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_DisableRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.DisableRuleInput{ - Name: aws.String("RuleName"), // Required - } - resp, err := svc.DisableRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_EnableRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.EnableRuleInput{ - Name: aws.String("RuleName"), // Required - } - resp, err := svc.EnableRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_ListRuleNamesByTarget() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.ListRuleNamesByTargetInput{ - TargetArn: aws.String("TargetArn"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListRuleNamesByTarget(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_ListRules() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.ListRulesInput{ - Limit: aws.Int64(1), - NamePrefix: aws.String("RuleName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListRules(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_ListTargetsByRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.ListTargetsByRuleInput{ - Rule: aws.String("RuleName"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTargetsByRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_PutEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.PutEventsInput{ - Entries: []*cloudwatchevents.PutEventsRequestEntry{ // Required - { // Required - Detail: aws.String("String"), - DetailType: aws.String("String"), - Resources: []*string{ - aws.String("EventResource"), // Required - // More values... - }, - Source: aws.String("String"), - Time: aws.Time(time.Now()), - }, - // More values... - }, - } - resp, err := svc.PutEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_PutRule() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.PutRuleInput{ - Name: aws.String("RuleName"), // Required - Description: aws.String("RuleDescription"), - EventPattern: aws.String("EventPattern"), - RoleArn: aws.String("RoleArn"), - ScheduleExpression: aws.String("ScheduleExpression"), - State: aws.String("RuleState"), - } - resp, err := svc.PutRule(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_PutTargets() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.PutTargetsInput{ - Rule: aws.String("RuleName"), // Required - Targets: []*cloudwatchevents.Target{ // Required - { // Required - Arn: aws.String("TargetArn"), // Required - Id: aws.String("TargetId"), // Required - EcsParameters: &cloudwatchevents.EcsParameters{ - TaskDefinitionArn: aws.String("Arn"), // Required - TaskCount: aws.Int64(1), - }, - Input: aws.String("TargetInput"), - InputPath: aws.String("TargetInputPath"), - InputTransformer: &cloudwatchevents.InputTransformer{ - InputTemplate: aws.String("TransformerInput"), // Required - InputPathsMap: map[string]*string{ - "Key": aws.String("TargetInputPath"), // Required - // More values... - }, - }, - KinesisParameters: &cloudwatchevents.KinesisParameters{ - PartitionKeyPath: aws.String("TargetPartitionKeyPath"), // Required - }, - RoleArn: aws.String("RoleArn"), - RunCommandParameters: &cloudwatchevents.RunCommandParameters{ - RunCommandTargets: []*cloudwatchevents.RunCommandTarget{ // Required - { // Required - Key: aws.String("RunCommandTargetKey"), // Required - Values: []*string{ // Required - aws.String("RunCommandTargetValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - }, - // More values... - }, - } - resp, err := svc.PutTargets(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_RemoveTargets() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.RemoveTargetsInput{ - Ids: []*string{ // Required - aws.String("TargetId"), // Required - // More values... - }, - Rule: aws.String("RuleName"), // Required - } - resp, err := svc.RemoveTargets(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchEvents_TestEventPattern() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchevents.New(sess) - - params := &cloudwatchevents.TestEventPatternInput{ - Event: aws.String("String"), // Required - EventPattern: aws.String("EventPattern"), // Required - } - resp, err := svc.TestEventPattern(params) - - if err != nil { - // 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) -} diff --git a/service/cloudwatchlogs/examples_test.go b/service/cloudwatchlogs/examples_test.go deleted file mode 100644 index c7bced0199b..00000000000 --- a/service/cloudwatchlogs/examples_test.go +++ /dev/null @@ -1,695 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cloudwatchlogs_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudwatchlogs" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCloudWatchLogs_CancelExportTask() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.CancelExportTaskInput{ - TaskId: aws.String("ExportTaskId"), // Required - } - resp, err := svc.CancelExportTask(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_CreateExportTask() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.CreateExportTaskInput{ - Destination: aws.String("ExportDestinationBucket"), // Required - From: aws.Int64(1), // Required - LogGroupName: aws.String("LogGroupName"), // Required - To: aws.Int64(1), // Required - DestinationPrefix: aws.String("ExportDestinationPrefix"), - LogStreamNamePrefix: aws.String("LogStreamName"), - TaskName: aws.String("ExportTaskName"), - } - resp, err := svc.CreateExportTask(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_CreateLogGroup() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.CreateLogGroupInput{ - LogGroupName: aws.String("LogGroupName"), // Required - Tags: map[string]*string{ - "Key": aws.String("TagValue"), // Required - // More values... - }, - } - resp, err := svc.CreateLogGroup(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_CreateLogStream() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.CreateLogStreamInput{ - LogGroupName: aws.String("LogGroupName"), // Required - LogStreamName: aws.String("LogStreamName"), // Required - } - resp, err := svc.CreateLogStream(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteDestination() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteDestinationInput{ - DestinationName: aws.String("DestinationName"), // Required - } - resp, err := svc.DeleteDestination(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteLogGroup() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteLogGroupInput{ - LogGroupName: aws.String("LogGroupName"), // Required - } - resp, err := svc.DeleteLogGroup(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteLogStream() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteLogStreamInput{ - LogGroupName: aws.String("LogGroupName"), // Required - LogStreamName: aws.String("LogStreamName"), // Required - } - resp, err := svc.DeleteLogStream(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteMetricFilter() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteMetricFilterInput{ - FilterName: aws.String("FilterName"), // Required - LogGroupName: aws.String("LogGroupName"), // Required - } - resp, err := svc.DeleteMetricFilter(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteRetentionPolicy() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteRetentionPolicyInput{ - LogGroupName: aws.String("LogGroupName"), // Required - } - resp, err := svc.DeleteRetentionPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DeleteSubscriptionFilter() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DeleteSubscriptionFilterInput{ - FilterName: aws.String("FilterName"), // Required - LogGroupName: aws.String("LogGroupName"), // Required - } - resp, err := svc.DeleteSubscriptionFilter(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeDestinations() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeDestinationsInput{ - DestinationNamePrefix: aws.String("DestinationName"), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeDestinations(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeExportTasks() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeExportTasksInput{ - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - StatusCode: aws.String("ExportTaskStatusCode"), - TaskId: aws.String("ExportTaskId"), - } - resp, err := svc.DescribeExportTasks(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeLogGroups() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeLogGroupsInput{ - Limit: aws.Int64(1), - LogGroupNamePrefix: aws.String("LogGroupName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeLogGroups(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeLogStreams() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeLogStreamsInput{ - LogGroupName: aws.String("LogGroupName"), // Required - Descending: aws.Bool(true), - Limit: aws.Int64(1), - LogStreamNamePrefix: aws.String("LogStreamName"), - NextToken: aws.String("NextToken"), - OrderBy: aws.String("OrderBy"), - } - resp, err := svc.DescribeLogStreams(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeMetricFilters() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeMetricFiltersInput{ - FilterNamePrefix: aws.String("FilterName"), - Limit: aws.Int64(1), - LogGroupName: aws.String("LogGroupName"), - MetricName: aws.String("MetricName"), - MetricNamespace: aws.String("MetricNamespace"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMetricFilters(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_DescribeSubscriptionFilters() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.DescribeSubscriptionFiltersInput{ - LogGroupName: aws.String("LogGroupName"), // Required - FilterNamePrefix: aws.String("FilterName"), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeSubscriptionFilters(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_FilterLogEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.FilterLogEventsInput{ - LogGroupName: aws.String("LogGroupName"), // Required - EndTime: aws.Int64(1), - FilterPattern: aws.String("FilterPattern"), - Interleaved: aws.Bool(true), - Limit: aws.Int64(1), - LogStreamNames: []*string{ - aws.String("LogStreamName"), // Required - // More values... - }, - NextToken: aws.String("NextToken"), - StartTime: aws.Int64(1), - } - resp, err := svc.FilterLogEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_GetLogEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.GetLogEventsInput{ - LogGroupName: aws.String("LogGroupName"), // Required - LogStreamName: aws.String("LogStreamName"), // Required - EndTime: aws.Int64(1), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - StartFromHead: aws.Bool(true), - StartTime: aws.Int64(1), - } - resp, err := svc.GetLogEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_ListTagsLogGroup() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.ListTagsLogGroupInput{ - LogGroupName: aws.String("LogGroupName"), // Required - } - resp, err := svc.ListTagsLogGroup(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutDestination() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutDestinationInput{ - DestinationName: aws.String("DestinationName"), // Required - RoleArn: aws.String("RoleArn"), // Required - TargetArn: aws.String("TargetArn"), // Required - } - resp, err := svc.PutDestination(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutDestinationPolicy() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutDestinationPolicyInput{ - AccessPolicy: aws.String("AccessPolicy"), // Required - DestinationName: aws.String("DestinationName"), // Required - } - resp, err := svc.PutDestinationPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutLogEvents() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutLogEventsInput{ - LogEvents: []*cloudwatchlogs.InputLogEvent{ // Required - { // Required - Message: aws.String("EventMessage"), // Required - Timestamp: aws.Int64(1), // Required - }, - // More values... - }, - LogGroupName: aws.String("LogGroupName"), // Required - LogStreamName: aws.String("LogStreamName"), // Required - SequenceToken: aws.String("SequenceToken"), - } - resp, err := svc.PutLogEvents(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutMetricFilter() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutMetricFilterInput{ - FilterName: aws.String("FilterName"), // Required - FilterPattern: aws.String("FilterPattern"), // Required - LogGroupName: aws.String("LogGroupName"), // Required - MetricTransformations: []*cloudwatchlogs.MetricTransformation{ // Required - { // Required - MetricName: aws.String("MetricName"), // Required - MetricNamespace: aws.String("MetricNamespace"), // Required - MetricValue: aws.String("MetricValue"), // Required - DefaultValue: aws.Float64(1.0), - }, - // More values... - }, - } - resp, err := svc.PutMetricFilter(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutRetentionPolicy() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutRetentionPolicyInput{ - LogGroupName: aws.String("LogGroupName"), // Required - RetentionInDays: aws.Int64(1), // Required - } - resp, err := svc.PutRetentionPolicy(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_PutSubscriptionFilter() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.PutSubscriptionFilterInput{ - DestinationArn: aws.String("DestinationArn"), // Required - FilterName: aws.String("FilterName"), // Required - FilterPattern: aws.String("FilterPattern"), // Required - LogGroupName: aws.String("LogGroupName"), // Required - Distribution: aws.String("Distribution"), - RoleArn: aws.String("RoleArn"), - } - resp, err := svc.PutSubscriptionFilter(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_TagLogGroup() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.TagLogGroupInput{ - LogGroupName: aws.String("LogGroupName"), // Required - Tags: map[string]*string{ // Required - "Key": aws.String("TagValue"), // Required - // More values... - }, - } - resp, err := svc.TagLogGroup(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_TestMetricFilter() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.TestMetricFilterInput{ - FilterPattern: aws.String("FilterPattern"), // Required - LogEventMessages: []*string{ // Required - aws.String("EventMessage"), // Required - // More values... - }, - } - resp, err := svc.TestMetricFilter(params) - - if err != nil { - // 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) -} - -func ExampleCloudWatchLogs_UntagLogGroup() { - sess := session.Must(session.NewSession()) - - svc := cloudwatchlogs.New(sess) - - params := &cloudwatchlogs.UntagLogGroupInput{ - LogGroupName: aws.String("LogGroupName"), // Required - Tags: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UntagLogGroup(params) - - if err != nil { - // 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) -} diff --git a/service/codebuild/examples_test.go b/service/codebuild/examples_test.go deleted file mode 100644 index ec96f12bb3e..00000000000 --- a/service/codebuild/examples_test.go +++ /dev/null @@ -1,354 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package codebuild_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/codebuild" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCodeBuild_BatchGetBuilds() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.BatchGetBuildsInput{ - Ids: []*string{ // Required - aws.String("NonEmptyString"), // Required - // More values... - }, - } - resp, err := svc.BatchGetBuilds(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_BatchGetProjects() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.BatchGetProjectsInput{ - Names: []*string{ // Required - aws.String("NonEmptyString"), // Required - // More values... - }, - } - resp, err := svc.BatchGetProjects(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_CreateProject() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.CreateProjectInput{ - Artifacts: &codebuild.ProjectArtifacts{ // Required - Type: aws.String("ArtifactsType"), // Required - Location: aws.String("String"), - Name: aws.String("String"), - NamespaceType: aws.String("ArtifactNamespace"), - Packaging: aws.String("ArtifactPackaging"), - Path: aws.String("String"), - }, - Environment: &codebuild.ProjectEnvironment{ // Required - ComputeType: aws.String("ComputeType"), // Required - Image: aws.String("NonEmptyString"), // Required - Type: aws.String("EnvironmentType"), // Required - EnvironmentVariables: []*codebuild.EnvironmentVariable{ - { // Required - Name: aws.String("NonEmptyString"), // Required - Value: aws.String("String"), // Required - }, - // More values... - }, - }, - Name: aws.String("ProjectName"), // Required - Source: &codebuild.ProjectSource{ // Required - Type: aws.String("SourceType"), // Required - Auth: &codebuild.SourceAuth{ - Type: aws.String("SourceAuthType"), // Required - Resource: aws.String("String"), - }, - Buildspec: aws.String("String"), - Location: aws.String("String"), - }, - Description: aws.String("ProjectDescription"), - EncryptionKey: aws.String("NonEmptyString"), - ServiceRole: aws.String("NonEmptyString"), - Tags: []*codebuild.Tag{ - { // Required - Key: aws.String("KeyInput"), - Value: aws.String("ValueInput"), - }, - // More values... - }, - TimeoutInMinutes: aws.Int64(1), - } - resp, err := svc.CreateProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_DeleteProject() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.DeleteProjectInput{ - Name: aws.String("NonEmptyString"), // Required - } - resp, err := svc.DeleteProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_ListBuilds() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.ListBuildsInput{ - NextToken: aws.String("String"), - SortOrder: aws.String("SortOrderType"), - } - resp, err := svc.ListBuilds(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_ListBuildsForProject() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.ListBuildsForProjectInput{ - ProjectName: aws.String("NonEmptyString"), // Required - NextToken: aws.String("String"), - SortOrder: aws.String("SortOrderType"), - } - resp, err := svc.ListBuildsForProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_ListCuratedEnvironmentImages() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - var params *codebuild.ListCuratedEnvironmentImagesInput - resp, err := svc.ListCuratedEnvironmentImages(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_ListProjects() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.ListProjectsInput{ - NextToken: aws.String("NonEmptyString"), - SortBy: aws.String("ProjectSortByType"), - SortOrder: aws.String("SortOrderType"), - } - resp, err := svc.ListProjects(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_StartBuild() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.StartBuildInput{ - ProjectName: aws.String("NonEmptyString"), // Required - ArtifactsOverride: &codebuild.ProjectArtifacts{ - Type: aws.String("ArtifactsType"), // Required - Location: aws.String("String"), - Name: aws.String("String"), - NamespaceType: aws.String("ArtifactNamespace"), - Packaging: aws.String("ArtifactPackaging"), - Path: aws.String("String"), - }, - BuildspecOverride: aws.String("String"), - EnvironmentVariablesOverride: []*codebuild.EnvironmentVariable{ - { // Required - Name: aws.String("NonEmptyString"), // Required - Value: aws.String("String"), // Required - }, - // More values... - }, - SourceVersion: aws.String("String"), - TimeoutInMinutesOverride: aws.Int64(1), - } - resp, err := svc.StartBuild(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_StopBuild() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.StopBuildInput{ - Id: aws.String("NonEmptyString"), // Required - } - resp, err := svc.StopBuild(params) - - if err != nil { - // 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) -} - -func ExampleCodeBuild_UpdateProject() { - sess := session.Must(session.NewSession()) - - svc := codebuild.New(sess) - - params := &codebuild.UpdateProjectInput{ - Name: aws.String("NonEmptyString"), // Required - Artifacts: &codebuild.ProjectArtifacts{ - Type: aws.String("ArtifactsType"), // Required - Location: aws.String("String"), - Name: aws.String("String"), - NamespaceType: aws.String("ArtifactNamespace"), - Packaging: aws.String("ArtifactPackaging"), - Path: aws.String("String"), - }, - Description: aws.String("ProjectDescription"), - EncryptionKey: aws.String("NonEmptyString"), - Environment: &codebuild.ProjectEnvironment{ - ComputeType: aws.String("ComputeType"), // Required - Image: aws.String("NonEmptyString"), // Required - Type: aws.String("EnvironmentType"), // Required - EnvironmentVariables: []*codebuild.EnvironmentVariable{ - { // Required - Name: aws.String("NonEmptyString"), // Required - Value: aws.String("String"), // Required - }, - // More values... - }, - }, - ServiceRole: aws.String("NonEmptyString"), - Source: &codebuild.ProjectSource{ - Type: aws.String("SourceType"), // Required - Auth: &codebuild.SourceAuth{ - Type: aws.String("SourceAuthType"), // Required - Resource: aws.String("String"), - }, - Buildspec: aws.String("String"), - Location: aws.String("String"), - }, - Tags: []*codebuild.Tag{ - { // Required - Key: aws.String("KeyInput"), - Value: aws.String("ValueInput"), - }, - // More values... - }, - TimeoutInMinutes: aws.Int64(1), - } - resp, err := svc.UpdateProject(params) - - if err != nil { - // 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) -} diff --git a/service/codecommit/examples_test.go b/service/codecommit/examples_test.go deleted file mode 100644 index e46908b1c31..00000000000 --- a/service/codecommit/examples_test.go +++ /dev/null @@ -1,426 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package codecommit_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/codecommit" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCodeCommit_BatchGetRepositories() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.BatchGetRepositoriesInput{ - RepositoryNames: []*string{ // Required - aws.String("RepositoryName"), // Required - // More values... - }, - } - resp, err := svc.BatchGetRepositories(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_CreateBranch() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.CreateBranchInput{ - BranchName: aws.String("BranchName"), // Required - CommitId: aws.String("CommitId"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.CreateBranch(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_CreateRepository() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.CreateRepositoryInput{ - RepositoryName: aws.String("RepositoryName"), // Required - RepositoryDescription: aws.String("RepositoryDescription"), - } - resp, err := svc.CreateRepository(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_DeleteRepository() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.DeleteRepositoryInput{ - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.DeleteRepository(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetBlob() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetBlobInput{ - BlobId: aws.String("ObjectId"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.GetBlob(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetBranch() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetBranchInput{ - BranchName: aws.String("BranchName"), - RepositoryName: aws.String("RepositoryName"), - } - resp, err := svc.GetBranch(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetCommit() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetCommitInput{ - CommitId: aws.String("ObjectId"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.GetCommit(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetDifferences() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetDifferencesInput{ - AfterCommitSpecifier: aws.String("CommitName"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - AfterPath: aws.String("Path"), - BeforeCommitSpecifier: aws.String("CommitName"), - BeforePath: aws.String("Path"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetDifferences(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetRepository() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetRepositoryInput{ - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.GetRepository(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_GetRepositoryTriggers() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.GetRepositoryTriggersInput{ - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.GetRepositoryTriggers(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_ListBranches() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.ListBranchesInput{ - RepositoryName: aws.String("RepositoryName"), // Required - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListBranches(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_ListRepositories() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.ListRepositoriesInput{ - NextToken: aws.String("NextToken"), - Order: aws.String("OrderEnum"), - SortBy: aws.String("SortByEnum"), - } - resp, err := svc.ListRepositories(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_PutRepositoryTriggers() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.PutRepositoryTriggersInput{ - RepositoryName: aws.String("RepositoryName"), // Required - Triggers: []*codecommit.RepositoryTrigger{ // Required - { // Required - DestinationArn: aws.String("Arn"), // Required - Events: []*string{ // Required - aws.String("RepositoryTriggerEventEnum"), // Required - // More values... - }, - Name: aws.String("RepositoryTriggerName"), // Required - Branches: []*string{ - aws.String("BranchName"), // Required - // More values... - }, - CustomData: aws.String("RepositoryTriggerCustomData"), - }, - // More values... - }, - } - resp, err := svc.PutRepositoryTriggers(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_TestRepositoryTriggers() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.TestRepositoryTriggersInput{ - RepositoryName: aws.String("RepositoryName"), // Required - Triggers: []*codecommit.RepositoryTrigger{ // Required - { // Required - DestinationArn: aws.String("Arn"), // Required - Events: []*string{ // Required - aws.String("RepositoryTriggerEventEnum"), // Required - // More values... - }, - Name: aws.String("RepositoryTriggerName"), // Required - Branches: []*string{ - aws.String("BranchName"), // Required - // More values... - }, - CustomData: aws.String("RepositoryTriggerCustomData"), - }, - // More values... - }, - } - resp, err := svc.TestRepositoryTriggers(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_UpdateDefaultBranch() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.UpdateDefaultBranchInput{ - DefaultBranchName: aws.String("BranchName"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.UpdateDefaultBranch(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_UpdateRepositoryDescription() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.UpdateRepositoryDescriptionInput{ - RepositoryName: aws.String("RepositoryName"), // Required - RepositoryDescription: aws.String("RepositoryDescription"), - } - resp, err := svc.UpdateRepositoryDescription(params) - - if err != nil { - // 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) -} - -func ExampleCodeCommit_UpdateRepositoryName() { - sess := session.Must(session.NewSession()) - - svc := codecommit.New(sess) - - params := &codecommit.UpdateRepositoryNameInput{ - NewName: aws.String("RepositoryName"), // Required - OldName: aws.String("RepositoryName"), // Required - } - resp, err := svc.UpdateRepositoryName(params) - - if err != nil { - // 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) -} diff --git a/service/codedeploy/examples_test.go b/service/codedeploy/examples_test.go deleted file mode 100644 index 8c5fcdbe23e..00000000000 --- a/service/codedeploy/examples_test.go +++ /dev/null @@ -1,1116 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package codedeploy_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/codedeploy" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCodeDeploy_AddTagsToOnPremisesInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.AddTagsToOnPremisesInstancesInput{ - InstanceNames: []*string{ // Required - aws.String("InstanceName"), // Required - // More values... - }, - Tags: []*codedeploy.Tag{ // Required - { // Required - Key: aws.String("Key"), - Value: aws.String("Value"), - }, - // More values... - }, - } - resp, err := svc.AddTagsToOnPremisesInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetApplicationRevisions() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetApplicationRevisionsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Revisions: []*codedeploy.RevisionLocation{ // Required - { // Required - GitHubLocation: &codedeploy.GitHubLocation{ - CommitId: aws.String("CommitId"), - Repository: aws.String("Repository"), - }, - RevisionType: aws.String("RevisionLocationType"), - S3Location: &codedeploy.S3Location{ - Bucket: aws.String("S3Bucket"), - BundleType: aws.String("BundleType"), - ETag: aws.String("ETag"), - Key: aws.String("S3Key"), - Version: aws.String("VersionId"), - }, - }, - // More values... - }, - } - resp, err := svc.BatchGetApplicationRevisions(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetApplications() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetApplicationsInput{ - ApplicationNames: []*string{ - aws.String("ApplicationName"), // Required - // More values... - }, - } - resp, err := svc.BatchGetApplications(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetDeploymentGroups() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetDeploymentGroupsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - DeploymentGroupNames: []*string{ // Required - aws.String("DeploymentGroupName"), // Required - // More values... - }, - } - resp, err := svc.BatchGetDeploymentGroups(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetDeploymentInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetDeploymentInstancesInput{ - DeploymentId: aws.String("DeploymentId"), // Required - InstanceIds: []*string{ // Required - aws.String("InstanceId"), // Required - // More values... - }, - } - resp, err := svc.BatchGetDeploymentInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetDeployments() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetDeploymentsInput{ - DeploymentIds: []*string{ - aws.String("DeploymentId"), // Required - // More values... - }, - } - resp, err := svc.BatchGetDeployments(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_BatchGetOnPremisesInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.BatchGetOnPremisesInstancesInput{ - InstanceNames: []*string{ - aws.String("InstanceName"), // Required - // More values... - }, - } - resp, err := svc.BatchGetOnPremisesInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ContinueDeployment() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ContinueDeploymentInput{ - DeploymentId: aws.String("DeploymentId"), - } - resp, err := svc.ContinueDeployment(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_CreateApplication() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.CreateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - } - resp, err := svc.CreateApplication(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_CreateDeployment() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.CreateDeploymentInput{ - ApplicationName: aws.String("ApplicationName"), // Required - AutoRollbackConfiguration: &codedeploy.AutoRollbackConfiguration{ - Enabled: aws.Bool(true), - Events: []*string{ - aws.String("AutoRollbackEvent"), // Required - // More values... - }, - }, - DeploymentConfigName: aws.String("DeploymentConfigName"), - DeploymentGroupName: aws.String("DeploymentGroupName"), - Description: aws.String("Description"), - FileExistsBehavior: aws.String("FileExistsBehavior"), - IgnoreApplicationStopFailures: aws.Bool(true), - Revision: &codedeploy.RevisionLocation{ - GitHubLocation: &codedeploy.GitHubLocation{ - CommitId: aws.String("CommitId"), - Repository: aws.String("Repository"), - }, - RevisionType: aws.String("RevisionLocationType"), - S3Location: &codedeploy.S3Location{ - Bucket: aws.String("S3Bucket"), - BundleType: aws.String("BundleType"), - ETag: aws.String("ETag"), - Key: aws.String("S3Key"), - Version: aws.String("VersionId"), - }, - }, - TargetInstances: &codedeploy.TargetInstances{ - AutoScalingGroups: []*string{ - aws.String("AutoScalingGroupName"), // Required - // More values... - }, - TagFilters: []*codedeploy.EC2TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("EC2TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - }, - UpdateOutdatedInstancesOnly: aws.Bool(true), - } - resp, err := svc.CreateDeployment(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_CreateDeploymentConfig() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.CreateDeploymentConfigInput{ - DeploymentConfigName: aws.String("DeploymentConfigName"), // Required - MinimumHealthyHosts: &codedeploy.MinimumHealthyHosts{ - Type: aws.String("MinimumHealthyHostsType"), - Value: aws.Int64(1), - }, - } - resp, err := svc.CreateDeploymentConfig(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_CreateDeploymentGroup() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.CreateDeploymentGroupInput{ - ApplicationName: aws.String("ApplicationName"), // Required - DeploymentGroupName: aws.String("DeploymentGroupName"), // Required - ServiceRoleArn: aws.String("Role"), // Required - AlarmConfiguration: &codedeploy.AlarmConfiguration{ - Alarms: []*codedeploy.Alarm{ - { // Required - Name: aws.String("AlarmName"), - }, - // More values... - }, - Enabled: aws.Bool(true), - IgnorePollAlarmFailure: aws.Bool(true), - }, - AutoRollbackConfiguration: &codedeploy.AutoRollbackConfiguration{ - Enabled: aws.Bool(true), - Events: []*string{ - aws.String("AutoRollbackEvent"), // Required - // More values... - }, - }, - AutoScalingGroups: []*string{ - aws.String("AutoScalingGroupName"), // Required - // More values... - }, - BlueGreenDeploymentConfiguration: &codedeploy.BlueGreenDeploymentConfiguration{ - DeploymentReadyOption: &codedeploy.DeploymentReadyOption{ - ActionOnTimeout: aws.String("DeploymentReadyAction"), - WaitTimeInMinutes: aws.Int64(1), - }, - GreenFleetProvisioningOption: &codedeploy.GreenFleetProvisioningOption{ - Action: aws.String("GreenFleetProvisioningAction"), - }, - TerminateBlueInstancesOnDeploymentSuccess: &codedeploy.BlueInstanceTerminationOption{ - Action: aws.String("InstanceAction"), - TerminationWaitTimeInMinutes: aws.Int64(1), - }, - }, - DeploymentConfigName: aws.String("DeploymentConfigName"), - DeploymentStyle: &codedeploy.DeploymentStyle{ - DeploymentOption: aws.String("DeploymentOption"), - DeploymentType: aws.String("DeploymentType"), - }, - Ec2TagFilters: []*codedeploy.EC2TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("EC2TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - LoadBalancerInfo: &codedeploy.LoadBalancerInfo{ - ElbInfoList: []*codedeploy.ELBInfo{ - { // Required - Name: aws.String("ELBName"), - }, - // More values... - }, - }, - OnPremisesInstanceTagFilters: []*codedeploy.TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - TriggerConfigurations: []*codedeploy.TriggerConfig{ - { // Required - TriggerEvents: []*string{ - aws.String("TriggerEventType"), // Required - // More values... - }, - TriggerName: aws.String("TriggerName"), - TriggerTargetArn: aws.String("TriggerTargetArn"), - }, - // More values... - }, - } - resp, err := svc.CreateDeploymentGroup(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_DeleteApplication() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.DeleteApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - } - resp, err := svc.DeleteApplication(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_DeleteDeploymentConfig() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.DeleteDeploymentConfigInput{ - DeploymentConfigName: aws.String("DeploymentConfigName"), // Required - } - resp, err := svc.DeleteDeploymentConfig(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_DeleteDeploymentGroup() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.DeleteDeploymentGroupInput{ - ApplicationName: aws.String("ApplicationName"), // Required - DeploymentGroupName: aws.String("DeploymentGroupName"), // Required - } - resp, err := svc.DeleteDeploymentGroup(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_DeregisterOnPremisesInstance() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.DeregisterOnPremisesInstanceInput{ - InstanceName: aws.String("InstanceName"), // Required - } - resp, err := svc.DeregisterOnPremisesInstance(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetApplication() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - } - resp, err := svc.GetApplication(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetApplicationRevision() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetApplicationRevisionInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Revision: &codedeploy.RevisionLocation{ // Required - GitHubLocation: &codedeploy.GitHubLocation{ - CommitId: aws.String("CommitId"), - Repository: aws.String("Repository"), - }, - RevisionType: aws.String("RevisionLocationType"), - S3Location: &codedeploy.S3Location{ - Bucket: aws.String("S3Bucket"), - BundleType: aws.String("BundleType"), - ETag: aws.String("ETag"), - Key: aws.String("S3Key"), - Version: aws.String("VersionId"), - }, - }, - } - resp, err := svc.GetApplicationRevision(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetDeployment() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetDeploymentInput{ - DeploymentId: aws.String("DeploymentId"), // Required - } - resp, err := svc.GetDeployment(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetDeploymentConfig() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetDeploymentConfigInput{ - DeploymentConfigName: aws.String("DeploymentConfigName"), // Required - } - resp, err := svc.GetDeploymentConfig(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetDeploymentGroup() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetDeploymentGroupInput{ - ApplicationName: aws.String("ApplicationName"), // Required - DeploymentGroupName: aws.String("DeploymentGroupName"), // Required - } - resp, err := svc.GetDeploymentGroup(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetDeploymentInstance() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetDeploymentInstanceInput{ - DeploymentId: aws.String("DeploymentId"), // Required - InstanceId: aws.String("InstanceId"), // Required - } - resp, err := svc.GetDeploymentInstance(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_GetOnPremisesInstance() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.GetOnPremisesInstanceInput{ - InstanceName: aws.String("InstanceName"), // Required - } - resp, err := svc.GetOnPremisesInstance(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListApplicationRevisions() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListApplicationRevisionsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Deployed: aws.String("ListStateFilterAction"), - NextToken: aws.String("NextToken"), - S3Bucket: aws.String("S3Bucket"), - S3KeyPrefix: aws.String("S3Key"), - SortBy: aws.String("ApplicationRevisionSortBy"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.ListApplicationRevisions(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListApplications() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListApplicationsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListApplications(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListDeploymentConfigs() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListDeploymentConfigsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDeploymentConfigs(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListDeploymentGroups() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListDeploymentGroupsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDeploymentGroups(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListDeploymentInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListDeploymentInstancesInput{ - DeploymentId: aws.String("DeploymentId"), // Required - InstanceStatusFilter: []*string{ - aws.String("InstanceStatus"), // Required - // More values... - }, - InstanceTypeFilter: []*string{ - aws.String("InstanceType"), // Required - // More values... - }, - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDeploymentInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListDeployments() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListDeploymentsInput{ - ApplicationName: aws.String("ApplicationName"), - CreateTimeRange: &codedeploy.TimeRange{ - End: aws.Time(time.Now()), - Start: aws.Time(time.Now()), - }, - DeploymentGroupName: aws.String("DeploymentGroupName"), - IncludeOnlyStatuses: []*string{ - aws.String("DeploymentStatus"), // Required - // More values... - }, - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDeployments(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_ListOnPremisesInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.ListOnPremisesInstancesInput{ - NextToken: aws.String("NextToken"), - RegistrationStatus: aws.String("RegistrationStatus"), - TagFilters: []*codedeploy.TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - } - resp, err := svc.ListOnPremisesInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_RegisterApplicationRevision() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.RegisterApplicationRevisionInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Revision: &codedeploy.RevisionLocation{ // Required - GitHubLocation: &codedeploy.GitHubLocation{ - CommitId: aws.String("CommitId"), - Repository: aws.String("Repository"), - }, - RevisionType: aws.String("RevisionLocationType"), - S3Location: &codedeploy.S3Location{ - Bucket: aws.String("S3Bucket"), - BundleType: aws.String("BundleType"), - ETag: aws.String("ETag"), - Key: aws.String("S3Key"), - Version: aws.String("VersionId"), - }, - }, - Description: aws.String("Description"), - } - resp, err := svc.RegisterApplicationRevision(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_RegisterOnPremisesInstance() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.RegisterOnPremisesInstanceInput{ - InstanceName: aws.String("InstanceName"), // Required - IamSessionArn: aws.String("IamSessionArn"), - IamUserArn: aws.String("IamUserArn"), - } - resp, err := svc.RegisterOnPremisesInstance(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_RemoveTagsFromOnPremisesInstances() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.RemoveTagsFromOnPremisesInstancesInput{ - InstanceNames: []*string{ // Required - aws.String("InstanceName"), // Required - // More values... - }, - Tags: []*codedeploy.Tag{ // Required - { // Required - Key: aws.String("Key"), - Value: aws.String("Value"), - }, - // More values... - }, - } - resp, err := svc.RemoveTagsFromOnPremisesInstances(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_SkipWaitTimeForInstanceTermination() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.SkipWaitTimeForInstanceTerminationInput{ - DeploymentId: aws.String("DeploymentId"), - } - resp, err := svc.SkipWaitTimeForInstanceTermination(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_StopDeployment() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.StopDeploymentInput{ - DeploymentId: aws.String("DeploymentId"), // Required - AutoRollbackEnabled: aws.Bool(true), - } - resp, err := svc.StopDeployment(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_UpdateApplication() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.UpdateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), - NewApplicationName: aws.String("ApplicationName"), - } - resp, err := svc.UpdateApplication(params) - - if err != nil { - // 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) -} - -func ExampleCodeDeploy_UpdateDeploymentGroup() { - sess := session.Must(session.NewSession()) - - svc := codedeploy.New(sess) - - params := &codedeploy.UpdateDeploymentGroupInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentDeploymentGroupName: aws.String("DeploymentGroupName"), // Required - AlarmConfiguration: &codedeploy.AlarmConfiguration{ - Alarms: []*codedeploy.Alarm{ - { // Required - Name: aws.String("AlarmName"), - }, - // More values... - }, - Enabled: aws.Bool(true), - IgnorePollAlarmFailure: aws.Bool(true), - }, - AutoRollbackConfiguration: &codedeploy.AutoRollbackConfiguration{ - Enabled: aws.Bool(true), - Events: []*string{ - aws.String("AutoRollbackEvent"), // Required - // More values... - }, - }, - AutoScalingGroups: []*string{ - aws.String("AutoScalingGroupName"), // Required - // More values... - }, - BlueGreenDeploymentConfiguration: &codedeploy.BlueGreenDeploymentConfiguration{ - DeploymentReadyOption: &codedeploy.DeploymentReadyOption{ - ActionOnTimeout: aws.String("DeploymentReadyAction"), - WaitTimeInMinutes: aws.Int64(1), - }, - GreenFleetProvisioningOption: &codedeploy.GreenFleetProvisioningOption{ - Action: aws.String("GreenFleetProvisioningAction"), - }, - TerminateBlueInstancesOnDeploymentSuccess: &codedeploy.BlueInstanceTerminationOption{ - Action: aws.String("InstanceAction"), - TerminationWaitTimeInMinutes: aws.Int64(1), - }, - }, - DeploymentConfigName: aws.String("DeploymentConfigName"), - DeploymentStyle: &codedeploy.DeploymentStyle{ - DeploymentOption: aws.String("DeploymentOption"), - DeploymentType: aws.String("DeploymentType"), - }, - Ec2TagFilters: []*codedeploy.EC2TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("EC2TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - LoadBalancerInfo: &codedeploy.LoadBalancerInfo{ - ElbInfoList: []*codedeploy.ELBInfo{ - { // Required - Name: aws.String("ELBName"), - }, - // More values... - }, - }, - NewDeploymentGroupName: aws.String("DeploymentGroupName"), - OnPremisesInstanceTagFilters: []*codedeploy.TagFilter{ - { // Required - Key: aws.String("Key"), - Type: aws.String("TagFilterType"), - Value: aws.String("Value"), - }, - // More values... - }, - ServiceRoleArn: aws.String("Role"), - TriggerConfigurations: []*codedeploy.TriggerConfig{ - { // Required - TriggerEvents: []*string{ - aws.String("TriggerEventType"), // Required - // More values... - }, - TriggerName: aws.String("TriggerName"), - TriggerTargetArn: aws.String("TriggerTargetArn"), - }, - // More values... - }, - } - resp, err := svc.UpdateDeploymentGroup(params) - - if err != nil { - // 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) -} diff --git a/service/codepipeline/examples_test.go b/service/codepipeline/examples_test.go deleted file mode 100644 index 9a4a654c372..00000000000 --- a/service/codepipeline/examples_test.go +++ /dev/null @@ -1,783 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package codepipeline_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/codepipeline" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCodePipeline_AcknowledgeJob() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.AcknowledgeJobInput{ - JobId: aws.String("JobId"), // Required - Nonce: aws.String("Nonce"), // Required - } - resp, err := svc.AcknowledgeJob(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_AcknowledgeThirdPartyJob() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.AcknowledgeThirdPartyJobInput{ - ClientToken: aws.String("ClientToken"), // Required - JobId: aws.String("ThirdPartyJobId"), // Required - Nonce: aws.String("Nonce"), // Required - } - resp, err := svc.AcknowledgeThirdPartyJob(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_CreateCustomActionType() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.CreateCustomActionTypeInput{ - Category: aws.String("ActionCategory"), // Required - InputArtifactDetails: &codepipeline.ArtifactDetails{ // Required - MaximumCount: aws.Int64(1), // Required - MinimumCount: aws.Int64(1), // Required - }, - OutputArtifactDetails: &codepipeline.ArtifactDetails{ // Required - MaximumCount: aws.Int64(1), // Required - MinimumCount: aws.Int64(1), // Required - }, - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - ConfigurationProperties: []*codepipeline.ActionConfigurationProperty{ - { // Required - Key: aws.Bool(true), // Required - Name: aws.String("ActionConfigurationKey"), // Required - Required: aws.Bool(true), // Required - Secret: aws.Bool(true), // Required - Description: aws.String("Description"), - Queryable: aws.Bool(true), - Type: aws.String("ActionConfigurationPropertyType"), - }, - // More values... - }, - Settings: &codepipeline.ActionTypeSettings{ - EntityUrlTemplate: aws.String("UrlTemplate"), - ExecutionUrlTemplate: aws.String("UrlTemplate"), - RevisionUrlTemplate: aws.String("UrlTemplate"), - ThirdPartyConfigurationUrl: aws.String("Url"), - }, - } - resp, err := svc.CreateCustomActionType(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_CreatePipeline() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.CreatePipelineInput{ - Pipeline: &codepipeline.PipelineDeclaration{ // Required - ArtifactStore: &codepipeline.ArtifactStore{ // Required - Location: aws.String("ArtifactStoreLocation"), // Required - Type: aws.String("ArtifactStoreType"), // Required - EncryptionKey: &codepipeline.EncryptionKey{ - Id: aws.String("EncryptionKeyId"), // Required - Type: aws.String("EncryptionKeyType"), // Required - }, - }, - Name: aws.String("PipelineName"), // Required - RoleArn: aws.String("RoleArn"), // Required - Stages: []*codepipeline.StageDeclaration{ // Required - { // Required - Actions: []*codepipeline.ActionDeclaration{ // Required - { // Required - ActionTypeId: &codepipeline.ActionTypeId{ // Required - Category: aws.String("ActionCategory"), // Required - Owner: aws.String("ActionOwner"), // Required - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - }, - Name: aws.String("ActionName"), // Required - Configuration: map[string]*string{ - "Key": aws.String("ActionConfigurationValue"), // Required - // More values... - }, - InputArtifacts: []*codepipeline.InputArtifact{ - { // Required - Name: aws.String("ArtifactName"), // Required - }, - // More values... - }, - OutputArtifacts: []*codepipeline.OutputArtifact{ - { // Required - Name: aws.String("ArtifactName"), // Required - }, - // More values... - }, - RoleArn: aws.String("RoleArn"), - RunOrder: aws.Int64(1), - }, - // More values... - }, - Name: aws.String("StageName"), // Required - Blockers: []*codepipeline.BlockerDeclaration{ - { // Required - Name: aws.String("BlockerName"), // Required - Type: aws.String("BlockerType"), // Required - }, - // More values... - }, - }, - // More values... - }, - Version: aws.Int64(1), - }, - } - resp, err := svc.CreatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_DeleteCustomActionType() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.DeleteCustomActionTypeInput{ - Category: aws.String("ActionCategory"), // Required - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - } - resp, err := svc.DeleteCustomActionType(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_DeletePipeline() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.DeletePipelineInput{ - Name: aws.String("PipelineName"), // Required - } - resp, err := svc.DeletePipeline(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_DisableStageTransition() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.DisableStageTransitionInput{ - PipelineName: aws.String("PipelineName"), // Required - Reason: aws.String("DisabledReason"), // Required - StageName: aws.String("StageName"), // Required - TransitionType: aws.String("StageTransitionType"), // Required - } - resp, err := svc.DisableStageTransition(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_EnableStageTransition() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.EnableStageTransitionInput{ - PipelineName: aws.String("PipelineName"), // Required - StageName: aws.String("StageName"), // Required - TransitionType: aws.String("StageTransitionType"), // Required - } - resp, err := svc.EnableStageTransition(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_GetJobDetails() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.GetJobDetailsInput{ - JobId: aws.String("JobId"), // Required - } - resp, err := svc.GetJobDetails(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_GetPipeline() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.GetPipelineInput{ - Name: aws.String("PipelineName"), // Required - Version: aws.Int64(1), - } - resp, err := svc.GetPipeline(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_GetPipelineExecution() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.GetPipelineExecutionInput{ - PipelineExecutionId: aws.String("PipelineExecutionId"), // Required - PipelineName: aws.String("PipelineName"), // Required - } - resp, err := svc.GetPipelineExecution(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_GetPipelineState() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.GetPipelineStateInput{ - Name: aws.String("PipelineName"), // Required - } - resp, err := svc.GetPipelineState(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_GetThirdPartyJobDetails() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.GetThirdPartyJobDetailsInput{ - ClientToken: aws.String("ClientToken"), // Required - JobId: aws.String("ThirdPartyJobId"), // Required - } - resp, err := svc.GetThirdPartyJobDetails(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_ListActionTypes() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.ListActionTypesInput{ - ActionOwnerFilter: aws.String("ActionOwner"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListActionTypes(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_ListPipelines() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.ListPipelinesInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPipelines(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PollForJobs() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PollForJobsInput{ - ActionTypeId: &codepipeline.ActionTypeId{ // Required - Category: aws.String("ActionCategory"), // Required - Owner: aws.String("ActionOwner"), // Required - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - }, - MaxBatchSize: aws.Int64(1), - QueryParam: map[string]*string{ - "Key": aws.String("ActionConfigurationQueryableValue"), // Required - // More values... - }, - } - resp, err := svc.PollForJobs(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PollForThirdPartyJobs() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PollForThirdPartyJobsInput{ - ActionTypeId: &codepipeline.ActionTypeId{ // Required - Category: aws.String("ActionCategory"), // Required - Owner: aws.String("ActionOwner"), // Required - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - }, - MaxBatchSize: aws.Int64(1), - } - resp, err := svc.PollForThirdPartyJobs(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutActionRevision() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutActionRevisionInput{ - ActionName: aws.String("ActionName"), // Required - ActionRevision: &codepipeline.ActionRevision{ // Required - Created: aws.Time(time.Now()), // Required - RevisionChangeId: aws.String("RevisionChangeIdentifier"), // Required - RevisionId: aws.String("Revision"), // Required - }, - PipelineName: aws.String("PipelineName"), // Required - StageName: aws.String("StageName"), // Required - } - resp, err := svc.PutActionRevision(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutApprovalResult() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutApprovalResultInput{ - ActionName: aws.String("ActionName"), // Required - PipelineName: aws.String("PipelineName"), // Required - Result: &codepipeline.ApprovalResult{ // Required - Status: aws.String("ApprovalStatus"), // Required - Summary: aws.String("ApprovalSummary"), // Required - }, - StageName: aws.String("StageName"), // Required - Token: aws.String("ApprovalToken"), // Required - } - resp, err := svc.PutApprovalResult(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutJobFailureResult() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutJobFailureResultInput{ - FailureDetails: &codepipeline.FailureDetails{ // Required - Message: aws.String("Message"), // Required - Type: aws.String("FailureType"), // Required - ExternalExecutionId: aws.String("ExecutionId"), - }, - JobId: aws.String("JobId"), // Required - } - resp, err := svc.PutJobFailureResult(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutJobSuccessResult() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutJobSuccessResultInput{ - JobId: aws.String("JobId"), // Required - ContinuationToken: aws.String("ContinuationToken"), - CurrentRevision: &codepipeline.CurrentRevision{ - ChangeIdentifier: aws.String("RevisionChangeIdentifier"), // Required - Revision: aws.String("Revision"), // Required - Created: aws.Time(time.Now()), - RevisionSummary: aws.String("RevisionSummary"), - }, - ExecutionDetails: &codepipeline.ExecutionDetails{ - ExternalExecutionId: aws.String("ExecutionId"), - PercentComplete: aws.Int64(1), - Summary: aws.String("ExecutionSummary"), - }, - } - resp, err := svc.PutJobSuccessResult(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutThirdPartyJobFailureResult() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutThirdPartyJobFailureResultInput{ - ClientToken: aws.String("ClientToken"), // Required - FailureDetails: &codepipeline.FailureDetails{ // Required - Message: aws.String("Message"), // Required - Type: aws.String("FailureType"), // Required - ExternalExecutionId: aws.String("ExecutionId"), - }, - JobId: aws.String("ThirdPartyJobId"), // Required - } - resp, err := svc.PutThirdPartyJobFailureResult(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_PutThirdPartyJobSuccessResult() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.PutThirdPartyJobSuccessResultInput{ - ClientToken: aws.String("ClientToken"), // Required - JobId: aws.String("ThirdPartyJobId"), // Required - ContinuationToken: aws.String("ContinuationToken"), - CurrentRevision: &codepipeline.CurrentRevision{ - ChangeIdentifier: aws.String("RevisionChangeIdentifier"), // Required - Revision: aws.String("Revision"), // Required - Created: aws.Time(time.Now()), - RevisionSummary: aws.String("RevisionSummary"), - }, - ExecutionDetails: &codepipeline.ExecutionDetails{ - ExternalExecutionId: aws.String("ExecutionId"), - PercentComplete: aws.Int64(1), - Summary: aws.String("ExecutionSummary"), - }, - } - resp, err := svc.PutThirdPartyJobSuccessResult(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_RetryStageExecution() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.RetryStageExecutionInput{ - PipelineExecutionId: aws.String("PipelineExecutionId"), // Required - PipelineName: aws.String("PipelineName"), // Required - RetryMode: aws.String("StageRetryMode"), // Required - StageName: aws.String("StageName"), // Required - } - resp, err := svc.RetryStageExecution(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_StartPipelineExecution() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.StartPipelineExecutionInput{ - Name: aws.String("PipelineName"), // Required - } - resp, err := svc.StartPipelineExecution(params) - - if err != nil { - // 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) -} - -func ExampleCodePipeline_UpdatePipeline() { - sess := session.Must(session.NewSession()) - - svc := codepipeline.New(sess) - - params := &codepipeline.UpdatePipelineInput{ - Pipeline: &codepipeline.PipelineDeclaration{ // Required - ArtifactStore: &codepipeline.ArtifactStore{ // Required - Location: aws.String("ArtifactStoreLocation"), // Required - Type: aws.String("ArtifactStoreType"), // Required - EncryptionKey: &codepipeline.EncryptionKey{ - Id: aws.String("EncryptionKeyId"), // Required - Type: aws.String("EncryptionKeyType"), // Required - }, - }, - Name: aws.String("PipelineName"), // Required - RoleArn: aws.String("RoleArn"), // Required - Stages: []*codepipeline.StageDeclaration{ // Required - { // Required - Actions: []*codepipeline.ActionDeclaration{ // Required - { // Required - ActionTypeId: &codepipeline.ActionTypeId{ // Required - Category: aws.String("ActionCategory"), // Required - Owner: aws.String("ActionOwner"), // Required - Provider: aws.String("ActionProvider"), // Required - Version: aws.String("Version"), // Required - }, - Name: aws.String("ActionName"), // Required - Configuration: map[string]*string{ - "Key": aws.String("ActionConfigurationValue"), // Required - // More values... - }, - InputArtifacts: []*codepipeline.InputArtifact{ - { // Required - Name: aws.String("ArtifactName"), // Required - }, - // More values... - }, - OutputArtifacts: []*codepipeline.OutputArtifact{ - { // Required - Name: aws.String("ArtifactName"), // Required - }, - // More values... - }, - RoleArn: aws.String("RoleArn"), - RunOrder: aws.Int64(1), - }, - // More values... - }, - Name: aws.String("StageName"), // Required - Blockers: []*codepipeline.BlockerDeclaration{ - { // Required - Name: aws.String("BlockerName"), // Required - Type: aws.String("BlockerType"), // Required - }, - // More values... - }, - }, - // More values... - }, - Version: aws.Int64(1), - }, - } - resp, err := svc.UpdatePipeline(params) - - if err != nil { - // 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) -} diff --git a/service/codestar/examples_test.go b/service/codestar/examples_test.go deleted file mode 100644 index e9515621764..00000000000 --- a/service/codestar/examples_test.go +++ /dev/null @@ -1,358 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package codestar_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/codestar" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCodeStar_AssociateTeamMember() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.AssociateTeamMemberInput{ - ProjectId: aws.String("ProjectId"), // Required - ProjectRole: aws.String("Role"), // Required - UserArn: aws.String("UserArn"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - RemoteAccessAllowed: aws.Bool(true), - } - resp, err := svc.AssociateTeamMember(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_CreateProject() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.CreateProjectInput{ - Id: aws.String("ProjectId"), // Required - Name: aws.String("ProjectName"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - Description: aws.String("ProjectDescription"), - } - resp, err := svc.CreateProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_CreateUserProfile() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.CreateUserProfileInput{ - DisplayName: aws.String("UserProfileDisplayName"), // Required - EmailAddress: aws.String("Email"), // Required - UserArn: aws.String("UserArn"), // Required - SshPublicKey: aws.String("SshPublicKey"), - } - resp, err := svc.CreateUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_DeleteProject() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.DeleteProjectInput{ - Id: aws.String("ProjectId"), // Required - ClientRequestToken: aws.String("ClientRequestToken"), - DeleteStack: aws.Bool(true), - } - resp, err := svc.DeleteProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_DeleteUserProfile() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.DeleteUserProfileInput{ - UserArn: aws.String("UserArn"), // Required - } - resp, err := svc.DeleteUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_DescribeProject() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.DescribeProjectInput{ - Id: aws.String("ProjectId"), // Required - } - resp, err := svc.DescribeProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_DescribeUserProfile() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.DescribeUserProfileInput{ - UserArn: aws.String("UserArn"), // Required - } - resp, err := svc.DescribeUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_DisassociateTeamMember() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.DisassociateTeamMemberInput{ - ProjectId: aws.String("ProjectId"), // Required - UserArn: aws.String("UserArn"), // Required - } - resp, err := svc.DisassociateTeamMember(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_ListProjects() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.ListProjectsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListProjects(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_ListResources() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.ListResourcesInput{ - ProjectId: aws.String("ProjectId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListResources(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_ListTeamMembers() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.ListTeamMembersInput{ - ProjectId: aws.String("ProjectId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListTeamMembers(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_ListUserProfiles() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.ListUserProfilesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListUserProfiles(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_UpdateProject() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.UpdateProjectInput{ - Id: aws.String("ProjectId"), // Required - Description: aws.String("ProjectDescription"), - Name: aws.String("ProjectName"), - } - resp, err := svc.UpdateProject(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_UpdateTeamMember() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.UpdateTeamMemberInput{ - ProjectId: aws.String("ProjectId"), // Required - UserArn: aws.String("UserArn"), // Required - ProjectRole: aws.String("Role"), - RemoteAccessAllowed: aws.Bool(true), - } - resp, err := svc.UpdateTeamMember(params) - - if err != nil { - // 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) -} - -func ExampleCodeStar_UpdateUserProfile() { - sess := session.Must(session.NewSession()) - - svc := codestar.New(sess) - - params := &codestar.UpdateUserProfileInput{ - UserArn: aws.String("UserArn"), // Required - DisplayName: aws.String("UserProfileDisplayName"), - EmailAddress: aws.String("Email"), - SshPublicKey: aws.String("SshPublicKey"), - } - resp, err := svc.UpdateUserProfile(params) - - if err != nil { - // 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) -} diff --git a/service/cognitoidentity/examples_test.go b/service/cognitoidentity/examples_test.go deleted file mode 100644 index 3c4c537204b..00000000000 --- a/service/cognitoidentity/examples_test.go +++ /dev/null @@ -1,506 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cognitoidentity_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cognitoidentity" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCognitoIdentity_CreateIdentityPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.CreateIdentityPoolInput{ - AllowUnauthenticatedIdentities: aws.Bool(true), // Required - IdentityPoolName: aws.String("IdentityPoolName"), // Required - CognitoIdentityProviders: []*cognitoidentity.Provider{ - { // Required - ClientId: aws.String("ProviderClientId"), - ProviderName: aws.String("ProviderName"), - ServerSideTokenCheck: aws.Bool(true), - }, - // More values... - }, - DeveloperProviderName: aws.String("DeveloperProviderName"), - OpenIdConnectProviderARNs: []*string{ - aws.String("ARNString"), // Required - // More values... - }, - SamlProviderARNs: []*string{ - aws.String("ARNString"), // Required - // More values... - }, - SupportedLoginProviders: map[string]*string{ - "Key": aws.String("IdentityProviderId"), // Required - // More values... - }, - } - resp, err := svc.CreateIdentityPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_DeleteIdentities() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.DeleteIdentitiesInput{ - IdentityIdsToDelete: []*string{ // Required - aws.String("IdentityId"), // Required - // More values... - }, - } - resp, err := svc.DeleteIdentities(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_DeleteIdentityPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.DeleteIdentityPoolInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DeleteIdentityPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_DescribeIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.DescribeIdentityInput{ - IdentityId: aws.String("IdentityId"), // Required - } - resp, err := svc.DescribeIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_DescribeIdentityPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.DescribeIdentityPoolInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DescribeIdentityPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_GetCredentialsForIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.GetCredentialsForIdentityInput{ - IdentityId: aws.String("IdentityId"), // Required - CustomRoleArn: aws.String("ARNString"), - Logins: map[string]*string{ - "Key": aws.String("IdentityProviderToken"), // Required - // More values... - }, - } - resp, err := svc.GetCredentialsForIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_GetId() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.GetIdInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - AccountId: aws.String("AccountId"), - Logins: map[string]*string{ - "Key": aws.String("IdentityProviderToken"), // Required - // More values... - }, - } - resp, err := svc.GetId(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_GetIdentityPoolRoles() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.GetIdentityPoolRolesInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.GetIdentityPoolRoles(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_GetOpenIdToken() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.GetOpenIdTokenInput{ - IdentityId: aws.String("IdentityId"), // Required - Logins: map[string]*string{ - "Key": aws.String("IdentityProviderToken"), // Required - // More values... - }, - } - resp, err := svc.GetOpenIdToken(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_GetOpenIdTokenForDeveloperIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - Logins: map[string]*string{ // Required - "Key": aws.String("IdentityProviderToken"), // Required - // More values... - }, - IdentityId: aws.String("IdentityId"), - TokenDuration: aws.Int64(1), - } - resp, err := svc.GetOpenIdTokenForDeveloperIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_ListIdentities() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.ListIdentitiesInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - MaxResults: aws.Int64(1), // Required - HideDisabled: aws.Bool(true), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.ListIdentities(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_ListIdentityPools() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.ListIdentityPoolsInput{ - MaxResults: aws.Int64(1), // Required - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.ListIdentityPools(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_LookupDeveloperIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.LookupDeveloperIdentityInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"), - IdentityId: aws.String("IdentityId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.LookupDeveloperIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_MergeDeveloperIdentities() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.MergeDeveloperIdentitiesInput{ - DestinationUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required - DeveloperProviderName: aws.String("DeveloperProviderName"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - SourceUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required - } - resp, err := svc.MergeDeveloperIdentities(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_SetIdentityPoolRoles() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.SetIdentityPoolRolesInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - Roles: map[string]*string{ // Required - "Key": aws.String("ARNString"), // Required - // More values... - }, - RoleMappings: map[string]*cognitoidentity.RoleMapping{ - "Key": { // Required - Type: aws.String("RoleMappingType"), // Required - AmbiguousRoleResolution: aws.String("AmbiguousRoleResolutionType"), - RulesConfiguration: &cognitoidentity.RulesConfigurationType{ - Rules: []*cognitoidentity.MappingRule{ // Required - { // Required - Claim: aws.String("ClaimName"), // Required - MatchType: aws.String("MappingRuleMatchType"), // Required - RoleARN: aws.String("ARNString"), // Required - Value: aws.String("ClaimValue"), // Required - }, - // More values... - }, - }, - }, - // More values... - }, - } - resp, err := svc.SetIdentityPoolRoles(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_UnlinkDeveloperIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.UnlinkDeveloperIdentityInput{ - DeveloperProviderName: aws.String("DeveloperProviderName"), // Required - DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.UnlinkDeveloperIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_UnlinkIdentity() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.UnlinkIdentityInput{ - IdentityId: aws.String("IdentityId"), // Required - Logins: map[string]*string{ // Required - "Key": aws.String("IdentityProviderToken"), // Required - // More values... - }, - LoginsToRemove: []*string{ // Required - aws.String("IdentityProviderName"), // Required - // More values... - }, - } - resp, err := svc.UnlinkIdentity(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentity_UpdateIdentityPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentity.New(sess) - - params := &cognitoidentity.IdentityPool{ - AllowUnauthenticatedIdentities: aws.Bool(true), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - IdentityPoolName: aws.String("IdentityPoolName"), // Required - CognitoIdentityProviders: []*cognitoidentity.Provider{ - { // Required - ClientId: aws.String("ProviderClientId"), - ProviderName: aws.String("ProviderName"), - ServerSideTokenCheck: aws.Bool(true), - }, - // More values... - }, - DeveloperProviderName: aws.String("DeveloperProviderName"), - OpenIdConnectProviderARNs: []*string{ - aws.String("ARNString"), // Required - // More values... - }, - SamlProviderARNs: []*string{ - aws.String("ARNString"), // Required - // More values... - }, - SupportedLoginProviders: map[string]*string{ - "Key": aws.String("IdentityProviderId"), // Required - // More values... - }, - } - resp, err := svc.UpdateIdentityPool(params) - - if err != nil { - // 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) -} diff --git a/service/cognitoidentityprovider/examples_test.go b/service/cognitoidentityprovider/examples_test.go deleted file mode 100644 index af0acce6beb..00000000000 --- a/service/cognitoidentityprovider/examples_test.go +++ /dev/null @@ -1,1754 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cognitoidentityprovider_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cognitoidentityprovider" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCognitoIdentityProvider_AddCustomAttributes() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AddCustomAttributesInput{ - CustomAttributes: []*cognitoidentityprovider.SchemaAttributeType{ // Required - { // Required - AttributeDataType: aws.String("AttributeDataType"), - DeveloperOnlyAttribute: aws.Bool(true), - Mutable: aws.Bool(true), - Name: aws.String("CustomAttributeNameType"), - NumberAttributeConstraints: &cognitoidentityprovider.NumberAttributeConstraintsType{ - MaxValue: aws.String("StringType"), - MinValue: aws.String("StringType"), - }, - Required: aws.Bool(true), - StringAttributeConstraints: &cognitoidentityprovider.StringAttributeConstraintsType{ - MaxLength: aws.String("StringType"), - MinLength: aws.String("StringType"), - }, - }, - // More values... - }, - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.AddCustomAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminAddUserToGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminAddUserToGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminAddUserToGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminConfirmSignUp() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminConfirmSignUpInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminConfirmSignUp(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminCreateUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminCreateUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - DesiredDeliveryMediums: []*string{ - aws.String("DeliveryMediumType"), // Required - // More values... - }, - ForceAliasCreation: aws.Bool(true), - MessageAction: aws.String("MessageActionType"), - TemporaryPassword: aws.String("PasswordType"), - UserAttributes: []*cognitoidentityprovider.AttributeType{ - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - ValidationData: []*cognitoidentityprovider.AttributeType{ - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - } - resp, err := svc.AdminCreateUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminDeleteUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminDeleteUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminDeleteUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminDeleteUserAttributes() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminDeleteUserAttributesInput{ - UserAttributeNames: []*string{ // Required - aws.String("AttributeNameType"), // Required - // More values... - }, - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminDeleteUserAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminDisableUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminDisableUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminDisableUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminEnableUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminEnableUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminEnableUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminForgetDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminForgetDeviceInput{ - DeviceKey: aws.String("DeviceKeyType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminForgetDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminGetDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminGetDeviceInput{ - DeviceKey: aws.String("DeviceKeyType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminGetDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminGetUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminGetUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminGetUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminInitiateAuth() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminInitiateAuthInput{ - AuthFlow: aws.String("AuthFlowType"), // Required - ClientId: aws.String("ClientIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - AuthParameters: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - ClientMetadata: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - } - resp, err := svc.AdminInitiateAuth(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminListDevices() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminListDevicesInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - Limit: aws.Int64(1), - PaginationToken: aws.String("SearchPaginationTokenType"), - } - resp, err := svc.AdminListDevices(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminListGroupsForUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminListGroupsForUserInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.AdminListGroupsForUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminRemoveUserFromGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminRemoveUserFromGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminRemoveUserFromGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminResetUserPassword() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminResetUserPasswordInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminResetUserPassword(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminRespondToAuthChallenge() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminRespondToAuthChallengeInput{ - ChallengeName: aws.String("ChallengeNameType"), // Required - ClientId: aws.String("ClientIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - ChallengeResponses: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - Session: aws.String("SessionType"), - } - resp, err := svc.AdminRespondToAuthChallenge(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminSetUserSettings() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminSetUserSettingsInput{ - MFAOptions: []*cognitoidentityprovider.MFAOptionType{ // Required - { // Required - AttributeName: aws.String("AttributeNameType"), - DeliveryMedium: aws.String("DeliveryMediumType"), - }, - // More values... - }, - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminSetUserSettings(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminUpdateDeviceStatus() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminUpdateDeviceStatusInput{ - DeviceKey: aws.String("DeviceKeyType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - DeviceRememberedStatus: aws.String("DeviceRememberedStatusType"), - } - resp, err := svc.AdminUpdateDeviceStatus(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminUpdateUserAttributes() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminUpdateUserAttributesInput{ - UserAttributes: []*cognitoidentityprovider.AttributeType{ // Required - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminUpdateUserAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_AdminUserGlobalSignOut() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.AdminUserGlobalSignOutInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Username: aws.String("UsernameType"), // Required - } - resp, err := svc.AdminUserGlobalSignOut(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ChangePassword() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ChangePasswordInput{ - PreviousPassword: aws.String("PasswordType"), // Required - ProposedPassword: aws.String("PasswordType"), // Required - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.ChangePassword(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ConfirmDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ConfirmDeviceInput{ - AccessToken: aws.String("TokenModelType"), // Required - DeviceKey: aws.String("DeviceKeyType"), // Required - DeviceName: aws.String("DeviceNameType"), - DeviceSecretVerifierConfig: &cognitoidentityprovider.DeviceSecretVerifierConfigType{ - PasswordVerifier: aws.String("StringType"), - Salt: aws.String("StringType"), - }, - } - resp, err := svc.ConfirmDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ConfirmForgotPassword() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ConfirmForgotPasswordInput{ - ClientId: aws.String("ClientIdType"), // Required - ConfirmationCode: aws.String("ConfirmationCodeType"), // Required - Password: aws.String("PasswordType"), // Required - Username: aws.String("UsernameType"), // Required - SecretHash: aws.String("SecretHashType"), - } - resp, err := svc.ConfirmForgotPassword(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ConfirmSignUp() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ConfirmSignUpInput{ - ClientId: aws.String("ClientIdType"), // Required - ConfirmationCode: aws.String("ConfirmationCodeType"), // Required - Username: aws.String("UsernameType"), // Required - ForceAliasCreation: aws.Bool(true), - SecretHash: aws.String("SecretHashType"), - } - resp, err := svc.ConfirmSignUp(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_CreateGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.CreateGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Description: aws.String("DescriptionType"), - Precedence: aws.Int64(1), - RoleArn: aws.String("ArnType"), - } - resp, err := svc.CreateGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_CreateUserImportJob() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.CreateUserImportJobInput{ - CloudWatchLogsRoleArn: aws.String("ArnType"), // Required - JobName: aws.String("UserImportJobNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.CreateUserImportJob(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_CreateUserPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.CreateUserPoolInput{ - PoolName: aws.String("UserPoolNameType"), // Required - AdminCreateUserConfig: &cognitoidentityprovider.AdminCreateUserConfigType{ - AllowAdminCreateUserOnly: aws.Bool(true), - InviteMessageTemplate: &cognitoidentityprovider.MessageTemplateType{ - EmailMessage: aws.String("EmailVerificationMessageType"), - EmailSubject: aws.String("EmailVerificationSubjectType"), - SMSMessage: aws.String("SmsVerificationMessageType"), - }, - UnusedAccountValidityDays: aws.Int64(1), - }, - AliasAttributes: []*string{ - aws.String("AliasAttributeType"), // Required - // More values... - }, - AutoVerifiedAttributes: []*string{ - aws.String("VerifiedAttributeType"), // Required - // More values... - }, - DeviceConfiguration: &cognitoidentityprovider.DeviceConfigurationType{ - ChallengeRequiredOnNewDevice: aws.Bool(true), - DeviceOnlyRememberedOnUserPrompt: aws.Bool(true), - }, - EmailConfiguration: &cognitoidentityprovider.EmailConfigurationType{ - ReplyToEmailAddress: aws.String("EmailAddressType"), - SourceArn: aws.String("ArnType"), - }, - EmailVerificationMessage: aws.String("EmailVerificationMessageType"), - EmailVerificationSubject: aws.String("EmailVerificationSubjectType"), - LambdaConfig: &cognitoidentityprovider.LambdaConfigType{ - CreateAuthChallenge: aws.String("ArnType"), - CustomMessage: aws.String("ArnType"), - DefineAuthChallenge: aws.String("ArnType"), - PostAuthentication: aws.String("ArnType"), - PostConfirmation: aws.String("ArnType"), - PreAuthentication: aws.String("ArnType"), - PreSignUp: aws.String("ArnType"), - VerifyAuthChallengeResponse: aws.String("ArnType"), - }, - MfaConfiguration: aws.String("UserPoolMfaType"), - Policies: &cognitoidentityprovider.UserPoolPolicyType{ - PasswordPolicy: &cognitoidentityprovider.PasswordPolicyType{ - MinimumLength: aws.Int64(1), - RequireLowercase: aws.Bool(true), - RequireNumbers: aws.Bool(true), - RequireSymbols: aws.Bool(true), - RequireUppercase: aws.Bool(true), - }, - }, - Schema: []*cognitoidentityprovider.SchemaAttributeType{ - { // Required - AttributeDataType: aws.String("AttributeDataType"), - DeveloperOnlyAttribute: aws.Bool(true), - Mutable: aws.Bool(true), - Name: aws.String("CustomAttributeNameType"), - NumberAttributeConstraints: &cognitoidentityprovider.NumberAttributeConstraintsType{ - MaxValue: aws.String("StringType"), - MinValue: aws.String("StringType"), - }, - Required: aws.Bool(true), - StringAttributeConstraints: &cognitoidentityprovider.StringAttributeConstraintsType{ - MaxLength: aws.String("StringType"), - MinLength: aws.String("StringType"), - }, - }, - // More values... - }, - SmsAuthenticationMessage: aws.String("SmsVerificationMessageType"), - SmsConfiguration: &cognitoidentityprovider.SmsConfigurationType{ - SnsCallerArn: aws.String("ArnType"), // Required - ExternalId: aws.String("StringType"), - }, - SmsVerificationMessage: aws.String("SmsVerificationMessageType"), - UserPoolTags: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - } - resp, err := svc.CreateUserPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_CreateUserPoolClient() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.CreateUserPoolClientInput{ - ClientName: aws.String("ClientNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - ExplicitAuthFlows: []*string{ - aws.String("ExplicitAuthFlowsType"), // Required - // More values... - }, - GenerateSecret: aws.Bool(true), - ReadAttributes: []*string{ - aws.String("ClientPermissionType"), // Required - // More values... - }, - RefreshTokenValidity: aws.Int64(1), - WriteAttributes: []*string{ - aws.String("ClientPermissionType"), // Required - // More values... - }, - } - resp, err := svc.CreateUserPoolClient(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DeleteGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DeleteGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DeleteGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DeleteUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DeleteUserInput{ - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.DeleteUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DeleteUserAttributes() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DeleteUserAttributesInput{ - UserAttributeNames: []*string{ // Required - aws.String("AttributeNameType"), // Required - // More values... - }, - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.DeleteUserAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DeleteUserPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DeleteUserPoolInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DeleteUserPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DeleteUserPoolClient() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DeleteUserPoolClientInput{ - ClientId: aws.String("ClientIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DeleteUserPoolClient(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DescribeUserImportJob() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DescribeUserImportJobInput{ - JobId: aws.String("UserImportJobIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DescribeUserImportJob(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DescribeUserPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DescribeUserPoolInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DescribeUserPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_DescribeUserPoolClient() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.DescribeUserPoolClientInput{ - ClientId: aws.String("ClientIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.DescribeUserPoolClient(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ForgetDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ForgetDeviceInput{ - DeviceKey: aws.String("DeviceKeyType"), // Required - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.ForgetDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ForgotPassword() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ForgotPasswordInput{ - ClientId: aws.String("ClientIdType"), // Required - Username: aws.String("UsernameType"), // Required - SecretHash: aws.String("SecretHashType"), - } - resp, err := svc.ForgotPassword(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GetCSVHeader() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GetCSVHeaderInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.GetCSVHeader(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GetDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GetDeviceInput{ - DeviceKey: aws.String("DeviceKeyType"), // Required - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.GetDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GetGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GetGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.GetGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GetUser() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GetUserInput{ - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.GetUser(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GetUserAttributeVerificationCode() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GetUserAttributeVerificationCodeInput{ - AttributeName: aws.String("AttributeNameType"), // Required - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.GetUserAttributeVerificationCode(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_GlobalSignOut() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.GlobalSignOutInput{ - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.GlobalSignOut(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_InitiateAuth() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.InitiateAuthInput{ - AuthFlow: aws.String("AuthFlowType"), // Required - ClientId: aws.String("ClientIdType"), // Required - AuthParameters: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - ClientMetadata: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - } - resp, err := svc.InitiateAuth(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListDevices() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListDevicesInput{ - AccessToken: aws.String("TokenModelType"), // Required - Limit: aws.Int64(1), - PaginationToken: aws.String("SearchPaginationTokenType"), - } - resp, err := svc.ListDevices(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListGroups() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListGroupsInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.ListGroups(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListUserImportJobs() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListUserImportJobsInput{ - MaxResults: aws.Int64(1), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - PaginationToken: aws.String("PaginationKeyType"), - } - resp, err := svc.ListUserImportJobs(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListUserPoolClients() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListUserPoolClientsInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.ListUserPoolClients(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListUserPools() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListUserPoolsInput{ - MaxResults: aws.Int64(1), // Required - NextToken: aws.String("PaginationKeyType"), - } - resp, err := svc.ListUserPools(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListUsers() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListUsersInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - AttributesToGet: []*string{ - aws.String("AttributeNameType"), // Required - // More values... - }, - Filter: aws.String("UserFilterType"), - Limit: aws.Int64(1), - PaginationToken: aws.String("SearchPaginationTokenType"), - } - resp, err := svc.ListUsers(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ListUsersInGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ListUsersInGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("PaginationKey"), - } - resp, err := svc.ListUsersInGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_ResendConfirmationCode() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.ResendConfirmationCodeInput{ - ClientId: aws.String("ClientIdType"), // Required - Username: aws.String("UsernameType"), // Required - SecretHash: aws.String("SecretHashType"), - } - resp, err := svc.ResendConfirmationCode(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_RespondToAuthChallenge() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.RespondToAuthChallengeInput{ - ChallengeName: aws.String("ChallengeNameType"), // Required - ClientId: aws.String("ClientIdType"), // Required - ChallengeResponses: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - Session: aws.String("SessionType"), - } - resp, err := svc.RespondToAuthChallenge(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_SetUserSettings() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.SetUserSettingsInput{ - AccessToken: aws.String("TokenModelType"), // Required - MFAOptions: []*cognitoidentityprovider.MFAOptionType{ // Required - { // Required - AttributeName: aws.String("AttributeNameType"), - DeliveryMedium: aws.String("DeliveryMediumType"), - }, - // More values... - }, - } - resp, err := svc.SetUserSettings(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_SignUp() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.SignUpInput{ - ClientId: aws.String("ClientIdType"), // Required - Password: aws.String("PasswordType"), // Required - Username: aws.String("UsernameType"), // Required - SecretHash: aws.String("SecretHashType"), - UserAttributes: []*cognitoidentityprovider.AttributeType{ - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - ValidationData: []*cognitoidentityprovider.AttributeType{ - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - } - resp, err := svc.SignUp(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_StartUserImportJob() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.StartUserImportJobInput{ - JobId: aws.String("UserImportJobIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.StartUserImportJob(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_StopUserImportJob() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.StopUserImportJobInput{ - JobId: aws.String("UserImportJobIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - } - resp, err := svc.StopUserImportJob(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_UpdateDeviceStatus() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.UpdateDeviceStatusInput{ - AccessToken: aws.String("TokenModelType"), // Required - DeviceKey: aws.String("DeviceKeyType"), // Required - DeviceRememberedStatus: aws.String("DeviceRememberedStatusType"), - } - resp, err := svc.UpdateDeviceStatus(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_UpdateGroup() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.UpdateGroupInput{ - GroupName: aws.String("GroupNameType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - Description: aws.String("DescriptionType"), - Precedence: aws.Int64(1), - RoleArn: aws.String("ArnType"), - } - resp, err := svc.UpdateGroup(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_UpdateUserAttributes() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.UpdateUserAttributesInput{ - UserAttributes: []*cognitoidentityprovider.AttributeType{ // Required - { // Required - Name: aws.String("AttributeNameType"), // Required - Value: aws.String("AttributeValueType"), - }, - // More values... - }, - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.UpdateUserAttributes(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_UpdateUserPool() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.UpdateUserPoolInput{ - UserPoolId: aws.String("UserPoolIdType"), // Required - AdminCreateUserConfig: &cognitoidentityprovider.AdminCreateUserConfigType{ - AllowAdminCreateUserOnly: aws.Bool(true), - InviteMessageTemplate: &cognitoidentityprovider.MessageTemplateType{ - EmailMessage: aws.String("EmailVerificationMessageType"), - EmailSubject: aws.String("EmailVerificationSubjectType"), - SMSMessage: aws.String("SmsVerificationMessageType"), - }, - UnusedAccountValidityDays: aws.Int64(1), - }, - AutoVerifiedAttributes: []*string{ - aws.String("VerifiedAttributeType"), // Required - // More values... - }, - DeviceConfiguration: &cognitoidentityprovider.DeviceConfigurationType{ - ChallengeRequiredOnNewDevice: aws.Bool(true), - DeviceOnlyRememberedOnUserPrompt: aws.Bool(true), - }, - EmailConfiguration: &cognitoidentityprovider.EmailConfigurationType{ - ReplyToEmailAddress: aws.String("EmailAddressType"), - SourceArn: aws.String("ArnType"), - }, - EmailVerificationMessage: aws.String("EmailVerificationMessageType"), - EmailVerificationSubject: aws.String("EmailVerificationSubjectType"), - LambdaConfig: &cognitoidentityprovider.LambdaConfigType{ - CreateAuthChallenge: aws.String("ArnType"), - CustomMessage: aws.String("ArnType"), - DefineAuthChallenge: aws.String("ArnType"), - PostAuthentication: aws.String("ArnType"), - PostConfirmation: aws.String("ArnType"), - PreAuthentication: aws.String("ArnType"), - PreSignUp: aws.String("ArnType"), - VerifyAuthChallengeResponse: aws.String("ArnType"), - }, - MfaConfiguration: aws.String("UserPoolMfaType"), - Policies: &cognitoidentityprovider.UserPoolPolicyType{ - PasswordPolicy: &cognitoidentityprovider.PasswordPolicyType{ - MinimumLength: aws.Int64(1), - RequireLowercase: aws.Bool(true), - RequireNumbers: aws.Bool(true), - RequireSymbols: aws.Bool(true), - RequireUppercase: aws.Bool(true), - }, - }, - SmsAuthenticationMessage: aws.String("SmsVerificationMessageType"), - SmsConfiguration: &cognitoidentityprovider.SmsConfigurationType{ - SnsCallerArn: aws.String("ArnType"), // Required - ExternalId: aws.String("StringType"), - }, - SmsVerificationMessage: aws.String("SmsVerificationMessageType"), - UserPoolTags: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - } - resp, err := svc.UpdateUserPool(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_UpdateUserPoolClient() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.UpdateUserPoolClientInput{ - ClientId: aws.String("ClientIdType"), // Required - UserPoolId: aws.String("UserPoolIdType"), // Required - ClientName: aws.String("ClientNameType"), - ExplicitAuthFlows: []*string{ - aws.String("ExplicitAuthFlowsType"), // Required - // More values... - }, - ReadAttributes: []*string{ - aws.String("ClientPermissionType"), // Required - // More values... - }, - RefreshTokenValidity: aws.Int64(1), - WriteAttributes: []*string{ - aws.String("ClientPermissionType"), // Required - // More values... - }, - } - resp, err := svc.UpdateUserPoolClient(params) - - if err != nil { - // 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) -} - -func ExampleCognitoIdentityProvider_VerifyUserAttribute() { - sess := session.Must(session.NewSession()) - - svc := cognitoidentityprovider.New(sess) - - params := &cognitoidentityprovider.VerifyUserAttributeInput{ - AttributeName: aws.String("AttributeNameType"), // Required - Code: aws.String("ConfirmationCodeType"), // Required - AccessToken: aws.String("TokenModelType"), - } - resp, err := svc.VerifyUserAttribute(params) - - if err != nil { - // 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) -} diff --git a/service/cognitosync/examples_test.go b/service/cognitosync/examples_test.go deleted file mode 100644 index 5c980d777b3..00000000000 --- a/service/cognitosync/examples_test.go +++ /dev/null @@ -1,428 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package cognitosync_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cognitosync" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCognitoSync_BulkPublish() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.BulkPublishInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.BulkPublish(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_DeleteDataset() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.DeleteDatasetInput{ - DatasetName: aws.String("DatasetName"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DeleteDataset(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_DescribeDataset() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.DescribeDatasetInput{ - DatasetName: aws.String("DatasetName"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DescribeDataset(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_DescribeIdentityPoolUsage() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.DescribeIdentityPoolUsageInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DescribeIdentityPoolUsage(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_DescribeIdentityUsage() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.DescribeIdentityUsageInput{ - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.DescribeIdentityUsage(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_GetBulkPublishDetails() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.GetBulkPublishDetailsInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.GetBulkPublishDetails(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_GetCognitoEvents() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.GetCognitoEventsInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.GetCognitoEvents(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_GetIdentityPoolConfiguration() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.GetIdentityPoolConfigurationInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.GetIdentityPoolConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_ListDatasets() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.ListDatasetsInput{ - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListDatasets(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_ListIdentityPoolUsage() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.ListIdentityPoolUsageInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListIdentityPoolUsage(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_ListRecords() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.ListRecordsInput{ - DatasetName: aws.String("DatasetName"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - LastSyncCount: aws.Int64(1), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - SyncSessionToken: aws.String("SyncSessionToken"), - } - resp, err := svc.ListRecords(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_RegisterDevice() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.RegisterDeviceInput{ - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - Platform: aws.String("Platform"), // Required - Token: aws.String("PushToken"), // Required - } - resp, err := svc.RegisterDevice(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_SetCognitoEvents() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.SetCognitoEventsInput{ - Events: map[string]*string{ // Required - "Key": aws.String("LambdaFunctionArn"), // Required - // More values... - }, - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.SetCognitoEvents(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_SetIdentityPoolConfiguration() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.SetIdentityPoolConfigurationInput{ - IdentityPoolId: aws.String("IdentityPoolId"), // Required - CognitoStreams: &cognitosync.CognitoStreams{ - RoleArn: aws.String("AssumeRoleArn"), - StreamName: aws.String("StreamName"), - StreamingStatus: aws.String("StreamingStatus"), - }, - PushSync: &cognitosync.PushSync{ - ApplicationArns: []*string{ - aws.String("ApplicationArn"), // Required - // More values... - }, - RoleArn: aws.String("AssumeRoleArn"), - }, - } - resp, err := svc.SetIdentityPoolConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_SubscribeToDataset() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.SubscribeToDatasetInput{ - DatasetName: aws.String("DatasetName"), // Required - DeviceId: aws.String("DeviceId"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.SubscribeToDataset(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_UnsubscribeFromDataset() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.UnsubscribeFromDatasetInput{ - DatasetName: aws.String("DatasetName"), // Required - DeviceId: aws.String("DeviceId"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - } - resp, err := svc.UnsubscribeFromDataset(params) - - if err != nil { - // 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) -} - -func ExampleCognitoSync_UpdateRecords() { - sess := session.Must(session.NewSession()) - - svc := cognitosync.New(sess) - - params := &cognitosync.UpdateRecordsInput{ - DatasetName: aws.String("DatasetName"), // Required - IdentityId: aws.String("IdentityId"), // Required - IdentityPoolId: aws.String("IdentityPoolId"), // Required - SyncSessionToken: aws.String("SyncSessionToken"), // Required - ClientContext: aws.String("ClientContext"), - DeviceId: aws.String("DeviceId"), - RecordPatches: []*cognitosync.RecordPatch{ - { // Required - Key: aws.String("RecordKey"), // Required - Op: aws.String("Operation"), // Required - SyncCount: aws.Int64(1), // Required - DeviceLastModifiedDate: aws.Time(time.Now()), - Value: aws.String("RecordValue"), - }, - // More values... - }, - } - resp, err := svc.UpdateRecords(params) - - if err != nil { - // 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) -} diff --git a/service/configservice/examples_test.go b/service/configservice/examples_test.go deleted file mode 100644 index 94cd56398d4..00000000000 --- a/service/configservice/examples_test.go +++ /dev/null @@ -1,687 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package configservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/configservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleConfigService_DeleteConfigRule() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DeleteConfigRuleInput{ - ConfigRuleName: aws.String("StringWithCharLimit64"), // Required - } - resp, err := svc.DeleteConfigRule(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DeleteConfigurationRecorder() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DeleteConfigurationRecorderInput{ - ConfigurationRecorderName: aws.String("RecorderName"), // Required - } - resp, err := svc.DeleteConfigurationRecorder(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DeleteDeliveryChannel() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DeleteDeliveryChannelInput{ - DeliveryChannelName: aws.String("ChannelName"), // Required - } - resp, err := svc.DeleteDeliveryChannel(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DeleteEvaluationResults() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DeleteEvaluationResultsInput{ - ConfigRuleName: aws.String("StringWithCharLimit64"), // Required - } - resp, err := svc.DeleteEvaluationResults(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DeliverConfigSnapshot() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DeliverConfigSnapshotInput{ - DeliveryChannelName: aws.String("ChannelName"), // Required - } - resp, err := svc.DeliverConfigSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeComplianceByConfigRule() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeComplianceByConfigRuleInput{ - ComplianceTypes: []*string{ - aws.String("ComplianceType"), // Required - // More values... - }, - ConfigRuleNames: []*string{ - aws.String("StringWithCharLimit64"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.DescribeComplianceByConfigRule(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeComplianceByResource() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeComplianceByResourceInput{ - ComplianceTypes: []*string{ - aws.String("ComplianceType"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - ResourceId: aws.String("StringWithCharLimit256"), - ResourceType: aws.String("StringWithCharLimit256"), - } - resp, err := svc.DescribeComplianceByResource(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeConfigRuleEvaluationStatus() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeConfigRuleEvaluationStatusInput{ - ConfigRuleNames: []*string{ - aws.String("StringWithCharLimit64"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeConfigRuleEvaluationStatus(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeConfigRules() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeConfigRulesInput{ - ConfigRuleNames: []*string{ - aws.String("StringWithCharLimit64"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.DescribeConfigRules(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeConfigurationRecorderStatus() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeConfigurationRecorderStatusInput{ - ConfigurationRecorderNames: []*string{ - aws.String("RecorderName"), // Required - // More values... - }, - } - resp, err := svc.DescribeConfigurationRecorderStatus(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeConfigurationRecorders() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeConfigurationRecordersInput{ - ConfigurationRecorderNames: []*string{ - aws.String("RecorderName"), // Required - // More values... - }, - } - resp, err := svc.DescribeConfigurationRecorders(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeDeliveryChannelStatus() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeDeliveryChannelStatusInput{ - DeliveryChannelNames: []*string{ - aws.String("ChannelName"), // Required - // More values... - }, - } - resp, err := svc.DescribeDeliveryChannelStatus(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_DescribeDeliveryChannels() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.DescribeDeliveryChannelsInput{ - DeliveryChannelNames: []*string{ - aws.String("ChannelName"), // Required - // More values... - }, - } - resp, err := svc.DescribeDeliveryChannels(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_GetComplianceDetailsByConfigRule() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.GetComplianceDetailsByConfigRuleInput{ - ConfigRuleName: aws.String("StringWithCharLimit64"), // Required - ComplianceTypes: []*string{ - aws.String("ComplianceType"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetComplianceDetailsByConfigRule(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_GetComplianceDetailsByResource() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.GetComplianceDetailsByResourceInput{ - ResourceId: aws.String("StringWithCharLimit256"), // Required - ResourceType: aws.String("StringWithCharLimit256"), // Required - ComplianceTypes: []*string{ - aws.String("ComplianceType"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.GetComplianceDetailsByResource(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_GetComplianceSummaryByConfigRule() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - var params *configservice.GetComplianceSummaryByConfigRuleInput - resp, err := svc.GetComplianceSummaryByConfigRule(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_GetComplianceSummaryByResourceType() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.GetComplianceSummaryByResourceTypeInput{ - ResourceTypes: []*string{ - aws.String("StringWithCharLimit256"), // Required - // More values... - }, - } - resp, err := svc.GetComplianceSummaryByResourceType(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_GetResourceConfigHistory() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.GetResourceConfigHistoryInput{ - ResourceId: aws.String("ResourceId"), // Required - ResourceType: aws.String("ResourceType"), // Required - ChronologicalOrder: aws.String("ChronologicalOrder"), - EarlierTime: aws.Time(time.Now()), - LaterTime: aws.Time(time.Now()), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetResourceConfigHistory(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_ListDiscoveredResources() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.ListDiscoveredResourcesInput{ - ResourceType: aws.String("ResourceType"), // Required - IncludeDeletedResources: aws.Bool(true), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - ResourceIds: []*string{ - aws.String("ResourceId"), // Required - // More values... - }, - ResourceName: aws.String("ResourceName"), - } - resp, err := svc.ListDiscoveredResources(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_PutConfigRule() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.PutConfigRuleInput{ - ConfigRule: &configservice.ConfigRule{ // Required - Source: &configservice.Source{ // Required - Owner: aws.String("Owner"), // Required - SourceIdentifier: aws.String("StringWithCharLimit256"), // Required - SourceDetails: []*configservice.SourceDetail{ - { // Required - EventSource: aws.String("EventSource"), - MaximumExecutionFrequency: aws.String("MaximumExecutionFrequency"), - MessageType: aws.String("MessageType"), - }, - // More values... - }, - }, - ConfigRuleArn: aws.String("String"), - ConfigRuleId: aws.String("String"), - ConfigRuleName: aws.String("StringWithCharLimit64"), - ConfigRuleState: aws.String("ConfigRuleState"), - Description: aws.String("EmptiableStringWithCharLimit256"), - InputParameters: aws.String("StringWithCharLimit1024"), - MaximumExecutionFrequency: aws.String("MaximumExecutionFrequency"), - Scope: &configservice.Scope{ - ComplianceResourceId: aws.String("StringWithCharLimit256"), - ComplianceResourceTypes: []*string{ - aws.String("StringWithCharLimit256"), // Required - // More values... - }, - TagKey: aws.String("StringWithCharLimit128"), - TagValue: aws.String("StringWithCharLimit256"), - }, - }, - } - resp, err := svc.PutConfigRule(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_PutConfigurationRecorder() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.PutConfigurationRecorderInput{ - ConfigurationRecorder: &configservice.ConfigurationRecorder{ // Required - Name: aws.String("RecorderName"), - RecordingGroup: &configservice.RecordingGroup{ - AllSupported: aws.Bool(true), - IncludeGlobalResourceTypes: aws.Bool(true), - ResourceTypes: []*string{ - aws.String("ResourceType"), // Required - // More values... - }, - }, - RoleARN: aws.String("String"), - }, - } - resp, err := svc.PutConfigurationRecorder(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_PutDeliveryChannel() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.PutDeliveryChannelInput{ - DeliveryChannel: &configservice.DeliveryChannel{ // Required - ConfigSnapshotDeliveryProperties: &configservice.ConfigSnapshotDeliveryProperties{ - DeliveryFrequency: aws.String("MaximumExecutionFrequency"), - }, - Name: aws.String("ChannelName"), - S3BucketName: aws.String("String"), - S3KeyPrefix: aws.String("String"), - SnsTopicARN: aws.String("String"), - }, - } - resp, err := svc.PutDeliveryChannel(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_PutEvaluations() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.PutEvaluationsInput{ - ResultToken: aws.String("String"), // Required - Evaluations: []*configservice.Evaluation{ - { // Required - ComplianceResourceId: aws.String("StringWithCharLimit256"), // Required - ComplianceResourceType: aws.String("StringWithCharLimit256"), // Required - ComplianceType: aws.String("ComplianceType"), // Required - OrderingTimestamp: aws.Time(time.Now()), // Required - Annotation: aws.String("StringWithCharLimit256"), - }, - // More values... - }, - TestMode: aws.Bool(true), - } - resp, err := svc.PutEvaluations(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_StartConfigRulesEvaluation() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.StartConfigRulesEvaluationInput{ - ConfigRuleNames: []*string{ - aws.String("StringWithCharLimit64"), // Required - // More values... - }, - } - resp, err := svc.StartConfigRulesEvaluation(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_StartConfigurationRecorder() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.StartConfigurationRecorderInput{ - ConfigurationRecorderName: aws.String("RecorderName"), // Required - } - resp, err := svc.StartConfigurationRecorder(params) - - if err != nil { - // 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) -} - -func ExampleConfigService_StopConfigurationRecorder() { - sess := session.Must(session.NewSession()) - - svc := configservice.New(sess) - - params := &configservice.StopConfigurationRecorderInput{ - ConfigurationRecorderName: aws.String("RecorderName"), // Required - } - resp, err := svc.StopConfigurationRecorder(params) - - if err != nil { - // 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) -} diff --git a/service/costandusagereportservice/examples_test.go b/service/costandusagereportservice/examples_test.go deleted file mode 100644 index 754b031d8ba..00000000000 --- a/service/costandusagereportservice/examples_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package costandusagereportservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/costandusagereportservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleCostandUsageReportService_DeleteReportDefinition() { - sess := session.Must(session.NewSession()) - - svc := costandusagereportservice.New(sess) - - params := &costandusagereportservice.DeleteReportDefinitionInput{ - ReportName: aws.String("ReportName"), - } - resp, err := svc.DeleteReportDefinition(params) - - if err != nil { - // 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) -} - -func ExampleCostandUsageReportService_DescribeReportDefinitions() { - sess := session.Must(session.NewSession()) - - svc := costandusagereportservice.New(sess) - - params := &costandusagereportservice.DescribeReportDefinitionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("GenericString"), - } - resp, err := svc.DescribeReportDefinitions(params) - - if err != nil { - // 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) -} - -func ExampleCostandUsageReportService_PutReportDefinition() { - sess := session.Must(session.NewSession()) - - svc := costandusagereportservice.New(sess) - - params := &costandusagereportservice.PutReportDefinitionInput{ - ReportDefinition: &costandusagereportservice.ReportDefinition{ // Required - AdditionalSchemaElements: []*string{ // Required - aws.String("SchemaElement"), // Required - // More values... - }, - Compression: aws.String("CompressionFormat"), // Required - Format: aws.String("ReportFormat"), // Required - ReportName: aws.String("ReportName"), // Required - S3Bucket: aws.String("S3Bucket"), // Required - S3Prefix: aws.String("S3Prefix"), // Required - S3Region: aws.String("AWSRegion"), // Required - TimeUnit: aws.String("TimeUnit"), // Required - AdditionalArtifacts: []*string{ - aws.String("AdditionalArtifact"), // Required - // More values... - }, - }, - } - resp, err := svc.PutReportDefinition(params) - - if err != nil { - // 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) -} diff --git a/service/databasemigrationservice/examples_test.go b/service/databasemigrationservice/examples_test.go deleted file mode 100644 index c56bc6f5c3a..00000000000 --- a/service/databasemigrationservice/examples_test.go +++ /dev/null @@ -1,1176 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package databasemigrationservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/databasemigrationservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDatabaseMigrationService_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.AddTagsToResourceInput{ - ResourceArn: aws.String("String"), // Required - Tags: []*databasemigrationservice.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_CreateEndpoint() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.CreateEndpointInput{ - EndpointIdentifier: aws.String("String"), // Required - EndpointType: aws.String("ReplicationEndpointTypeValue"), // Required - EngineName: aws.String("String"), // Required - CertificateArn: aws.String("String"), - DatabaseName: aws.String("String"), - DynamoDbSettings: &databasemigrationservice.DynamoDbSettings{ - ServiceAccessRoleArn: aws.String("String"), // Required - }, - ExtraConnectionAttributes: aws.String("String"), - KmsKeyId: aws.String("String"), - MongoDbSettings: &databasemigrationservice.MongoDbSettings{ - AuthMechanism: aws.String("AuthMechanismValue"), - AuthSource: aws.String("String"), - AuthType: aws.String("AuthTypeValue"), - DatabaseName: aws.String("String"), - DocsToInvestigate: aws.String("String"), - ExtractDocId: aws.String("String"), - NestingLevel: aws.String("NestingLevelValue"), - Password: aws.String("SecretString"), - Port: aws.Int64(1), - ServerName: aws.String("String"), - Username: aws.String("String"), - }, - Password: aws.String("SecretString"), - Port: aws.Int64(1), - S3Settings: &databasemigrationservice.S3Settings{ - BucketFolder: aws.String("String"), - BucketName: aws.String("String"), - CompressionType: aws.String("CompressionTypeValue"), - CsvDelimiter: aws.String("String"), - CsvRowDelimiter: aws.String("String"), - ExternalTableDefinition: aws.String("String"), - ServiceAccessRoleArn: aws.String("String"), - }, - ServerName: aws.String("String"), - SslMode: aws.String("DmsSslModeValue"), - Tags: []*databasemigrationservice.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - Username: aws.String("String"), - } - resp, err := svc.CreateEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_CreateEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.CreateEventSubscriptionInput{ - SnsTopicArn: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceType: aws.String("String"), - Tags: []*databasemigrationservice.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_CreateReplicationInstance() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.CreateReplicationInstanceInput{ - ReplicationInstanceClass: aws.String("String"), // Required - ReplicationInstanceIdentifier: aws.String("String"), // Required - AllocatedStorage: aws.Int64(1), - AutoMinorVersionUpgrade: aws.Bool(true), - AvailabilityZone: aws.String("String"), - EngineVersion: aws.String("String"), - KmsKeyId: aws.String("String"), - MultiAZ: aws.Bool(true), - PreferredMaintenanceWindow: aws.String("String"), - PubliclyAccessible: aws.Bool(true), - ReplicationSubnetGroupIdentifier: aws.String("String"), - Tags: []*databasemigrationservice.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateReplicationInstance(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_CreateReplicationSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.CreateReplicationSubnetGroupInput{ - ReplicationSubnetGroupDescription: aws.String("String"), // Required - ReplicationSubnetGroupIdentifier: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Tags: []*databasemigrationservice.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateReplicationSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_CreateReplicationTask() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.CreateReplicationTaskInput{ - MigrationType: aws.String("MigrationTypeValue"), // Required - ReplicationInstanceArn: aws.String("String"), // Required - ReplicationTaskIdentifier: aws.String("String"), // Required - SourceEndpointArn: aws.String("String"), // Required - TableMappings: aws.String("String"), // Required - TargetEndpointArn: aws.String("String"), // Required - CdcStartTime: aws.Time(time.Now()), - ReplicationTaskSettings: aws.String("String"), - Tags: []*databasemigrationservice.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateReplicationTask(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteCertificate() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteCertificateInput{ - CertificateArn: aws.String("String"), // Required - } - resp, err := svc.DeleteCertificate(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteEndpoint() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteEndpointInput{ - EndpointArn: aws.String("String"), // Required - } - resp, err := svc.DeleteEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - } - resp, err := svc.DeleteEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteReplicationInstance() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteReplicationInstanceInput{ - ReplicationInstanceArn: aws.String("String"), // Required - } - resp, err := svc.DeleteReplicationInstance(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteReplicationSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteReplicationSubnetGroupInput{ - ReplicationSubnetGroupIdentifier: aws.String("String"), // Required - } - resp, err := svc.DeleteReplicationSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DeleteReplicationTask() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DeleteReplicationTaskInput{ - ReplicationTaskArn: aws.String("String"), // Required - } - resp, err := svc.DeleteReplicationTask(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeAccountAttributes() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - var params *databasemigrationservice.DescribeAccountAttributesInput - resp, err := svc.DescribeAccountAttributes(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeCertificates() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeCertificatesInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeCertificates(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeConnections() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeConnectionsInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeConnections(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeEndpointTypes() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeEndpointTypesInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeEndpointTypes(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeEndpoints() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeEndpointsInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeEndpoints(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeEventCategories() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeEventCategoriesInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - SourceType: aws.String("String"), - } - resp, err := svc.DescribeEventCategories(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeEventSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeEventSubscriptionsInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SubscriptionName: aws.String("String"), - } - resp, err := svc.DescribeEventSubscriptions(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeEventsInput{ - Duration: aws.Int64(1), - EndTime: aws.Time(time.Now()), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SourceIdentifier: aws.String("String"), - SourceType: aws.String("SourceType"), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.DescribeEvents(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeOrderableReplicationInstances() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeOrderableReplicationInstancesInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeOrderableReplicationInstances(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeRefreshSchemasStatus() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeRefreshSchemasStatusInput{ - EndpointArn: aws.String("String"), // Required - } - resp, err := svc.DescribeRefreshSchemasStatus(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeReplicationInstances() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeReplicationInstancesInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeReplicationInstances(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeReplicationSubnetGroups() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeReplicationSubnetGroupsInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeReplicationSubnetGroups(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeReplicationTasks() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeReplicationTasksInput{ - Filters: []*databasemigrationservice.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeReplicationTasks(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeSchemas() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeSchemasInput{ - EndpointArn: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeSchemas(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_DescribeTableStatistics() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.DescribeTableStatisticsInput{ - ReplicationTaskArn: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeTableStatistics(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ImportCertificate() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ImportCertificateInput{ - CertificateIdentifier: aws.String("String"), // Required - CertificatePem: aws.String("String"), - CertificateWallet: []byte("PAYLOAD"), - } - resp, err := svc.ImportCertificate(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ListTagsForResourceInput{ - ResourceArn: aws.String("String"), // Required - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ModifyEndpoint() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ModifyEndpointInput{ - EndpointArn: aws.String("String"), // Required - CertificateArn: aws.String("String"), - DatabaseName: aws.String("String"), - DynamoDbSettings: &databasemigrationservice.DynamoDbSettings{ - ServiceAccessRoleArn: aws.String("String"), // Required - }, - EndpointIdentifier: aws.String("String"), - EndpointType: aws.String("ReplicationEndpointTypeValue"), - EngineName: aws.String("String"), - ExtraConnectionAttributes: aws.String("String"), - MongoDbSettings: &databasemigrationservice.MongoDbSettings{ - AuthMechanism: aws.String("AuthMechanismValue"), - AuthSource: aws.String("String"), - AuthType: aws.String("AuthTypeValue"), - DatabaseName: aws.String("String"), - DocsToInvestigate: aws.String("String"), - ExtractDocId: aws.String("String"), - NestingLevel: aws.String("NestingLevelValue"), - Password: aws.String("SecretString"), - Port: aws.Int64(1), - ServerName: aws.String("String"), - Username: aws.String("String"), - }, - Password: aws.String("SecretString"), - Port: aws.Int64(1), - S3Settings: &databasemigrationservice.S3Settings{ - BucketFolder: aws.String("String"), - BucketName: aws.String("String"), - CompressionType: aws.String("CompressionTypeValue"), - CsvDelimiter: aws.String("String"), - CsvRowDelimiter: aws.String("String"), - ExternalTableDefinition: aws.String("String"), - ServiceAccessRoleArn: aws.String("String"), - }, - ServerName: aws.String("String"), - SslMode: aws.String("DmsSslModeValue"), - Username: aws.String("String"), - } - resp, err := svc.ModifyEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ModifyEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ModifyEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - SnsTopicArn: aws.String("String"), - SourceType: aws.String("String"), - } - resp, err := svc.ModifyEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ModifyReplicationInstance() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ModifyReplicationInstanceInput{ - ReplicationInstanceArn: aws.String("String"), // Required - AllocatedStorage: aws.Int64(1), - AllowMajorVersionUpgrade: aws.Bool(true), - ApplyImmediately: aws.Bool(true), - AutoMinorVersionUpgrade: aws.Bool(true), - EngineVersion: aws.String("String"), - MultiAZ: aws.Bool(true), - PreferredMaintenanceWindow: aws.String("String"), - ReplicationInstanceClass: aws.String("String"), - ReplicationInstanceIdentifier: aws.String("String"), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ModifyReplicationInstance(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ModifyReplicationSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ModifyReplicationSubnetGroupInput{ - ReplicationSubnetGroupIdentifier: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - ReplicationSubnetGroupDescription: aws.String("String"), - } - resp, err := svc.ModifyReplicationSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ModifyReplicationTask() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ModifyReplicationTaskInput{ - ReplicationTaskArn: aws.String("String"), // Required - CdcStartTime: aws.Time(time.Now()), - MigrationType: aws.String("MigrationTypeValue"), - ReplicationTaskIdentifier: aws.String("String"), - ReplicationTaskSettings: aws.String("String"), - TableMappings: aws.String("String"), - } - resp, err := svc.ModifyReplicationTask(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_RefreshSchemas() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.RefreshSchemasInput{ - EndpointArn: aws.String("String"), // Required - ReplicationInstanceArn: aws.String("String"), // Required - } - resp, err := svc.RefreshSchemas(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_ReloadTables() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.ReloadTablesInput{ - ReplicationTaskArn: aws.String("String"), // Required - TablesToReload: []*databasemigrationservice.TableToReload{ // Required - { // Required - SchemaName: aws.String("String"), - TableName: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.ReloadTables(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.RemoveTagsFromResourceInput{ - ResourceArn: aws.String("String"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromResource(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_StartReplicationTask() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.StartReplicationTaskInput{ - ReplicationTaskArn: aws.String("String"), // Required - StartReplicationTaskType: aws.String("StartReplicationTaskTypeValue"), // Required - CdcStartTime: aws.Time(time.Now()), - } - resp, err := svc.StartReplicationTask(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_StopReplicationTask() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.StopReplicationTaskInput{ - ReplicationTaskArn: aws.String("String"), // Required - } - resp, err := svc.StopReplicationTask(params) - - if err != nil { - // 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) -} - -func ExampleDatabaseMigrationService_TestConnection() { - sess := session.Must(session.NewSession()) - - svc := databasemigrationservice.New(sess) - - params := &databasemigrationservice.TestConnectionInput{ - EndpointArn: aws.String("String"), // Required - ReplicationInstanceArn: aws.String("String"), // Required - } - resp, err := svc.TestConnection(params) - - if err != nil { - // 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) -} diff --git a/service/datapipeline/examples_test.go b/service/datapipeline/examples_test.go deleted file mode 100644 index 455d08bf3c6..00000000000 --- a/service/datapipeline/examples_test.go +++ /dev/null @@ -1,568 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package datapipeline_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/datapipeline" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDataPipeline_ActivatePipeline() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.ActivatePipelineInput{ - PipelineId: aws.String("id"), // Required - ParameterValues: []*datapipeline.ParameterValue{ - { // Required - Id: aws.String("fieldNameString"), // Required - StringValue: aws.String("fieldStringValue"), // Required - }, - // More values... - }, - StartTimestamp: aws.Time(time.Now()), - } - resp, err := svc.ActivatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_AddTags() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.AddTagsInput{ - PipelineId: aws.String("id"), // Required - Tags: []*datapipeline.Tag{ // Required - { // Required - Key: aws.String("tagKey"), // Required - Value: aws.String("tagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTags(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_CreatePipeline() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.CreatePipelineInput{ - Name: aws.String("id"), // Required - UniqueId: aws.String("id"), // Required - Description: aws.String("string"), - Tags: []*datapipeline.Tag{ - { // Required - Key: aws.String("tagKey"), // Required - Value: aws.String("tagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.CreatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_DeactivatePipeline() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.DeactivatePipelineInput{ - PipelineId: aws.String("id"), // Required - CancelActive: aws.Bool(true), - } - resp, err := svc.DeactivatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_DeletePipeline() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.DeletePipelineInput{ - PipelineId: aws.String("id"), // Required - } - resp, err := svc.DeletePipeline(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_DescribeObjects() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.DescribeObjectsInput{ - ObjectIds: []*string{ // Required - aws.String("id"), // Required - // More values... - }, - PipelineId: aws.String("id"), // Required - EvaluateExpressions: aws.Bool(true), - Marker: aws.String("string"), - } - resp, err := svc.DescribeObjects(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_DescribePipelines() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.DescribePipelinesInput{ - PipelineIds: []*string{ // Required - aws.String("id"), // Required - // More values... - }, - } - resp, err := svc.DescribePipelines(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_EvaluateExpression() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.EvaluateExpressionInput{ - Expression: aws.String("longString"), // Required - ObjectId: aws.String("id"), // Required - PipelineId: aws.String("id"), // Required - } - resp, err := svc.EvaluateExpression(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_GetPipelineDefinition() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.GetPipelineDefinitionInput{ - PipelineId: aws.String("id"), // Required - Version: aws.String("string"), - } - resp, err := svc.GetPipelineDefinition(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_ListPipelines() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.ListPipelinesInput{ - Marker: aws.String("string"), - } - resp, err := svc.ListPipelines(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_PollForTask() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.PollForTaskInput{ - WorkerGroup: aws.String("string"), // Required - Hostname: aws.String("id"), - InstanceIdentity: &datapipeline.InstanceIdentity{ - Document: aws.String("string"), - Signature: aws.String("string"), - }, - } - resp, err := svc.PollForTask(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_PutPipelineDefinition() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.PutPipelineDefinitionInput{ - PipelineId: aws.String("id"), // Required - PipelineObjects: []*datapipeline.PipelineObject{ // Required - { // Required - Fields: []*datapipeline.Field{ // Required - { // Required - Key: aws.String("fieldNameString"), // Required - RefValue: aws.String("fieldNameString"), - StringValue: aws.String("fieldStringValue"), - }, - // More values... - }, - Id: aws.String("id"), // Required - Name: aws.String("id"), // Required - }, - // More values... - }, - ParameterObjects: []*datapipeline.ParameterObject{ - { // Required - Attributes: []*datapipeline.ParameterAttribute{ // Required - { // Required - Key: aws.String("attributeNameString"), // Required - StringValue: aws.String("attributeValueString"), // Required - }, - // More values... - }, - Id: aws.String("fieldNameString"), // Required - }, - // More values... - }, - ParameterValues: []*datapipeline.ParameterValue{ - { // Required - Id: aws.String("fieldNameString"), // Required - StringValue: aws.String("fieldStringValue"), // Required - }, - // More values... - }, - } - resp, err := svc.PutPipelineDefinition(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_QueryObjects() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.QueryObjectsInput{ - PipelineId: aws.String("id"), // Required - Sphere: aws.String("string"), // Required - Limit: aws.Int64(1), - Marker: aws.String("string"), - Query: &datapipeline.Query{ - Selectors: []*datapipeline.Selector{ - { // Required - FieldName: aws.String("string"), - Operator: &datapipeline.Operator{ - Type: aws.String("OperatorType"), - Values: []*string{ - aws.String("string"), // Required - // More values... - }, - }, - }, - // More values... - }, - }, - } - resp, err := svc.QueryObjects(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_RemoveTags() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.RemoveTagsInput{ - PipelineId: aws.String("id"), // Required - TagKeys: []*string{ // Required - aws.String("string"), // Required - // More values... - }, - } - resp, err := svc.RemoveTags(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_ReportTaskProgress() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.ReportTaskProgressInput{ - TaskId: aws.String("taskId"), // Required - Fields: []*datapipeline.Field{ - { // Required - Key: aws.String("fieldNameString"), // Required - RefValue: aws.String("fieldNameString"), - StringValue: aws.String("fieldStringValue"), - }, - // More values... - }, - } - resp, err := svc.ReportTaskProgress(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_ReportTaskRunnerHeartbeat() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.ReportTaskRunnerHeartbeatInput{ - TaskrunnerId: aws.String("id"), // Required - Hostname: aws.String("id"), - WorkerGroup: aws.String("string"), - } - resp, err := svc.ReportTaskRunnerHeartbeat(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_SetStatus() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.SetStatusInput{ - ObjectIds: []*string{ // Required - aws.String("id"), // Required - // More values... - }, - PipelineId: aws.String("id"), // Required - Status: aws.String("string"), // Required - } - resp, err := svc.SetStatus(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_SetTaskStatus() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.SetTaskStatusInput{ - TaskId: aws.String("taskId"), // Required - TaskStatus: aws.String("TaskStatus"), // Required - ErrorId: aws.String("string"), - ErrorMessage: aws.String("errorMessage"), - ErrorStackTrace: aws.String("string"), - } - resp, err := svc.SetTaskStatus(params) - - if err != nil { - // 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) -} - -func ExampleDataPipeline_ValidatePipelineDefinition() { - sess := session.Must(session.NewSession()) - - svc := datapipeline.New(sess) - - params := &datapipeline.ValidatePipelineDefinitionInput{ - PipelineId: aws.String("id"), // Required - PipelineObjects: []*datapipeline.PipelineObject{ // Required - { // Required - Fields: []*datapipeline.Field{ // Required - { // Required - Key: aws.String("fieldNameString"), // Required - RefValue: aws.String("fieldNameString"), - StringValue: aws.String("fieldStringValue"), - }, - // More values... - }, - Id: aws.String("id"), // Required - Name: aws.String("id"), // Required - }, - // More values... - }, - ParameterObjects: []*datapipeline.ParameterObject{ - { // Required - Attributes: []*datapipeline.ParameterAttribute{ // Required - { // Required - Key: aws.String("attributeNameString"), // Required - StringValue: aws.String("attributeValueString"), // Required - }, - // More values... - }, - Id: aws.String("fieldNameString"), // Required - }, - // More values... - }, - ParameterValues: []*datapipeline.ParameterValue{ - { // Required - Id: aws.String("fieldNameString"), // Required - StringValue: aws.String("fieldStringValue"), // Required - }, - // More values... - }, - } - resp, err := svc.ValidatePipelineDefinition(params) - - if err != nil { - // 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) -} diff --git a/service/devicefarm/examples_test.go b/service/devicefarm/examples_test.go deleted file mode 100644 index 0480ba4d0d0..00000000000 --- a/service/devicefarm/examples_test.go +++ /dev/null @@ -1,1164 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package devicefarm_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/devicefarm" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDeviceFarm_CreateDevicePool() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.CreateDevicePoolInput{ - Name: aws.String("Name"), // Required - ProjectArn: aws.String("AmazonResourceName"), // Required - Rules: []*devicefarm.Rule{ // Required - { // Required - Attribute: aws.String("DeviceAttribute"), - Operator: aws.String("RuleOperator"), - Value: aws.String("String"), - }, - // More values... - }, - Description: aws.String("Message"), - } - resp, err := svc.CreateDevicePool(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_CreateNetworkProfile() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.CreateNetworkProfileInput{ - Name: aws.String("Name"), // Required - ProjectArn: aws.String("AmazonResourceName"), // Required - Description: aws.String("Message"), - DownlinkBandwidthBits: aws.Int64(1), - DownlinkDelayMs: aws.Int64(1), - DownlinkJitterMs: aws.Int64(1), - DownlinkLossPercent: aws.Int64(1), - Type: aws.String("NetworkProfileType"), - UplinkBandwidthBits: aws.Int64(1), - UplinkDelayMs: aws.Int64(1), - UplinkJitterMs: aws.Int64(1), - UplinkLossPercent: aws.Int64(1), - } - resp, err := svc.CreateNetworkProfile(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_CreateProject() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.CreateProjectInput{ - Name: aws.String("Name"), // Required - DefaultJobTimeoutMinutes: aws.Int64(1), - } - resp, err := svc.CreateProject(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_CreateRemoteAccessSession() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.CreateRemoteAccessSessionInput{ - DeviceArn: aws.String("AmazonResourceName"), // Required - ProjectArn: aws.String("AmazonResourceName"), // Required - Configuration: &devicefarm.CreateRemoteAccessSessionConfiguration{ - BillingMethod: aws.String("BillingMethod"), - }, - Name: aws.String("Name"), - } - resp, err := svc.CreateRemoteAccessSession(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_CreateUpload() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.CreateUploadInput{ - Name: aws.String("Name"), // Required - ProjectArn: aws.String("AmazonResourceName"), // Required - Type: aws.String("UploadType"), // Required - ContentType: aws.String("ContentType"), - } - resp, err := svc.CreateUpload(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteDevicePool() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteDevicePoolInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteDevicePool(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteNetworkProfile() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteNetworkProfileInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteNetworkProfile(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteProject() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteProjectInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteProject(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteRemoteAccessSession() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteRemoteAccessSessionInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteRemoteAccessSession(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteRun() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteRunInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteRun(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_DeleteUpload() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.DeleteUploadInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.DeleteUpload(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetAccountSettings() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - var params *devicefarm.GetAccountSettingsInput - resp, err := svc.GetAccountSettings(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetDevice() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetDeviceInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetDevice(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetDevicePool() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetDevicePoolInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetDevicePool(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetDevicePoolCompatibility() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetDevicePoolCompatibilityInput{ - DevicePoolArn: aws.String("AmazonResourceName"), // Required - AppArn: aws.String("AmazonResourceName"), - Test: &devicefarm.ScheduleRunTest{ - Type: aws.String("TestType"), // Required - Filter: aws.String("Filter"), - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - TestPackageArn: aws.String("AmazonResourceName"), - }, - TestType: aws.String("TestType"), - } - resp, err := svc.GetDevicePoolCompatibility(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetJob() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetJobInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetJob(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetNetworkProfile() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetNetworkProfileInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetNetworkProfile(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetOfferingStatus() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetOfferingStatusInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.GetOfferingStatus(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetProject() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetProjectInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetProject(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetRemoteAccessSession() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetRemoteAccessSessionInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetRemoteAccessSession(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetRun() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetRunInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetRun(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetSuite() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetSuiteInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetSuite(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetTest() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetTestInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetTest(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_GetUpload() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.GetUploadInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.GetUpload(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_InstallToRemoteAccessSession() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.InstallToRemoteAccessSessionInput{ - AppArn: aws.String("AmazonResourceName"), // Required - RemoteAccessSessionArn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.InstallToRemoteAccessSession(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListArtifacts() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListArtifactsInput{ - Arn: aws.String("AmazonResourceName"), // Required - Type: aws.String("ArtifactCategory"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListArtifacts(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListDevicePools() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListDevicePoolsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - Type: aws.String("DevicePoolType"), - } - resp, err := svc.ListDevicePools(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListDevices() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListDevicesInput{ - Arn: aws.String("AmazonResourceName"), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListDevices(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListJobs() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListJobsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListJobs(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListNetworkProfiles() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListNetworkProfilesInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - Type: aws.String("NetworkProfileType"), - } - resp, err := svc.ListNetworkProfiles(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListOfferingPromotions() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListOfferingPromotionsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListOfferingPromotions(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListOfferingTransactions() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListOfferingTransactionsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListOfferingTransactions(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListOfferings() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListOfferingsInput{ - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListOfferings(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListProjects() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListProjectsInput{ - Arn: aws.String("AmazonResourceName"), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListProjects(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListRemoteAccessSessions() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListRemoteAccessSessionsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListRemoteAccessSessions(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListRuns() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListRunsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListRuns(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListSamples() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListSamplesInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListSamples(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListSuites() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListSuitesInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListSuites(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListTests() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListTestsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListTests(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListUniqueProblems() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListUniqueProblemsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListUniqueProblems(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ListUploads() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ListUploadsInput{ - Arn: aws.String("AmazonResourceName"), // Required - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListUploads(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_PurchaseOffering() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.PurchaseOfferingInput{ - OfferingId: aws.String("OfferingIdentifier"), - OfferingPromotionId: aws.String("OfferingPromotionIdentifier"), - Quantity: aws.Int64(1), - } - resp, err := svc.PurchaseOffering(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_RenewOffering() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.RenewOfferingInput{ - OfferingId: aws.String("OfferingIdentifier"), - Quantity: aws.Int64(1), - } - resp, err := svc.RenewOffering(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_ScheduleRun() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.ScheduleRunInput{ - DevicePoolArn: aws.String("AmazonResourceName"), // Required - ProjectArn: aws.String("AmazonResourceName"), // Required - Test: &devicefarm.ScheduleRunTest{ // Required - Type: aws.String("TestType"), // Required - Filter: aws.String("Filter"), - Parameters: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - TestPackageArn: aws.String("AmazonResourceName"), - }, - AppArn: aws.String("AmazonResourceName"), - Configuration: &devicefarm.ScheduleRunConfiguration{ - AuxiliaryApps: []*string{ - aws.String("AmazonResourceName"), // Required - // More values... - }, - BillingMethod: aws.String("BillingMethod"), - ExtraDataPackageArn: aws.String("AmazonResourceName"), - Locale: aws.String("String"), - Location: &devicefarm.Location{ - Latitude: aws.Float64(1.0), // Required - Longitude: aws.Float64(1.0), // Required - }, - NetworkProfileArn: aws.String("AmazonResourceName"), - Radios: &devicefarm.Radios{ - Bluetooth: aws.Bool(true), - Gps: aws.Bool(true), - Nfc: aws.Bool(true), - Wifi: aws.Bool(true), - }, - }, - ExecutionConfiguration: &devicefarm.ExecutionConfiguration{ - AccountsCleanup: aws.Bool(true), - AppPackagesCleanup: aws.Bool(true), - JobTimeoutMinutes: aws.Int64(1), - }, - Name: aws.String("Name"), - } - resp, err := svc.ScheduleRun(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_StopRemoteAccessSession() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.StopRemoteAccessSessionInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.StopRemoteAccessSession(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_StopRun() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.StopRunInput{ - Arn: aws.String("AmazonResourceName"), // Required - } - resp, err := svc.StopRun(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_UpdateDevicePool() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.UpdateDevicePoolInput{ - Arn: aws.String("AmazonResourceName"), // Required - Description: aws.String("Message"), - Name: aws.String("Name"), - Rules: []*devicefarm.Rule{ - { // Required - Attribute: aws.String("DeviceAttribute"), - Operator: aws.String("RuleOperator"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateDevicePool(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_UpdateNetworkProfile() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.UpdateNetworkProfileInput{ - Arn: aws.String("AmazonResourceName"), // Required - Description: aws.String("Message"), - DownlinkBandwidthBits: aws.Int64(1), - DownlinkDelayMs: aws.Int64(1), - DownlinkJitterMs: aws.Int64(1), - DownlinkLossPercent: aws.Int64(1), - Name: aws.String("Name"), - Type: aws.String("NetworkProfileType"), - UplinkBandwidthBits: aws.Int64(1), - UplinkDelayMs: aws.Int64(1), - UplinkJitterMs: aws.Int64(1), - UplinkLossPercent: aws.Int64(1), - } - resp, err := svc.UpdateNetworkProfile(params) - - if err != nil { - // 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) -} - -func ExampleDeviceFarm_UpdateProject() { - sess := session.Must(session.NewSession()) - - svc := devicefarm.New(sess) - - params := &devicefarm.UpdateProjectInput{ - Arn: aws.String("AmazonResourceName"), // Required - DefaultJobTimeoutMinutes: aws.Int64(1), - Name: aws.String("Name"), - } - resp, err := svc.UpdateProject(params) - - if err != nil { - // 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) -} diff --git a/service/directconnect/examples_test.go b/service/directconnect/examples_test.go deleted file mode 100644 index e910f8cd41e..00000000000 --- a/service/directconnect/examples_test.go +++ /dev/null @@ -1,895 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package directconnect_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/directconnect" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDirectConnect_AllocateConnectionOnInterconnect() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AllocateConnectionOnInterconnectInput{ - Bandwidth: aws.String("Bandwidth"), // Required - ConnectionName: aws.String("ConnectionName"), // Required - InterconnectId: aws.String("InterconnectId"), // Required - OwnerAccount: aws.String("OwnerAccount"), // Required - Vlan: aws.Int64(1), // Required - } - resp, err := svc.AllocateConnectionOnInterconnect(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AllocateHostedConnection() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AllocateHostedConnectionInput{ - Bandwidth: aws.String("Bandwidth"), // Required - ConnectionId: aws.String("ConnectionId"), // Required - ConnectionName: aws.String("ConnectionName"), // Required - OwnerAccount: aws.String("OwnerAccount"), // Required - Vlan: aws.Int64(1), // Required - } - resp, err := svc.AllocateHostedConnection(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AllocatePrivateVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AllocatePrivateVirtualInterfaceInput{ - ConnectionId: aws.String("ConnectionId"), // Required - NewPrivateVirtualInterfaceAllocation: &directconnect.NewPrivateVirtualInterfaceAllocation{ // Required - Asn: aws.Int64(1), // Required - VirtualInterfaceName: aws.String("VirtualInterfaceName"), // Required - Vlan: aws.Int64(1), // Required - AddressFamily: aws.String("AddressFamily"), - AmazonAddress: aws.String("AmazonAddress"), - AuthKey: aws.String("BGPAuthKey"), - CustomerAddress: aws.String("CustomerAddress"), - }, - OwnerAccount: aws.String("OwnerAccount"), // Required - } - resp, err := svc.AllocatePrivateVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AllocatePublicVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AllocatePublicVirtualInterfaceInput{ - ConnectionId: aws.String("ConnectionId"), // Required - NewPublicVirtualInterfaceAllocation: &directconnect.NewPublicVirtualInterfaceAllocation{ // Required - Asn: aws.Int64(1), // Required - VirtualInterfaceName: aws.String("VirtualInterfaceName"), // Required - Vlan: aws.Int64(1), // Required - AddressFamily: aws.String("AddressFamily"), - AmazonAddress: aws.String("AmazonAddress"), - AuthKey: aws.String("BGPAuthKey"), - CustomerAddress: aws.String("CustomerAddress"), - RouteFilterPrefixes: []*directconnect.RouteFilterPrefix{ - { // Required - Cidr: aws.String("CIDR"), - }, - // More values... - }, - }, - OwnerAccount: aws.String("OwnerAccount"), // Required - } - resp, err := svc.AllocatePublicVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AssociateConnectionWithLag() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AssociateConnectionWithLagInput{ - ConnectionId: aws.String("ConnectionId"), // Required - LagId: aws.String("LagId"), // Required - } - resp, err := svc.AssociateConnectionWithLag(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AssociateHostedConnection() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AssociateHostedConnectionInput{ - ConnectionId: aws.String("ConnectionId"), // Required - ParentConnectionId: aws.String("ConnectionId"), // Required - } - resp, err := svc.AssociateHostedConnection(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_AssociateVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.AssociateVirtualInterfaceInput{ - ConnectionId: aws.String("ConnectionId"), // Required - VirtualInterfaceId: aws.String("VirtualInterfaceId"), // Required - } - resp, err := svc.AssociateVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_ConfirmConnection() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.ConfirmConnectionInput{ - ConnectionId: aws.String("ConnectionId"), // Required - } - resp, err := svc.ConfirmConnection(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_ConfirmPrivateVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.ConfirmPrivateVirtualInterfaceInput{ - VirtualGatewayId: aws.String("VirtualGatewayId"), // Required - VirtualInterfaceId: aws.String("VirtualInterfaceId"), // Required - } - resp, err := svc.ConfirmPrivateVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_ConfirmPublicVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.ConfirmPublicVirtualInterfaceInput{ - VirtualInterfaceId: aws.String("VirtualInterfaceId"), // Required - } - resp, err := svc.ConfirmPublicVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreateBGPPeer() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreateBGPPeerInput{ - NewBGPPeer: &directconnect.NewBGPPeer{ - AddressFamily: aws.String("AddressFamily"), - AmazonAddress: aws.String("AmazonAddress"), - Asn: aws.Int64(1), - AuthKey: aws.String("BGPAuthKey"), - CustomerAddress: aws.String("CustomerAddress"), - }, - VirtualInterfaceId: aws.String("VirtualInterfaceId"), - } - resp, err := svc.CreateBGPPeer(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreateConnection() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreateConnectionInput{ - Bandwidth: aws.String("Bandwidth"), // Required - ConnectionName: aws.String("ConnectionName"), // Required - Location: aws.String("LocationCode"), // Required - LagId: aws.String("LagId"), - } - resp, err := svc.CreateConnection(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreateInterconnect() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreateInterconnectInput{ - Bandwidth: aws.String("Bandwidth"), // Required - InterconnectName: aws.String("InterconnectName"), // Required - Location: aws.String("LocationCode"), // Required - LagId: aws.String("LagId"), - } - resp, err := svc.CreateInterconnect(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreateLag() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreateLagInput{ - ConnectionsBandwidth: aws.String("Bandwidth"), // Required - LagName: aws.String("LagName"), // Required - Location: aws.String("LocationCode"), // Required - NumberOfConnections: aws.Int64(1), // Required - ConnectionId: aws.String("ConnectionId"), - } - resp, err := svc.CreateLag(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreatePrivateVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreatePrivateVirtualInterfaceInput{ - ConnectionId: aws.String("ConnectionId"), // Required - NewPrivateVirtualInterface: &directconnect.NewPrivateVirtualInterface{ // Required - Asn: aws.Int64(1), // Required - VirtualGatewayId: aws.String("VirtualGatewayId"), // Required - VirtualInterfaceName: aws.String("VirtualInterfaceName"), // Required - Vlan: aws.Int64(1), // Required - AddressFamily: aws.String("AddressFamily"), - AmazonAddress: aws.String("AmazonAddress"), - AuthKey: aws.String("BGPAuthKey"), - CustomerAddress: aws.String("CustomerAddress"), - }, - } - resp, err := svc.CreatePrivateVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_CreatePublicVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.CreatePublicVirtualInterfaceInput{ - ConnectionId: aws.String("ConnectionId"), // Required - NewPublicVirtualInterface: &directconnect.NewPublicVirtualInterface{ // Required - Asn: aws.Int64(1), // Required - VirtualInterfaceName: aws.String("VirtualInterfaceName"), // Required - Vlan: aws.Int64(1), // Required - AddressFamily: aws.String("AddressFamily"), - AmazonAddress: aws.String("AmazonAddress"), - AuthKey: aws.String("BGPAuthKey"), - CustomerAddress: aws.String("CustomerAddress"), - RouteFilterPrefixes: []*directconnect.RouteFilterPrefix{ - { // Required - Cidr: aws.String("CIDR"), - }, - // More values... - }, - }, - } - resp, err := svc.CreatePublicVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DeleteBGPPeer() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DeleteBGPPeerInput{ - Asn: aws.Int64(1), - CustomerAddress: aws.String("CustomerAddress"), - VirtualInterfaceId: aws.String("VirtualInterfaceId"), - } - resp, err := svc.DeleteBGPPeer(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DeleteConnection() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DeleteConnectionInput{ - ConnectionId: aws.String("ConnectionId"), // Required - } - resp, err := svc.DeleteConnection(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DeleteInterconnect() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DeleteInterconnectInput{ - InterconnectId: aws.String("InterconnectId"), // Required - } - resp, err := svc.DeleteInterconnect(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DeleteLag() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DeleteLagInput{ - LagId: aws.String("LagId"), // Required - } - resp, err := svc.DeleteLag(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DeleteVirtualInterface() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DeleteVirtualInterfaceInput{ - VirtualInterfaceId: aws.String("VirtualInterfaceId"), // Required - } - resp, err := svc.DeleteVirtualInterface(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeConnectionLoa() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeConnectionLoaInput{ - ConnectionId: aws.String("ConnectionId"), // Required - LoaContentType: aws.String("LoaContentType"), - ProviderName: aws.String("ProviderName"), - } - resp, err := svc.DescribeConnectionLoa(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeConnections() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeConnectionsInput{ - ConnectionId: aws.String("ConnectionId"), - } - resp, err := svc.DescribeConnections(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeConnectionsOnInterconnect() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeConnectionsOnInterconnectInput{ - InterconnectId: aws.String("InterconnectId"), // Required - } - resp, err := svc.DescribeConnectionsOnInterconnect(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeHostedConnections() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeHostedConnectionsInput{ - ConnectionId: aws.String("ConnectionId"), // Required - } - resp, err := svc.DescribeHostedConnections(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeInterconnectLoa() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeInterconnectLoaInput{ - InterconnectId: aws.String("InterconnectId"), // Required - LoaContentType: aws.String("LoaContentType"), - ProviderName: aws.String("ProviderName"), - } - resp, err := svc.DescribeInterconnectLoa(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeInterconnects() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeInterconnectsInput{ - InterconnectId: aws.String("InterconnectId"), - } - resp, err := svc.DescribeInterconnects(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeLags() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeLagsInput{ - LagId: aws.String("LagId"), - } - resp, err := svc.DescribeLags(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeLoa() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeLoaInput{ - ConnectionId: aws.String("ConnectionId"), // Required - LoaContentType: aws.String("LoaContentType"), - ProviderName: aws.String("ProviderName"), - } - resp, err := svc.DescribeLoa(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeLocations() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - var params *directconnect.DescribeLocationsInput - resp, err := svc.DescribeLocations(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeTagsInput{ - ResourceArns: []*string{ // Required - aws.String("ResourceArn"), // Required - // More values... - }, - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeVirtualGateways() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - var params *directconnect.DescribeVirtualGatewaysInput - resp, err := svc.DescribeVirtualGateways(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DescribeVirtualInterfaces() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DescribeVirtualInterfacesInput{ - ConnectionId: aws.String("ConnectionId"), - VirtualInterfaceId: aws.String("VirtualInterfaceId"), - } - resp, err := svc.DescribeVirtualInterfaces(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_DisassociateConnectionFromLag() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.DisassociateConnectionFromLagInput{ - ConnectionId: aws.String("ConnectionId"), // Required - LagId: aws.String("LagId"), // Required - } - resp, err := svc.DisassociateConnectionFromLag(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_TagResource() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.TagResourceInput{ - ResourceArn: aws.String("ResourceArn"), // Required - Tags: []*directconnect.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.TagResource(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.UntagResourceInput{ - ResourceArn: aws.String("ResourceArn"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UntagResource(params) - - if err != nil { - // 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) -} - -func ExampleDirectConnect_UpdateLag() { - sess := session.Must(session.NewSession()) - - svc := directconnect.New(sess) - - params := &directconnect.UpdateLagInput{ - LagId: aws.String("LagId"), // Required - LagName: aws.String("LagName"), - MinimumLinks: aws.Int64(1), - } - resp, err := svc.UpdateLag(params) - - if err != nil { - // 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) -} diff --git a/service/directoryservice/examples_test.go b/service/directoryservice/examples_test.go deleted file mode 100644 index aa5ac8f8bf4..00000000000 --- a/service/directoryservice/examples_test.go +++ /dev/null @@ -1,971 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package directoryservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/directoryservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDirectoryService_AddIpRoutes() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.AddIpRoutesInput{ - DirectoryId: aws.String("DirectoryId"), // Required - IpRoutes: []*directoryservice.IpRoute{ // Required - { // Required - CidrIp: aws.String("CidrIp"), - Description: aws.String("Description"), - }, - // More values... - }, - UpdateSecurityGroupForDirectoryControllers: aws.Bool(true), - } - resp, err := svc.AddIpRoutes(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.AddTagsToResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - Tags: []*directoryservice.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CancelSchemaExtension() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CancelSchemaExtensionInput{ - DirectoryId: aws.String("DirectoryId"), // Required - SchemaExtensionId: aws.String("SchemaExtensionId"), // Required - } - resp, err := svc.CancelSchemaExtension(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_ConnectDirectory() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.ConnectDirectoryInput{ - ConnectSettings: &directoryservice.DirectoryConnectSettings{ // Required - CustomerDnsIps: []*string{ // Required - aws.String("IpAddr"), // Required - // More values... - }, - CustomerUserName: aws.String("UserName"), // Required - SubnetIds: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... - }, - VpcId: aws.String("VpcId"), // Required - }, - Name: aws.String("DirectoryName"), // Required - Password: aws.String("ConnectPassword"), // Required - Size: aws.String("DirectorySize"), // Required - Description: aws.String("Description"), - ShortName: aws.String("DirectoryShortName"), - } - resp, err := svc.ConnectDirectory(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateAlias() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateAliasInput{ - Alias: aws.String("AliasName"), // Required - DirectoryId: aws.String("DirectoryId"), // Required - } - resp, err := svc.CreateAlias(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateComputer() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateComputerInput{ - ComputerName: aws.String("ComputerName"), // Required - DirectoryId: aws.String("DirectoryId"), // Required - Password: aws.String("ComputerPassword"), // Required - ComputerAttributes: []*directoryservice.Attribute{ - { // Required - Name: aws.String("AttributeName"), - Value: aws.String("AttributeValue"), - }, - // More values... - }, - OrganizationalUnitDistinguishedName: aws.String("OrganizationalUnitDN"), - } - resp, err := svc.CreateComputer(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateConditionalForwarder() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateConditionalForwarderInput{ - DirectoryId: aws.String("DirectoryId"), // Required - DnsIpAddrs: []*string{ // Required - aws.String("IpAddr"), // Required - // More values... - }, - RemoteDomainName: aws.String("RemoteDomainName"), // Required - } - resp, err := svc.CreateConditionalForwarder(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateDirectory() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateDirectoryInput{ - Name: aws.String("DirectoryName"), // Required - Password: aws.String("Password"), // Required - Size: aws.String("DirectorySize"), // Required - Description: aws.String("Description"), - ShortName: aws.String("DirectoryShortName"), - VpcSettings: &directoryservice.DirectoryVpcSettings{ - SubnetIds: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... - }, - VpcId: aws.String("VpcId"), // Required - }, - } - resp, err := svc.CreateDirectory(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateMicrosoftAD() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateMicrosoftADInput{ - Name: aws.String("DirectoryName"), // Required - Password: aws.String("Password"), // Required - VpcSettings: &directoryservice.DirectoryVpcSettings{ // Required - SubnetIds: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... - }, - VpcId: aws.String("VpcId"), // Required - }, - Description: aws.String("Description"), - ShortName: aws.String("DirectoryShortName"), - } - resp, err := svc.CreateMicrosoftAD(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateSnapshot() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateSnapshotInput{ - DirectoryId: aws.String("DirectoryId"), // Required - Name: aws.String("SnapshotName"), - } - resp, err := svc.CreateSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_CreateTrust() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.CreateTrustInput{ - DirectoryId: aws.String("DirectoryId"), // Required - RemoteDomainName: aws.String("RemoteDomainName"), // Required - TrustDirection: aws.String("TrustDirection"), // Required - TrustPassword: aws.String("TrustPassword"), // Required - ConditionalForwarderIpAddrs: []*string{ - aws.String("IpAddr"), // Required - // More values... - }, - TrustType: aws.String("TrustType"), - } - resp, err := svc.CreateTrust(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DeleteConditionalForwarder() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DeleteConditionalForwarderInput{ - DirectoryId: aws.String("DirectoryId"), // Required - RemoteDomainName: aws.String("RemoteDomainName"), // Required - } - resp, err := svc.DeleteConditionalForwarder(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DeleteDirectory() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DeleteDirectoryInput{ - DirectoryId: aws.String("DirectoryId"), // Required - } - resp, err := svc.DeleteDirectory(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DeleteSnapshot() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DeleteSnapshotInput{ - SnapshotId: aws.String("SnapshotId"), // Required - } - resp, err := svc.DeleteSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DeleteTrust() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DeleteTrustInput{ - TrustId: aws.String("TrustId"), // Required - DeleteAssociatedConditionalForwarder: aws.Bool(true), - } - resp, err := svc.DeleteTrust(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DeregisterEventTopic() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DeregisterEventTopicInput{ - DirectoryId: aws.String("DirectoryId"), // Required - TopicName: aws.String("TopicName"), // Required - } - resp, err := svc.DeregisterEventTopic(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DescribeConditionalForwarders() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DescribeConditionalForwardersInput{ - DirectoryId: aws.String("DirectoryId"), // Required - RemoteDomainNames: []*string{ - aws.String("RemoteDomainName"), // Required - // More values... - }, - } - resp, err := svc.DescribeConditionalForwarders(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DescribeDirectories() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DescribeDirectoriesInput{ - DirectoryIds: []*string{ - aws.String("DirectoryId"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeDirectories(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DescribeEventTopics() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DescribeEventTopicsInput{ - DirectoryId: aws.String("DirectoryId"), - TopicNames: []*string{ - aws.String("TopicName"), // Required - // More values... - }, - } - resp, err := svc.DescribeEventTopics(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DescribeSnapshots() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DescribeSnapshotsInput{ - DirectoryId: aws.String("DirectoryId"), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - SnapshotIds: []*string{ - aws.String("SnapshotId"), // Required - // More values... - }, - } - resp, err := svc.DescribeSnapshots(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DescribeTrusts() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DescribeTrustsInput{ - DirectoryId: aws.String("DirectoryId"), - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - TrustIds: []*string{ - aws.String("TrustId"), // Required - // More values... - }, - } - resp, err := svc.DescribeTrusts(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DisableRadius() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DisableRadiusInput{ - DirectoryId: aws.String("DirectoryId"), // Required - } - resp, err := svc.DisableRadius(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_DisableSso() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.DisableSsoInput{ - DirectoryId: aws.String("DirectoryId"), // Required - Password: aws.String("ConnectPassword"), - UserName: aws.String("UserName"), - } - resp, err := svc.DisableSso(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_EnableRadius() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.EnableRadiusInput{ - DirectoryId: aws.String("DirectoryId"), // Required - RadiusSettings: &directoryservice.RadiusSettings{ // Required - AuthenticationProtocol: aws.String("RadiusAuthenticationProtocol"), - DisplayLabel: aws.String("RadiusDisplayLabel"), - RadiusPort: aws.Int64(1), - RadiusRetries: aws.Int64(1), - RadiusServers: []*string{ - aws.String("Server"), // Required - // More values... - }, - RadiusTimeout: aws.Int64(1), - SharedSecret: aws.String("RadiusSharedSecret"), - UseSameUsername: aws.Bool(true), - }, - } - resp, err := svc.EnableRadius(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_EnableSso() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.EnableSsoInput{ - DirectoryId: aws.String("DirectoryId"), // Required - Password: aws.String("ConnectPassword"), - UserName: aws.String("UserName"), - } - resp, err := svc.EnableSso(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_GetDirectoryLimits() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - var params *directoryservice.GetDirectoryLimitsInput - resp, err := svc.GetDirectoryLimits(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_GetSnapshotLimits() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.GetSnapshotLimitsInput{ - DirectoryId: aws.String("DirectoryId"), // Required - } - resp, err := svc.GetSnapshotLimits(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_ListIpRoutes() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.ListIpRoutesInput{ - DirectoryId: aws.String("DirectoryId"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListIpRoutes(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_ListSchemaExtensions() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.ListSchemaExtensionsInput{ - DirectoryId: aws.String("DirectoryId"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListSchemaExtensions(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.ListTagsForResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_RegisterEventTopic() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.RegisterEventTopicInput{ - DirectoryId: aws.String("DirectoryId"), // Required - TopicName: aws.String("TopicName"), // Required - } - resp, err := svc.RegisterEventTopic(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_RemoveIpRoutes() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.RemoveIpRoutesInput{ - CidrIps: []*string{ // Required - aws.String("CidrIp"), // Required - // More values... - }, - DirectoryId: aws.String("DirectoryId"), // Required - } - resp, err := svc.RemoveIpRoutes(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.RemoveTagsFromResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromResource(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_RestoreFromSnapshot() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.RestoreFromSnapshotInput{ - SnapshotId: aws.String("SnapshotId"), // Required - } - resp, err := svc.RestoreFromSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_StartSchemaExtension() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.StartSchemaExtensionInput{ - CreateSnapshotBeforeSchemaExtension: aws.Bool(true), // Required - Description: aws.String("Description"), // Required - DirectoryId: aws.String("DirectoryId"), // Required - LdifContent: aws.String("LdifContent"), // Required - } - resp, err := svc.StartSchemaExtension(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_UpdateConditionalForwarder() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.UpdateConditionalForwarderInput{ - DirectoryId: aws.String("DirectoryId"), // Required - DnsIpAddrs: []*string{ // Required - aws.String("IpAddr"), // Required - // More values... - }, - RemoteDomainName: aws.String("RemoteDomainName"), // Required - } - resp, err := svc.UpdateConditionalForwarder(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_UpdateRadius() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.UpdateRadiusInput{ - DirectoryId: aws.String("DirectoryId"), // Required - RadiusSettings: &directoryservice.RadiusSettings{ // Required - AuthenticationProtocol: aws.String("RadiusAuthenticationProtocol"), - DisplayLabel: aws.String("RadiusDisplayLabel"), - RadiusPort: aws.Int64(1), - RadiusRetries: aws.Int64(1), - RadiusServers: []*string{ - aws.String("Server"), // Required - // More values... - }, - RadiusTimeout: aws.Int64(1), - SharedSecret: aws.String("RadiusSharedSecret"), - UseSameUsername: aws.Bool(true), - }, - } - resp, err := svc.UpdateRadius(params) - - if err != nil { - // 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) -} - -func ExampleDirectoryService_VerifyTrust() { - sess := session.Must(session.NewSession()) - - svc := directoryservice.New(sess) - - params := &directoryservice.VerifyTrustInput{ - TrustId: aws.String("TrustId"), // Required - } - resp, err := svc.VerifyTrust(params) - - if err != nil { - // 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) -} diff --git a/service/dynamodb/examples_test.go b/service/dynamodb/examples_test.go index a29286f10cf..e26e3ce5aa9 100644 --- a/service/dynamodb/examples_test.go +++ b/service/dynamodb/examples_test.go @@ -8,1495 +8,644 @@ import ( "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/dynamodb" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleDynamoDB_BatchGetItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &dynamodb.BatchGetItemInput{ - RequestItems: map[string]*dynamodb.KeysAndAttributes{ // Required - "Key": { // Required - Keys: []map[string]*dynamodb.AttributeValue{ // Required - { // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - // More values... - }, - AttributesToGet: []*string{ - aws.String("AttributeName"), // Required - // More values... - }, - ConsistentRead: aws.Bool(true), - ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... - }, - ProjectionExpression: aws.String("ProjectionExpression"), +// To retrieve multiple items from a table +// +// This example reads multiple items from the Music table using a batch of three GetItem +// requests. Only the AlbumTitle attribute is returned. +func ExampleDynamoDB_BatchGetItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.BatchGetItemInput{ + RequestItems: map[string]*dynamodb.KeysAndAttributes{ + "Music": { + ProjectionExpression: aws.String("AlbumTitle"), }, - // More values... }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), } - resp, err := svc.BatchGetItem(params) + result, err := svc.BatchGetItem(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 dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_BatchWriteItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.BatchWriteItemInput{ - RequestItems: map[string][]*dynamodb.WriteRequest{ // Required - "Key": { // Required - { // Required - DeleteRequest: &dynamodb.DeleteRequest{ - Key: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, +// To add multiple items to a table +// +// This example adds three new items to the Music table using a batch of three PutItem +// requests. +func ExampleDynamoDB_BatchWriteItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.BatchWriteItemInput{ + RequestItems: map[string][]*dynamodb.WriteRequest{ + "Music": { + { + PutRequest: &dynamodb.PutRequest{ + Item: map[string]*dynamodb.AttributeValue{ + "AlbumTitle": { + S: aws.String("Somewhat Famous"), + }, + "Artist": { + S: aws.String("No One You Know"), + }, + "SongTitle": { + S: aws.String("Call Me Today"), + }, + }, + }, + }, + { + PutRequest: &dynamodb.PutRequest{ + Item: map[string]*dynamodb.AttributeValue{ + "AlbumTitle": { + S: aws.String("Songs About Life"), + }, + "Artist": { + S: aws.String("Acme Band"), + }, + "SongTitle": { + S: aws.String("Happy Day"), }, - // More values... }, }, + }, + { PutRequest: &dynamodb.PutRequest{ - Item: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, + Item: map[string]*dynamodb.AttributeValue{ + "AlbumTitle": { + S: aws.String("Blue Sky Blues"), + }, + "Artist": { + S: aws.String("No One You Know"), + }, + "SongTitle": { + S: aws.String("Scared of My Shadow"), }, - // More values... }, }, }, - // More values... }, - // More values... }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"), } - resp, err := svc.BatchWriteItem(params) + result, err := svc.BatchWriteItem(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 dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeItemCollectionSizeLimitExceededException: + fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_CreateTable() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.CreateTableInput{ - AttributeDefinitions: []*dynamodb.AttributeDefinition{ // Required - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - AttributeType: aws.String("ScalarAttributeType"), // Required +// To create a table +// +// This example creates a table named Music. +func ExampleDynamoDB_CreateTable_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.CreateTableInput{ + AttributeDefinitions: []*dynamodb.AttributeDefinitions{ + { + AttributeName: aws.String("Artist"), + AttributeType: aws.String("S"), }, - // More values... - }, - KeySchema: []*dynamodb.KeySchemaElement{ // Required - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - KeyType: aws.String("KeyType"), // Required + { + AttributeName: aws.String("SongTitle"), + AttributeType: aws.String("S"), }, - // More values... }, - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required - ReadCapacityUnits: aws.Int64(1), // Required - WriteCapacityUnits: aws.Int64(1), // Required - }, - TableName: aws.String("TableName"), // Required - GlobalSecondaryIndexes: []*dynamodb.GlobalSecondaryIndex{ - { // Required - IndexName: aws.String("IndexName"), // Required - KeySchema: []*dynamodb.KeySchemaElement{ // Required - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - KeyType: aws.String("KeyType"), // Required - }, - // More values... - }, - Projection: &dynamodb.Projection{ // Required - NonKeyAttributes: []*string{ - aws.String("NonKeyAttributeName"), // Required - // More values... - }, - ProjectionType: aws.String("ProjectionType"), - }, - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required - ReadCapacityUnits: aws.Int64(1), // Required - WriteCapacityUnits: aws.Int64(1), // Required - }, + KeySchema: []*dynamodb.KeySchema{ + { + AttributeName: aws.String("Artist"), + KeyType: aws.String("HASH"), }, - // More values... - }, - LocalSecondaryIndexes: []*dynamodb.LocalSecondaryIndex{ - { // Required - IndexName: aws.String("IndexName"), // Required - KeySchema: []*dynamodb.KeySchemaElement{ // Required - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - KeyType: aws.String("KeyType"), // Required - }, - // More values... - }, - Projection: &dynamodb.Projection{ // Required - NonKeyAttributes: []*string{ - aws.String("NonKeyAttributeName"), // Required - // More values... - }, - ProjectionType: aws.String("ProjectionType"), - }, + { + AttributeName: aws.String("SongTitle"), + KeyType: aws.String("RANGE"), }, - // More values... }, - StreamSpecification: &dynamodb.StreamSpecification{ - StreamEnabled: aws.Bool(true), - StreamViewType: aws.String("StreamViewType"), + ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(5.000000), + WriteCapacityUnits: aws.Int64(5.000000), }, + TableName: aws.String("Music"), } - resp, err := svc.CreateTable(params) + result, err := svc.CreateTable(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 dynamodb.ErrCodeResourceInUseException: + fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error()) + case dynamodb.ErrCodeLimitExceededException: + fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_DeleteItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DeleteItemInput{ - Key: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - TableName: aws.String("TableName"), // Required - ConditionExpression: aws.String("ConditionExpression"), - ConditionalOperator: aws.String("ConditionalOperator"), - Expected: map[string]*dynamodb.ExpectedAttributeValue{ - "Key": { // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - ComparisonOperator: aws.String("ComparisonOperator"), - Exists: aws.Bool(true), - Value: &dynamodb.AttributeValue{ - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, +// To delete an item +// +// This example deletes an item from the Music table. +func ExampleDynamoDB_DeleteItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.DeleteItemInput{ + Key: map[string]*dynamodb.AttributeValue{ + "Artist": { + S: aws.String("No One You Know"), }, - // More values... - }, - ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... - }, - ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, + "SongTitle": { + S: aws.String("Scared of My Shadow"), }, - // More values... }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"), - ReturnValues: aws.String("ReturnValue"), + TableName: aws.String("Music"), } - resp, err := svc.DeleteItem(params) + result, err := svc.DeleteItem(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 dynamodb.ErrCodeConditionalCheckFailedException: + fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error()) + case dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeItemCollectionSizeLimitExceededException: + fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_DeleteTable() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DeleteTableInput{ - TableName: aws.String("TableName"), // Required +// To delete a table +// +// This example deletes the Music table. +func ExampleDynamoDB_DeleteTable_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.DeleteTableInput{ + TableName: aws.String("Music"), } - resp, err := svc.DeleteTable(params) + result, err := svc.DeleteTable(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 dynamodb.ErrCodeResourceInUseException: + fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeLimitExceededException: + fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_DescribeLimits() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - var params *dynamodb.DescribeLimitsInput - resp, err := svc.DescribeLimits(params) +// To determine capacity limits per table and account, in the current AWS region +// +// The following example returns the maximum read and write capacity units per table, +// and for the AWS account, in the current AWS region. +func ExampleDynamoDB_DescribeLimits_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.DescribeLimitsInput{} + result, err := svc.DescribeLimits(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 dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_DescribeTable() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DescribeTableInput{ - TableName: aws.String("TableName"), // Required +// To describe a table +// +// This example describes the Music table. +func ExampleDynamoDB_DescribeTable_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.DescribeTableInput{ + TableName: aws.String("Music"), } - resp, err := svc.DescribeTable(params) + result, err := svc.DescribeTable(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 dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_DescribeTimeToLive() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DescribeTimeToLiveInput{ - TableName: aws.String("TableName"), // Required - } - resp, err := svc.DescribeTimeToLive(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDB_GetItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.GetItemInput{ - Key: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, +// To read an item from a table +// +// This example retrieves an item from the Music table. The table has a partition key +// and a sort key (Artist and SongTitle), so you must specify both of these attributes. +func ExampleDynamoDB_GetItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.GetItemInput{ + Key: map[string]*dynamodb.AttributeValue{ + "Artist": { + S: aws.String("Acme Band"), + }, + "SongTitle": { + S: aws.String("Happy Day"), }, - // More values... - }, - TableName: aws.String("TableName"), // Required - AttributesToGet: []*string{ - aws.String("AttributeName"), // Required - // More values... - }, - ConsistentRead: aws.Bool(true), - ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... }, - ProjectionExpression: aws.String("ProjectionExpression"), - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), + TableName: aws.String("Music"), } - resp, err := svc.GetItem(params) + result, err := svc.GetItem(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 dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_ListTables() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.ListTablesInput{ - ExclusiveStartTableName: aws.String("TableName"), - Limit: aws.Int64(1), - } - resp, err := svc.ListTables(params) +// To list tables +// +// This example lists all of the tables associated with the current AWS account and +// endpoint. +func ExampleDynamoDB_ListTables_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.ListTablesInput{} + result, err := svc.ListTables(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 dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_ListTagsOfResource() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.ListTagsOfResourceInput{ - ResourceArn: aws.String("ResourceArnString"), // Required - NextToken: aws.String("NextTokenString"), - } - resp, err := svc.ListTagsOfResource(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDB_PutItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.PutItemInput{ - Item: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, +// To add an item to a table +// +// This example adds a new item to the Music table. +func ExampleDynamoDB_PutItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.PutItemInput{ + Item: map[string]*dynamodb.AttributeValue{ + "AlbumTitle": { + S: aws.String("Somewhat Famous"), }, - // More values... - }, - TableName: aws.String("TableName"), // Required - ConditionExpression: aws.String("ConditionExpression"), - ConditionalOperator: aws.String("ConditionalOperator"), - Expected: map[string]*dynamodb.ExpectedAttributeValue{ - "Key": { // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - ComparisonOperator: aws.String("ComparisonOperator"), - Exists: aws.Bool(true), - Value: &dynamodb.AttributeValue{ - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, + "Artist": { + S: aws.String("No One You Know"), }, - // More values... - }, - ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... - }, - ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, + "SongTitle": { + S: aws.String("Call Me Today"), }, - // More values... }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"), - ReturnValues: aws.String("ReturnValue"), + ReturnConsumedCapacity: aws.String("TOTAL"), + TableName: aws.String("Music"), } - resp, err := svc.PutItem(params) + result, err := svc.PutItem(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 dynamodb.ErrCodeConditionalCheckFailedException: + fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error()) + case dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeItemCollectionSizeLimitExceededException: + fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_Query() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.QueryInput{ - TableName: aws.String("TableName"), // Required - AttributesToGet: []*string{ - aws.String("AttributeName"), // Required - // More values... - }, - ConditionalOperator: aws.String("ConditionalOperator"), - ConsistentRead: aws.Bool(true), - ExclusiveStartKey: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... - }, +// To query an item +// +// This example queries items in the Music table. The table has a partition key and +// sort key (Artist and SongTitle), but this query only specifies the partition key +// value. It returns song titles by the artist named "No One You Know". +func ExampleDynamoDB_Query_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.QueryInput{ ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - FilterExpression: aws.String("ConditionExpression"), - IndexName: aws.String("IndexName"), - KeyConditionExpression: aws.String("KeyExpression"), - KeyConditions: map[string]*dynamodb.Condition{ - "Key": { // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, + ":v1": { + S: aws.String("No One You Know"), }, - // More values... }, - Limit: aws.Int64(1), - ProjectionExpression: aws.String("ProjectionExpression"), - QueryFilter: map[string]*dynamodb.Condition{ - "Key": { // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - // More values... - }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ScanIndexForward: aws.Bool(true), - Select: aws.String("Select"), + KeyConditionExpression: aws.String("Artist = :v1"), + ProjectionExpression: aws.String("SongTitle"), + TableName: aws.String("Music"), } - resp, err := svc.Query(params) + result, err := svc.Query(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 dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_Scan() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.ScanInput{ - TableName: aws.String("TableName"), // Required - AttributesToGet: []*string{ - aws.String("AttributeName"), // Required - // More values... - }, - ConditionalOperator: aws.String("ConditionalOperator"), - ConsistentRead: aws.Bool(true), - ExclusiveStartKey: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, +// To scan a table +// +// This example scans the entire Music table, and then narrows the results to songs +// by the artist "No One You Know". For each item, only the album title and song title +// are returned. +func ExampleDynamoDB_Scan_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.ScanInput{ ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... + "AT": aws.String("AlbumTitle"), + "ST": aws.String("SongTitle"), }, ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, + ":a": { + S: aws.String("No One You Know"), }, - // More values... - }, - FilterExpression: aws.String("ConditionExpression"), - IndexName: aws.String("IndexName"), - Limit: aws.Int64(1), - ProjectionExpression: aws.String("ProjectionExpression"), - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ScanFilter: map[string]*dynamodb.Condition{ - "Key": { // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - // More values... - }, - Segment: aws.Int64(1), - Select: aws.String("Select"), - TotalSegments: aws.Int64(1), - } - resp, err := svc.Scan(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDB_TagResource() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.TagResourceInput{ - ResourceArn: aws.String("ResourceArnString"), // Required - Tags: []*dynamodb.Tag{ // Required - { // Required - Key: aws.String("TagKeyString"), // Required - Value: aws.String("TagValueString"), // Required - }, - // More values... - }, - } - resp, err := svc.TagResource(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDB_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.UntagResourceInput{ - ResourceArn: aws.String("ResourceArnString"), // Required - TagKeys: []*string{ // Required - aws.String("TagKeyString"), // Required - // More values... }, + FilterExpression: aws.String("Artist = :a"), + ProjectionExpression: aws.String("#ST, #AT"), + TableName: aws.String("Music"), } - resp, err := svc.UntagResource(params) + result, err := svc.Scan(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 dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_UpdateItem() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.UpdateItemInput{ - Key: map[string]*dynamodb.AttributeValue{ // Required - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - TableName: aws.String("TableName"), // Required - AttributeUpdates: map[string]*dynamodb.AttributeValueUpdate{ - "Key": { // Required - Action: aws.String("AttributeAction"), - Value: &dynamodb.AttributeValue{ - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - }, - // More values... - }, - ConditionExpression: aws.String("ConditionExpression"), - ConditionalOperator: aws.String("ConditionalOperator"), - Expected: map[string]*dynamodb.ExpectedAttributeValue{ - "Key": { // Required - AttributeValueList: []*dynamodb.AttributeValue{ - { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - // More values... - }, - ComparisonOperator: aws.String("ComparisonOperator"), - Exists: aws.Bool(true), - Value: &dynamodb.AttributeValue{ - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, - }, - }, - // More values... - }, +// To update an item in a table +// +// This example updates an item in the Music table. It adds a new attribute (Year) and +// modifies the AlbumTitle attribute. All of the attributes in the item, as they appear +// after the update, are returned in the response. +func ExampleDynamoDB_UpdateItem_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.UpdateItemInput{ ExpressionAttributeNames: map[string]*string{ - "Key": aws.String("AttributeName"), // Required - // More values... + "#AT": aws.String("AlbumTitle"), + "#Y": aws.String("Year"), }, ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - B: []byte("PAYLOAD"), - BOOL: aws.Bool(true), - BS: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - L: []*dynamodb.AttributeValue{ - { // Required - // Recursive values... - }, - // More values... - }, - M: map[string]*dynamodb.AttributeValue{ - "Key": { // Required - // Recursive values... - }, - // More values... - }, - N: aws.String("NumberAttributeValue"), - NS: []*string{ - aws.String("NumberAttributeValue"), // Required - // More values... - }, - NULL: aws.Bool(true), - S: aws.String("StringAttributeValue"), - SS: []*string{ - aws.String("StringAttributeValue"), // Required - // More values... - }, + ":t": { + S: aws.String("Louder Than Ever"), }, - // More values... - }, - ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"), - ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"), - ReturnValues: aws.String("ReturnValue"), - UpdateExpression: aws.String("UpdateExpression"), - } - resp, err := svc.UpdateItem(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDB_UpdateTable() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.UpdateTableInput{ - TableName: aws.String("TableName"), // Required - AttributeDefinitions: []*dynamodb.AttributeDefinition{ - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - AttributeType: aws.String("ScalarAttributeType"), // Required + ":y": { + N: aws.String("2015"), }, - // More values... }, - GlobalSecondaryIndexUpdates: []*dynamodb.GlobalSecondaryIndexUpdate{ - { // Required - Create: &dynamodb.CreateGlobalSecondaryIndexAction{ - IndexName: aws.String("IndexName"), // Required - KeySchema: []*dynamodb.KeySchemaElement{ // Required - { // Required - AttributeName: aws.String("KeySchemaAttributeName"), // Required - KeyType: aws.String("KeyType"), // Required - }, - // More values... - }, - Projection: &dynamodb.Projection{ // Required - NonKeyAttributes: []*string{ - aws.String("NonKeyAttributeName"), // Required - // More values... - }, - ProjectionType: aws.String("ProjectionType"), - }, - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required - ReadCapacityUnits: aws.Int64(1), // Required - WriteCapacityUnits: aws.Int64(1), // Required - }, - }, - Delete: &dynamodb.DeleteGlobalSecondaryIndexAction{ - IndexName: aws.String("IndexName"), // Required - }, - Update: &dynamodb.UpdateGlobalSecondaryIndexAction{ - IndexName: aws.String("IndexName"), // Required - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required - ReadCapacityUnits: aws.Int64(1), // Required - WriteCapacityUnits: aws.Int64(1), // Required - }, - }, + Key: map[string]*dynamodb.AttributeValue{ + "Artist": { + S: aws.String("Acme Band"), + }, + "SongTitle": { + S: aws.String("Happy Day"), }, - // More values... - }, - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ - ReadCapacityUnits: aws.Int64(1), // Required - WriteCapacityUnits: aws.Int64(1), // Required - }, - StreamSpecification: &dynamodb.StreamSpecification{ - StreamEnabled: aws.Bool(true), - StreamViewType: aws.String("StreamViewType"), }, + ReturnValues: aws.String("ALL_NEW"), + TableName: aws.String("Music"), + UpdateExpression: aws.String("SET #Y = :y, #AT = :t"), } - resp, err := svc.UpdateTable(params) + result, err := svc.UpdateItem(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 dynamodb.ErrCodeConditionalCheckFailedException: + fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error()) + case dynamodb.ErrCodeProvisionedThroughputExceededException: + fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeItemCollectionSizeLimitExceededException: + fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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 ExampleDynamoDB_UpdateTimeToLive() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.UpdateTimeToLiveInput{ - TableName: aws.String("TableName"), // Required - TimeToLiveSpecification: &dynamodb.TimeToLiveSpecification{ // Required - AttributeName: aws.String("TimeToLiveAttributeName"), // Required - Enabled: aws.Bool(true), // Required +// To modify a table's provisioned throughput +// +// This example increases the provisioned read and write capacity on the Music table. +func ExampleDynamoDB_UpdateTable_shared00() { + svc := dynamodb.New(session.New()) + input := &dynamodb.UpdateTableInput{ + ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(10.000000), + WriteCapacityUnits: aws.Int64(10.000000), }, + TableName: aws.String("MusicCollection"), } - resp, err := svc.UpdateTimeToLive(params) + result, err := svc.UpdateTable(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 dynamodb.ErrCodeResourceInUseException: + fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error()) + case dynamodb.ErrCodeResourceNotFoundException: + fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error()) + case dynamodb.ErrCodeLimitExceededException: + fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error()) + case dynamodb.ErrCodeInternalServerError: + fmt.Println(dynamodb.ErrCodeInternalServerError, 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) } diff --git a/service/dynamodbstreams/examples_test.go b/service/dynamodbstreams/examples_test.go deleted file mode 100644 index 2bb83483404..00000000000 --- a/service/dynamodbstreams/examples_test.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package dynamodbstreams_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/dynamodbstreams" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleDynamoDBStreams_DescribeStream() { - sess := session.Must(session.NewSession()) - - svc := dynamodbstreams.New(sess) - - params := &dynamodbstreams.DescribeStreamInput{ - StreamArn: aws.String("StreamArn"), // Required - ExclusiveStartShardId: aws.String("ShardId"), - Limit: aws.Int64(1), - } - resp, err := svc.DescribeStream(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDBStreams_GetRecords() { - sess := session.Must(session.NewSession()) - - svc := dynamodbstreams.New(sess) - - params := &dynamodbstreams.GetRecordsInput{ - ShardIterator: aws.String("ShardIterator"), // Required - Limit: aws.Int64(1), - } - resp, err := svc.GetRecords(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDBStreams_GetShardIterator() { - sess := session.Must(session.NewSession()) - - svc := dynamodbstreams.New(sess) - - params := &dynamodbstreams.GetShardIteratorInput{ - ShardId: aws.String("ShardId"), // Required - ShardIteratorType: aws.String("ShardIteratorType"), // Required - StreamArn: aws.String("StreamArn"), // Required - SequenceNumber: aws.String("SequenceNumber"), - } - resp, err := svc.GetShardIterator(params) - - if err != nil { - // 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) -} - -func ExampleDynamoDBStreams_ListStreams() { - sess := session.Must(session.NewSession()) - - svc := dynamodbstreams.New(sess) - - params := &dynamodbstreams.ListStreamsInput{ - ExclusiveStartStreamArn: aws.String("StreamArn"), - Limit: aws.Int64(1), - TableName: aws.String("TableName"), - } - resp, err := svc.ListStreams(params) - - if err != nil { - // 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) -} diff --git a/service/ec2/examples_test.go b/service/ec2/examples_test.go index 7a2133f4612..4d875fcd4ca 100644 --- a/service/ec2/examples_test.go +++ b/service/ec2/examples_test.go @@ -8,6957 +8,4194 @@ import ( "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/ec2" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleEC2_AcceptReservedInstancesExchangeQuote() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &ec2.AcceptReservedInstancesExchangeQuoteInput{ - ReservedInstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - TargetConfigurations: []*ec2.TargetConfigurationRequest{ - { // Required - OfferingId: aws.String("String"), // Required - InstanceCount: aws.Int64(1), - }, - // More values... - }, +// To allocate an Elastic IP address for EC2-VPC +// +// This example allocates an Elastic IP address to use with an instance in a VPC. +func ExampleEC2_AllocateAddress_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AllocateAddressInput{ + Domain: aws.String("vpc"), } - resp, err := svc.AcceptReservedInstancesExchangeQuote(params) + result, err := svc.AllocateAddress(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() { + 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 ExampleEC2_AcceptVpcPeeringConnection() { - sess := session.Must(session.NewSession()) +// To allocate an Elastic IP address for EC2-Classic +// +// This example allocates an Elastic IP address to use with an instance in EC2-Classic. +func ExampleEC2_AllocateAddress_shared01() { + svc := ec2.New(session.New()) + input := &ec2.AllocateAddressInput{} + + result, err := svc.AllocateAddress(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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 + } - svc := ec2.New(sess) + fmt.Println(result) +} - params := &ec2.AcceptVpcPeeringConnectionInput{ - DryRun: aws.Bool(true), - VpcPeeringConnectionId: aws.String("String"), +// To assign a specific secondary private IP address to an interface +// +// This example assigns the specified secondary private IP address to the specified +// network interface. +func ExampleEC2_AssignPrivateIpAddresses_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AssignPrivateIpAddressesInput{ + NetworkInterfaceId: aws.String("eni-e5aa89a3"), + PrivateIpAddresses: []*string{ + aws.String("10.0.0.82"), + }, } - resp, err := svc.AcceptVpcPeeringConnection(params) + result, err := svc.AssignPrivateIpAddresses(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() { + 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 ExampleEC2_AllocateAddress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AllocateAddressInput{ - Domain: aws.String("DomainType"), - DryRun: aws.Bool(true), +// To assign secondary private IP addresses that Amazon EC2 selects to an interface +// +// This example assigns two secondary private IP addresses to the specified network +// interface. Amazon EC2 automatically assigns these IP addresses from the available +// IP addresses in the CIDR block range of the subnet the network interface is associated +// with. +func ExampleEC2_AssignPrivateIpAddresses_shared01() { + svc := ec2.New(session.New()) + input := &ec2.AssignPrivateIpAddressesInput{ + NetworkInterfaceId: aws.String("eni-e5aa89a3"), + SecondaryPrivateIpAddressCount: aws.Int64(2.000000), } - resp, err := svc.AllocateAddress(params) + result, err := svc.AssignPrivateIpAddresses(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() { + 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 ExampleEC2_AllocateHosts() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AllocateHostsInput{ - AvailabilityZone: aws.String("String"), // Required - InstanceType: aws.String("String"), // Required - Quantity: aws.Int64(1), // Required - AutoPlacement: aws.String("AutoPlacement"), - ClientToken: aws.String("String"), +// To associate an Elastic IP address in EC2-VPC +// +// This example associates the specified Elastic IP address with the specified instance +// in a VPC. +func ExampleEC2_AssociateAddress_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AssociateAddressInput{ + AllocationId: aws.String("eipalloc-64d5890a"), + InstanceId: aws.String("i-0b263919b6498b123"), } - resp, err := svc.AllocateHosts(params) + result, err := svc.AssociateAddress(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() { + 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 ExampleEC2_AssignIpv6Addresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssignIpv6AddressesInput{ - NetworkInterfaceId: aws.String("String"), // Required - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*string{ - aws.String("String"), // Required - // More values... - }, +// To associate an Elastic IP address with a network interface +// +// This example associates the specified Elastic IP address with the specified network +// interface. +func ExampleEC2_AssociateAddress_shared01() { + svc := ec2.New(session.New()) + input := &ec2.AssociateAddressInput{ + AllocationId: aws.String("eipalloc-64d5890a"), + NetworkInterfaceId: aws.String("eni-1a2b3c4d"), } - resp, err := svc.AssignIpv6Addresses(params) + result, err := svc.AssociateAddress(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() { + 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 ExampleEC2_AssignPrivateIpAddresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssignPrivateIpAddressesInput{ - NetworkInterfaceId: aws.String("String"), // Required - AllowReassignment: aws.Bool(true), - PrivateIpAddresses: []*string{ - aws.String("String"), // Required - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), +// To associate an Elastic IP address in EC2-Classic +// +// This example associates an Elastic IP address with an instance in EC2-Classic. +func ExampleEC2_AssociateAddress_shared02() { + svc := ec2.New(session.New()) + input := &ec2.AssociateAddressInput{ + InstanceId: aws.String("i-07ffe74c7330ebf53"), + PublicIp: aws.String("198.51.100.0"), } - resp, err := svc.AssignPrivateIpAddresses(params) + result, err := svc.AssociateAddress(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() { + 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 ExampleEC2_AssociateAddress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateAddressInput{ - AllocationId: aws.String("String"), - AllowReassociation: aws.Bool(true), - DryRun: aws.Bool(true), - InstanceId: aws.String("String"), - NetworkInterfaceId: aws.String("String"), - PrivateIpAddress: aws.String("String"), - PublicIp: aws.String("String"), +// To associate a DHCP options set with a VPC +// +// This example associates the specified DHCP options set with the specified VPC. +func ExampleEC2_AssociateDhcpOptions_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AssociateDhcpOptionsInput{ + DhcpOptionsId: aws.String("dopt-d9070ebb"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.AssociateAddress(params) + result, err := svc.AssociateDhcpOptions(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() { + 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 ExampleEC2_AssociateDhcpOptions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateDhcpOptionsInput{ - DhcpOptionsId: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To associate the default DHCP options set with a VPC +// +// This example associates the default DHCP options set with the specified VPC. +func ExampleEC2_AssociateDhcpOptions_shared01() { + svc := ec2.New(session.New()) + input := &ec2.AssociateDhcpOptionsInput{ + DhcpOptionsId: aws.String("default"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.AssociateDhcpOptions(params) + result, err := svc.AssociateDhcpOptions(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() { + 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 ExampleEC2_AssociateIamInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateIamInstanceProfileInput{ - IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ // Required - Arn: aws.String("String"), - Name: aws.String("String"), - }, - InstanceId: aws.String("String"), // Required +// To associate a route table with a subnet +// +// This example associates the specified route table with the specified subnet. +func ExampleEC2_AssociateRouteTable_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AssociateRouteTableInput{ + RouteTableId: aws.String("rtb-22574640"), + SubnetId: aws.String("subnet-9d4a7b6"), } - resp, err := svc.AssociateIamInstanceProfile(params) + result, err := svc.AssociateRouteTable(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() { + 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 ExampleEC2_AssociateRouteTable() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateRouteTableInput{ - RouteTableId: aws.String("String"), // Required - SubnetId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To attach an Internet gateway to a VPC +// +// This example attaches the specified Internet gateway to the specified VPC. +func ExampleEC2_AttachInternetGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AttachInternetGatewayInput{ + InternetGatewayId: aws.String("igw-c0a643a9"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.AssociateRouteTable(params) + result, err := svc.AttachInternetGateway(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() { + 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 ExampleEC2_AssociateSubnetCidrBlock() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateSubnetCidrBlockInput{ - Ipv6CidrBlock: aws.String("String"), // Required - SubnetId: aws.String("String"), // Required +// To attach a network interface to an instance +// +// This example attaches the specified network interface to the specified instance. +func ExampleEC2_AttachNetworkInterface_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AttachNetworkInterfaceInput{ + DeviceIndex: aws.Int64(1.000000), + InstanceId: aws.String("i-1234567890abcdef0"), + NetworkInterfaceId: aws.String("eni-e5aa89a3"), } - resp, err := svc.AssociateSubnetCidrBlock(params) + result, err := svc.AttachNetworkInterface(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() { + 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 ExampleEC2_AssociateVpcCidrBlock() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AssociateVpcCidrBlockInput{ - VpcId: aws.String("String"), // Required - AmazonProvidedIpv6CidrBlock: aws.Bool(true), +// To attach a volume to an instance +// +// This example attaches a volume (``vol-1234567890abcdef0``) to an instance (``i-01474ef662b89480``) +// as ``/dev/sdf``. +func ExampleEC2_AttachVolume_shared00() { + svc := ec2.New(session.New()) + input := &ec2.AttachVolumeInput{ + Device: aws.String("/dev/sdf"), + InstanceId: aws.String("i-01474ef662b89480"), + VolumeId: aws.String("vol-1234567890abcdef0"), } - resp, err := svc.AssociateVpcCidrBlock(params) + result, err := svc.AttachVolume(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() { + 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 ExampleEC2_AttachClassicLinkVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AttachClassicLinkVpcInput{ - Groups: []*string{ // Required - aws.String("String"), // Required - // More values... +// To cancel a Spot fleet request +// +// This example cancels the specified Spot fleet request and terminates its associated +// Spot Instances. +func ExampleEC2_CancelSpotFleetRequests_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CancelSpotFleetRequestsInput{ + SpotFleetRequestIds: []*string{ + aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), }, - InstanceId: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), + TerminateInstances: aws.Bool(true), } - resp, err := svc.AttachClassicLinkVpc(params) + result, err := svc.CancelSpotFleetRequests(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() { + 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 ExampleEC2_AttachInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AttachInternetGatewayInput{ - InternetGatewayId: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To cancel a Spot fleet request without terminating its Spot Instances +// +// This example cancels the specified Spot fleet request without terminating its associated +// Spot Instances. +func ExampleEC2_CancelSpotFleetRequests_shared01() { + svc := ec2.New(session.New()) + input := &ec2.CancelSpotFleetRequestsInput{ + SpotFleetRequestIds: []*string{ + aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), + }, + TerminateInstances: aws.Bool(false), } - resp, err := svc.AttachInternetGateway(params) + result, err := svc.CancelSpotFleetRequests(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() { + 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 ExampleEC2_AttachNetworkInterface() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AttachNetworkInterfaceInput{ - DeviceIndex: aws.Int64(1), // Required - InstanceId: aws.String("String"), // Required - NetworkInterfaceId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To cancel Spot Instance requests +// +// This example cancels a Spot Instance request. +func ExampleEC2_CancelSpotInstanceRequests_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CancelSpotInstanceRequestsInput{ + SpotInstanceRequestIds: []*string{ + aws.String("sir-08b93456"), + }, } - resp, err := svc.AttachNetworkInterface(params) + result, err := svc.CancelSpotInstanceRequests(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() { + 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 ExampleEC2_AttachVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AttachVolumeInput{ - Device: aws.String("String"), // Required - InstanceId: aws.String("String"), // Required - VolumeId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To confirm the product instance +// +// This example determines whether the specified product code is associated with the +// specified instance. +func ExampleEC2_ConfirmProductInstance_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ConfirmProductInstanceInput{ + InstanceId: aws.String("i-1234567890abcdef0"), + ProductCode: aws.String("774F4FF8"), } - resp, err := svc.AttachVolume(params) + result, err := svc.ConfirmProductInstance(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() { + 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 ExampleEC2_AttachVpnGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AttachVpnGatewayInput{ - VpcId: aws.String("String"), // Required - VpnGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To copy a snapshot +// +// This example copies a snapshot with the snapshot ID of ``snap-066877671789bd71b`` +// from the ``us-west-2`` region to the ``us-east-1`` region and adds a short description +// to identify the snapshot. +func ExampleEC2_CopySnapshot_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CopySnapshotInput{ + Description: aws.String("This is my copied snapshot."), + DestinationRegion: aws.String("us-east-1"), + SourceRegion: aws.String("us-west-2"), + SourceSnapshotId: aws.String("snap-066877671789bd71b"), } - resp, err := svc.AttachVpnGateway(params) + result, err := svc.CopySnapshot(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() { + 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 ExampleEC2_AuthorizeSecurityGroupEgress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AuthorizeSecurityGroupEgressInput{ - GroupId: aws.String("String"), // Required - CidrIp: aws.String("String"), - DryRun: aws.Bool(true), - FromPort: aws.Int64(1), - IpPermissions: []*ec2.IpPermission{ - { // Required - FromPort: aws.Int64(1), - IpProtocol: aws.String("String"), - IpRanges: []*ec2.IpRange{ - { // Required - CidrIp: aws.String("String"), - }, - // More values... - }, - Ipv6Ranges: []*ec2.Ipv6Range{ - { // Required - CidrIpv6: aws.String("String"), - }, - // More values... - }, - PrefixListIds: []*ec2.PrefixListId{ - { // Required - PrefixListId: aws.String("String"), - }, - // More values... - }, - ToPort: aws.Int64(1), - UserIdGroupPairs: []*ec2.UserIdGroupPair{ - { // Required - GroupId: aws.String("String"), - GroupName: aws.String("String"), - PeeringStatus: aws.String("String"), - UserId: aws.String("String"), - VpcId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), - }, - // More values... - }, - }, - // More values... - }, - IpProtocol: aws.String("String"), - SourceSecurityGroupName: aws.String("String"), - SourceSecurityGroupOwnerId: aws.String("String"), - ToPort: aws.Int64(1), +// To create a customer gateway +// +// This example creates a customer gateway with the specified IP address for its outside +// interface. +func ExampleEC2_CreateCustomerGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateCustomerGatewayInput{ + BgpAsn: aws.Int64(65534.000000), + PublicIp: aws.String("12.1.2.3"), + Type: aws.String("ipsec.1"), } - resp, err := svc.AuthorizeSecurityGroupEgress(params) + result, err := svc.CreateCustomerGateway(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() { + 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 ExampleEC2_AuthorizeSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.AuthorizeSecurityGroupIngressInput{ - CidrIp: aws.String("String"), - DryRun: aws.Bool(true), - FromPort: aws.Int64(1), - GroupId: aws.String("String"), - GroupName: aws.String("String"), - IpPermissions: []*ec2.IpPermission{ - { // Required - FromPort: aws.Int64(1), - IpProtocol: aws.String("String"), - IpRanges: []*ec2.IpRange{ - { // Required - CidrIp: aws.String("String"), - }, - // More values... - }, - Ipv6Ranges: []*ec2.Ipv6Range{ - { // Required - CidrIpv6: aws.String("String"), - }, - // More values... - }, - PrefixListIds: []*ec2.PrefixListId{ - { // Required - PrefixListId: aws.String("String"), - }, - // More values... - }, - ToPort: aws.Int64(1), - UserIdGroupPairs: []*ec2.UserIdGroupPair{ - { // Required - GroupId: aws.String("String"), - GroupName: aws.String("String"), - PeeringStatus: aws.String("String"), - UserId: aws.String("String"), - VpcId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), - }, - // More values... +// To create a DHCP options set +// +// This example creates a DHCP options set. +func ExampleEC2_CreateDhcpOptions_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateDhcpOptionsInput{ + DhcpConfigurations: []*ec2.NewDhcpConfigurationList{ + { + Key: aws.String("domain-name-servers"), + Values: []*string{ + aws.String("10.2.5.1"), + aws.String("10.2.5.2"), }, }, - // More values... }, - IpProtocol: aws.String("String"), - SourceSecurityGroupName: aws.String("String"), - SourceSecurityGroupOwnerId: aws.String("String"), - ToPort: aws.Int64(1), } - resp, err := svc.AuthorizeSecurityGroupIngress(params) + result, err := svc.CreateDhcpOptions(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() { + 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 ExampleEC2_BundleInstance() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.BundleInstanceInput{ - InstanceId: aws.String("String"), // Required - Storage: &ec2.Storage{ // Required - S3: &ec2.S3Storage{ - AWSAccessKeyId: aws.String("String"), - Bucket: aws.String("String"), - Prefix: aws.String("String"), - UploadPolicy: []byte("PAYLOAD"), - UploadPolicySignature: aws.String("String"), - }, - }, - DryRun: aws.Bool(true), - } - resp, err := svc.BundleInstance(params) +// To create an Internet gateway +// +// This example creates an Internet gateway. +func ExampleEC2_CreateInternetGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateInternetGatewayInput{} + result, err := svc.CreateInternetGateway(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() { + 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 ExampleEC2_CancelBundleTask() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelBundleTaskInput{ - BundleId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To create a key pair +// +// This example creates a key pair named my-key-pair. +func ExampleEC2_CreateKeyPair_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateKeyPairInput{ + KeyName: aws.String("my-key-pair"), } - resp, err := svc.CancelBundleTask(params) + result, err := svc.CreateKeyPair(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() { + 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 ExampleEC2_CancelConversionTask() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelConversionTaskInput{ - ConversionTaskId: aws.String("String"), // Required - DryRun: aws.Bool(true), - ReasonMessage: aws.String("String"), +// To create a NAT gateway +// +// This example creates a NAT gateway in subnet subnet-1a2b3c4d and associates an Elastic +// IP address with the allocation ID eipalloc-37fc1a52 with the NAT gateway. +func ExampleEC2_CreateNatGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateNatGatewayInput{ + AllocationId: aws.String("eipalloc-37fc1a52"), + SubnetId: aws.String("subnet-1a2b3c4d"), } - resp, err := svc.CancelConversionTask(params) + result, err := svc.CreateNatGateway(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() { + 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 ExampleEC2_CancelExportTask() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelExportTaskInput{ - ExportTaskId: aws.String("String"), // Required +// To create a network ACL +// +// This example creates a network ACL for the specified VPC. +func ExampleEC2_CreateNetworkAcl_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateNetworkAclInput{ + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.CancelExportTask(params) + result, err := svc.CreateNetworkAcl(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() { + 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 ExampleEC2_CancelImportTask() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelImportTaskInput{ - CancelReason: aws.String("String"), - DryRun: aws.Bool(true), - ImportTaskId: aws.String("String"), +// To create a network ACL entry +// +// This example creates an entry for the specified network ACL. The rule allows ingress +// traffic from anywhere (0.0.0.0/0) on UDP port 53 (DNS) into any associated subnet. +func ExampleEC2_CreateNetworkAclEntry_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateNetworkAclEntryInput{ + CidrBlock: aws.String("0.0.0.0/0"), + Egress: aws.Bool(false), + NetworkAclId: aws.String("acl-5fb85d36"), + PortRange: &ec2.PortRange{ + From: aws.Int64(53.000000), + To: aws.Int64(53.000000), + }, + Protocol: aws.String("udp"), + RuleAction: aws.String("allow"), + RuleNumber: aws.Int64(100.000000), } - resp, err := svc.CancelImportTask(params) + result, err := svc.CreateNetworkAclEntry(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() { + 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 ExampleEC2_CancelReservedInstancesListing() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelReservedInstancesListingInput{ - ReservedInstancesListingId: aws.String("String"), // Required +// To create a network interface +// +// This example creates a network interface for the specified subnet. +func ExampleEC2_CreateNetworkInterface_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateNetworkInterfaceInput{ + Description: aws.String("my network interface"), + Groups: []*string{ + aws.String("sg-903004f8"), + }, + PrivateIpAddress: aws.String("10.0.2.17"), + SubnetId: aws.String("subnet-9d4a7b6c"), } - resp, err := svc.CancelReservedInstancesListing(params) + result, err := svc.CreateNetworkInterface(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() { + 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 ExampleEC2_CancelSpotFleetRequests() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelSpotFleetRequestsInput{ - SpotFleetRequestIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - TerminateInstances: aws.Bool(true), // Required - DryRun: aws.Bool(true), +// To create a placement group +// +// This example creates a placement group with the specified name. +func ExampleEC2_CreatePlacementGroup_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreatePlacementGroupInput{ + GroupName: aws.String("my-cluster"), + Strategy: aws.String("cluster"), } - resp, err := svc.CancelSpotFleetRequests(params) + result, err := svc.CreatePlacementGroup(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() { + 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 ExampleEC2_CancelSpotInstanceRequests() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CancelSpotInstanceRequestsInput{ - SpotInstanceRequestIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), +// To create a route +// +// This example creates a route for the specified route table. The route matches all +// traffic (0.0.0.0/0) and routes it to the specified Internet gateway. +func ExampleEC2_CreateRoute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateRouteInput{ + DestinationCidrBlock: aws.String("0.0.0.0/0"), + GatewayId: aws.String("igw-c0a643a9"), + RouteTableId: aws.String("rtb-22574640"), } - resp, err := svc.CancelSpotInstanceRequests(params) + result, err := svc.CreateRoute(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() { + 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 ExampleEC2_ConfirmProductInstance() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ConfirmProductInstanceInput{ - InstanceId: aws.String("String"), // Required - ProductCode: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To create a route table +// +// This example creates a route table for the specified VPC. +func ExampleEC2_CreateRouteTable_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateRouteTableInput{ + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.ConfirmProductInstance(params) + result, err := svc.CreateRouteTable(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() { + 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 ExampleEC2_CopyImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CopyImageInput{ - Name: aws.String("String"), // Required - SourceImageId: aws.String("String"), // Required - SourceRegion: aws.String("String"), // Required - ClientToken: aws.String("String"), - Description: aws.String("String"), - DryRun: aws.Bool(true), - Encrypted: aws.Bool(true), - KmsKeyId: aws.String("String"), +// To create a snapshot +// +// This example creates a snapshot of the volume with a volume ID of ``vol-1234567890abcdef0`` +// and a short description to identify the snapshot. +func ExampleEC2_CreateSnapshot_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateSnapshotInput{ + Description: aws.String("This is my root volume snapshot."), + VolumeId: aws.String("vol-1234567890abcdef0"), } - resp, err := svc.CopyImage(params) + result, err := svc.CreateSnapshot(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() { + 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 ExampleEC2_CopySnapshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CopySnapshotInput{ - SourceRegion: aws.String("String"), // Required - SourceSnapshotId: aws.String("String"), // Required - Description: aws.String("String"), - DestinationRegion: aws.String("String"), - DryRun: aws.Bool(true), - Encrypted: aws.Bool(true), - KmsKeyId: aws.String("String"), - PresignedUrl: aws.String("String"), +// To create a Spot Instance datafeed +// +// This example creates a Spot Instance data feed for your AWS account. +func ExampleEC2_CreateSpotDatafeedSubscription_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateSpotDatafeedSubscriptionInput{ + Bucket: aws.String("my-s3-bucket"), + Prefix: aws.String("spotdata"), } - resp, err := svc.CopySnapshot(params) + result, err := svc.CreateSpotDatafeedSubscription(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() { + 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 ExampleEC2_CreateCustomerGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateCustomerGatewayInput{ - BgpAsn: aws.Int64(1), // Required - PublicIp: aws.String("String"), // Required - Type: aws.String("GatewayType"), // Required - DryRun: aws.Bool(true), +// To create a subnet +// +// This example creates a subnet in the specified VPC with the specified CIDR block. +// We recommend that you let us select an Availability Zone for you. +func ExampleEC2_CreateSubnet_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateSubnetInput{ + CidrBlock: aws.String("10.0.1.0/24"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.CreateCustomerGateway(params) + result, err := svc.CreateSubnet(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() { + 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 ExampleEC2_CreateDhcpOptions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateDhcpOptionsInput{ - DhcpConfigurations: []*ec2.NewDhcpConfiguration{ // Required - { // Required - Key: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, +// To add a tag to a resource +// +// This example adds the tag Stack=production to the specified image, or overwrites +// an existing tag for the AMI where the tag key is Stack. +func ExampleEC2_CreateTags_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateTagsInput{ + Resources: []*string{ + aws.String("ami-78a54011"), + }, + Tags: []*ec2.TagList{ + { + Key: aws.String("Stack"), + Value: aws.String("production"), }, - // More values... }, - DryRun: aws.Bool(true), } - resp, err := svc.CreateDhcpOptions(params) + result, err := svc.CreateTags(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() { + 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 ExampleEC2_CreateEgressOnlyInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateEgressOnlyInternetGatewayInput{ - VpcId: aws.String("String"), // Required - ClientToken: aws.String("String"), - DryRun: aws.Bool(true), +// To create a new volume +// +// This example creates an 80 GiB General Purpose (SSD) volume in the Availability Zone +// ``us-east-1a``. +func ExampleEC2_CreateVolume_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateVolumeInput{ + AvailabilityZone: aws.String("us-east-1a"), + Size: aws.Int64(80.000000), + VolumeType: aws.String("gp2"), } - resp, err := svc.CreateEgressOnlyInternetGateway(params) + result, err := svc.CreateVolume(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() { + 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 ExampleEC2_CreateFlowLogs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateFlowLogsInput{ - DeliverLogsPermissionArn: aws.String("String"), // Required - LogGroupName: aws.String("String"), // Required - ResourceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - ResourceType: aws.String("FlowLogsResourceType"), // Required - TrafficType: aws.String("TrafficType"), // Required - ClientToken: aws.String("String"), +// To create a new Provisioned IOPS (SSD) volume from a snapshot +// +// This example creates a new Provisioned IOPS (SSD) volume with 1000 provisioned IOPS +// from a snapshot in the Availability Zone ``us-east-1a``. +func ExampleEC2_CreateVolume_shared01() { + svc := ec2.New(session.New()) + input := &ec2.CreateVolumeInput{ + AvailabilityZone: aws.String("us-east-1a"), + Iops: aws.Int64(1000.000000), + SnapshotId: aws.String("snap-066877671789bd71b"), + VolumeType: aws.String("io1"), } - resp, err := svc.CreateFlowLogs(params) + result, err := svc.CreateVolume(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() { + 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 ExampleEC2_CreateFpgaImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateFpgaImageInput{ - InputStorageLocation: &ec2.StorageLocation{ // Required - Bucket: aws.String("String"), - Key: aws.String("String"), - }, - ClientToken: aws.String("String"), - Description: aws.String("String"), - DryRun: aws.Bool(true), - LogsStorageLocation: &ec2.StorageLocation{ - Bucket: aws.String("String"), - Key: aws.String("String"), - }, - Name: aws.String("String"), +// To create a VPC +// +// This example creates a VPC with the specified CIDR block. +func ExampleEC2_CreateVpc_shared00() { + svc := ec2.New(session.New()) + input := &ec2.CreateVpcInput{ + CidrBlock: aws.String("10.0.0.0/16"), } - resp, err := svc.CreateFpgaImage(params) + result, err := svc.CreateVpc(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() { + 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 ExampleEC2_CreateImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateImageInput{ - InstanceId: aws.String("String"), // Required - Name: aws.String("String"), // Required - BlockDeviceMappings: []*ec2.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - Description: aws.String("String"), - DryRun: aws.Bool(true), - NoReboot: aws.Bool(true), +// To delete a customer gateway +// +// This example deletes the specified customer gateway. +func ExampleEC2_DeleteCustomerGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteCustomerGatewayInput{ + CustomerGatewayId: aws.String("cgw-0e11f167"), } - resp, err := svc.CreateImage(params) + result, err := svc.DeleteCustomerGateway(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() { + 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 ExampleEC2_CreateInstanceExportTask() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateInstanceExportTaskInput{ - InstanceId: aws.String("String"), // Required - Description: aws.String("String"), - ExportToS3Task: &ec2.ExportToS3TaskSpecification{ - ContainerFormat: aws.String("ContainerFormat"), - DiskImageFormat: aws.String("DiskImageFormat"), - S3Bucket: aws.String("String"), - S3Prefix: aws.String("String"), - }, - TargetEnvironment: aws.String("ExportEnvironment"), +// To delete a DHCP options set +// +// This example deletes the specified DHCP options set. +func ExampleEC2_DeleteDhcpOptions_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteDhcpOptionsInput{ + DhcpOptionsId: aws.String("dopt-d9070ebb"), } - resp, err := svc.CreateInstanceExportTask(params) + result, err := svc.DeleteDhcpOptions(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() { + 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 ExampleEC2_CreateInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateInternetGatewayInput{ - DryRun: aws.Bool(true), +// To delete an Internet gateway +// +// This example deletes the specified Internet gateway. +func ExampleEC2_DeleteInternetGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteInternetGatewayInput{ + InternetGatewayId: aws.String("igw-c0a643a9"), } - resp, err := svc.CreateInternetGateway(params) + result, err := svc.DeleteInternetGateway(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() { + 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 ExampleEC2_CreateKeyPair() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateKeyPairInput{ - KeyName: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To delete a key pair +// +// This example deletes the specified key pair. +func ExampleEC2_DeleteKeyPair_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteKeyPairInput{ + KeyName: aws.String("my-key-pair"), } - resp, err := svc.CreateKeyPair(params) + result, err := svc.DeleteKeyPair(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() { + 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 ExampleEC2_CreateNatGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateNatGatewayInput{ - AllocationId: aws.String("String"), // Required - SubnetId: aws.String("String"), // Required - ClientToken: aws.String("String"), +// To delete a NAT gateway +// +// This example deletes the specified NAT gateway. +func ExampleEC2_DeleteNatGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteNatGatewayInput{ + NatGatewayId: aws.String("nat-04ae55e711cec5680"), } - resp, err := svc.CreateNatGateway(params) + result, err := svc.DeleteNatGateway(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() { + 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 ExampleEC2_CreateNetworkAcl() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateNetworkAclInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To delete a network ACL +// +// This example deletes the specified network ACL. +func ExampleEC2_DeleteNetworkAcl_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteNetworkAclInput{ + NetworkAclId: aws.String("acl-5fb85d36"), } - resp, err := svc.CreateNetworkAcl(params) + result, err := svc.DeleteNetworkAcl(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() { + 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 ExampleEC2_CreateNetworkAclEntry() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateNetworkAclEntryInput{ - Egress: aws.Bool(true), // Required - NetworkAclId: aws.String("String"), // Required - Protocol: aws.String("String"), // Required - RuleAction: aws.String("RuleAction"), // Required - RuleNumber: aws.Int64(1), // Required - CidrBlock: aws.String("String"), - DryRun: aws.Bool(true), - IcmpTypeCode: &ec2.IcmpTypeCode{ - Code: aws.Int64(1), - Type: aws.Int64(1), - }, - Ipv6CidrBlock: aws.String("String"), - PortRange: &ec2.PortRange{ - From: aws.Int64(1), - To: aws.Int64(1), - }, +// To delete a network ACL entry +// +// This example deletes ingress rule number 100 from the specified network ACL. +func ExampleEC2_DeleteNetworkAclEntry_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteNetworkAclEntryInput{ + Egress: aws.Bool(true), + NetworkAclId: aws.String("acl-5fb85d36"), + RuleNumber: aws.Int64(100.000000), } - resp, err := svc.CreateNetworkAclEntry(params) + result, err := svc.DeleteNetworkAclEntry(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() { + 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 ExampleEC2_CreateNetworkInterface() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateNetworkInterfaceInput{ - SubnetId: aws.String("String"), // Required - Description: aws.String("String"), - DryRun: aws.Bool(true), - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.InstanceIpv6Address{ - { // Required - Ipv6Address: aws.String("String"), - }, - // More values... - }, - PrivateIpAddress: aws.String("String"), - PrivateIpAddresses: []*ec2.PrivateIpAddressSpecification{ - { // Required - PrivateIpAddress: aws.String("String"), // Required - Primary: aws.Bool(true), - }, - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), +// To delete a network interface +// +// This example deletes the specified network interface. +func ExampleEC2_DeleteNetworkInterface_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteNetworkInterfaceInput{ + NetworkInterfaceId: aws.String("eni-e5aa89a3"), } - resp, err := svc.CreateNetworkInterface(params) + result, err := svc.DeleteNetworkInterface(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() { + 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 ExampleEC2_CreatePlacementGroup() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreatePlacementGroupInput{ - GroupName: aws.String("String"), // Required - Strategy: aws.String("PlacementStrategy"), // Required - DryRun: aws.Bool(true), +// To delete a placement group +// +// This example deletes the specified placement group. +// +func ExampleEC2_DeletePlacementGroup_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeletePlacementGroupInput{ + GroupName: aws.String("my-cluster"), } - resp, err := svc.CreatePlacementGroup(params) + result, err := svc.DeletePlacementGroup(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() { + 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 ExampleEC2_CreateReservedInstancesListing() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateReservedInstancesListingInput{ - ClientToken: aws.String("String"), // Required - InstanceCount: aws.Int64(1), // Required - PriceSchedules: []*ec2.PriceScheduleSpecification{ // Required - { // Required - CurrencyCode: aws.String("CurrencyCodeValues"), - Price: aws.Float64(1.0), - Term: aws.Int64(1), - }, - // More values... - }, - ReservedInstancesId: aws.String("String"), // Required +// To delete a route +// +// This example deletes the specified route from the specified route table. +func ExampleEC2_DeleteRoute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteRouteInput{ + DestinationCidrBlock: aws.String("0.0.0.0/0"), + RouteTableId: aws.String("rtb-22574640"), } - resp, err := svc.CreateReservedInstancesListing(params) + result, err := svc.DeleteRoute(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() { + 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 ExampleEC2_CreateRoute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateRouteInput{ - RouteTableId: aws.String("String"), // Required - DestinationCidrBlock: aws.String("String"), - DestinationIpv6CidrBlock: aws.String("String"), - DryRun: aws.Bool(true), - EgressOnlyInternetGatewayId: aws.String("String"), - GatewayId: aws.String("String"), - InstanceId: aws.String("String"), - NatGatewayId: aws.String("String"), - NetworkInterfaceId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), +// To delete a route table +// +// This example deletes the specified route table. +func ExampleEC2_DeleteRouteTable_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteRouteTableInput{ + RouteTableId: aws.String("rtb-22574640"), } - resp, err := svc.CreateRoute(params) + result, err := svc.DeleteRouteTable(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() { + 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 ExampleEC2_CreateRouteTable() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateRouteTableInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To delete a snapshot +// +// This example deletes a snapshot with the snapshot ID of ``snap-1234567890abcdef0``. +// If the command succeeds, no output is returned. +func ExampleEC2_DeleteSnapshot_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteSnapshotInput{ + SnapshotId: aws.String("snap-1234567890abcdef0"), } - resp, err := svc.CreateRouteTable(params) + result, err := svc.DeleteSnapshot(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() { + 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 ExampleEC2_CreateSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateSecurityGroupInput{ - Description: aws.String("String"), // Required - GroupName: aws.String("String"), // Required - DryRun: aws.Bool(true), - VpcId: aws.String("String"), - } - resp, err := svc.CreateSecurityGroup(params) +// To cancel a Spot Instance data feed subscription +// +// This example deletes a Spot data feed subscription for the account. +func ExampleEC2_DeleteSpotDatafeedSubscription_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteSpotDatafeedSubscriptionInput{} + result, err := svc.DeleteSpotDatafeedSubscription(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() { + 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 ExampleEC2_CreateSnapshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateSnapshotInput{ - VolumeId: aws.String("String"), // Required - Description: aws.String("String"), - DryRun: aws.Bool(true), +// To delete a subnet +// +// This example deletes the specified subnet. +func ExampleEC2_DeleteSubnet_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteSubnetInput{ + SubnetId: aws.String("subnet-9d4a7b6c"), } - resp, err := svc.CreateSnapshot(params) + result, err := svc.DeleteSubnet(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() { + 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 ExampleEC2_CreateSpotDatafeedSubscription() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateSpotDatafeedSubscriptionInput{ - Bucket: aws.String("String"), // Required - DryRun: aws.Bool(true), - Prefix: aws.String("String"), +// To delete a tag from a resource +// +// This example deletes the tag Stack=test from the specified image. +func ExampleEC2_DeleteTags_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteTagsInput{ + Resources: []*string{ + aws.String("ami-78a54011"), + }, + Tags: []*ec2.TagList{ + { + Key: aws.String("Stack"), + Value: aws.String("test"), + }, + }, } - resp, err := svc.CreateSpotDatafeedSubscription(params) + result, err := svc.DeleteTags(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() { + 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 ExampleEC2_CreateSubnet() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateSubnetInput{ - CidrBlock: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - AvailabilityZone: aws.String("String"), - DryRun: aws.Bool(true), - Ipv6CidrBlock: aws.String("String"), +// To delete a volume +// +// This example deletes an available volume with the volume ID of ``vol-049df61146c4d7901``. +// If the command succeeds, no output is returned. +func ExampleEC2_DeleteVolume_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteVolumeInput{ + VolumeId: aws.String("vol-049df61146c4d7901"), } - resp, err := svc.CreateSubnet(params) + result, err := svc.DeleteVolume(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() { + 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 ExampleEC2_CreateTags() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateTagsInput{ - Resources: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Tags: []*ec2.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - DryRun: aws.Bool(true), +// To delete a VPC +// +// This example deletes the specified VPC. +func ExampleEC2_DeleteVpc_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DeleteVpcInput{ + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.CreateTags(params) + result, err := svc.DeleteVpc(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() { + 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 ExampleEC2_CreateVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVolumeInput{ - AvailabilityZone: aws.String("String"), // Required - DryRun: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - KmsKeyId: aws.String("String"), - Size: aws.Int64(1), - SnapshotId: aws.String("String"), - TagSpecifications: []*ec2.TagSpecification{ - { // Required - ResourceType: aws.String("ResourceType"), - Tags: []*ec2.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - }, - // More values... +// To describe a single attribute for your AWS account +// +// This example describes the supported-platforms attribute for your AWS account. +func ExampleEC2_DescribeAccountAttributes_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAccountAttributesInput{ + AttributeNames: []*string{ + aws.String("supported-platforms"), }, - VolumeType: aws.String("VolumeType"), } - resp, err := svc.CreateVolume(params) + result, err := svc.DescribeAccountAttributes(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() { + 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 ExampleEC2_CreateVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpcInput{ - CidrBlock: aws.String("String"), // Required - AmazonProvidedIpv6CidrBlock: aws.Bool(true), - DryRun: aws.Bool(true), - InstanceTenancy: aws.String("Tenancy"), - } - resp, err := svc.CreateVpc(params) +// To describe all attributes for your AWS account +// +// This example describes the attributes for your AWS account. +func ExampleEC2_DescribeAccountAttributes_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAccountAttributesInput{} + result, err := svc.DescribeAccountAttributes(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() { + 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 ExampleEC2_CreateVpcEndpoint() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpcEndpointInput{ - ServiceName: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - ClientToken: aws.String("String"), - DryRun: aws.Bool(true), - PolicyDocument: aws.String("String"), - RouteTableIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateVpcEndpoint(params) +// To describe your Elastic IP addresses +// +// This example describes your Elastic IP addresses. +func ExampleEC2_DescribeAddresses_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAddressesInput{} + result, err := svc.DescribeAddresses(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() { + 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 ExampleEC2_CreateVpcPeeringConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpcPeeringConnectionInput{ - DryRun: aws.Bool(true), - PeerOwnerId: aws.String("String"), - PeerVpcId: aws.String("String"), - VpcId: aws.String("String"), +// To describe your Elastic IP addresses for EC2-VPC +// +// This example describes your Elastic IP addresses for use with instances in a VPC. +func ExampleEC2_DescribeAddresses_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAddressesInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("domain"), + Values: []*string{ + aws.String("vpc"), + }, + }, + }, } - resp, err := svc.CreateVpcPeeringConnection(params) + result, err := svc.DescribeAddresses(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() { + 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 ExampleEC2_CreateVpnConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpnConnectionInput{ - CustomerGatewayId: aws.String("String"), // Required - Type: aws.String("String"), // Required - VpnGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), - Options: &ec2.VpnConnectionOptionsSpecification{ - StaticRoutesOnly: aws.Bool(true), +// To describe your Elastic IP addresses for EC2-Classic +// +// This example describes your Elastic IP addresses for use with instances in EC2-Classic. +func ExampleEC2_DescribeAddresses_shared02() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAddressesInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("domain"), + Values: []*string{ + aws.String("standard"), + }, + }, }, } - resp, err := svc.CreateVpnConnection(params) + result, err := svc.DescribeAddresses(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() { + 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 ExampleEC2_CreateVpnConnectionRoute() { - sess := session.Must(session.NewSession()) +// To describe your Availability Zones +// +// This example describes the Availability Zones that are available to you. The response +// includes Availability Zones only for the current region. +func ExampleEC2_DescribeAvailabilityZones_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeAvailabilityZonesInput{} + + result, err := svc.DescribeAvailabilityZones(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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 + } - svc := ec2.New(sess) + fmt.Println(result) +} - params := &ec2.CreateVpnConnectionRouteInput{ - DestinationCidrBlock: aws.String("String"), // Required - VpnConnectionId: aws.String("String"), // Required +// To describe a customer gateway +// +// This example describes the specified customer gateway. +func ExampleEC2_DescribeCustomerGateways_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeCustomerGatewaysInput{ + CustomerGatewayIds: []*string{ + aws.String("cgw-0e11f167"), + }, } - resp, err := svc.CreateVpnConnectionRoute(params) + result, err := svc.DescribeCustomerGateways(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() { + 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 ExampleEC2_CreateVpnGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpnGatewayInput{ - Type: aws.String("GatewayType"), // Required - AvailabilityZone: aws.String("String"), - DryRun: aws.Bool(true), +// To describe a DHCP options set +// +// This example describes the specified DHCP options set. +func ExampleEC2_DescribeDhcpOptions_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeDhcpOptionsInput{ + DhcpOptionsIds: []*string{ + aws.String("dopt-d9070ebb"), + }, } - resp, err := svc.CreateVpnGateway(params) + result, err := svc.DescribeDhcpOptions(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() { + 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 ExampleEC2_DeleteCustomerGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteCustomerGatewayInput{ - CustomerGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe the instance type +// +// This example describes the instance type of the specified instance. +// +func ExampleEC2_DescribeInstanceAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeInstanceAttributeInput{ + Attribute: aws.String("instanceType"), + InstanceId: aws.String("i-1234567890abcdef0"), } - resp, err := svc.DeleteCustomerGateway(params) + result, err := svc.DescribeInstanceAttribute(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() { + 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 ExampleEC2_DeleteDhcpOptions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteDhcpOptionsInput{ - DhcpOptionsId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe the disableApiTermination attribute +// +// This example describes the ``disableApiTermination`` attribute of the specified instance. +// +func ExampleEC2_DescribeInstanceAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeInstanceAttributeInput{ + Attribute: aws.String("disableApiTermination"), + InstanceId: aws.String("i-1234567890abcdef0"), } - resp, err := svc.DeleteDhcpOptions(params) + result, err := svc.DescribeInstanceAttribute(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() { + 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 ExampleEC2_DeleteEgressOnlyInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteEgressOnlyInternetGatewayInput{ - EgressOnlyInternetGatewayId: aws.String("EgressOnlyInternetGatewayId"), // Required - DryRun: aws.Bool(true), +// To describe the block device mapping for an instance +// +// This example describes the ``blockDeviceMapping`` attribute of the specified instance. +// +func ExampleEC2_DescribeInstanceAttribute_shared02() { + svc := ec2.New(session.New()) + input := &ec2.DescribeInstanceAttributeInput{ + Attribute: aws.String("blockDeviceMapping"), + InstanceId: aws.String("i-1234567890abcdef0"), } - resp, err := svc.DeleteEgressOnlyInternetGateway(params) + result, err := svc.DescribeInstanceAttribute(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() { + 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 ExampleEC2_DeleteFlowLogs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteFlowLogsInput{ - FlowLogIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// To describe the Internet gateway for a VPC +// +// This example describes the Internet gateway for the specified VPC. +func ExampleEC2_DescribeInternetGateways_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeInternetGatewaysInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("attachment.vpc-id"), + Values: []*string{ + aws.String("vpc-a01106c2"), + }, + }, }, } - resp, err := svc.DeleteFlowLogs(params) + result, err := svc.DescribeInternetGateways(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() { + 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 ExampleEC2_DeleteInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteInternetGatewayInput{ - InternetGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To display a key pair +// +// This example displays the fingerprint for the specified key. +func ExampleEC2_DescribeKeyPairs_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeKeyPairsInput{ + KeyNames: []*string{ + aws.String("my-key-pair"), + }, } - resp, err := svc.DeleteInternetGateway(params) + result, err := svc.DescribeKeyPairs(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() { + 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 ExampleEC2_DeleteKeyPair() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteKeyPairInput{ - KeyName: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DeleteKeyPair(params) +// To describe your moving addresses +// +// This example describes all of your moving Elastic IP addresses. +func ExampleEC2_DescribeMovingAddresses_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeMovingAddressesInput{} + result, err := svc.DescribeMovingAddresses(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() { + 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 ExampleEC2_DeleteNatGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNatGatewayInput{ - NatGatewayId: aws.String("String"), // Required +// To describe a NAT gateway +// +// This example describes the NAT gateway for the specified VPC. +func ExampleEC2_DescribeNatGateways_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNatGatewaysInput{ + Filter: []*ec2.FilterList{ + { + Name: aws.String("vpc-id"), + Values: []*string{ + aws.String("vpc-1a2b3c4d"), + }, + }, + }, } - resp, err := svc.DeleteNatGateway(params) + result, err := svc.DescribeNatGateways(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() { + 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 ExampleEC2_DeleteNetworkAcl() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNetworkAclInput{ - NetworkAclId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe a network ACL +// +// This example describes the specified network ACL. +func ExampleEC2_DescribeNetworkAcls_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkAclsInput{ + NetworkAclIds: []*string{ + aws.String("acl-5fb85d36"), + }, } - resp, err := svc.DeleteNetworkAcl(params) + result, err := svc.DescribeNetworkAcls(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() { + 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 ExampleEC2_DeleteNetworkAclEntry() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNetworkAclEntryInput{ - Egress: aws.Bool(true), // Required - NetworkAclId: aws.String("String"), // Required - RuleNumber: aws.Int64(1), // Required - DryRun: aws.Bool(true), +// To describe the attachment attribute of a network interface +// +// This example describes the attachment attribute of the specified network interface. +func ExampleEC2_DescribeNetworkInterfaceAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkInterfaceAttributeInput{ + Attribute: aws.String("attachment"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DeleteNetworkAclEntry(params) + result, err := svc.DescribeNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DeleteNetworkInterface() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNetworkInterfaceInput{ - NetworkInterfaceId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe the description attribute of a network interface +// +// This example describes the description attribute of the specified network interface. +func ExampleEC2_DescribeNetworkInterfaceAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkInterfaceAttributeInput{ + Attribute: aws.String("description"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DeleteNetworkInterface(params) + result, err := svc.DescribeNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DeletePlacementGroup() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeletePlacementGroupInput{ - GroupName: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe the groupSet attribute of a network interface +// +// This example describes the groupSet attribute of the specified network interface. +func ExampleEC2_DescribeNetworkInterfaceAttribute_shared02() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkInterfaceAttributeInput{ + Attribute: aws.String("groupSet"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DeletePlacementGroup(params) + result, err := svc.DescribeNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DeleteRoute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteRouteInput{ - RouteTableId: aws.String("String"), // Required - DestinationCidrBlock: aws.String("String"), - DestinationIpv6CidrBlock: aws.String("String"), - DryRun: aws.Bool(true), +// To describe the sourceDestCheck attribute of a network interface +// +// This example describes the sourceDestCheck attribute of the specified network interface. +func ExampleEC2_DescribeNetworkInterfaceAttribute_shared03() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkInterfaceAttributeInput{ + Attribute: aws.String("sourceDestCheck"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DeleteRoute(params) + result, err := svc.DescribeNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DeleteRouteTable() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) +// To describe a network interface +// - params := &ec2.DeleteRouteTableInput{ - RouteTableId: aws.String("String"), // Required - DryRun: aws.Bool(true), +func ExampleEC2_DescribeNetworkInterfaces_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeNetworkInterfacesInput{ + NetworkInterfaceIds: []*string{ + aws.String("eni-e5aa89a3"), + }, } - resp, err := svc.DeleteRouteTable(params) + result, err := svc.DescribeNetworkInterfaces(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() { + 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 ExampleEC2_DeleteSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSecurityGroupInput{ - DryRun: aws.Bool(true), - GroupId: aws.String("String"), - GroupName: aws.String("String"), - } - resp, err := svc.DeleteSecurityGroup(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DeleteSnapshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSnapshotInput{ - SnapshotId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DeleteSnapshot(params) +// To describe your regions +// +// This example describes all the regions that are available to you. +func ExampleEC2_DescribeRegions_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeRegionsInput{} + result, err := svc.DescribeRegions(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() { + 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 ExampleEC2_DeleteSpotDatafeedSubscription() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSpotDatafeedSubscriptionInput{ - DryRun: aws.Bool(true), +// To describe a route table +// +// This example describes the specified route table. +func ExampleEC2_DescribeRouteTables_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeRouteTablesInput{ + RouteTableIds: []*string{ + aws.String("rtb-1f382e7d"), + }, } - resp, err := svc.DeleteSpotDatafeedSubscription(params) + result, err := svc.DescribeRouteTables(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() { + 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 ExampleEC2_DeleteSubnet() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSubnetInput{ - SubnetId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe an available schedule +// +// This example describes a schedule that occurs every week on Sunday, starting on the +// specified date. Note that the output contains a single schedule as an example. +func ExampleEC2_DescribeScheduledInstanceAvailability_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeScheduledInstanceAvailabilityInput{ + FirstSlotStartTimeRange: &ec2.SlotDateTimeRangeRequest{ + EarliestTime: parseTime("2006-01-02T15:04:05Z", "2016-01-31T00:00:00Z"), + LatestTime: parseTime("2006-01-02T15:04:05Z", "2016-01-31T04:00:00Z"), + }, + Recurrence: &ec2.ScheduledInstanceRecurrenceRequest{ + Frequency: aws.String("Weekly"), + Interval: aws.Int64(1.000000), + OccurrenceDays: []*float64{ + aws.Float64(1.000000), + }, + }, } - resp, err := svc.DeleteSubnet(params) + result, err := svc.DescribeScheduledInstanceAvailability(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() { + 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 ExampleEC2_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteTagsInput{ - Resources: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Tags: []*ec2.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... +// To describe your Scheduled Instances +// +// This example describes the specified Scheduled Instance. +func ExampleEC2_DescribeScheduledInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeScheduledInstancesInput{ + ScheduledInstanceIds: []*string{ + aws.String("sci-1234-1234-1234-1234-123456789012"), }, } - resp, err := svc.DeleteTags(params) + result, err := svc.DescribeScheduledInstances(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() { + 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 ExampleEC2_DeleteVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVolumeInput{ - VolumeId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe snapshot attributes +// +// This example describes the ``createVolumePermission`` attribute on a snapshot with +// the snapshot ID of ``snap-066877671789bd71b``. +func ExampleEC2_DescribeSnapshotAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSnapshotAttributeInput{ + Attribute: aws.String("createVolumePermission"), + SnapshotId: aws.String("snap-066877671789bd71b"), } - resp, err := svc.DeleteVolume(params) + result, err := svc.DescribeSnapshotAttribute(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() { + 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 ExampleEC2_DeleteVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe a snapshot +// +// This example describes a snapshot with the snapshot ID of ``snap-1234567890abcdef0``. +func ExampleEC2_DescribeSnapshots_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSnapshotsInput{ + SnapshotIds: []*string{ + aws.String("snap-1234567890abcdef0"), + }, } - resp, err := svc.DeleteVpc(params) + result, err := svc.DescribeSnapshots(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() { + 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 ExampleEC2_DeleteVpcEndpoints() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcEndpointsInput{ - VpcEndpointIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// To describe snapshots using filters +// +// This example describes all snapshots owned by the ID 012345678910 that are in the +// ``pending`` status. +func ExampleEC2_DescribeSnapshots_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSnapshotsInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("status"), + Values: []*string{ + aws.String("pending"), + }, + }, + }, + OwnerIds: []*string{ + aws.String("012345678910"), }, - DryRun: aws.Bool(true), } - resp, err := svc.DeleteVpcEndpoints(params) + result, err := svc.DescribeSnapshots(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() { + 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 ExampleEC2_DeleteVpcPeeringConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcPeeringConnectionInput{ - VpcPeeringConnectionId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DeleteVpcPeeringConnection(params) +// To describe the datafeed for your AWS account +// +// This example describes the Spot Instance datafeed subscription for your AWS account. +func ExampleEC2_DescribeSpotDatafeedSubscription_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotDatafeedSubscriptionInput{} + result, err := svc.DescribeSpotDatafeedSubscription(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() { + 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 ExampleEC2_DeleteVpnConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpnConnectionInput{ - VpnConnectionId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe the Spot Instances associated with a Spot fleet +// +// This example lists the Spot Instances associated with the specified Spot fleet. +func ExampleEC2_DescribeSpotFleetInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotFleetInstancesInput{ + SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), } - resp, err := svc.DeleteVpnConnection(params) + result, err := svc.DescribeSpotFleetInstances(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() { + 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 ExampleEC2_DeleteVpnConnectionRoute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpnConnectionRouteInput{ - DestinationCidrBlock: aws.String("String"), // Required - VpnConnectionId: aws.String("String"), // Required +// To describe Spot fleet history +// +// This example returns the history for the specified Spot fleet starting at the specified +// time. +func ExampleEC2_DescribeSpotFleetRequestHistory_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotFleetRequestHistoryInput{ + SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), + StartTime: parseTime("2006-01-02T15:04:05Z", "2015-05-26T00:00:00Z"), } - resp, err := svc.DeleteVpnConnectionRoute(params) + result, err := svc.DescribeSpotFleetRequestHistory(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() { + 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 ExampleEC2_DeleteVpnGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpnGatewayInput{ - VpnGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe a Spot fleet request +// +// This example describes the specified Spot fleet request. +func ExampleEC2_DescribeSpotFleetRequests_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotFleetRequestsInput{ + SpotFleetRequestIds: []*string{ + aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), + }, } - resp, err := svc.DeleteVpnGateway(params) + result, err := svc.DescribeSpotFleetRequests(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() { + 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 ExampleEC2_DeregisterImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeregisterImageInput{ - ImageId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To describe a Spot Instance request +// +// This example describes the specified Spot Instance request. +func ExampleEC2_DescribeSpotInstanceRequests_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotInstanceRequestsInput{ + SpotInstanceRequestIds: []*string{ + aws.String("sir-08b93456"), + }, } - resp, err := svc.DeregisterImage(params) + result, err := svc.DescribeSpotInstanceRequests(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() { + 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 ExampleEC2_DescribeAccountAttributes() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeAccountAttributesInput{ - AttributeNames: []*string{ - aws.String("AccountAttributeName"), // Required - // More values... +// To describe Spot price history for Linux/UNIX (Amazon VPC) +// +// This example returns the Spot Price history for m1.xlarge, Linux/UNIX (Amazon VPC) +// instances for a particular day in January. +func ExampleEC2_DescribeSpotPriceHistory_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSpotPriceHistoryInput{ + EndTime: parseTime("2006-01-02T15:04:05Z", "2014-01-06T08:09:10"), + InstanceTypes: []*string{ + aws.String("m1.xlarge"), + }, + ProductDescriptions: []*string{ + aws.String("Linux/UNIX (Amazon VPC)"), }, - DryRun: aws.Bool(true), + StartTime: parseTime("2006-01-02T15:04:05Z", "2014-01-06T07:08:09"), } - resp, err := svc.DescribeAccountAttributes(params) + result, err := svc.DescribeSpotPriceHistory(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() { + 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 ExampleEC2_DescribeAddresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeAddressesInput{ - AllocationIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), +// To describe the subnets for a VPC +// +// This example describes the subnets for the specified VPC. +func ExampleEC2_DescribeSubnets_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeSubnetsInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("vpc-id"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("vpc-a01106c2"), }, }, - // More values... - }, - PublicIps: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.DescribeAddresses(params) + result, err := svc.DescribeSubnets(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() { + 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 ExampleEC2_DescribeAvailabilityZones() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeAvailabilityZonesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), +// To describe the tags for a single resource +// +// This example describes the tags for the specified instance. +func ExampleEC2_DescribeTags_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeTagsInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("resource-id"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("i-1234567890abcdef8"), }, }, - // More values... - }, - ZoneNames: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.DescribeAvailabilityZones(params) + result, err := svc.DescribeTags(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() { + 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 ExampleEC2_DescribeBundleTasks() { - sess := session.Must(session.NewSession()) +// To describe a volume attribute +// +// This example describes the ``autoEnableIo`` attribute of the volume with the ID ``vol-049df61146c4d7901``. +func ExampleEC2_DescribeVolumeAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVolumeAttributeInput{ + Attribute: aws.String("autoEnableIO"), + VolumeId: aws.String("vol-049df61146c4d7901"), + } + + result, err := svc.DescribeVolumeAttribute(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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 + } - svc := ec2.New(sess) + fmt.Println(result) +} - params := &ec2.DescribeBundleTasksInput{ - BundleIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... +// To describe the status of a single volume +// +// This example describes the status for the volume ``vol-1234567890abcdef0``. +func ExampleEC2_DescribeVolumeStatus_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVolumeStatusInput{ + VolumeIds: []*string{ + aws.String("vol-1234567890abcdef0"), }, } - resp, err := svc.DescribeBundleTasks(params) + result, err := svc.DescribeVolumeStatus(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() { + 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 ExampleEC2_DescribeClassicLinkInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeClassicLinkInstancesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), +// To describe the status of impaired volumes +// +// This example describes the status for all volumes that are impaired. In this example +// output, there are no impaired volumes. +func ExampleEC2_DescribeVolumeStatus_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVolumeStatusInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("volume-status.status"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("impaired"), }, }, - // More values... - }, - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), } - resp, err := svc.DescribeClassicLinkInstances(params) + result, err := svc.DescribeVolumeStatus(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() { + 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 ExampleEC2_DescribeConversionTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeConversionTasksInput{ - ConversionTaskIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeConversionTasks(params) +// To describe all volumes +// +// This example describes all of your volumes in the default region. +func ExampleEC2_DescribeVolumes_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVolumesInput{} + result, err := svc.DescribeVolumes(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() { + 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 ExampleEC2_DescribeCustomerGateways() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeCustomerGatewaysInput{ - CustomerGatewayIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), +// To describe volumes that are attached to a specific instance +// +// This example describes all volumes that are both attached to the instance with the +// ID i-1234567890abcdef0 and set to delete when the instance terminates. +func ExampleEC2_DescribeVolumes_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVolumesInput{ + Filters: []*ec2.FilterList{ + { + Name: aws.String("attachment.instance-id"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("i-1234567890abcdef0"), + }, + }, + { + Name: aws.String("attachment.delete-on-termination"), + Values: []*string{ + aws.String("true"), }, }, - // More values... }, } - resp, err := svc.DescribeCustomerGateways(params) + result, err := svc.DescribeVolumes(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() { + 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 ExampleEC2_DescribeDhcpOptions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeDhcpOptionsInput{ - DhcpOptionsIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, +// To describe the enableDnsSupport attribute +// +// This example describes the enableDnsSupport attribute. This attribute indicates whether +// DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS +// server resolves DNS hostnames for your instances to their corresponding IP addresses; +// otherwise, it does not. +func ExampleEC2_DescribeVpcAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVpcAttributeInput{ + Attribute: aws.String("enableDnsSupport"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.DescribeDhcpOptions(params) + result, err := svc.DescribeVpcAttribute(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() { + 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 ExampleEC2_DescribeEgressOnlyInternetGateways() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeEgressOnlyInternetGatewaysInput{ - DryRun: aws.Bool(true), - EgressOnlyInternetGatewayIds: []*string{ - aws.String("EgressOnlyInternetGatewayId"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// To describe the enableDnsHostnames attribute +// +// This example describes the enableDnsHostnames attribute. This attribute indicates +// whether the instances launched in the VPC get DNS hostnames. If this attribute is +// true, instances in the VPC get DNS hostnames; otherwise, they do not. +func ExampleEC2_DescribeVpcAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVpcAttributeInput{ + Attribute: aws.String("enableDnsHostnames"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.DescribeEgressOnlyInternetGateways(params) + result, err := svc.DescribeVpcAttribute(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() { + 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 ExampleEC2_DescribeExportTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeExportTasksInput{ - ExportTaskIds: []*string{ - aws.String("String"), // Required - // More values... +// To describe a VPC +// +// This example describes the specified VPC. +func ExampleEC2_DescribeVpcs_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DescribeVpcsInput{ + VpcIds: []*string{ + aws.String("vpc-a01106c2"), }, } - resp, err := svc.DescribeExportTasks(params) + result, err := svc.DescribeVpcs(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() { + 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 ExampleEC2_DescribeFlowLogs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeFlowLogsInput{ - Filter: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - FlowLogIds: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// To detach an Internet gateway from a VPC +// +// This example detaches the specified Internet gateway from the specified VPC. +func ExampleEC2_DetachInternetGateway_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DetachInternetGatewayInput{ + InternetGatewayId: aws.String("igw-c0a643a9"), + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.DescribeFlowLogs(params) + result, err := svc.DetachInternetGateway(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() { + 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 ExampleEC2_DescribeHostReservationOfferings() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeHostReservationOfferingsInput{ - Filter: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxDuration: aws.Int64(1), - MaxResults: aws.Int64(1), - MinDuration: aws.Int64(1), - NextToken: aws.String("String"), - OfferingId: aws.String("String"), +// To detach a network interface from an instance +// +// This example detaches the specified network interface from its attached instance. +func ExampleEC2_DetachNetworkInterface_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DetachNetworkInterfaceInput{ + AttachmentId: aws.String("eni-attach-66c4350a"), } - resp, err := svc.DescribeHostReservationOfferings(params) + result, err := svc.DetachNetworkInterface(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() { + 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 ExampleEC2_DescribeHostReservations() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeHostReservationsInput{ - Filter: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - HostReservationIdSet: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// To detach a volume from an instance +// +// This example detaches the volume (``vol-049df61146c4d7901``) from the instance it +// is attached to. +func ExampleEC2_DetachVolume_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DetachVolumeInput{ + VolumeId: aws.String("vol-1234567890abcdef0"), } - resp, err := svc.DescribeHostReservations(params) + result, err := svc.DetachVolume(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() { + 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 ExampleEC2_DescribeHosts() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeHostsInput{ - Filter: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - HostIds: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// To disable route propagation +// +// This example disables the specified virtual private gateway from propagating static +// routes to the specified route table. +func ExampleEC2_DisableVgwRoutePropagation_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DisableVgwRoutePropagationInput{ + GatewayId: aws.String("vgw-9a4cacf3"), + RouteTableId: aws.String("rtb-22574640"), } - resp, err := svc.DescribeHosts(params) + result, err := svc.DisableVgwRoutePropagation(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() { + 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 ExampleEC2_DescribeIamInstanceProfileAssociations() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeIamInstanceProfileAssociationsInput{ - AssociationIds: []*string{ - aws.String("String"), // Required - // More values... - }, - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), +// To disassociate an Elastic IP address in EC2-VPC +// +// This example disassociates an Elastic IP address from an instance in a VPC. +func ExampleEC2_DisassociateAddress_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DisassociateAddressInput{ + AssociationId: aws.String("eipassoc-2bebb745"), } - resp, err := svc.DescribeIamInstanceProfileAssociations(params) + result, err := svc.DisassociateAddress(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() { + 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 ExampleEC2_DescribeIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeIdFormatInput{ - Resource: aws.String("String"), +// To disassociate an Elastic IP addresses in EC2-Classic +// +// This example disassociates an Elastic IP address from an instance in EC2-Classic. +func ExampleEC2_DisassociateAddress_shared01() { + svc := ec2.New(session.New()) + input := &ec2.DisassociateAddressInput{ + PublicIp: aws.String("198.51.100.0"), } - resp, err := svc.DescribeIdFormat(params) + result, err := svc.DisassociateAddress(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() { + 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 ExampleEC2_DescribeIdentityIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeIdentityIdFormatInput{ - PrincipalArn: aws.String("String"), // Required - Resource: aws.String("String"), +// To disassociate a route table +// +// This example disassociates the specified route table from its associated subnet. +func ExampleEC2_DisassociateRouteTable_shared00() { + svc := ec2.New(session.New()) + input := &ec2.DisassociateRouteTableInput{ + AssociationId: aws.String("rtbassoc-781d0d1a"), } - resp, err := svc.DescribeIdentityIdFormat(params) + result, err := svc.DisassociateRouteTable(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() { + 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 ExampleEC2_DescribeImageAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeImageAttributeInput{ - Attribute: aws.String("ImageAttributeName"), // Required - ImageId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To enable route propagation +// +// This example enables the specified virtual private gateway to propagate static routes +// to the specified route table. +func ExampleEC2_EnableVgwRoutePropagation_shared00() { + svc := ec2.New(session.New()) + input := &ec2.EnableVgwRoutePropagationInput{ + GatewayId: aws.String("vgw-9a4cacf3"), + RouteTableId: aws.String("rtb-22574640"), } - resp, err := svc.DescribeImageAttribute(params) + result, err := svc.EnableVgwRoutePropagation(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() { + 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 ExampleEC2_DescribeImages() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeImagesInput{ - DryRun: aws.Bool(true), - ExecutableUsers: []*string{ - aws.String("String"), // Required - // More values... - }, - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ImageIds: []*string{ - aws.String("String"), // Required - // More values... - }, - Owners: []*string{ - aws.String("String"), // Required - // More values... - }, +// To enable I/O for a volume +// +// This example enables I/O on volume ``vol-1234567890abcdef0``. +func ExampleEC2_EnableVolumeIO_shared00() { + svc := ec2.New(session.New()) + input := &ec2.EnableVolumeIOInput{ + VolumeId: aws.String("vol-1234567890abcdef0"), } - resp, err := svc.DescribeImages(params) + result, err := svc.EnableVolumeIO(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() { + 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 ExampleEC2_DescribeImportImageTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeImportImageTasksInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ImportTaskIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify the attachment attribute of a network interface +// +// This example modifies the attachment attribute of the specified network interface. +func ExampleEC2_ModifyNetworkInterfaceAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifyNetworkInterfaceAttributeInput{ + Attachment: &ec2.NetworkInterfaceAttachmentChanges{ + AttachmentId: aws.String("eni-attach-43348162"), + DeleteOnTermination: aws.Bool(false), }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DescribeImportImageTasks(params) + result, err := svc.ModifyNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DescribeImportSnapshotTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeImportSnapshotTasksInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ImportTaskIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify the description attribute of a network interface +// +// This example modifies the description attribute of the specified network interface. +func ExampleEC2_ModifyNetworkInterfaceAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.ModifyNetworkInterfaceAttributeInput{ + Description: &ec2.AttributeValue{ + Value: aws.String("My description"), }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DescribeImportSnapshotTasks(params) + result, err := svc.ModifyNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DescribeInstanceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeInstanceAttributeInput{ - Attribute: aws.String("InstanceAttributeName"), // Required - InstanceId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To modify the groupSet attribute of a network interface +// +// This example command modifies the groupSet attribute of the specified network interface. +func ExampleEC2_ModifyNetworkInterfaceAttribute_shared02() { + svc := ec2.New(session.New()) + input := &ec2.ModifyNetworkInterfaceAttributeInput{ + Groups: []*string{ + aws.String("sg-903004f8"), + aws.String("sg-1a2b3c4d"), + }, + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DescribeInstanceAttribute(params) + result, err := svc.ModifyNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DescribeInstanceStatus() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeInstanceStatusInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - IncludeAllInstances: aws.Bool(true), - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify the sourceDestCheck attribute of a network interface +// +// This example command modifies the sourceDestCheck attribute of the specified network +// interface. +func ExampleEC2_ModifyNetworkInterfaceAttribute_shared03() { + svc := ec2.New(session.New()) + input := &ec2.ModifyNetworkInterfaceAttributeInput{ + NetworkInterfaceId: aws.String("eni-686ea200"), + SourceDestCheck: &ec2.AttributeBooleanValue{ + Value: aws.Bool(false), }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), } - resp, err := svc.DescribeInstanceStatus(params) + result, err := svc.ModifyNetworkInterfaceAttribute(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() { + 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 ExampleEC2_DescribeInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeInstancesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify a snapshot attribute +// +// This example modifies snapshot ``snap-1234567890abcdef0`` to remove the create volume +// permission for a user with the account ID ``123456789012``. If the command succeeds, +// no output is returned. +func ExampleEC2_ModifySnapshotAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifySnapshotAttributeInput{ + Attribute: aws.String("createVolumePermission"), + OperationType: aws.String("remove"), + SnapshotId: aws.String("snap-1234567890abcdef0"), + UserIds: []*string{ + aws.String("123456789012"), }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), } - resp, err := svc.DescribeInstances(params) + result, err := svc.ModifySnapshotAttribute(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() { + 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 ExampleEC2_DescribeInternetGateways() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeInternetGatewaysInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - InternetGatewayIds: []*string{ - aws.String("String"), // Required - // More values... +// To make a snapshot public +// +// This example makes the snapshot ``snap-1234567890abcdef0`` public. +func ExampleEC2_ModifySnapshotAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.ModifySnapshotAttributeInput{ + Attribute: aws.String("createVolumePermission"), + GroupNames: []*string{ + aws.String("all"), }, + OperationType: aws.String("add"), + SnapshotId: aws.String("snap-1234567890abcdef0"), } - resp, err := svc.DescribeInternetGateways(params) + result, err := svc.ModifySnapshotAttribute(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() { + 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 ExampleEC2_DescribeKeyPairs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeKeyPairsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - KeyNames: []*string{ - aws.String("String"), // Required - // More values... - }, +// To increase the target capacity of a Spot fleet request +// +// This example increases the target capacity of the specified Spot fleet request. +func ExampleEC2_ModifySpotFleetRequest_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifySpotFleetRequestInput{ + SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), + TargetCapacity: aws.Int64(20.000000), } - resp, err := svc.DescribeKeyPairs(params) + result, err := svc.ModifySpotFleetRequest(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() { + 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 ExampleEC2_DescribeMovingAddresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeMovingAddressesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - PublicIps: []*string{ - aws.String("String"), // Required - // More values... - }, +// To decrease the target capacity of a Spot fleet request +// +// This example decreases the target capacity of the specified Spot fleet request without +// terminating any Spot Instances as a result. +func ExampleEC2_ModifySpotFleetRequest_shared01() { + svc := ec2.New(session.New()) + input := &ec2.ModifySpotFleetRequestInput{ + ExcessCapacityTerminationPolicy: aws.String("NoTermination "), + SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"), + TargetCapacity: aws.Int64(10.000000), } - resp, err := svc.DescribeMovingAddresses(params) + result, err := svc.ModifySpotFleetRequest(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() { + 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 ExampleEC2_DescribeNatGateways() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeNatGatewaysInput{ - Filter: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NatGatewayIds: []*string{ - aws.String("String"), // Required - // More values... +// To change a subnet's public IP addressing behavior +// +// This example modifies the specified subnet so that all instances launched into this +// subnet are assigned a public IP address. +func ExampleEC2_ModifySubnetAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifySubnetAttributeInput{ + MapPublicIpOnLaunch: &ec2.AttributeBooleanValue{ + Value: aws.Bool(true), }, - NextToken: aws.String("String"), + SubnetId: aws.String("subnet-1a2b3c4d"), } - resp, err := svc.DescribeNatGateways(params) + result, err := svc.ModifySubnetAttribute(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() { + 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 ExampleEC2_DescribeNetworkAcls() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeNetworkAclsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - NetworkAclIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify a volume attribute +// +// This example sets the ``autoEnableIo`` attribute of the volume with the ID ``vol-1234567890abcdef0`` +// to ``true``. If the command succeeds, no output is returned. +func ExampleEC2_ModifyVolumeAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifyVolumeAttributeInput{ + AutoEnableIO: &ec2.AttributeBooleanValue{ + Value: aws.Bool(true), }, + DryRun: aws.Bool(true), + VolumeId: aws.String("vol-1234567890abcdef0"), } - resp, err := svc.DescribeNetworkAcls(params) + result, err := svc.ModifyVolumeAttribute(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() { + 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 ExampleEC2_DescribeNetworkInterfaceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeNetworkInterfaceAttributeInput{ - NetworkInterfaceId: aws.String("String"), // Required - Attribute: aws.String("NetworkInterfaceAttribute"), - DryRun: aws.Bool(true), +// To modify the enableDnsSupport attribute +// +// This example modifies the enableDnsSupport attribute. This attribute indicates whether +// DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS +// server resolves DNS hostnames for instances in the VPC to their corresponding IP +// addresses; otherwise, it does not. +func ExampleEC2_ModifyVpcAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ModifyVpcAttributeInput{ + EnableDnsSupport: &ec2.AttributeBooleanValue{ + Value: aws.Bool(false), + }, + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.DescribeNetworkInterfaceAttribute(params) + result, err := svc.ModifyVpcAttribute(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() { + 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 ExampleEC2_DescribeNetworkInterfaces() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeNetworkInterfacesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - NetworkInterfaceIds: []*string{ - aws.String("String"), // Required - // More values... +// To modify the enableDnsHostnames attribute +// +// This example modifies the enableDnsHostnames attribute. This attribute indicates +// whether instances launched in the VPC get DNS hostnames. If this attribute is true, +// instances in the VPC get DNS hostnames; otherwise, they do not. +func ExampleEC2_ModifyVpcAttribute_shared01() { + svc := ec2.New(session.New()) + input := &ec2.ModifyVpcAttributeInput{ + EnableDnsHostnames: &ec2.AttributeBooleanValue{ + Value: aws.Bool(false), }, + VpcId: aws.String("vpc-a01106c2"), } - resp, err := svc.DescribeNetworkInterfaces(params) + result, err := svc.ModifyVpcAttribute(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() { + 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 ExampleEC2_DescribePlacementGroups() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribePlacementGroupsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - GroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, +// To move an address to EC2-VPC +// +// This example moves the specified Elastic IP address to the EC2-VPC platform. +func ExampleEC2_MoveAddressToVpc_shared00() { + svc := ec2.New(session.New()) + input := &ec2.MoveAddressToVpcInput{ + PublicIp: aws.String("54.123.4.56"), } - resp, err := svc.DescribePlacementGroups(params) + result, err := svc.MoveAddressToVpc(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() { + 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 ExampleEC2_DescribePrefixLists() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribePrefixListsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, +// To purchase a Scheduled Instance +// +// This example purchases a Scheduled Instance. +func ExampleEC2_PurchaseScheduledInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.PurchaseScheduledInstancesInput{ + PurchaseRequests: []*ec2.PurchaseRequestSet{ + { + InstanceCount: aws.Float64(1.000000), + PurchaseToken: aws.String("eyJ2IjoiMSIsInMiOjEsImMiOi..."), }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - PrefixListIds: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.DescribePrefixLists(params) + result, err := svc.PurchaseScheduledInstances(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() { + 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 ExampleEC2_DescribeRegions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeRegionsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - RegionNames: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeRegions(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeReservedInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeReservedInstancesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - OfferingClass: aws.String("OfferingClassType"), - OfferingType: aws.String("OfferingTypeValues"), - ReservedInstancesIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeReservedInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeReservedInstancesListings() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeReservedInstancesListingsInput{ - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ReservedInstancesId: aws.String("String"), - ReservedInstancesListingId: aws.String("String"), - } - resp, err := svc.DescribeReservedInstancesListings(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeReservedInstancesModifications() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeReservedInstancesModificationsInput{ - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - NextToken: aws.String("String"), - ReservedInstancesModificationIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeReservedInstancesModifications(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeReservedInstancesOfferings() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeReservedInstancesOfferingsInput{ - AvailabilityZone: aws.String("String"), - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - IncludeMarketplace: aws.Bool(true), - InstanceTenancy: aws.String("Tenancy"), - InstanceType: aws.String("InstanceType"), - MaxDuration: aws.Int64(1), - MaxInstanceCount: aws.Int64(1), - MaxResults: aws.Int64(1), - MinDuration: aws.Int64(1), - NextToken: aws.String("String"), - OfferingClass: aws.String("OfferingClassType"), - OfferingType: aws.String("OfferingTypeValues"), - ProductDescription: aws.String("RIProductDescription"), - ReservedInstancesOfferingIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeReservedInstancesOfferings(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeRouteTables() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeRouteTablesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - RouteTableIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeRouteTables(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeScheduledInstanceAvailability() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeScheduledInstanceAvailabilityInput{ - FirstSlotStartTimeRange: &ec2.SlotDateTimeRangeRequest{ // Required - EarliestTime: aws.Time(time.Now()), // Required - LatestTime: aws.Time(time.Now()), // Required - }, - Recurrence: &ec2.ScheduledInstanceRecurrenceRequest{ // Required - Frequency: aws.String("String"), - Interval: aws.Int64(1), - OccurrenceDays: []*int64{ - aws.Int64(1), // Required - // More values... - }, - OccurrenceRelativeToEnd: aws.Bool(true), - OccurrenceUnit: aws.String("String"), - }, - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - MaxSlotDurationInHours: aws.Int64(1), - MinSlotDurationInHours: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeScheduledInstanceAvailability(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeScheduledInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeScheduledInstancesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - ScheduledInstanceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SlotStartTimeRange: &ec2.SlotStartTimeRangeRequest{ - EarliestTime: aws.Time(time.Now()), - LatestTime: aws.Time(time.Now()), - }, - } - resp, err := svc.DescribeScheduledInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSecurityGroupReferences() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSecurityGroupReferencesInput{ - GroupId: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeSecurityGroupReferences(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSecurityGroupsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - GroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - GroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSecurityGroups(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSnapshotAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSnapshotAttributeInput{ - Attribute: aws.String("SnapshotAttributeName"), // Required - SnapshotId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeSnapshotAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSnapshots() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSnapshotsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - OwnerIds: []*string{ - aws.String("String"), // Required - // More values... - }, - RestorableByUserIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSnapshots(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotDatafeedSubscription() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotDatafeedSubscriptionInput{ - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeSpotDatafeedSubscription(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotFleetInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotFleetInstancesInput{ - SpotFleetRequestId: aws.String("String"), // Required - DryRun: aws.Bool(true), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeSpotFleetInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotFleetRequestHistory() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotFleetRequestHistoryInput{ - SpotFleetRequestId: aws.String("String"), // Required - StartTime: aws.Time(time.Now()), // Required - DryRun: aws.Bool(true), - EventType: aws.String("EventType"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeSpotFleetRequestHistory(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotFleetRequests() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotFleetRequestsInput{ - DryRun: aws.Bool(true), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - SpotFleetRequestIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSpotFleetRequests(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotInstanceRequests() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotInstanceRequestsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - SpotInstanceRequestIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSpotInstanceRequests(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSpotPriceHistory() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSpotPriceHistoryInput{ - AvailabilityZone: aws.String("String"), - DryRun: aws.Bool(true), - EndTime: aws.Time(time.Now()), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - InstanceTypes: []*string{ - aws.String("InstanceType"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - ProductDescriptions: []*string{ - aws.String("String"), // Required - // More values... - }, - StartTime: aws.Time(time.Now()), - } - resp, err := svc.DescribeSpotPriceHistory(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeStaleSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeStaleSecurityGroupsInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeStaleSecurityGroups(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeSubnets() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeSubnetsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - SubnetIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSubnets(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeTagsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVolumeAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVolumeAttributeInput{ - VolumeId: aws.String("String"), // Required - Attribute: aws.String("VolumeAttributeName"), - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeVolumeAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVolumeStatus() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVolumeStatusInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - VolumeIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVolumeStatus(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVolumes() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVolumesInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - VolumeIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVolumes(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVolumesModifications() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVolumesModificationsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - VolumeIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVolumesModifications(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcAttributeInput{ - Attribute: aws.String("VpcAttributeName"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DescribeVpcAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcClassicLink() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcClassicLinkInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - VpcIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpcClassicLink(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcClassicLinkDnsSupport() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcClassicLinkDnsSupportInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - VpcIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpcClassicLinkDnsSupport(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcEndpointServices() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcEndpointServicesInput{ - DryRun: aws.Bool(true), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeVpcEndpointServices(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcEndpoints() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcEndpointsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - VpcEndpointIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpcEndpoints(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcPeeringConnections() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcPeeringConnectionsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - VpcPeeringConnectionIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpcPeeringConnections(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpcs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpcsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - VpcIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpcs(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpnConnections() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpnConnectionsInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - VpnConnectionIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpnConnections(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DescribeVpnGateways() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeVpnGatewaysInput{ - DryRun: aws.Bool(true), - Filters: []*ec2.Filter{ - { // Required - Name: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - VpnGatewayIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVpnGateways(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DetachClassicLinkVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DetachClassicLinkVpcInput{ - InstanceId: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DetachClassicLinkVpc(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DetachInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DetachInternetGatewayInput{ - InternetGatewayId: aws.String("String"), // Required - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DetachInternetGateway(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DetachNetworkInterface() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DetachNetworkInterfaceInput{ - AttachmentId: aws.String("String"), // Required - DryRun: aws.Bool(true), - Force: aws.Bool(true), - } - resp, err := svc.DetachNetworkInterface(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DetachVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DetachVolumeInput{ - VolumeId: aws.String("String"), // Required - Device: aws.String("String"), - DryRun: aws.Bool(true), - Force: aws.Bool(true), - InstanceId: aws.String("String"), - } - resp, err := svc.DetachVolume(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DetachVpnGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DetachVpnGatewayInput{ - VpcId: aws.String("String"), // Required - VpnGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DetachVpnGateway(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisableVgwRoutePropagation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisableVgwRoutePropagationInput{ - GatewayId: aws.String("String"), // Required - RouteTableId: aws.String("String"), // Required - } - resp, err := svc.DisableVgwRoutePropagation(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisableVpcClassicLink() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisableVpcClassicLinkInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DisableVpcClassicLink(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisableVpcClassicLinkDnsSupport() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisableVpcClassicLinkDnsSupportInput{ - VpcId: aws.String("String"), - } - resp, err := svc.DisableVpcClassicLinkDnsSupport(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisassociateAddress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisassociateAddressInput{ - AssociationId: aws.String("String"), - DryRun: aws.Bool(true), - PublicIp: aws.String("String"), - } - resp, err := svc.DisassociateAddress(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisassociateIamInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisassociateIamInstanceProfileInput{ - AssociationId: aws.String("String"), // Required - } - resp, err := svc.DisassociateIamInstanceProfile(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisassociateRouteTable() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisassociateRouteTableInput{ - AssociationId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DisassociateRouteTable(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisassociateSubnetCidrBlock() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisassociateSubnetCidrBlockInput{ - AssociationId: aws.String("String"), // Required - } - resp, err := svc.DisassociateSubnetCidrBlock(params) - - if err != nil { - // 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) -} - -func ExampleEC2_DisassociateVpcCidrBlock() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DisassociateVpcCidrBlockInput{ - AssociationId: aws.String("String"), // Required - } - resp, err := svc.DisassociateVpcCidrBlock(params) - - if err != nil { - // 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) -} - -func ExampleEC2_EnableVgwRoutePropagation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.EnableVgwRoutePropagationInput{ - GatewayId: aws.String("String"), // Required - RouteTableId: aws.String("String"), // Required - } - resp, err := svc.EnableVgwRoutePropagation(params) - - if err != nil { - // 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) -} - -func ExampleEC2_EnableVolumeIO() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.EnableVolumeIOInput{ - VolumeId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.EnableVolumeIO(params) - - if err != nil { - // 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) -} - -func ExampleEC2_EnableVpcClassicLink() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.EnableVpcClassicLinkInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.EnableVpcClassicLink(params) - - if err != nil { - // 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) -} - -func ExampleEC2_EnableVpcClassicLinkDnsSupport() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.EnableVpcClassicLinkDnsSupportInput{ - VpcId: aws.String("String"), - } - resp, err := svc.EnableVpcClassicLinkDnsSupport(params) - - if err != nil { - // 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) -} - -func ExampleEC2_GetConsoleOutput() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.GetConsoleOutputInput{ - InstanceId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.GetConsoleOutput(params) - - if err != nil { - // 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) -} - -func ExampleEC2_GetConsoleScreenshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.GetConsoleScreenshotInput{ - InstanceId: aws.String("String"), // Required - DryRun: aws.Bool(true), - WakeUp: aws.Bool(true), - } - resp, err := svc.GetConsoleScreenshot(params) - - if err != nil { - // 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) -} - -func ExampleEC2_GetHostReservationPurchasePreview() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.GetHostReservationPurchasePreviewInput{ - HostIdSet: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - OfferingId: aws.String("String"), // Required - } - resp, err := svc.GetHostReservationPurchasePreview(params) - - if err != nil { - // 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) -} - -func ExampleEC2_GetPasswordData() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.GetPasswordDataInput{ - InstanceId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.GetPasswordData(params) - - if err != nil { - // 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) -} - -func ExampleEC2_GetReservedInstancesExchangeQuote() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.GetReservedInstancesExchangeQuoteInput{ - ReservedInstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - TargetConfigurations: []*ec2.TargetConfigurationRequest{ - { // Required - OfferingId: aws.String("String"), // Required - InstanceCount: aws.Int64(1), - }, - // More values... - }, - } - resp, err := svc.GetReservedInstancesExchangeQuote(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ImportImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ImportImageInput{ - Architecture: aws.String("String"), - ClientData: &ec2.ClientData{ - Comment: aws.String("String"), - UploadEnd: aws.Time(time.Now()), - UploadSize: aws.Float64(1.0), - UploadStart: aws.Time(time.Now()), - }, - ClientToken: aws.String("String"), - Description: aws.String("String"), - DiskContainers: []*ec2.ImageDiskContainer{ - { // Required - Description: aws.String("String"), - DeviceName: aws.String("String"), - Format: aws.String("String"), - SnapshotId: aws.String("String"), - Url: aws.String("String"), - UserBucket: &ec2.UserBucket{ - S3Bucket: aws.String("String"), - S3Key: aws.String("String"), - }, - }, - // More values... - }, - DryRun: aws.Bool(true), - Hypervisor: aws.String("String"), - LicenseType: aws.String("String"), - Platform: aws.String("String"), - RoleName: aws.String("String"), - } - resp, err := svc.ImportImage(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ImportInstance() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ImportInstanceInput{ - Platform: aws.String("PlatformValues"), // Required - Description: aws.String("String"), - DiskImages: []*ec2.DiskImage{ - { // Required - Description: aws.String("String"), - Image: &ec2.DiskImageDetail{ - Bytes: aws.Int64(1), // Required - Format: aws.String("DiskImageFormat"), // Required - ImportManifestUrl: aws.String("String"), // Required - }, - Volume: &ec2.VolumeDetail{ - Size: aws.Int64(1), // Required - }, - }, - // More values... - }, - DryRun: aws.Bool(true), - LaunchSpecification: &ec2.ImportInstanceLaunchSpecification{ - AdditionalInfo: aws.String("String"), - Architecture: aws.String("ArchitectureValues"), - GroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - GroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - InstanceInitiatedShutdownBehavior: aws.String("ShutdownBehavior"), - InstanceType: aws.String("InstanceType"), - Monitoring: aws.Bool(true), - Placement: &ec2.Placement{ - Affinity: aws.String("String"), - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), - HostId: aws.String("String"), - Tenancy: aws.String("Tenancy"), - }, - PrivateIpAddress: aws.String("String"), - SubnetId: aws.String("String"), - UserData: &ec2.UserData{ - Data: aws.String("String"), - }, - }, - } - resp, err := svc.ImportInstance(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ImportKeyPair() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ImportKeyPairInput{ - KeyName: aws.String("String"), // Required - PublicKeyMaterial: []byte("PAYLOAD"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.ImportKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ImportSnapshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ImportSnapshotInput{ - ClientData: &ec2.ClientData{ - Comment: aws.String("String"), - UploadEnd: aws.Time(time.Now()), - UploadSize: aws.Float64(1.0), - UploadStart: aws.Time(time.Now()), - }, - ClientToken: aws.String("String"), - Description: aws.String("String"), - DiskContainer: &ec2.SnapshotDiskContainer{ - Description: aws.String("String"), - Format: aws.String("String"), - Url: aws.String("String"), - UserBucket: &ec2.UserBucket{ - S3Bucket: aws.String("String"), - S3Key: aws.String("String"), - }, - }, - DryRun: aws.Bool(true), - RoleName: aws.String("String"), - } - resp, err := svc.ImportSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ImportVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ImportVolumeInput{ - AvailabilityZone: aws.String("String"), // Required - Image: &ec2.DiskImageDetail{ // Required - Bytes: aws.Int64(1), // Required - Format: aws.String("DiskImageFormat"), // Required - ImportManifestUrl: aws.String("String"), // Required - }, - Volume: &ec2.VolumeDetail{ // Required - Size: aws.Int64(1), // Required - }, - Description: aws.String("String"), - DryRun: aws.Bool(true), - } - resp, err := svc.ImportVolume(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyHosts() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyHostsInput{ - AutoPlacement: aws.String("AutoPlacement"), // Required - HostIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ModifyHosts(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyIdFormatInput{ - Resource: aws.String("String"), // Required - UseLongIds: aws.Bool(true), // Required - } - resp, err := svc.ModifyIdFormat(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyIdentityIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyIdentityIdFormatInput{ - PrincipalArn: aws.String("String"), // Required - Resource: aws.String("String"), // Required - UseLongIds: aws.Bool(true), // Required - } - resp, err := svc.ModifyIdentityIdFormat(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyImageAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyImageAttributeInput{ - ImageId: aws.String("String"), // Required - Attribute: aws.String("String"), - Description: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - DryRun: aws.Bool(true), - LaunchPermission: &ec2.LaunchPermissionModifications{ - Add: []*ec2.LaunchPermission{ - { // Required - Group: aws.String("PermissionGroup"), - UserId: aws.String("String"), - }, - // More values... - }, - Remove: []*ec2.LaunchPermission{ - { // Required - Group: aws.String("PermissionGroup"), - UserId: aws.String("String"), - }, - // More values... - }, - }, - OperationType: aws.String("OperationType"), - ProductCodes: []*string{ - aws.String("String"), // Required - // More values... - }, - UserGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - UserIds: []*string{ - aws.String("String"), // Required - // More values... - }, - Value: aws.String("String"), - } - resp, err := svc.ModifyImageAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyInstanceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyInstanceAttributeInput{ - InstanceId: aws.String("String"), // Required - Attribute: aws.String("InstanceAttributeName"), - BlockDeviceMappings: []*ec2.InstanceBlockDeviceMappingSpecification{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsInstanceBlockDeviceSpecification{ - DeleteOnTermination: aws.Bool(true), - VolumeId: aws.String("String"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - DisableApiTermination: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - DryRun: aws.Bool(true), - EbsOptimized: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - EnaSupport: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - InstanceInitiatedShutdownBehavior: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - InstanceType: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - Kernel: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - Ramdisk: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - SourceDestCheck: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - SriovNetSupport: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - UserData: &ec2.BlobAttributeValue{ - Value: []byte("PAYLOAD"), - }, - Value: aws.String("String"), - } - resp, err := svc.ModifyInstanceAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyInstancePlacement() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyInstancePlacementInput{ - InstanceId: aws.String("String"), // Required - Affinity: aws.String("Affinity"), - HostId: aws.String("String"), - Tenancy: aws.String("HostTenancy"), - } - resp, err := svc.ModifyInstancePlacement(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyNetworkInterfaceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyNetworkInterfaceAttributeInput{ - NetworkInterfaceId: aws.String("String"), // Required - Attachment: &ec2.NetworkInterfaceAttachmentChanges{ - AttachmentId: aws.String("String"), - DeleteOnTermination: aws.Bool(true), - }, - Description: &ec2.AttributeValue{ - Value: aws.String("String"), - }, - DryRun: aws.Bool(true), - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceDestCheck: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - } - resp, err := svc.ModifyNetworkInterfaceAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyReservedInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyReservedInstancesInput{ - ReservedInstancesIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - TargetConfigurations: []*ec2.ReservedInstancesConfiguration{ // Required - { // Required - AvailabilityZone: aws.String("String"), - InstanceCount: aws.Int64(1), - InstanceType: aws.String("InstanceType"), - Platform: aws.String("String"), - Scope: aws.String("scope"), - }, - // More values... - }, - ClientToken: aws.String("String"), - } - resp, err := svc.ModifyReservedInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifySnapshotAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifySnapshotAttributeInput{ - SnapshotId: aws.String("String"), // Required - Attribute: aws.String("SnapshotAttributeName"), - CreateVolumePermission: &ec2.CreateVolumePermissionModifications{ - Add: []*ec2.CreateVolumePermission{ - { // Required - Group: aws.String("PermissionGroup"), - UserId: aws.String("String"), - }, - // More values... - }, - Remove: []*ec2.CreateVolumePermission{ - { // Required - Group: aws.String("PermissionGroup"), - UserId: aws.String("String"), - }, - // More values... - }, - }, - DryRun: aws.Bool(true), - GroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - OperationType: aws.String("OperationType"), - UserIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ModifySnapshotAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifySpotFleetRequest() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifySpotFleetRequestInput{ - SpotFleetRequestId: aws.String("String"), // Required - ExcessCapacityTerminationPolicy: aws.String("ExcessCapacityTerminationPolicy"), - TargetCapacity: aws.Int64(1), - } - resp, err := svc.ModifySpotFleetRequest(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifySubnetAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifySubnetAttributeInput{ - SubnetId: aws.String("String"), // Required - AssignIpv6AddressOnCreation: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - MapPublicIpOnLaunch: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - } - resp, err := svc.ModifySubnetAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyVolume() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyVolumeInput{ - VolumeId: aws.String("String"), // Required - DryRun: aws.Bool(true), - Iops: aws.Int64(1), - Size: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - } - resp, err := svc.ModifyVolume(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyVolumeAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyVolumeAttributeInput{ - VolumeId: aws.String("String"), // Required - AutoEnableIO: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - DryRun: aws.Bool(true), - } - resp, err := svc.ModifyVolumeAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyVpcAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyVpcAttributeInput{ - VpcId: aws.String("String"), // Required - EnableDnsHostnames: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - EnableDnsSupport: &ec2.AttributeBooleanValue{ - Value: aws.Bool(true), - }, - } - resp, err := svc.ModifyVpcAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyVpcEndpoint() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyVpcEndpointInput{ - VpcEndpointId: aws.String("String"), // Required - AddRouteTableIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - PolicyDocument: aws.String("String"), - RemoveRouteTableIds: []*string{ - aws.String("String"), // Required - // More values... - }, - ResetPolicy: aws.Bool(true), - } - resp, err := svc.ModifyVpcEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ModifyVpcPeeringConnectionOptions() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ModifyVpcPeeringConnectionOptionsInput{ - VpcPeeringConnectionId: aws.String("String"), // Required - AccepterPeeringConnectionOptions: &ec2.PeeringConnectionOptionsRequest{ - AllowDnsResolutionFromRemoteVpc: aws.Bool(true), - AllowEgressFromLocalClassicLinkToRemoteVpc: aws.Bool(true), - AllowEgressFromLocalVpcToRemoteClassicLink: aws.Bool(true), - }, - DryRun: aws.Bool(true), - RequesterPeeringConnectionOptions: &ec2.PeeringConnectionOptionsRequest{ - AllowDnsResolutionFromRemoteVpc: aws.Bool(true), - AllowEgressFromLocalClassicLinkToRemoteVpc: aws.Bool(true), - AllowEgressFromLocalVpcToRemoteClassicLink: aws.Bool(true), - }, - } - resp, err := svc.ModifyVpcPeeringConnectionOptions(params) - - if err != nil { - // 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) -} - -func ExampleEC2_MonitorInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.MonitorInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - } - resp, err := svc.MonitorInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_MoveAddressToVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.MoveAddressToVpcInput{ - PublicIp: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.MoveAddressToVpc(params) - - if err != nil { - // 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) -} - -func ExampleEC2_PurchaseHostReservation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.PurchaseHostReservationInput{ - HostIdSet: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - OfferingId: aws.String("String"), // Required - ClientToken: aws.String("String"), - CurrencyCode: aws.String("CurrencyCodeValues"), - LimitPrice: aws.String("String"), - } - resp, err := svc.PurchaseHostReservation(params) - - if err != nil { - // 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) -} - -func ExampleEC2_PurchaseReservedInstancesOffering() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.PurchaseReservedInstancesOfferingInput{ - InstanceCount: aws.Int64(1), // Required - ReservedInstancesOfferingId: aws.String("String"), // Required - DryRun: aws.Bool(true), - LimitPrice: &ec2.ReservedInstanceLimitPrice{ - Amount: aws.Float64(1.0), - CurrencyCode: aws.String("CurrencyCodeValues"), - }, - } - resp, err := svc.PurchaseReservedInstancesOffering(params) - - if err != nil { - // 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) -} - -func ExampleEC2_PurchaseScheduledInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.PurchaseScheduledInstancesInput{ - PurchaseRequests: []*ec2.PurchaseRequest{ // Required - { // Required - InstanceCount: aws.Int64(1), // Required - PurchaseToken: aws.String("String"), // Required - }, - // More values... - }, - ClientToken: aws.String("String"), - DryRun: aws.Bool(true), - } - resp, err := svc.PurchaseScheduledInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_RebootInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RebootInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - } - resp, err := svc.RebootInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_RegisterImage() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RegisterImageInput{ - Name: aws.String("String"), // Required - Architecture: aws.String("ArchitectureValues"), - BillingProducts: []*string{ - aws.String("String"), // Required - // More values... - }, - BlockDeviceMappings: []*ec2.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - Description: aws.String("String"), - DryRun: aws.Bool(true), - EnaSupport: aws.Bool(true), - ImageLocation: aws.String("String"), - KernelId: aws.String("String"), - RamdiskId: aws.String("String"), - RootDeviceName: aws.String("String"), - SriovNetSupport: aws.String("String"), - VirtualizationType: aws.String("String"), - } - resp, err := svc.RegisterImage(params) - - if err != nil { - // 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) -} - -func ExampleEC2_RejectVpcPeeringConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RejectVpcPeeringConnectionInput{ - VpcPeeringConnectionId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.RejectVpcPeeringConnection(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ReleaseAddress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReleaseAddressInput{ - AllocationId: aws.String("String"), - DryRun: aws.Bool(true), - PublicIp: aws.String("String"), - } - resp, err := svc.ReleaseAddress(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ReleaseHosts() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReleaseHostsInput{ - HostIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ReleaseHosts(params) +// To release an Elastic IP address for EC2-VPC +// +// This example releases an Elastic IP address for use with instances in a VPC. +func ExampleEC2_ReleaseAddress_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ReleaseAddressInput{ + AllocationId: aws.String("eipalloc-64d5890a"), + } + result, err := svc.ReleaseAddress(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() { + 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 ExampleEC2_ReplaceIamInstanceProfileAssociation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReplaceIamInstanceProfileAssociationInput{ - AssociationId: aws.String("String"), // Required - IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ // Required - Arn: aws.String("String"), - Name: aws.String("String"), - }, +// To release an Elastic IP addresses for EC2-Classic +// +// This example releases an Elastic IP address for use with instances in EC2-Classic. +func ExampleEC2_ReleaseAddress_shared01() { + svc := ec2.New(session.New()) + input := &ec2.ReleaseAddressInput{ + PublicIp: aws.String("198.51.100.0"), } - resp, err := svc.ReplaceIamInstanceProfileAssociation(params) + result, err := svc.ReleaseAddress(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() { + 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 ExampleEC2_ReplaceNetworkAclAssociation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReplaceNetworkAclAssociationInput{ - AssociationId: aws.String("String"), // Required - NetworkAclId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To replace the network ACL associated with a subnet +// +// This example associates the specified network ACL with the subnet for the specified +// network ACL association. +func ExampleEC2_ReplaceNetworkAclAssociation_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ReplaceNetworkAclAssociationInput{ + AssociationId: aws.String("aclassoc-e5b95c8c"), + NetworkAclId: aws.String("acl-5fb85d36"), } - resp, err := svc.ReplaceNetworkAclAssociation(params) + result, err := svc.ReplaceNetworkAclAssociation(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() { + 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 ExampleEC2_ReplaceNetworkAclEntry() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReplaceNetworkAclEntryInput{ - Egress: aws.Bool(true), // Required - NetworkAclId: aws.String("String"), // Required - Protocol: aws.String("String"), // Required - RuleAction: aws.String("RuleAction"), // Required - RuleNumber: aws.Int64(1), // Required - CidrBlock: aws.String("String"), - DryRun: aws.Bool(true), - IcmpTypeCode: &ec2.IcmpTypeCode{ - Code: aws.Int64(1), - Type: aws.Int64(1), - }, - Ipv6CidrBlock: aws.String("String"), +// To replace a network ACL entry +// +// This example replaces an entry for the specified network ACL. The new rule 100 allows +// ingress traffic from 203.0.113.12/24 on UDP port 53 (DNS) into any associated subnet. +func ExampleEC2_ReplaceNetworkAclEntry_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ReplaceNetworkAclEntryInput{ + CidrBlock: aws.String("203.0.113.12/24"), + Egress: aws.Bool(false), + NetworkAclId: aws.String("acl-5fb85d36"), PortRange: &ec2.PortRange{ - From: aws.Int64(1), - To: aws.Int64(1), - }, - } - resp, err := svc.ReplaceNetworkAclEntry(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ReplaceRoute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReplaceRouteInput{ - RouteTableId: aws.String("String"), // Required - DestinationCidrBlock: aws.String("String"), - DestinationIpv6CidrBlock: aws.String("String"), - DryRun: aws.Bool(true), - EgressOnlyInternetGatewayId: aws.String("String"), - GatewayId: aws.String("String"), - InstanceId: aws.String("String"), - NatGatewayId: aws.String("String"), - NetworkInterfaceId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), - } - resp, err := svc.ReplaceRoute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ReplaceRouteTableAssociation() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReplaceRouteTableAssociationInput{ - AssociationId: aws.String("String"), // Required - RouteTableId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.ReplaceRouteTableAssociation(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ReportInstanceStatus() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReportInstanceStatusInput{ - Instances: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - ReasonCodes: []*string{ // Required - aws.String("ReportInstanceReasonCodes"), // Required - // More values... + From: aws.Int64(53.000000), + To: aws.Int64(53.000000), }, - Status: aws.String("ReportStatusType"), // Required - Description: aws.String("String"), - DryRun: aws.Bool(true), - EndTime: aws.Time(time.Now()), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.ReportInstanceStatus(params) - - if err != nil { - // 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) -} - -func ExampleEC2_RequestSpotFleet() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RequestSpotFleetInput{ - SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{ // Required - IamFleetRole: aws.String("String"), // Required - LaunchSpecifications: []*ec2.SpotFleetLaunchSpecification{ // Required - { // Required - AddressingType: aws.String("String"), - BlockDeviceMappings: []*ec2.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), + Protocol: aws.String("udp"), + RuleAction: aws.String("allow"), + RuleNumber: aws.Int64(100.000000), + } + + result, err := svc.ReplaceNetworkAclEntry(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To replace a route +// +// This example replaces the specified route in the specified table table. The new route +// matches the specified CIDR and sends the traffic to the specified virtual private +// gateway. +func ExampleEC2_ReplaceRoute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ReplaceRouteInput{ + DestinationCidrBlock: aws.String("10.0.0.0/16"), + GatewayId: aws.String("vgw-9a4cacf3"), + RouteTableId: aws.String("rtb-22574640"), + } + + result, err := svc.ReplaceRoute(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To replace the route table associated with a subnet +// +// This example associates the specified route table with the subnet for the specified +// route table association. +func ExampleEC2_ReplaceRouteTableAssociation_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ReplaceRouteTableAssociationInput{ + AssociationId: aws.String("rtbassoc-781d0d1a"), + RouteTableId: aws.String("rtb-22574640"), + } + + result, err := svc.ReplaceRouteTableAssociation(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To request a Spot fleet in the subnet with the lowest price +// +// This example creates a Spot fleet request with two launch specifications that differ +// only by subnet. The Spot fleet launches the instances in the specified subnet with +// the lowest price. If the instances are launched in a default VPC, they receive a +// public IP address by default. If the instances are launched in a nondefault VPC, +// they do not receive a public IP address by default. Note that you can't specify different +// subnets from the same Availability Zone in a Spot fleet request. +func ExampleEC2_RequestSpotFleet_shared00() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotFleetInput{ + SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{ + IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"), + LaunchSpecifications: []*ec2.LaunchSpecsList{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), + SecurityGroups: []*ec2.SpotFleetLaunchSpecification{ + { + GroupId: aws.String("sg-1a2b3c4d"), }, - // More values... - }, - EbsOptimized: aws.Bool(true), - IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ - Arn: aws.String("String"), - Name: aws.String("String"), }, - ImageId: aws.String("String"), - InstanceType: aws.String("InstanceType"), - KernelId: aws.String("String"), - KeyName: aws.String("String"), - Monitoring: &ec2.SpotFleetMonitoring{ - Enabled: aws.Bool(true), + SubnetId: aws.String("subnet-1a2b3c4d, subnet-3c4d5e6f"), + }, + }, + SpotPrice: aws.String("0.04"), + TargetCapacity: aws.Int64(2.000000), + }, + } + + result, err := svc.RequestSpotFleet(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To request a Spot fleet in the Availability Zone with the lowest price +// +// This example creates a Spot fleet request with two launch specifications that differ +// only by Availability Zone. The Spot fleet launches the instances in the specified +// Availability Zone with the lowest price. If your account supports EC2-VPC only, Amazon +// EC2 launches the Spot instances in the default subnet of the Availability Zone. If +// your account supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic +// in the Availability Zone. +func ExampleEC2_RequestSpotFleet_shared01() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotFleetInput{ + SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{ + IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"), + LaunchSpecifications: []*ec2.LaunchSpecsList{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), + SecurityGroups: []*ec2.SpotFleetLaunchSpecification{ + { + GroupId: aws.String("sg-1a2b3c4d"), + }, }, - NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ - { // Required + }, + }, + SpotPrice: aws.String("0.04"), + TargetCapacity: aws.Int64(2.000000), + }, + } + + result, err := svc.RequestSpotFleet(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To launch Spot instances in a subnet and assign them public IP addresses +// +// This example assigns public addresses to instances launched in a nondefault VPC. +// Note that when you specify a network interface, you must include the subnet ID and +// security group ID using the network interface. +func ExampleEC2_RequestSpotFleet_shared02() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotFleetInput{ + SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{ + IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"), + LaunchSpecifications: []*ec2.LaunchSpecsList{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), + NetworkInterfaces: []*ec2.SpotFleetLaunchSpecification{ + { AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), + DeviceIndex: aws.Float64(0.000000), Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.InstanceIpv6Address{ - { // Required - Ipv6Address: aws.String("String"), - }, - // More values... + aws.String("sg-1a2b3c4d"), }, - NetworkInterfaceId: aws.String("String"), - PrivateIpAddress: aws.String("String"), - PrivateIpAddresses: []*ec2.PrivateIpAddressSpecification{ - { // Required - PrivateIpAddress: aws.String("String"), // Required - Primary: aws.Bool(true), - }, - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), - SubnetId: aws.String("String"), - }, - // More values... - }, - Placement: &ec2.SpotPlacement{ - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), - Tenancy: aws.String("Tenancy"), - }, - RamdiskId: aws.String("String"), - SecurityGroups: []*ec2.GroupIdentifier{ - { // Required - GroupId: aws.String("String"), - GroupName: aws.String("String"), + SubnetId: aws.String("subnet-1a2b3c4d"), }, - // More values... }, - SpotPrice: aws.String("String"), - SubnetId: aws.String("String"), - UserData: aws.String("String"), - WeightedCapacity: aws.Float64(1.0), }, - // More values... }, - SpotPrice: aws.String("String"), // Required - TargetCapacity: aws.Int64(1), // Required - AllocationStrategy: aws.String("AllocationStrategy"), - ClientToken: aws.String("String"), - ExcessCapacityTerminationPolicy: aws.String("ExcessCapacityTerminationPolicy"), - FulfilledCapacity: aws.Float64(1.0), - ReplaceUnhealthyInstances: aws.Bool(true), - TerminateInstancesWithExpiration: aws.Bool(true), - Type: aws.String("FleetType"), - ValidFrom: aws.Time(time.Now()), - ValidUntil: aws.Time(time.Now()), + SpotPrice: aws.String("0.04"), + TargetCapacity: aws.Int64(2.000000), + }, + } + + result, err := svc.RequestSpotFleet(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To request a Spot fleet using the diversified allocation strategy +// +// This example creates a Spot fleet request that launches 30 instances using the diversified +// allocation strategy. The launch specifications differ by instance type. The Spot +// fleet distributes the instances across the launch specifications such that there +// are 10 instances of each type. +func ExampleEC2_RequestSpotFleet_shared03() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotFleetInput{ + SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{ + AllocationStrategy: aws.String("diversified"), + IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"), + LaunchSpecifications: []*ec2.LaunchSpecsList{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("c4.2xlarge"), + SubnetId: aws.String("subnet-1a2b3c4d"), + }, + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.2xlarge"), + SubnetId: aws.String("subnet-1a2b3c4d"), + }, + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("r3.2xlarge"), + SubnetId: aws.String("subnet-1a2b3c4d"), + }, + }, + SpotPrice: aws.String("0.70"), + TargetCapacity: aws.Int64(30.000000), }, - DryRun: aws.Bool(true), } - resp, err := svc.RequestSpotFleet(params) + result, err := svc.RequestSpotFleet(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() { + 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 ExampleEC2_RequestSpotInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RequestSpotInstancesInput{ - SpotPrice: aws.String("String"), // Required - AvailabilityZoneGroup: aws.String("String"), - BlockDurationMinutes: aws.Int64(1), - ClientToken: aws.String("String"), - DryRun: aws.Bool(true), - InstanceCount: aws.Int64(1), - LaunchGroup: aws.String("String"), +// To create a one-time Spot Instance request +// +// This example creates a one-time Spot Instance request for five instances in the specified +// Availability Zone. If your account supports EC2-VPC only, Amazon EC2 launches the +// instances in the default subnet of the specified Availability Zone. If your account +// supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic in the specified +// Availability Zone. +func ExampleEC2_RequestSpotInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotInstancesInput{ + InstanceCount: aws.Int64(5.000000), LaunchSpecification: &ec2.RequestSpotLaunchSpecification{ - AddressingType: aws.String("String"), - BlockDeviceMappings: []*ec2.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ - Arn: aws.String("String"), - Name: aws.String("String"), - }, - ImageId: aws.String("String"), - InstanceType: aws.String("InstanceType"), - KernelId: aws.String("String"), - KeyName: aws.String("String"), - Monitoring: &ec2.RunInstancesMonitoringEnabled{ - Enabled: aws.Bool(true), // Required - }, - NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ - { // Required - AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.InstanceIpv6Address{ - { // Required - Ipv6Address: aws.String("String"), - }, - // More values... - }, - NetworkInterfaceId: aws.String("String"), - PrivateIpAddress: aws.String("String"), - PrivateIpAddresses: []*ec2.PrivateIpAddressSpecification{ - { // Required - PrivateIpAddress: aws.String("String"), // Required - Primary: aws.Bool(true), - }, - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), - SubnetId: aws.String("String"), - }, - // More values... + Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"), }, + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), Placement: &ec2.SpotPlacement{ - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), - Tenancy: aws.String("Tenancy"), + AvailabilityZone: aws.String("us-west-2a"), }, - RamdiskId: aws.String("String"), SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SecurityGroups: []*string{ - aws.String("String"), // Required - // More values... + aws.String("sg-1a2b3c4d"), }, - SubnetId: aws.String("String"), - UserData: aws.String("String"), }, - Type: aws.String("SpotInstanceType"), - ValidFrom: aws.Time(time.Now()), - ValidUntil: aws.Time(time.Now()), - } - resp, err := svc.RequestSpotInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ResetImageAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ResetImageAttributeInput{ - Attribute: aws.String("ResetImageAttributeName"), // Required - ImageId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.ResetImageAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ResetInstanceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ResetInstanceAttributeInput{ - Attribute: aws.String("InstanceAttributeName"), // Required - InstanceId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.ResetInstanceAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ResetNetworkInterfaceAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ResetNetworkInterfaceAttributeInput{ - NetworkInterfaceId: aws.String("String"), // Required - DryRun: aws.Bool(true), - SourceDestCheck: aws.String("String"), - } - resp, err := svc.ResetNetworkInterfaceAttribute(params) - - if err != nil { - // 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) -} - -func ExampleEC2_ResetSnapshotAttribute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ResetSnapshotAttributeInput{ - Attribute: aws.String("SnapshotAttributeName"), // Required - SnapshotId: aws.String("String"), // Required - DryRun: aws.Bool(true), + SpotPrice: aws.String("0.03"), + Type: aws.String("one-time"), } - resp, err := svc.ResetSnapshotAttribute(params) + result, err := svc.RequestSpotInstances(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() { + 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 ExampleEC2_RestoreAddressToClassic() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RestoreAddressToClassicInput{ - PublicIp: aws.String("String"), // Required - DryRun: aws.Bool(true), +// To create a one-time Spot Instance request +// +// This example command creates a one-time Spot Instance request for five instances +// in the specified subnet. Amazon EC2 launches the instances in the specified subnet. +// If the VPC is a nondefault VPC, the instances do not receive a public IP address +// by default. +func ExampleEC2_RequestSpotInstances_shared01() { + svc := ec2.New(session.New()) + input := &ec2.RequestSpotInstancesInput{ + InstanceCount: aws.Int64(5.000000), + LaunchSpecification: &ec2.RequestSpotLaunchSpecification{ + IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ + Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"), + }, + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + SecurityGroupIds: []*string{ + aws.String("sg-1a2b3c4d"), + }, + SubnetId: aws.String("subnet-1a2b3c4d"), + }, + SpotPrice: aws.String("0.050"), + Type: aws.String("one-time"), } - resp, err := svc.RestoreAddressToClassic(params) + result, err := svc.RequestSpotInstances(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() { + 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 ExampleEC2_RevokeSecurityGroupEgress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RevokeSecurityGroupEgressInput{ - GroupId: aws.String("String"), // Required - CidrIp: aws.String("String"), - DryRun: aws.Bool(true), - FromPort: aws.Int64(1), - IpPermissions: []*ec2.IpPermission{ - { // Required - FromPort: aws.Int64(1), - IpProtocol: aws.String("String"), - IpRanges: []*ec2.IpRange{ - { // Required - CidrIp: aws.String("String"), - }, - // More values... - }, - Ipv6Ranges: []*ec2.Ipv6Range{ - { // Required - CidrIpv6: aws.String("String"), - }, - // More values... - }, - PrefixListIds: []*ec2.PrefixListId{ - { // Required - PrefixListId: aws.String("String"), - }, - // More values... - }, - ToPort: aws.Int64(1), - UserIdGroupPairs: []*ec2.UserIdGroupPair{ - { // Required - GroupId: aws.String("String"), - GroupName: aws.String("String"), - PeeringStatus: aws.String("String"), - UserId: aws.String("String"), - VpcId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), - }, - // More values... - }, - }, - // More values... - }, - IpProtocol: aws.String("String"), - SourceSecurityGroupName: aws.String("String"), - SourceSecurityGroupOwnerId: aws.String("String"), - ToPort: aws.Int64(1), +// To reset a snapshot attribute +// +// This example resets the create volume permissions for snapshot ``snap-1234567890abcdef0``. +// If the command succeeds, no output is returned. +func ExampleEC2_ResetSnapshotAttribute_shared00() { + svc := ec2.New(session.New()) + input := &ec2.ResetSnapshotAttributeInput{ + Attribute: aws.String("createVolumePermission"), + SnapshotId: aws.String("snap-1234567890abcdef0"), } - resp, err := svc.RevokeSecurityGroupEgress(params) + result, err := svc.ResetSnapshotAttribute(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() { + 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 ExampleEC2_RevokeSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RevokeSecurityGroupIngressInput{ - CidrIp: aws.String("String"), - DryRun: aws.Bool(true), - FromPort: aws.Int64(1), - GroupId: aws.String("String"), - GroupName: aws.String("String"), - IpPermissions: []*ec2.IpPermission{ - { // Required - FromPort: aws.Int64(1), - IpProtocol: aws.String("String"), - IpRanges: []*ec2.IpRange{ - { // Required - CidrIp: aws.String("String"), - }, - // More values... - }, - Ipv6Ranges: []*ec2.Ipv6Range{ - { // Required - CidrIpv6: aws.String("String"), - }, - // More values... - }, - PrefixListIds: []*ec2.PrefixListId{ - { // Required - PrefixListId: aws.String("String"), - }, - // More values... - }, - ToPort: aws.Int64(1), - UserIdGroupPairs: []*ec2.UserIdGroupPair{ - { // Required - GroupId: aws.String("String"), - GroupName: aws.String("String"), - PeeringStatus: aws.String("String"), - UserId: aws.String("String"), - VpcId: aws.String("String"), - VpcPeeringConnectionId: aws.String("String"), - }, - // More values... - }, - }, - // More values... - }, - IpProtocol: aws.String("String"), - SourceSecurityGroupName: aws.String("String"), - SourceSecurityGroupOwnerId: aws.String("String"), - ToPort: aws.Int64(1), +// To restore an address to EC2-Classic +// +// This example restores the specified Elastic IP address to the EC2-Classic platform. +func ExampleEC2_RestoreAddressToClassic_shared00() { + svc := ec2.New(session.New()) + input := &ec2.RestoreAddressToClassicInput{ + PublicIp: aws.String("198.51.100.0"), } - resp, err := svc.RevokeSecurityGroupIngress(params) + result, err := svc.RestoreAddressToClassic(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() { + 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 ExampleEC2_RunInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RunInstancesInput{ - ImageId: aws.String("String"), // Required - MaxCount: aws.Int64(1), // Required - MinCount: aws.Int64(1), // Required - AdditionalInfo: aws.String("String"), - BlockDeviceMappings: []*ec2.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - ClientToken: aws.String("String"), - DisableApiTermination: aws.Bool(true), - DryRun: aws.Bool(true), - EbsOptimized: aws.Bool(true), - IamInstanceProfile: &ec2.IamInstanceProfileSpecification{ - Arn: aws.String("String"), - Name: aws.String("String"), - }, - InstanceInitiatedShutdownBehavior: aws.String("ShutdownBehavior"), - InstanceType: aws.String("InstanceType"), - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.InstanceIpv6Address{ - { // Required - Ipv6Address: aws.String("String"), - }, - // More values... - }, - KernelId: aws.String("String"), - KeyName: aws.String("String"), - Monitoring: &ec2.RunInstancesMonitoringEnabled{ - Enabled: aws.Bool(true), // Required - }, - NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ - { // Required - AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.InstanceIpv6Address{ - { // Required - Ipv6Address: aws.String("String"), - }, - // More values... - }, - NetworkInterfaceId: aws.String("String"), - PrivateIpAddress: aws.String("String"), - PrivateIpAddresses: []*ec2.PrivateIpAddressSpecification{ - { // Required - PrivateIpAddress: aws.String("String"), // Required - Primary: aws.Bool(true), - }, - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), - SubnetId: aws.String("String"), +// To launch a Scheduled Instance in a VPC +// +// This example launches the specified Scheduled Instance in a VPC. +func ExampleEC2_RunScheduledInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.RunScheduledInstancesInput{ + InstanceCount: aws.Int64(1.000000), + LaunchSpecification: &ec2.ScheduledInstancesLaunchSpecification{ + IamInstanceProfile: &ec2.ScheduledInstancesIamInstanceProfile{ + Name: aws.String("my-iam-role"), }, - // More values... - }, - Placement: &ec2.Placement{ - Affinity: aws.String("String"), - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), - HostId: aws.String("String"), - Tenancy: aws.String("Tenancy"), - }, - PrivateIpAddress: aws.String("String"), - RamdiskId: aws.String("String"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - SubnetId: aws.String("String"), - TagSpecifications: []*ec2.TagSpecification{ - { // Required - ResourceType: aws.String("ResourceType"), - Tags: []*ec2.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), + ImageId: aws.String("ami-12345678"), + InstanceType: aws.String("c4.large"), + KeyName: aws.String("my-key-pair"), + NetworkInterfaces: []*ec2.ScheduledInstancesNetworkInterfaceSet{ + { + AssociatePublicIpAddress: aws.Bool(true), + DeviceIndex: aws.Float64(0.000000), + Groups: []*string{ + aws.String("sg-12345678"), }, - // More values... + SubnetId: aws.String("subnet-12345678"), }, }, - // More values... }, - UserData: aws.String("String"), + ScheduledInstanceId: aws.String("sci-1234-1234-1234-1234-123456789012"), } - resp, err := svc.RunInstances(params) + result, err := svc.RunScheduledInstances(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() { + 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 ExampleEC2_RunScheduledInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RunScheduledInstancesInput{ - LaunchSpecification: &ec2.ScheduledInstancesLaunchSpecification{ // Required - ImageId: aws.String("String"), // Required - BlockDeviceMappings: []*ec2.ScheduledInstancesBlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &ec2.ScheduledInstancesEbs{ - DeleteOnTermination: aws.Bool(true), - Encrypted: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("String"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), +// To launch a Scheduled Instance in EC2-Classic +// +// This example launches the specified Scheduled Instance in EC2-Classic. +func ExampleEC2_RunScheduledInstances_shared01() { + svc := ec2.New(session.New()) + input := &ec2.RunScheduledInstancesInput{ + InstanceCount: aws.Int64(1.000000), + LaunchSpecification: &ec2.ScheduledInstancesLaunchSpecification{ IamInstanceProfile: &ec2.ScheduledInstancesIamInstanceProfile{ - Arn: aws.String("String"), - Name: aws.String("String"), - }, - InstanceType: aws.String("String"), - KernelId: aws.String("String"), - KeyName: aws.String("String"), - Monitoring: &ec2.ScheduledInstancesMonitoring{ - Enabled: aws.Bool(true), - }, - NetworkInterfaces: []*ec2.ScheduledInstancesNetworkInterface{ - { // Required - AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), - Groups: []*string{ - aws.String("String"), // Required - // More values... - }, - Ipv6AddressCount: aws.Int64(1), - Ipv6Addresses: []*ec2.ScheduledInstancesIpv6Address{ - { // Required - Ipv6Address: aws.String("Ipv6Address"), - }, - // More values... - }, - NetworkInterfaceId: aws.String("String"), - PrivateIpAddress: aws.String("String"), - PrivateIpAddressConfigs: []*ec2.ScheduledInstancesPrivateIpAddressConfig{ - { // Required - Primary: aws.Bool(true), - PrivateIpAddress: aws.String("String"), - }, - // More values... - }, - SecondaryPrivateIpAddressCount: aws.Int64(1), - SubnetId: aws.String("String"), - }, - // More values... + Name: aws.String("my-iam-role"), }, + ImageId: aws.String("ami-12345678"), + InstanceType: aws.String("c4.large"), + KeyName: aws.String("my-key-pair"), Placement: &ec2.ScheduledInstancesPlacement{ - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), + AvailabilityZone: aws.String("us-west-2b"), }, - RamdiskId: aws.String("String"), SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... + aws.String("sg-12345678"), }, - SubnetId: aws.String("String"), - UserData: aws.String("String"), - }, - ScheduledInstanceId: aws.String("String"), // Required - ClientToken: aws.String("String"), - DryRun: aws.Bool(true), - InstanceCount: aws.Int64(1), - } - resp, err := svc.RunScheduledInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_StartInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.StartInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - AdditionalInfo: aws.String("String"), - DryRun: aws.Bool(true), - } - resp, err := svc.StartInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_StopInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.StopInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - Force: aws.Bool(true), - } - resp, err := svc.StopInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_TerminateInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.TerminateInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), - } - resp, err := svc.TerminateInstances(params) - - if err != nil { - // 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) -} - -func ExampleEC2_UnassignIpv6Addresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.UnassignIpv6AddressesInput{ - Ipv6Addresses: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - NetworkInterfaceId: aws.String("String"), // Required - } - resp, err := svc.UnassignIpv6Addresses(params) - - if err != nil { - // 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) -} - -func ExampleEC2_UnassignPrivateIpAddresses() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.UnassignPrivateIpAddressesInput{ - NetworkInterfaceId: aws.String("String"), // Required - PrivateIpAddresses: []*string{ // Required - aws.String("String"), // Required - // More values... }, + ScheduledInstanceId: aws.String("sci-1234-1234-1234-1234-123456789012"), } - resp, err := svc.UnassignPrivateIpAddresses(params) + result, err := svc.RunScheduledInstances(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() { + 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 ExampleEC2_UnmonitorInstances() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.UnmonitorInstancesInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// To unassign a secondary private IP address from a network interface +// +// This example unassigns the specified private IP address from the specified network +// interface. +func ExampleEC2_UnassignPrivateIpAddresses_shared00() { + svc := ec2.New(session.New()) + input := &ec2.UnassignPrivateIpAddressesInput{ + NetworkInterfaceId: aws.String("eni-e5aa89a3"), + PrivateIpAddresses: []*string{ + aws.String("10.0.0.82"), }, - DryRun: aws.Bool(true), } - resp, err := svc.UnmonitorInstances(params) + result, err := svc.UnassignPrivateIpAddresses(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() { + 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) } diff --git a/service/ecr/examples_test.go b/service/ecr/examples_test.go deleted file mode 100644 index 29df9d86fd3..00000000000 --- a/service/ecr/examples_test.go +++ /dev/null @@ -1,450 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package ecr_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/ecr" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleECR_BatchCheckLayerAvailability() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.BatchCheckLayerAvailabilityInput{ - LayerDigests: []*string{ // Required - aws.String("BatchedOperationLayerDigest"), // Required - // More values... - }, - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.BatchCheckLayerAvailability(params) - - if err != nil { - // 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) -} - -func ExampleECR_BatchDeleteImage() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.BatchDeleteImageInput{ - ImageIds: []*ecr.ImageIdentifier{ // Required - { // Required - ImageDigest: aws.String("ImageDigest"), - ImageTag: aws.String("ImageTag"), - }, - // More values... - }, - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.BatchDeleteImage(params) - - if err != nil { - // 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) -} - -func ExampleECR_BatchGetImage() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.BatchGetImageInput{ - ImageIds: []*ecr.ImageIdentifier{ // Required - { // Required - ImageDigest: aws.String("ImageDigest"), - ImageTag: aws.String("ImageTag"), - }, - // More values... - }, - RepositoryName: aws.String("RepositoryName"), // Required - AcceptedMediaTypes: []*string{ - aws.String("MediaType"), // Required - // More values... - }, - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.BatchGetImage(params) - - if err != nil { - // 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) -} - -func ExampleECR_CompleteLayerUpload() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.CompleteLayerUploadInput{ - LayerDigests: []*string{ // Required - aws.String("LayerDigest"), // Required - // More values... - }, - RepositoryName: aws.String("RepositoryName"), // Required - UploadId: aws.String("UploadId"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.CompleteLayerUpload(params) - - if err != nil { - // 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) -} - -func ExampleECR_CreateRepository() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.CreateRepositoryInput{ - RepositoryName: aws.String("RepositoryName"), // Required - } - resp, err := svc.CreateRepository(params) - - if err != nil { - // 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) -} - -func ExampleECR_DeleteRepository() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.DeleteRepositoryInput{ - RepositoryName: aws.String("RepositoryName"), // Required - Force: aws.Bool(true), - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.DeleteRepository(params) - - if err != nil { - // 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) -} - -func ExampleECR_DeleteRepositoryPolicy() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.DeleteRepositoryPolicyInput{ - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.DeleteRepositoryPolicy(params) - - if err != nil { - // 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) -} - -func ExampleECR_DescribeImages() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.DescribeImagesInput{ - RepositoryName: aws.String("RepositoryName"), // Required - Filter: &ecr.DescribeImagesFilter{ - TagStatus: aws.String("TagStatus"), - }, - ImageIds: []*ecr.ImageIdentifier{ - { // Required - ImageDigest: aws.String("ImageDigest"), - ImageTag: aws.String("ImageTag"), - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.DescribeImages(params) - - if err != nil { - // 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) -} - -func ExampleECR_DescribeRepositories() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.DescribeRepositoriesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - RegistryId: aws.String("RegistryId"), - RepositoryNames: []*string{ - aws.String("RepositoryName"), // Required - // More values... - }, - } - resp, err := svc.DescribeRepositories(params) - - if err != nil { - // 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) -} - -func ExampleECR_GetAuthorizationToken() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.GetAuthorizationTokenInput{ - RegistryIds: []*string{ - aws.String("RegistryId"), // Required - // More values... - }, - } - resp, err := svc.GetAuthorizationToken(params) - - if err != nil { - // 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) -} - -func ExampleECR_GetDownloadUrlForLayer() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.GetDownloadUrlForLayerInput{ - LayerDigest: aws.String("LayerDigest"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.GetDownloadUrlForLayer(params) - - if err != nil { - // 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) -} - -func ExampleECR_GetRepositoryPolicy() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.GetRepositoryPolicyInput{ - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.GetRepositoryPolicy(params) - - if err != nil { - // 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) -} - -func ExampleECR_InitiateLayerUpload() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.InitiateLayerUploadInput{ - RepositoryName: aws.String("RepositoryName"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.InitiateLayerUpload(params) - - if err != nil { - // 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) -} - -func ExampleECR_ListImages() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.ListImagesInput{ - RepositoryName: aws.String("RepositoryName"), // Required - Filter: &ecr.ListImagesFilter{ - TagStatus: aws.String("TagStatus"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.ListImages(params) - - if err != nil { - // 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) -} - -func ExampleECR_PutImage() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.PutImageInput{ - ImageManifest: aws.String("ImageManifest"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - ImageTag: aws.String("ImageTag"), - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.PutImage(params) - - if err != nil { - // 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) -} - -func ExampleECR_SetRepositoryPolicy() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.SetRepositoryPolicyInput{ - PolicyText: aws.String("RepositoryPolicyText"), // Required - RepositoryName: aws.String("RepositoryName"), // Required - Force: aws.Bool(true), - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.SetRepositoryPolicy(params) - - if err != nil { - // 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) -} - -func ExampleECR_UploadLayerPart() { - sess := session.Must(session.NewSession()) - - svc := ecr.New(sess) - - params := &ecr.UploadLayerPartInput{ - LayerPartBlob: []byte("PAYLOAD"), // Required - PartFirstByte: aws.Int64(1), // Required - PartLastByte: aws.Int64(1), // Required - RepositoryName: aws.String("RepositoryName"), // Required - UploadId: aws.String("UploadId"), // Required - RegistryId: aws.String("RegistryId"), - } - resp, err := svc.UploadLayerPart(params) - - if err != nil { - // 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) -} diff --git a/service/ecs/examples_test.go b/service/ecs/examples_test.go index 19fae622f5d..d4d1f6e9780 100644 --- a/service/ecs/examples_test.go +++ b/service/ecs/examples_test.go @@ -8,998 +8,904 @@ import ( "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/ecs" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleECS_CreateCluster() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.CreateClusterInput{ - ClusterName: aws.String("String"), - } - resp, err := svc.CreateCluster(params) - +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()) - return + panic(err) } - - // Pretty-print the response data. - fmt.Println(resp) + return &t } -func ExampleECS_CreateService() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.CreateServiceInput{ - DesiredCount: aws.Int64(1), // Required - ServiceName: aws.String("String"), // Required - TaskDefinition: aws.String("String"), // Required - ClientToken: aws.String("String"), - Cluster: aws.String("String"), - DeploymentConfiguration: &ecs.DeploymentConfiguration{ - MaximumPercent: aws.Int64(1), - MinimumHealthyPercent: aws.Int64(1), - }, - LoadBalancers: []*ecs.LoadBalancer{ - { // Required - ContainerName: aws.String("String"), - ContainerPort: aws.Int64(1), - LoadBalancerName: aws.String("String"), - TargetGroupArn: aws.String("String"), - }, - // More values... - }, - PlacementConstraints: []*ecs.PlacementConstraint{ - { // Required - Expression: aws.String("String"), - Type: aws.String("PlacementConstraintType"), - }, - // More values... - }, - PlacementStrategy: []*ecs.PlacementStrategy{ - { // Required - Field: aws.String("String"), - Type: aws.String("PlacementStrategyType"), - }, - // More values... - }, - Role: aws.String("String"), +// To create a new cluster +// +// This example creates a cluster in your default region. +func ExampleECS_CreateCluster_shared00() { + svc := ecs.New(session.New()) + input := &ecs.CreateClusterInput{ + ClusterName: aws.String("my_cluster"), } - resp, err := svc.CreateService(params) + result, err := svc.CreateCluster(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_DeleteAttributes() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DeleteAttributesInput{ - Attributes: []*ecs.Attribute{ // Required - { // Required - Name: aws.String("String"), // Required - TargetId: aws.String("String"), - TargetType: aws.String("TargetType"), - Value: aws.String("String"), - }, - // More values... - }, - Cluster: aws.String("String"), +// To create a new service +// +// This example creates a service in your default region called ``ecs-simple-service``. +// The service uses the ``hello_world`` task definition and it maintains 10 copies of +// that task. +func ExampleECS_CreateService_shared00() { + svc := ecs.New(session.New()) + input := &ecs.CreateServiceInput{ + DesiredCount: aws.Int64(10.000000), + ServiceName: aws.String("ecs-simple-service"), + TaskDefinition: aws.String("hello_world"), } - resp, err := svc.DeleteAttributes(params) + result, err := svc.CreateService(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_DeleteCluster() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DeleteClusterInput{ - Cluster: aws.String("String"), // Required +// To create a new service behind a load balancer +// +// This example creates a service in your default region called ``ecs-simple-service-elb``. +// The service uses the ``ecs-demo`` task definition and it maintains 10 copies of that +// task. You must reference an existing load balancer in the same region by its name. +func ExampleECS_CreateService_shared01() { + svc := ecs.New(session.New()) + input := &ecs.CreateServiceInput{ + DesiredCount: aws.Int64(10.000000), + LoadBalancers: []*ecs.LoadBalancers{ + { + ContainerName: aws.String("simple-app"), + ContainerPort: aws.Float64(80.000000), + LoadBalancerName: aws.String("EC2Contai-EcsElast-15DCDAURT3ZO2"), + }, + }, + Role: aws.String("ecsServiceRole"), + ServiceName: aws.String("ecs-simple-service-elb"), + TaskDefinition: aws.String("console-sample-app-static"), } - resp, err := svc.DeleteCluster(params) + result, err := svc.CreateService(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_DeleteService() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DeleteServiceInput{ - Service: aws.String("String"), // Required - Cluster: aws.String("String"), +// To delete an empty cluster +// +// This example deletes an empty cluster in your default region. +func ExampleECS_DeleteCluster_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DeleteClusterInput{ + Cluster: aws.String("my_cluster"), } - resp, err := svc.DeleteService(params) + result, err := svc.DeleteCluster(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeClusterContainsContainerInstancesException: + fmt.Println(ecs.ErrCodeClusterContainsContainerInstancesException, aerr.Error()) + case ecs.ErrCodeClusterContainsServicesException: + fmt.Println(ecs.ErrCodeClusterContainsServicesException, 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 ExampleECS_DeregisterContainerInstance() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DeregisterContainerInstanceInput{ - ContainerInstance: aws.String("String"), // Required - Cluster: aws.String("String"), - Force: aws.Bool(true), +// To delete a service +// +// This example deletes the my-http-service service. The service must have a desired +// count and running count of 0 before you can delete it. +func ExampleECS_DeleteService_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DeleteServiceInput{ + Service: aws.String("my-http-service"), } - resp, err := svc.DeregisterContainerInstance(params) + result, err := svc.DeleteService(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotFoundException: + fmt.Println(ecs.ErrCodeServiceNotFoundException, 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 ExampleECS_DeregisterTaskDefinition() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DeregisterTaskDefinitionInput{ - TaskDefinition: aws.String("String"), // Required +// To deregister a container instance from a cluster +// +// This example deregisters a container instance from the specified cluster in your +// default region. If there are still tasks running on the container instance, you must +// either stop those tasks before deregistering, or use the force option. +func ExampleECS_DeregisterContainerInstance_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DeregisterContainerInstanceInput{ + Cluster: aws.String("default"), + ContainerInstance: aws.String("container_instance_UUID"), + Force: aws.Bool(true), } - resp, err := svc.DeregisterTaskDefinition(params) + result, err := svc.DeregisterContainerInstance(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_DescribeClusters() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DescribeClustersInput{ +// To describe a cluster +// +// This example provides a description of the specified cluster in your default region. +func ExampleECS_DescribeClusters_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DescribeClustersInput{ Clusters: []*string{ - aws.String("String"), // Required - // More values... + aws.String("default"), }, } - resp, err := svc.DescribeClusters(params) + result, err := svc.DescribeClusters(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_DescribeContainerInstances() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DescribeContainerInstancesInput{ - ContainerInstances: []*string{ // Required - aws.String("String"), // Required - // More values... +// To describe container instance +// +// This example provides a description of the specified container instance in your default +// region, using the container instance UUID as an identifier. +func ExampleECS_DescribeContainerInstances_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DescribeContainerInstancesInput{ + Cluster: aws.String("default"), + ContainerInstances: []*string{ + aws.String("f2756532-8f13-4d53-87c9-aed50dc94cd7"), }, - Cluster: aws.String("String"), } - resp, err := svc.DescribeContainerInstances(params) + result, err := svc.DescribeContainerInstances(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_DescribeServices() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DescribeServicesInput{ - Services: []*string{ // Required - aws.String("String"), // Required - // More values... +// To describe a service +// +// This example provides descriptive information about the service named ``ecs-simple-service``. +func ExampleECS_DescribeServices_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DescribeServicesInput{ + Services: []*string{ + aws.String("ecs-simple-service"), }, - Cluster: aws.String("String"), } - resp, err := svc.DescribeServices(params) + result, err := svc.DescribeServices(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_DescribeTaskDefinition() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DescribeTaskDefinitionInput{ - TaskDefinition: aws.String("String"), // Required +// To describe a task definition +// +// This example provides a description of the specified task definition. +func ExampleECS_DescribeTaskDefinition_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DescribeTaskDefinitionInput{ + TaskDefinition: aws.String("hello_world:8"), } - resp, err := svc.DescribeTaskDefinition(params) + result, err := svc.DescribeTaskDefinition(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_DescribeTasks() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DescribeTasksInput{ - Tasks: []*string{ // Required - aws.String("String"), // Required - // More values... +// To describe a task +// +// This example provides a description of the specified task, using the task UUID as +// an identifier. +func ExampleECS_DescribeTasks_shared00() { + svc := ecs.New(session.New()) + input := &ecs.DescribeTasksInput{ + Tasks: []*string{ + aws.String("c5cba4eb-5dad-405e-96db-71ef8eefe6a8"), }, - Cluster: aws.String("String"), - } - resp, err := svc.DescribeTasks(params) - - if err != nil { - // 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) -} - -func ExampleECS_DiscoverPollEndpoint() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.DiscoverPollEndpointInput{ - Cluster: aws.String("String"), - ContainerInstance: aws.String("String"), - } - resp, err := svc.DiscoverPollEndpoint(params) - + result, err := svc.DescribeTasks(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_ListAttributes() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListAttributesInput{ - TargetType: aws.String("TargetType"), // Required - AttributeName: aws.String("String"), - AttributeValue: aws.String("String"), - Cluster: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListAttributes(params) +// To list your available clusters +// +// This example lists all of your available clusters in your default region. +func ExampleECS_ListClusters_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListClustersInput{} + result, err := svc.ListClusters(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_ListClusters() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListClustersInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// To list your available container instances in a cluster +// +// This example lists all of your available container instances in the specified cluster +// in your default region. +func ExampleECS_ListContainerInstances_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListContainerInstancesInput{ + Cluster: aws.String("default"), } - resp, err := svc.ListClusters(params) + result, err := svc.ListContainerInstances(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_ListContainerInstances() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListContainerInstancesInput{ - Cluster: aws.String("String"), - Filter: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - Status: aws.String("ContainerInstanceStatus"), - } - resp, err := svc.ListContainerInstances(params) +// To list the services in a cluster +// +// This example lists the services running in the default cluster for an account. +func ExampleECS_ListServices_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListServicesInput{} + result, err := svc.ListServices(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_ListServices() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListServicesInput{ - Cluster: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListServices(params) +// To list your registered task definition families +// +// This example lists all of your registered task definition families. +func ExampleECS_ListTaskDefinitionFamilies_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListTaskDefinitionFamiliesInput{} + result, err := svc.ListTaskDefinitionFamilies(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_ListTaskDefinitionFamilies() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListTaskDefinitionFamiliesInput{ - FamilyPrefix: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - Status: aws.String("TaskDefinitionFamilyStatus"), +// To filter your registered task definition families +// +// This example lists the task definition revisions that start with "hpcc". +func ExampleECS_ListTaskDefinitionFamilies_shared01() { + svc := ecs.New(session.New()) + input := &ecs.ListTaskDefinitionFamiliesInput{ + FamilyPrefix: aws.String("hpcc"), } - resp, err := svc.ListTaskDefinitionFamilies(params) + result, err := svc.ListTaskDefinitionFamilies(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_ListTaskDefinitions() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListTaskDefinitionsInput{ - FamilyPrefix: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - Sort: aws.String("SortOrder"), - Status: aws.String("TaskDefinitionStatus"), - } - resp, err := svc.ListTaskDefinitions(params) +// To list your registered task definitions +// +// This example lists all of your registered task definitions. +func ExampleECS_ListTaskDefinitions_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListTaskDefinitionsInput{} + result, err := svc.ListTaskDefinitions(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_ListTasks() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListTasksInput{ - Cluster: aws.String("String"), - ContainerInstance: aws.String("String"), - DesiredStatus: aws.String("DesiredStatus"), - Family: aws.String("String"), - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - ServiceName: aws.String("String"), - StartedBy: aws.String("String"), +// To list the registered task definitions in a family +// +// This example lists the task definition revisions of a specified family. +func ExampleECS_ListTaskDefinitions_shared01() { + svc := ecs.New(session.New()) + input := &ecs.ListTaskDefinitionsInput{ + FamilyPrefix: aws.String("wordpress"), } - resp, err := svc.ListTasks(params) + result, err := svc.ListTaskDefinitions(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_PutAttributes() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.PutAttributesInput{ - Attributes: []*ecs.Attribute{ // Required - { // Required - Name: aws.String("String"), // Required - TargetId: aws.String("String"), - TargetType: aws.String("TargetType"), - Value: aws.String("String"), - }, - // More values... - }, - Cluster: aws.String("String"), +// To list the tasks in a cluster +// +// This example lists all of the tasks in a cluster. +func ExampleECS_ListTasks_shared00() { + svc := ecs.New(session.New()) + input := &ecs.ListTasksInput{ + Cluster: aws.String("default"), } - resp, err := svc.PutAttributes(params) + result, err := svc.ListTasks(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotFoundException: + fmt.Println(ecs.ErrCodeServiceNotFoundException, 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 ExampleECS_RegisterContainerInstance() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.RegisterContainerInstanceInput{ - Attributes: []*ecs.Attribute{ - { // Required - Name: aws.String("String"), // Required - TargetId: aws.String("String"), - TargetType: aws.String("TargetType"), - Value: aws.String("String"), - }, - // More values... - }, - Cluster: aws.String("String"), - ContainerInstanceArn: aws.String("String"), - InstanceIdentityDocument: aws.String("String"), - InstanceIdentityDocumentSignature: aws.String("String"), - TotalResources: []*ecs.Resource{ - { // Required - DoubleValue: aws.Float64(1.0), - IntegerValue: aws.Int64(1), - LongValue: aws.Int64(1), - Name: aws.String("String"), - StringSetValue: []*string{ - aws.String("String"), // Required - // More values... - }, - Type: aws.String("String"), - }, - // More values... - }, - VersionInfo: &ecs.VersionInfo{ - AgentHash: aws.String("String"), - AgentVersion: aws.String("String"), - DockerVersion: aws.String("String"), - }, +// To list the tasks on a particular container instance +// +// This example lists the tasks of a specified container instance. Specifying a ``containerInstance`` +// value limits the results to tasks that belong to that container instance. +func ExampleECS_ListTasks_shared01() { + svc := ecs.New(session.New()) + input := &ecs.ListTasksInput{ + Cluster: aws.String("default"), + ContainerInstance: aws.String("f6bbb147-5370-4ace-8c73-c7181ded911f"), } - resp, err := svc.RegisterContainerInstance(params) + result, err := svc.ListTasks(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotFoundException: + fmt.Println(ecs.ErrCodeServiceNotFoundException, 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 ExampleECS_RegisterTaskDefinition() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.RegisterTaskDefinitionInput{ - ContainerDefinitions: []*ecs.ContainerDefinition{ // Required - { // Required +// To register a task definition +// +// This example registers a task definition to the specified family. +func ExampleECS_RegisterTaskDefinition_shared00() { + svc := ecs.New(session.New()) + input := &ecs.RegisterTaskDefinitionInput{ + ContainerDefinitions: []*ecs.ContainerDefinitions{ + { Command: []*string{ - aws.String("String"), // Required - // More values... - }, - Cpu: aws.Int64(1), - DisableNetworking: aws.Bool(true), - DnsSearchDomains: []*string{ - aws.String("String"), // Required - // More values... - }, - DnsServers: []*string{ - aws.String("String"), // Required - // More values... - }, - DockerLabels: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - DockerSecurityOptions: []*string{ - aws.String("String"), // Required - // More values... - }, - EntryPoint: []*string{ - aws.String("String"), // Required - // More values... - }, - Environment: []*ecs.KeyValuePair{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... + aws.String("sleep"), + aws.String("360"), }, + Cpu: aws.Float64(10.000000), Essential: aws.Bool(true), - ExtraHosts: []*ecs.HostEntry{ - { // Required - Hostname: aws.String("String"), // Required - IpAddress: aws.String("String"), // Required - }, - // More values... - }, - Hostname: aws.String("String"), - Image: aws.String("String"), - Links: []*string{ - aws.String("String"), // Required - // More values... - }, - LogConfiguration: &ecs.LogConfiguration{ - LogDriver: aws.String("LogDriver"), // Required - Options: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - Memory: aws.Int64(1), - MemoryReservation: aws.Int64(1), - MountPoints: []*ecs.MountPoint{ - { // Required - ContainerPath: aws.String("String"), - ReadOnly: aws.Bool(true), - SourceVolume: aws.String("String"), - }, - // More values... - }, - Name: aws.String("String"), - PortMappings: []*ecs.PortMapping{ - { // Required - ContainerPort: aws.Int64(1), - HostPort: aws.Int64(1), - Protocol: aws.String("TransportProtocol"), - }, - // More values... - }, - Privileged: aws.Bool(true), - ReadonlyRootFilesystem: aws.Bool(true), - Ulimits: []*ecs.Ulimit{ - { // Required - HardLimit: aws.Int64(1), // Required - Name: aws.String("UlimitName"), // Required - SoftLimit: aws.Int64(1), // Required - }, - // More values... - }, - User: aws.String("String"), - VolumesFrom: []*ecs.VolumeFrom{ - { // Required - ReadOnly: aws.Bool(true), - SourceContainer: aws.String("String"), - }, - // More values... - }, - WorkingDirectory: aws.String("String"), - }, - // More values... - }, - Family: aws.String("String"), // Required - NetworkMode: aws.String("NetworkMode"), - PlacementConstraints: []*ecs.TaskDefinitionPlacementConstraint{ - { // Required - Expression: aws.String("String"), - Type: aws.String("TaskDefinitionPlacementConstraintType"), - }, - // More values... - }, - TaskRoleArn: aws.String("String"), - Volumes: []*ecs.Volume{ - { // Required - Host: &ecs.HostVolumeProperties{ - SourcePath: aws.String("String"), - }, - Name: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.RegisterTaskDefinition(params) - - if err != nil { - // 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) -} - -func ExampleECS_RunTask() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.RunTaskInput{ - TaskDefinition: aws.String("String"), // Required - Cluster: aws.String("String"), - Count: aws.Int64(1), - Group: aws.String("String"), - Overrides: &ecs.TaskOverride{ - ContainerOverrides: []*ecs.ContainerOverride{ - { // Required - Command: []*string{ - aws.String("String"), // Required - // More values... - }, - Environment: []*ecs.KeyValuePair{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - Name: aws.String("String"), - }, - // More values... - }, - TaskRoleArn: aws.String("String"), - }, - PlacementConstraints: []*ecs.PlacementConstraint{ - { // Required - Expression: aws.String("String"), - Type: aws.String("PlacementConstraintType"), - }, - // More values... - }, - PlacementStrategy: []*ecs.PlacementStrategy{ - { // Required - Field: aws.String("String"), - Type: aws.String("PlacementStrategyType"), - }, - // More values... - }, - StartedBy: aws.String("String"), - } - resp, err := svc.RunTask(params) - - if err != nil { - // 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) -} - -func ExampleECS_StartTask() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.StartTaskInput{ - ContainerInstances: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - TaskDefinition: aws.String("String"), // Required - Cluster: aws.String("String"), - Group: aws.String("String"), - Overrides: &ecs.TaskOverride{ - ContainerOverrides: []*ecs.ContainerOverride{ - { // Required - Command: []*string{ - aws.String("String"), // Required - // More values... - }, - Environment: []*ecs.KeyValuePair{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - Name: aws.String("String"), - }, - // More values... - }, - TaskRoleArn: aws.String("String"), - }, - StartedBy: aws.String("String"), - } - resp, err := svc.StartTask(params) - - if err != nil { - // 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) -} - -func ExampleECS_StopTask() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.StopTaskInput{ - Task: aws.String("String"), // Required - Cluster: aws.String("String"), - Reason: aws.String("String"), - } - resp, err := svc.StopTask(params) - - if err != nil { - // 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) -} - -func ExampleECS_SubmitContainerStateChange() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.SubmitContainerStateChangeInput{ - Cluster: aws.String("String"), - ContainerName: aws.String("String"), - ExitCode: aws.Int64(1), - NetworkBindings: []*ecs.NetworkBinding{ - { // Required - BindIP: aws.String("String"), - ContainerPort: aws.Int64(1), - HostPort: aws.Int64(1), - Protocol: aws.String("TransportProtocol"), + Image: aws.String("busybox"), + Memory: aws.Float64(10.000000), + Name: aws.String("sleep"), }, - // More values... }, - Reason: aws.String("String"), - Status: aws.String("String"), - Task: aws.String("String"), + Family: aws.String("sleep360"), + TaskRoleArn: aws.String(""), } - resp, err := svc.SubmitContainerStateChange(params) + result, err := svc.RegisterTaskDefinition(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, 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 ExampleECS_SubmitTaskStateChange() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.SubmitTaskStateChangeInput{ - Cluster: aws.String("String"), - Reason: aws.String("String"), - Status: aws.String("String"), - Task: aws.String("String"), +// To run a task on your default cluster +// +// This example runs the specified task definition on your default cluster. +func ExampleECS_RunTask_shared00() { + svc := ecs.New(session.New()) + input := &ecs.RunTaskInput{ + Cluster: aws.String("default"), + TaskDefinition: aws.String("sleep360:1"), } - resp, err := svc.SubmitTaskStateChange(params) + result, err := svc.RunTask(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, 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 ExampleECS_UpdateContainerAgent() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.UpdateContainerAgentInput{ - ContainerInstance: aws.String("String"), // Required - Cluster: aws.String("String"), +// To change the task definition used in a service +// +// This example updates the my-http-service service to use the amazon-ecs-sample task +// definition. +func ExampleECS_UpdateService_shared00() { + svc := ecs.New(session.New()) + input := &ecs.UpdateServiceInput{ + Service: aws.String("my-http-service"), + TaskDefinition: aws.String("amazon-ecs-sample"), } - resp, err := svc.UpdateContainerAgent(params) + result, err := svc.UpdateService(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotFoundException: + fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotActiveException: + fmt.Println(ecs.ErrCodeServiceNotActiveException, 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 ExampleECS_UpdateContainerInstancesState() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.UpdateContainerInstancesStateInput{ - ContainerInstances: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Status: aws.String("ContainerInstanceStatus"), // Required - Cluster: aws.String("String"), - } - resp, err := svc.UpdateContainerInstancesState(params) - - if err != nil { - // 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) -} - -func ExampleECS_UpdateService() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.UpdateServiceInput{ - Service: aws.String("String"), // Required - Cluster: aws.String("String"), - DeploymentConfiguration: &ecs.DeploymentConfiguration{ - MaximumPercent: aws.Int64(1), - MinimumHealthyPercent: aws.Int64(1), - }, - DesiredCount: aws.Int64(1), - TaskDefinition: aws.String("String"), +// To change the number of tasks in a service +// +// This example updates the desired count of the my-http-service service to 10. +func ExampleECS_UpdateService_shared01() { + svc := ecs.New(session.New()) + input := &ecs.UpdateServiceInput{ + DesiredCount: aws.Int64(10.000000), + Service: aws.String("my-http-service"), } - resp, err := svc.UpdateService(params) + result, err := svc.UpdateService(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 ecs.ErrCodeServerException: + fmt.Println(ecs.ErrCodeServerException, aerr.Error()) + case ecs.ErrCodeClientException: + fmt.Println(ecs.ErrCodeClientException, aerr.Error()) + case ecs.ErrCodeInvalidParameterException: + fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) + case ecs.ErrCodeClusterNotFoundException: + fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotFoundException: + fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) + case ecs.ErrCodeServiceNotActiveException: + fmt.Println(ecs.ErrCodeServiceNotActiveException, 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) } diff --git a/service/efs/examples_test.go b/service/efs/examples_test.go deleted file mode 100644 index 3938e32e9b5..00000000000 --- a/service/efs/examples_test.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package efs_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/efs" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleEFS_CreateFileSystem() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.CreateFileSystemInput{ - CreationToken: aws.String("CreationToken"), // Required - PerformanceMode: aws.String("PerformanceMode"), - } - resp, err := svc.CreateFileSystem(params) - - if err != nil { - // 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) -} - -func ExampleEFS_CreateMountTarget() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.CreateMountTargetInput{ - FileSystemId: aws.String("FileSystemId"), // Required - SubnetId: aws.String("SubnetId"), // Required - IpAddress: aws.String("IpAddress"), - SecurityGroups: []*string{ - aws.String("SecurityGroup"), // Required - // More values... - }, - } - resp, err := svc.CreateMountTarget(params) - - if err != nil { - // 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) -} - -func ExampleEFS_CreateTags() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.CreateTagsInput{ - FileSystemId: aws.String("FileSystemId"), // Required - Tags: []*efs.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.CreateTags(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DeleteFileSystem() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DeleteFileSystemInput{ - FileSystemId: aws.String("FileSystemId"), // Required - } - resp, err := svc.DeleteFileSystem(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DeleteMountTarget() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DeleteMountTargetInput{ - MountTargetId: aws.String("MountTargetId"), // Required - } - resp, err := svc.DeleteMountTarget(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DeleteTagsInput{ - FileSystemId: aws.String("FileSystemId"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.DeleteTags(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DescribeFileSystems() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DescribeFileSystemsInput{ - CreationToken: aws.String("CreationToken"), - FileSystemId: aws.String("FileSystemId"), - Marker: aws.String("Marker"), - MaxItems: aws.Int64(1), - } - resp, err := svc.DescribeFileSystems(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DescribeMountTargetSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DescribeMountTargetSecurityGroupsInput{ - MountTargetId: aws.String("MountTargetId"), // Required - } - resp, err := svc.DescribeMountTargetSecurityGroups(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DescribeMountTargets() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DescribeMountTargetsInput{ - FileSystemId: aws.String("FileSystemId"), - Marker: aws.String("Marker"), - MaxItems: aws.Int64(1), - MountTargetId: aws.String("MountTargetId"), - } - resp, err := svc.DescribeMountTargets(params) - - if err != nil { - // 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) -} - -func ExampleEFS_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.DescribeTagsInput{ - FileSystemId: aws.String("FileSystemId"), // Required - Marker: aws.String("Marker"), - MaxItems: aws.Int64(1), - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleEFS_ModifyMountTargetSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := efs.New(sess) - - params := &efs.ModifyMountTargetSecurityGroupsInput{ - MountTargetId: aws.String("MountTargetId"), // Required - SecurityGroups: []*string{ - aws.String("SecurityGroup"), // Required - // More values... - }, - } - resp, err := svc.ModifyMountTargetSecurityGroups(params) - - if err != nil { - // 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) -} diff --git a/service/elasticache/examples_test.go b/service/elasticache/examples_test.go index c3da9c02656..4f52d8f0a07 100644 --- a/service/elasticache/examples_test.go +++ b/service/elasticache/examples_test.go @@ -8,1078 +8,1946 @@ import ( "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/elasticache" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleElastiCache_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &elasticache.AddTagsToResourceInput{ - ResourceName: aws.String("String"), // Required - Tags: []*elasticache.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), +// AddTagsToResource +// +// Adds up to 10 tags, key/value pairs, to a cluster or snapshot resource. +func ExampleElastiCache_AddTagsToResource_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.AddTagsToResourceInput{ + ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"), + Tags: []*elasticache.TagList{ + { + Key: aws.String("APIVersion"), + Value: aws.String("20150202"), + }, + { + Key: aws.String("Service"), + Value: aws.String("ElastiCache"), }, - // More values... }, } - resp, err := svc.AddTagsToResource(params) + result, err := svc.AddTagsToResource(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeTagQuotaPerResourceExceeded: + fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) + case elasticache.ErrCodeInvalidARNFault: + fmt.Println(elasticache.ErrCodeInvalidARNFault, 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 ExampleElastiCache_AuthorizeCacheSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.AuthorizeCacheSecurityGroupIngressInput{ - CacheSecurityGroupName: aws.String("String"), // Required - EC2SecurityGroupName: aws.String("String"), // Required - EC2SecurityGroupOwnerId: aws.String("String"), // Required +// AuthorizeCacheCacheSecurityGroupIngress +// +// Allows network ingress to a cache security group. Applications using ElastiCache +// must be running on Amazon EC2. Amazon EC2 security groups are used as the authorization +// mechanism. +func ExampleElastiCache_AuthorizeCacheSecurityGroupIngress_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.AuthorizeCacheSecurityGroupIngressInput{ + CacheSecurityGroupName: aws.String("my-sec-grp"), + EC2SecurityGroupName: aws.String("my-ec2-sec-grp"), + EC2SecurityGroupOwnerId: aws.String("1234567890"), } - resp, err := svc.AuthorizeCacheSecurityGroupIngress(params) + result, err := svc.AuthorizeCacheSecurityGroupIngress(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 elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) + case elasticache.ErrCodeAuthorizationAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeAuthorizationAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CopySnapshot() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.CopySnapshotInput{ - SourceSnapshotName: aws.String("String"), // Required - TargetSnapshotName: aws.String("String"), // Required - TargetBucket: aws.String("String"), +// CopySnapshot +// +// Copies a snapshot to a specified name. +func ExampleElastiCache_CopySnapshot_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CopySnapshotInput{ + SourceSnapshotName: aws.String("my-snapshot"), + TargetBucket: aws.String(""), + TargetSnapshotName: aws.String("my-snapshot-copy"), } - resp, err := svc.CopySnapshot(params) + result, err := svc.CopySnapshot(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 elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidSnapshotStateFault: + fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CreateCacheCluster() { - sess := session.Must(session.NewSession()) +// CreateCacheCluster +// +// Creates a Memcached cluster with 2 nodes. +func ExampleElastiCache_CreateCacheCluster_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateCacheClusterInput{ + AZMode: aws.String("cross-az"), + CacheClusterId: aws.String("my-memcached-cluster"), + CacheNodeType: aws.String("cache.r3.large"), + CacheSubnetGroupName: aws.String("default"), + Engine: aws.String("memcached"), + EngineVersion: aws.String("1.4.24"), + NumCacheNodes: aws.Int64(2.000000), + Port: aws.Int64(11211.000000), + } + + result, err := svc.CreateCacheCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeTagQuotaPerResourceExceeded: + fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 + } - svc := elasticache.New(sess) + fmt.Println(result) +} - params := &elasticache.CreateCacheClusterInput{ - CacheClusterId: aws.String("String"), // Required - AZMode: aws.String("AZMode"), - AuthToken: aws.String("String"), +// CreateCacheCluster +// +// Creates a Redis cluster with 1 node. +func ExampleElastiCache_CreateCacheCluster_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateCacheClusterInput{ AutoMinorVersionUpgrade: aws.Bool(true), - CacheNodeType: aws.String("String"), - CacheParameterGroupName: aws.String("String"), - CacheSecurityGroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - CacheSubnetGroupName: aws.String("String"), - Engine: aws.String("String"), - EngineVersion: aws.String("String"), - NotificationTopicArn: aws.String("String"), - NumCacheNodes: aws.Int64(1), - Port: aws.Int64(1), - PreferredAvailabilityZone: aws.String("String"), - PreferredAvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... - }, - PreferredMaintenanceWindow: aws.String("String"), - ReplicationGroupId: aws.String("String"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotArns: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotName: aws.String("String"), - SnapshotRetentionLimit: aws.Int64(1), - SnapshotWindow: aws.String("String"), - Tags: []*elasticache.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateCacheCluster(params) - + CacheClusterId: aws.String("my-redis"), + CacheNodeType: aws.String("cache.r3.larage"), + CacheSubnetGroupName: aws.String("default"), + Engine: aws.String("redis"), + EngineVersion: aws.String("3.2.4"), + NumCacheNodes: aws.Int64(1.000000), + Port: aws.Int64(6379.000000), + PreferredAvailabilityZone: aws.String("us-east-1c"), + SnapshotRetentionLimit: aws.Int64(7.000000), + } + + result, err := svc.CreateCacheCluster(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 elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeTagQuotaPerResourceExceeded: + fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CreateCacheParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.CreateCacheParameterGroupInput{ - CacheParameterGroupFamily: aws.String("String"), // Required - CacheParameterGroupName: aws.String("String"), // Required - Description: aws.String("String"), // Required +// CreateCacheParameterGroup +// +// Creates the Amazon ElastiCache parameter group custom-redis2-8. +func ExampleElastiCache_CreateCacheParameterGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateCacheParameterGroupInput{ + CacheParameterGroupFamily: aws.String("redis2.8"), + CacheParameterGroupName: aws.String("custom-redis2-8"), + Description: aws.String("Custom Redis 2.8 parameter group."), } - resp, err := svc.CreateCacheParameterGroup(params) + result, err := svc.CreateCacheParameterGroup(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 elasticache.ErrCodeCacheParameterGroupQuotaExceededFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CreateCacheSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.CreateCacheSecurityGroupInput{ - CacheSecurityGroupName: aws.String("String"), // Required - Description: aws.String("String"), // Required +// CreateCacheSecurityGroup +// +// Creates an ElastiCache security group. ElastiCache security groups are only for clusters +// not running in an AWS VPC. +func ExampleElastiCache_CreateCacheSecurityGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateCacheSecurityGroupInput{ + CacheSecurityGroupName: aws.String("my-cache-sec-grp"), + Description: aws.String("Example ElastiCache security group."), } - resp, err := svc.CreateCacheSecurityGroup(params) + result, err := svc.CreateCacheSecurityGroup(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 elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CreateCacheSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.CreateCacheSubnetGroupInput{ - CacheSubnetGroupDescription: aws.String("String"), // Required - CacheSubnetGroupName: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// CreateCacheSubnet +// +// Creates a new cache subnet group. +func ExampleElastiCache_CreateCacheSubnetGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateCacheSubnetGroupInput{ + CacheSubnetGroupDescription: aws.String("Sample subnet group"), + CacheSubnetGroupName: aws.String("my-sn-grp2"), + SubnetIds: []*string{ + aws.String("subnet-6f28c982"), + aws.String("subnet-bcd382f3"), + aws.String("subnet-845b3e7c0"), }, } - resp, err := svc.CreateCacheSubnetGroup(params) + result, err := svc.CreateCacheSubnetGroup(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 elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetQuotaExceededFault: + fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidSubnet: + fmt.Println(elasticache.ErrCodeInvalidSubnet, 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 ExampleElastiCache_CreateReplicationGroup() { - sess := session.Must(session.NewSession()) +// CreateCacheReplicationGroup +// +// Creates a Redis replication group with 3 nodes. +func ExampleElastiCache_CreateReplicationGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateReplicationGroupInput{ + AutomaticFailoverEnabled: aws.Bool(true), + CacheNodeType: aws.String("cache.m3.medium"), + Engine: aws.String("redis"), + EngineVersion: aws.String("2.8.24"), + NumCacheClusters: aws.Int64(3.000000), + ReplicationGroupDescription: aws.String("A Redis replication group."), + ReplicationGroupId: aws.String("my-redis-rg"), + SnapshotRetentionLimit: aws.Int64(30.000000), + } - svc := elasticache.New(sess) + result, err := svc.CreateReplicationGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeTagQuotaPerResourceExceeded: + fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) + case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault: + fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 := &elasticache.CreateReplicationGroupInput{ - ReplicationGroupDescription: aws.String("String"), // Required - ReplicationGroupId: aws.String("String"), // Required - AuthToken: aws.String("String"), - AutoMinorVersionUpgrade: aws.Bool(true), - AutomaticFailoverEnabled: aws.Bool(true), - CacheNodeType: aws.String("String"), - CacheParameterGroupName: aws.String("String"), - CacheSecurityGroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - CacheSubnetGroupName: aws.String("String"), - Engine: aws.String("String"), - EngineVersion: aws.String("String"), - NodeGroupConfiguration: []*elasticache.NodeGroupConfiguration{ - { // Required - PrimaryAvailabilityZone: aws.String("String"), + fmt.Println(result) +} + +// CreateReplicationGroup +// +// Creates a Redis (cluster mode enabled) replication group with two shards. One shard +// has one read replica node and the other shard has two read replicas. +func ExampleElastiCache_CreateReplicationGroup_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateReplicationGroupInput{ + AutoMinorVersionUpgrade: aws.Bool(true), + CacheNodeType: aws.String("cache.m3.medium"), + CacheParameterGroupName: aws.String("default.redis3.2.cluster.on"), + Engine: aws.String("redis"), + EngineVersion: aws.String("3.2.4"), + NodeGroupConfiguration: []*elasticache.NodeGroupConfigurationList{ + { + PrimaryAvailabilityZone: aws.String("us-east-1c"), ReplicaAvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... + aws.String("us-east-1b"), }, - ReplicaCount: aws.Int64(1), - Slots: aws.String("String"), + ReplicaCount: aws.Float64(1.000000), + Slots: aws.String("0-8999"), }, - // More values... - }, - NotificationTopicArn: aws.String("String"), - NumCacheClusters: aws.Int64(1), - NumNodeGroups: aws.Int64(1), - Port: aws.Int64(1), - PreferredCacheClusterAZs: []*string{ - aws.String("String"), // Required - // More values... - }, - PreferredMaintenanceWindow: aws.String("String"), - PrimaryClusterId: aws.String("String"), - ReplicasPerNodeGroup: aws.Int64(1), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotArns: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotName: aws.String("String"), - SnapshotRetentionLimit: aws.Int64(1), - SnapshotWindow: aws.String("String"), - Tags: []*elasticache.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), + { + PrimaryAvailabilityZone: aws.String("us-east-1a"), + ReplicaAvailabilityZones: []*string{ + aws.String("us-east-1a"), + aws.String("us-east-1c"), + }, + ReplicaCount: aws.Float64(2.000000), + Slots: aws.String("9000-16383"), }, - // More values... }, + NumNodeGroups: aws.Int64(2.000000), + ReplicationGroupDescription: aws.String("A multi-sharded replication group"), + ReplicationGroupId: aws.String("clustered-redis-rg"), + SnapshotRetentionLimit: aws.Int64(8.000000), } - resp, err := svc.CreateReplicationGroup(params) + result, err := svc.CreateReplicationGroup(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeTagQuotaPerResourceExceeded: + fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) + case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault: + fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_CreateSnapshot() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.CreateSnapshotInput{ - SnapshotName: aws.String("String"), // Required - CacheClusterId: aws.String("String"), - ReplicationGroupId: aws.String("String"), +// CreateSnapshot - NonClustered Redis, no read-replicas +// +// Creates a snapshot of a non-clustered Redis cluster that has only one node. +func ExampleElastiCache_CreateSnapshot_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateSnapshotInput{ + CacheClusterId: aws.String("onenoderedis"), + SnapshotName: aws.String("snapshot-1"), } - resp, err := svc.CreateSnapshot(params) + result, err := svc.CreateSnapshot(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 elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: + fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, 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 ExampleElastiCache_DeleteCacheCluster() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteCacheClusterInput{ - CacheClusterId: aws.String("String"), // Required - FinalSnapshotIdentifier: aws.String("String"), +// CreateSnapshot - NonClustered Redis, 2 read-replicas +// +// Creates a snapshot of a non-clustered Redis cluster that has only three nodes, primary +// and two read-replicas. CacheClusterId must be a specific node in the cluster. +func ExampleElastiCache_CreateSnapshot_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateSnapshotInput{ + CacheClusterId: aws.String("threenoderedis-001"), + SnapshotName: aws.String("snapshot-2"), } - resp, err := svc.DeleteCacheCluster(params) + result, err := svc.CreateSnapshot(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 elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: + fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, 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 ExampleElastiCache_DeleteCacheParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteCacheParameterGroupInput{ - CacheParameterGroupName: aws.String("String"), // Required +// CreateSnapshot-clustered Redis +// +// Creates a snapshot of a clustered Redis cluster that has 2 shards, each with a primary +// and 4 read-replicas. +func ExampleElastiCache_CreateSnapshot_shared02() { + svc := elasticache.New(session.New()) + input := &elasticache.CreateSnapshotInput{ + ReplicationGroupId: aws.String("clusteredredis"), + SnapshotName: aws.String("snapshot-2x5"), } - resp, err := svc.DeleteCacheParameterGroup(params) + result, err := svc.CreateSnapshot(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 elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: + fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, 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 ExampleElastiCache_DeleteCacheSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteCacheSecurityGroupInput{ - CacheSecurityGroupName: aws.String("String"), // Required +// DeleteCacheCluster +// +// Deletes an Amazon ElastiCache cluster. +func ExampleElastiCache_DeleteCacheCluster_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteCacheClusterInput{ + CacheClusterId: aws.String("my-memcached"), } - resp, err := svc.DeleteCacheSecurityGroup(params) + result, err := svc.DeleteCacheCluster(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: + fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DeleteCacheSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteCacheSubnetGroupInput{ - CacheSubnetGroupName: aws.String("String"), // Required +// DeleteCacheParameterGroup +// +// Deletes the Amazon ElastiCache parameter group custom-mem1-4. +func ExampleElastiCache_DeleteCacheParameterGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteCacheParameterGroupInput{ + CacheParameterGroupName: aws.String("custom-mem1-4"), } - resp, err := svc.DeleteCacheSubnetGroup(params) + result, err := svc.DeleteCacheParameterGroup(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 elasticache.ErrCodeInvalidCacheParameterGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DeleteReplicationGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteReplicationGroupInput{ - ReplicationGroupId: aws.String("String"), // Required - FinalSnapshotIdentifier: aws.String("String"), - RetainPrimaryCluster: aws.Bool(true), +// DeleteCacheSecurityGroup +// +// Deletes a cache security group. +func ExampleElastiCache_DeleteCacheSecurityGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteCacheSecurityGroupInput{ + CacheSecurityGroupName: aws.String("my-sec-group"), } - resp, err := svc.DeleteReplicationGroup(params) + result, err := svc.DeleteCacheSecurityGroup(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 elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DeleteSnapshot() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DeleteSnapshotInput{ - SnapshotName: aws.String("String"), // Required +// DeleteCacheSubnetGroup +// +// Deletes the Amazon ElastiCache subnet group my-subnet-group. +func ExampleElastiCache_DeleteCacheSubnetGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteCacheSubnetGroupInput{ + CacheSubnetGroupName: aws.String("my-subnet-group"), } - resp, err := svc.DeleteSnapshot(params) + result, err := svc.DeleteCacheSubnetGroup(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 elasticache.ErrCodeCacheSubnetGroupInUse: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupInUse, aerr.Error()) + case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, 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 ExampleElastiCache_DescribeCacheClusters() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeCacheClustersInput{ - CacheClusterId: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ShowCacheClustersNotInReplicationGroups: aws.Bool(true), - ShowCacheNodeInfo: aws.Bool(true), +// DeleteReplicationGroup +// +// Deletes the Amazon ElastiCache replication group my-redis-rg. +func ExampleElastiCache_DeleteReplicationGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteReplicationGroupInput{ + ReplicationGroupId: aws.String("my-redis-rg"), + RetainPrimaryCluster: aws.Bool(false), } - resp, err := svc.DescribeCacheClusters(params) + result, err := svc.DeleteReplicationGroup(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 elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeSnapshotAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: + fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) + case elasticache.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeCacheEngineVersions() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeCacheEngineVersionsInput{ - CacheParameterGroupFamily: aws.String("String"), - DefaultOnly: aws.Bool(true), - Engine: aws.String("String"), - EngineVersion: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// DeleteSnapshot +// +// Deletes the Redis snapshot snapshot-20160822. +func ExampleElastiCache_DeleteSnapshot_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DeleteSnapshotInput{ + SnapshotName: aws.String("snapshot-20161212"), } - resp, err := svc.DescribeCacheEngineVersions(params) + result, err := svc.DeleteSnapshot(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 elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidSnapshotStateFault: + fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeCacheParameterGroups() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeCacheParameterGroupsInput{ - CacheParameterGroupName: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// DescribeCacheClusters +// +// Lists the details for up to 50 cache clusters. +func ExampleElastiCache_DescribeCacheClusters_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheClustersInput{ + CacheClusterId: aws.String("my-mem-cluster"), } - resp, err := svc.DescribeCacheParameterGroups(params) + result, err := svc.DescribeCacheClusters(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeCacheParameters() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeCacheParametersInput{ - CacheParameterGroupName: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Source: aws.String("String"), +// DescribeCacheClusters +// +// Lists the details for the cache cluster my-mem-cluster. +func ExampleElastiCache_DescribeCacheClusters_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheClustersInput{ + CacheClusterId: aws.String("my-mem-cluster"), + ShowCacheNodeInfo: aws.Bool(true), } - resp, err := svc.DescribeCacheParameters(params) + result, err := svc.DescribeCacheClusters(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeCacheSecurityGroups() { - sess := session.Must(session.NewSession()) +// DescribeCacheEngineVersions +// +// Lists the details for up to 25 Memcached and Redis cache engine versions. +func ExampleElastiCache_DescribeCacheEngineVersions_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheEngineVersionsInput{} + + result, err := svc.DescribeCacheEngineVersions(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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 + } - svc := elasticache.New(sess) + fmt.Println(result) +} - params := &elasticache.DescribeCacheSecurityGroupsInput{ - CacheSecurityGroupName: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// DescribeCacheEngineVersions +// +// Lists the details for up to 50 Redis cache engine versions. +func ExampleElastiCache_DescribeCacheEngineVersions_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheEngineVersionsInput{ + DefaultOnly: aws.Bool(false), + Engine: aws.String("redis"), + MaxRecords: aws.Int64(50.000000), } - resp, err := svc.DescribeCacheSecurityGroups(params) + result, err := svc.DescribeCacheEngineVersions(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() { + 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 ExampleElastiCache_DescribeCacheSubnetGroups() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeCacheSubnetGroupsInput{ - CacheSubnetGroupName: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// DescribeCacheParameterGroups +// +// Returns a list of cache parameter group descriptions. If a cache parameter group +// name is specified, the list contains only the descriptions for that group. +func ExampleElastiCache_DescribeCacheParameterGroups_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheParameterGroupsInput{ + CacheParameterGroupName: aws.String("custom-mem1-4"), } - resp, err := svc.DescribeCacheSubnetGroups(params) + result, err := svc.DescribeCacheParameterGroups(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 elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeEngineDefaultParameters() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeEngineDefaultParametersInput{ - CacheParameterGroupFamily: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// DescribeCacheParameters +// +// Lists up to 100 user parameter values for the parameter group custom.redis2.8. +func ExampleElastiCache_DescribeCacheParameters_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheParametersInput{ + CacheParameterGroupName: aws.String("custom-redis2-8"), + MaxRecords: aws.Int64(100.000000), + Source: aws.String("user"), } - resp, err := svc.DescribeEngineDefaultParameters(params) + result, err := svc.DescribeCacheParameters(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 elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeEventsInput{ - Duration: aws.Int64(1), - EndTime: aws.Time(time.Now()), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SourceIdentifier: aws.String("String"), - SourceType: aws.String("SourceType"), - StartTime: aws.Time(time.Now()), +// DescribeCacheSecurityGroups +// +// Returns a list of cache security group descriptions. If a cache security group name +// is specified, the list contains only the description of that group. +func ExampleElastiCache_DescribeCacheSecurityGroups_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheSecurityGroupsInput{ + CacheSecurityGroupName: aws.String("my-sec-group"), } - resp, err := svc.DescribeEvents(params) + result, err := svc.DescribeCacheSecurityGroups(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 elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeReplicationGroups() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeReplicationGroupsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ReplicationGroupId: aws.String("String"), +// DescribeCacheSubnetGroups +// +// Describes up to 25 cache subnet groups. +func ExampleElastiCache_DescribeCacheSubnetGroups_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeCacheSubnetGroupsInput{ + MaxRecords: aws.Int64(25.000000), } - resp, err := svc.DescribeReplicationGroups(params) + result, err := svc.DescribeCacheSubnetGroups(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 elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, 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 ExampleElastiCache_DescribeReservedCacheNodes() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.DescribeReservedCacheNodesInput{ - CacheNodeType: aws.String("String"), - Duration: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - OfferingType: aws.String("String"), - ProductDescription: aws.String("String"), - ReservedCacheNodeId: aws.String("String"), - ReservedCacheNodesOfferingId: aws.String("String"), +// DescribeEngineDefaultParameters +// +// Returns the default engine and system parameter information for the specified cache +// engine. +func ExampleElastiCache_DescribeEngineDefaultParameters_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeEngineDefaultParametersInput{ + CacheParameterGroupFamily: aws.String("redis2.8"), + MaxRecords: aws.Int64(25.000000), } - resp, err := svc.DescribeReservedCacheNodes(params) + result, err := svc.DescribeEngineDefaultParameters(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 elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeReservedCacheNodesOfferings() { - sess := session.Must(session.NewSession()) +// DescribeEvents +// +// Describes all the cache-cluster events for the past 120 minutes. +func ExampleElastiCache_DescribeEvents_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeEventsInput{ + Duration: aws.Int64(360.000000), + SourceType: aws.String("cache-cluster"), + } - svc := elasticache.New(sess) + result, err := svc.DescribeEvents(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 := &elasticache.DescribeReservedCacheNodesOfferingsInput{ - CacheNodeType: aws.String("String"), - Duration: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - OfferingType: aws.String("String"), - ProductDescription: aws.String("String"), - ReservedCacheNodesOfferingId: aws.String("String"), + fmt.Println(result) +} + +// DescribeEvents +// +// Describes all the replication-group events from 3:00P to 5:00P on November 11, 2016. +func ExampleElastiCache_DescribeEvents_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeEventsInput{ + StartTime: parseTime("2006-01-02T15:04:05Z", "2016-12-22T15:00:00.000Z"), } - resp, err := svc.DescribeReservedCacheNodesOfferings(params) + result, err := svc.DescribeEvents(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 elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_DescribeSnapshots() { - sess := session.Must(session.NewSession()) +// DescribeReplicationGroups +// +// Returns information about the replication group myreplgroup. +func ExampleElastiCache_DescribeReplicationGroups_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeReplicationGroupsInput{} - svc := elasticache.New(sess) + result, err := svc.DescribeReplicationGroups(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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) +} - params := &elasticache.DescribeSnapshotsInput{ - CacheClusterId: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ReplicationGroupId: aws.String("String"), - ShowNodeGroupConfig: aws.Bool(true), - SnapshotName: aws.String("String"), - SnapshotSource: aws.String("String"), +// DescribeReservedCacheNodes +// +// Returns information about reserved cache nodes for this account, or about a specified +// reserved cache node. If the account has no reserved cache nodes, the operation returns +// an empty list, as shown here. +func ExampleElastiCache_DescribeReservedCacheNodes_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeReservedCacheNodesInput{ + MaxRecords: aws.Int64(25.000000), } - resp, err := svc.DescribeSnapshots(params) + result, err := svc.DescribeReservedCacheNodes(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 elasticache.ErrCodeReservedCacheNodeNotFoundFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_ListAllowedNodeTypeModifications() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) +// DescribeReseredCacheNodeOfferings +// +// Lists available reserved cache node offerings. +func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ + MaxRecords: aws.Int64(20.000000), + } - params := &elasticache.ListAllowedNodeTypeModificationsInput{ - CacheClusterId: aws.String("String"), - ReplicationGroupId: aws.String("String"), + result, err := svc.DescribeReservedCacheNodesOfferings(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 } - resp, err := svc.ListAllowedNodeTypeModifications(params) + fmt.Println(result) +} + +// DescribeReseredCacheNodeOfferings +// +// Lists available reserved cache node offerings for cache.r3.large nodes with a 3 year +// commitment. +func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ + CacheNodeType: aws.String("cache.r3.large"), + Duration: aws.String("3"), + MaxRecords: aws.Int64(25.000000), + OfferingType: aws.String("Light Utilization"), + ReservedCacheNodesOfferingId: aws.String(""), + } + + result, err := svc.DescribeReservedCacheNodesOfferings(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 elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_ListTagsForResource() { - sess := session.Must(session.NewSession()) +// DescribeReseredCacheNodeOfferings +// +// Lists available reserved cache node offerings. +func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared02() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ + CacheNodeType: aws.String(""), + Duration: aws.String(""), + Marker: aws.String(""), + MaxRecords: aws.Int64(25.000000), + OfferingType: aws.String(""), + ProductDescription: aws.String(""), + ReservedCacheNodesOfferingId: aws.String("438012d3-4052-4cc7-b2e3-8d3372e0e706"), + } + + result, err := svc.DescribeReservedCacheNodesOfferings(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 + } - svc := elasticache.New(sess) + fmt.Println(result) +} - params := &elasticache.ListTagsForResourceInput{ - ResourceName: aws.String("String"), // Required +// DescribeSnapshots +// +// Returns information about the snapshot mysnapshot. By default. +func ExampleElastiCache_DescribeSnapshots_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.DescribeSnapshotsInput{ + SnapshotName: aws.String("snapshot-20161212"), } - resp, err := svc.ListTagsForResource(params) + result, err := svc.DescribeSnapshots(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_ModifyCacheCluster() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.ModifyCacheClusterInput{ - CacheClusterId: aws.String("String"), // Required - AZMode: aws.String("AZMode"), - ApplyImmediately: aws.Bool(true), - AutoMinorVersionUpgrade: aws.Bool(true), - CacheNodeIdsToRemove: []*string{ - aws.String("String"), // Required - // More values... - }, - CacheNodeType: aws.String("String"), - CacheParameterGroupName: aws.String("String"), - CacheSecurityGroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - EngineVersion: aws.String("String"), - NewAvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... - }, - NotificationTopicArn: aws.String("String"), - NotificationTopicStatus: aws.String("String"), - NumCacheNodes: aws.Int64(1), - PreferredMaintenanceWindow: aws.String("String"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SnapshotRetentionLimit: aws.Int64(1), - SnapshotWindow: aws.String("String"), +// ListAllowedNodeTypeModifications +// +// Lists all available node types that you can scale your Redis cluster's or replication +// group's current node type up to. +func ExampleElastiCache_ListAllowedNodeTypeModifications_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ListAllowedNodeTypeModificationsInput{ + ReplicationGroupId: aws.String("myreplgroup"), } - resp, err := svc.ModifyCacheCluster(params) + result, err := svc.ListAllowedNodeTypeModifications(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, 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 ExampleElastiCache_ModifyCacheParameterGroup() { - sess := session.Must(session.NewSession()) +// ListAllowedNodeTypeModifications +// +// Lists all available node types that you can scale your Redis cluster's or replication +// group's current node type up to. +func ExampleElastiCache_ListAllowedNodeTypeModifications_shared01() { + svc := elasticache.New(session.New()) + input := &elasticache.ListAllowedNodeTypeModificationsInput{ + CacheClusterId: aws.String("mycluster"), + } - svc := elasticache.New(sess) + result, err := svc.ListAllowedNodeTypeModifications(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, 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 := &elasticache.ModifyCacheParameterGroupInput{ - CacheParameterGroupName: aws.String("String"), // Required - ParameterNameValues: []*elasticache.ParameterNameValue{ // Required - { // Required - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - }, - // More values... - }, + fmt.Println(result) +} + +// ListTagsForResource +// +// Lists all cost allocation tags currently on the named resource. A cost allocation +// tag is a key-value pair where the key is case-sensitive and the value is optional. +// You can use cost allocation tags to categorize and track your AWS costs. +func ExampleElastiCache_ListTagsForResource_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ListTagsForResourceInput{ + ResourceName: aws.String("arn:aws:elasticache:us-west-2::cluster:mycluster"), } - resp, err := svc.ModifyCacheParameterGroup(params) + result, err := svc.ListTagsForResource(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidARNFault: + fmt.Println(elasticache.ErrCodeInvalidARNFault, 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 ExampleElastiCache_ModifyCacheSubnetGroup() { - sess := session.Must(session.NewSession()) +// ModifyCacheCluster +// +// Copies a snapshot to a specified name. +func ExampleElastiCache_ModifyCacheCluster_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ModifyCacheClusterInput{ + ApplyImmediately: aws.Bool(true), + CacheClusterId: aws.String("redis-cluster"), + SnapshotRetentionLimit: aws.Int64(14.000000), + } - svc := elasticache.New(sess) + result, err := svc.ModifyCacheCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 := &elasticache.ModifyCacheSubnetGroupInput{ - CacheSubnetGroupName: aws.String("String"), // Required - CacheSubnetGroupDescription: aws.String("String"), - SubnetIds: []*string{ - aws.String("String"), // Required - // More values... + fmt.Println(result) +} + +// ModifyCacheParameterGroup +// +// Modifies one or more parameter values in the specified parameter group. You cannot +// modify any default parameter group. +func ExampleElastiCache_ModifyCacheParameterGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ModifyCacheParameterGroupInput{ + CacheParameterGroupName: aws.String("custom-mem1-4"), + ParameterNameValues: []*elasticache.ParameterNameValueList{ + { + ParameterName: aws.String("binding_protocol"), + ParameterValue: aws.String("ascii"), + }, + { + ParameterName: aws.String("chunk_size"), + ParameterValue: aws.String("96"), + }, }, } - resp, err := svc.ModifyCacheSubnetGroup(params) + result, err := svc.ModifyCacheParameterGroup(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 elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_ModifyReplicationGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.ModifyReplicationGroupInput{ - ReplicationGroupId: aws.String("String"), // Required - ApplyImmediately: aws.Bool(true), - AutoMinorVersionUpgrade: aws.Bool(true), - AutomaticFailoverEnabled: aws.Bool(true), - CacheNodeType: aws.String("String"), - CacheParameterGroupName: aws.String("String"), - CacheSecurityGroupNames: []*string{ - aws.String("String"), // Required - // More values... - }, - EngineVersion: aws.String("String"), - NodeGroupId: aws.String("String"), - NotificationTopicArn: aws.String("String"), - NotificationTopicStatus: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - PrimaryClusterId: aws.String("String"), - ReplicationGroupDescription: aws.String("String"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... +// ModifyCacheSubnetGroup +// +// Modifies an existing ElastiCache subnet group. +func ExampleElastiCache_ModifyCacheSubnetGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ModifyCacheSubnetGroupInput{ + CacheSubnetGroupName: aws.String("my-sn-grp"), + SubnetIds: []*string{ + aws.String("subnet-bcde2345"), }, - SnapshotRetentionLimit: aws.Int64(1), - SnapshotWindow: aws.String("String"), - SnapshottingClusterId: aws.String("String"), } - resp, err := svc.ModifyReplicationGroup(params) + result, err := svc.ModifyCacheSubnetGroup(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 elasticache.ErrCodeCacheSubnetGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheSubnetQuotaExceededFault: + fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeSubnetInUse: + fmt.Println(elasticache.ErrCodeSubnetInUse, aerr.Error()) + case elasticache.ErrCodeInvalidSubnet: + fmt.Println(elasticache.ErrCodeInvalidSubnet, 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 ExampleElastiCache_PurchaseReservedCacheNodesOffering() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) +// ModifyReplicationGroup +// - params := &elasticache.PurchaseReservedCacheNodesOfferingInput{ - ReservedCacheNodesOfferingId: aws.String("String"), // Required - CacheNodeCount: aws.Int64(1), - ReservedCacheNodeId: aws.String("String"), +func ExampleElastiCache_ModifyReplicationGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ModifyReplicationGroupInput{ + ApplyImmediately: aws.Bool(true), + ReplicationGroupDescription: aws.String("Modified replication group"), + ReplicationGroupId: aws.String("my-redis-rg"), + SnapshotRetentionLimit: aws.Int64(30.000000), + SnapshottingClusterId: aws.String("my-redis-rg-001"), } - resp, err := svc.PurchaseReservedCacheNodesOffering(params) + result, err := svc.ModifyReplicationGroup(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 elasticache.ErrCodeReplicationGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidReplicationGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: + fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForClusterExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) + case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: + fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) + case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_RebootCacheCluster() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.RebootCacheClusterInput{ - CacheClusterId: aws.String("String"), // Required - CacheNodeIdsToReboot: []*string{ // Required - aws.String("String"), // Required - // More values... - }, +// PurchaseReservedCacheNodesOfferings +// +// Allows you to purchase a reserved cache node offering. +func ExampleElastiCache_PurchaseReservedCacheNodesOffering_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.PurchaseReservedCacheNodesOfferingInput{ + ReservedCacheNodesOfferingId: aws.String("1ef01f5b-94ff-433f-a530-61a56bfc8e7a"), } - resp, err := svc.RebootCacheCluster(params) + result, err := svc.PurchaseReservedCacheNodesOffering(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 elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) + case elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault, aerr.Error()) + case elasticache.ErrCodeReservedCacheNodeQuotaExceededFault: + fmt.Println(elasticache.ErrCodeReservedCacheNodeQuotaExceededFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.RemoveTagsFromResourceInput{ - ResourceName: aws.String("String"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... +// RebootCacheCluster +// +// Reboots the specified nodes in the names cluster. +func ExampleElastiCache_RebootCacheCluster_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.RebootCacheClusterInput{ + CacheClusterId: aws.String("custom-mem1-4 "), + CacheNodeIdsToReboot: []*string{ + aws.String("0001"), + aws.String("0002"), }, } - resp, err := svc.RemoveTagsFromResource(params) + result, err := svc.RebootCacheCluster(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 elasticache.ErrCodeInvalidCacheClusterStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) + case elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, 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 ExampleElastiCache_ResetCacheParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.ResetCacheParameterGroupInput{ - CacheParameterGroupName: aws.String("String"), // Required - ParameterNameValues: []*elasticache.ParameterNameValue{ - { // Required - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - }, - // More values... +// RemoveTagsFromResource +// +// Removes tags identified by a list of tag keys from the list of tags on the specified +// resource. +func ExampleElastiCache_RemoveTagsFromResource_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.RemoveTagsFromResourceInput{ + ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"), + TagKeys: []*string{ + aws.String("A"), + aws.String("C"), + aws.String("E"), }, - ResetAllParameters: aws.Bool(true), } - resp, err := svc.ResetCacheParameterGroup(params) + result, err := svc.RemoveTagsFromResource(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 elasticache.ErrCodeCacheClusterNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) + case elasticache.ErrCodeSnapshotNotFoundFault: + fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidARNFault: + fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error()) + case elasticache.ErrCodeTagNotFoundFault: + fmt.Println(elasticache.ErrCodeTagNotFoundFault, 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 ExampleElastiCache_RevokeCacheSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.RevokeCacheSecurityGroupIngressInput{ - CacheSecurityGroupName: aws.String("String"), // Required - EC2SecurityGroupName: aws.String("String"), // Required - EC2SecurityGroupOwnerId: aws.String("String"), // Required +// ResetCacheParameterGroup +// +// Modifies the parameters of a cache parameter group to the engine or system default +// value. +func ExampleElastiCache_ResetCacheParameterGroup_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.ResetCacheParameterGroupInput{ + CacheParameterGroupName: aws.String("custom-mem1-4"), + ResetAllParameters: aws.Bool(true), } - resp, err := svc.RevokeCacheSecurityGroupIngress(params) + result, err := svc.ResetCacheParameterGroup(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 elasticache.ErrCodeInvalidCacheParameterGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) + case elasticache.ErrCodeCacheParameterGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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 ExampleElastiCache_TestFailover() { - sess := session.Must(session.NewSession()) - - svc := elasticache.New(sess) - - params := &elasticache.TestFailoverInput{ - NodeGroupId: aws.String("String"), // Required - ReplicationGroupId: aws.String("String"), // Required +// DescribeCacheSecurityGroups +// +// Returns a list of cache security group descriptions. If a cache security group name +// is specified, the list contains only the description of that group. +func ExampleElastiCache_RevokeCacheSecurityGroupIngress_shared00() { + svc := elasticache.New(session.New()) + input := &elasticache.RevokeCacheSecurityGroupIngressInput{ + CacheSecurityGroupName: aws.String("my-sec-grp"), + EC2SecurityGroupName: aws.String("my-ec2-sec-grp"), + EC2SecurityGroupOwnerId: aws.String("1234567890"), } - resp, err := svc.TestFailover(params) + result, err := svc.RevokeCacheSecurityGroupIngress(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 elasticache.ErrCodeCacheSecurityGroupNotFoundFault: + fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) + case elasticache.ErrCodeAuthorizationNotFoundFault: + fmt.Println(elasticache.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: + fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) + case elasticache.ErrCodeInvalidParameterValueException: + fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) + case elasticache.ErrCodeInvalidParameterCombinationException: + fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, 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) } diff --git a/service/elasticbeanstalk/examples_test.go b/service/elasticbeanstalk/examples_test.go deleted file mode 100644 index 5130b138fcf..00000000000 --- a/service/elasticbeanstalk/examples_test.go +++ /dev/null @@ -1,1156 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package elasticbeanstalk_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/elasticbeanstalk" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleElasticBeanstalk_AbortEnvironmentUpdate() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.AbortEnvironmentUpdateInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.AbortEnvironmentUpdate(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_ApplyEnvironmentManagedAction() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.ApplyEnvironmentManagedActionInput{ - ActionId: aws.String("String"), // Required - EnvironmentId: aws.String("String"), - EnvironmentName: aws.String("String"), - } - resp, err := svc.ApplyEnvironmentManagedAction(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CheckDNSAvailability() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CheckDNSAvailabilityInput{ - CNAMEPrefix: aws.String("DNSCnamePrefix"), // Required - } - resp, err := svc.CheckDNSAvailability(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_ComposeEnvironments() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.ComposeEnvironmentsInput{ - ApplicationName: aws.String("ApplicationName"), - GroupName: aws.String("GroupName"), - VersionLabels: []*string{ - aws.String("VersionLabel"), // Required - // More values... - }, - } - resp, err := svc.ComposeEnvironments(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreateApplication() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CreateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Description: aws.String("Description"), - ResourceLifecycleConfig: &elasticbeanstalk.ApplicationResourceLifecycleConfig{ - ServiceRole: aws.String("String"), - VersionLifecycleConfig: &elasticbeanstalk.ApplicationVersionLifecycleConfig{ - MaxAgeRule: &elasticbeanstalk.MaxAgeRule{ - Enabled: aws.Bool(true), // Required - DeleteSourceFromS3: aws.Bool(true), - MaxAgeInDays: aws.Int64(1), - }, - MaxCountRule: &elasticbeanstalk.MaxCountRule{ - Enabled: aws.Bool(true), // Required - DeleteSourceFromS3: aws.Bool(true), - MaxCount: aws.Int64(1), - }, - }, - }, - } - resp, err := svc.CreateApplication(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreateApplicationVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CreateApplicationVersionInput{ - ApplicationName: aws.String("ApplicationName"), // Required - VersionLabel: aws.String("VersionLabel"), // Required - AutoCreateApplication: aws.Bool(true), - BuildConfiguration: &elasticbeanstalk.BuildConfiguration{ - CodeBuildServiceRole: aws.String("NonEmptyString"), // Required - Image: aws.String("NonEmptyString"), // Required - ArtifactName: aws.String("String"), - ComputeType: aws.String("ComputeType"), - TimeoutInMinutes: aws.Int64(1), - }, - Description: aws.String("Description"), - Process: aws.Bool(true), - SourceBuildInformation: &elasticbeanstalk.SourceBuildInformation{ - SourceLocation: aws.String("SourceLocation"), // Required - SourceRepository: aws.String("SourceRepository"), // Required - SourceType: aws.String("SourceType"), // Required - }, - SourceBundle: &elasticbeanstalk.S3Location{ - S3Bucket: aws.String("S3Bucket"), - S3Key: aws.String("S3Key"), - }, - } - resp, err := svc.CreateApplicationVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreateConfigurationTemplate() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CreateConfigurationTemplateInput{ - ApplicationName: aws.String("ApplicationName"), // Required - TemplateName: aws.String("ConfigurationTemplateName"), // Required - Description: aws.String("Description"), - EnvironmentId: aws.String("EnvironmentId"), - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - PlatformArn: aws.String("PlatformArn"), - SolutionStackName: aws.String("SolutionStackName"), - SourceConfiguration: &elasticbeanstalk.SourceConfiguration{ - ApplicationName: aws.String("ApplicationName"), - TemplateName: aws.String("ConfigurationTemplateName"), - }, - } - resp, err := svc.CreateConfigurationTemplate(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreateEnvironment() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CreateEnvironmentInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CNAMEPrefix: aws.String("DNSCnamePrefix"), - Description: aws.String("Description"), - EnvironmentName: aws.String("EnvironmentName"), - GroupName: aws.String("GroupName"), - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - OptionsToRemove: []*elasticbeanstalk.OptionSpecification{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - }, - // More values... - }, - PlatformArn: aws.String("PlatformArn"), - SolutionStackName: aws.String("SolutionStackName"), - Tags: []*elasticbeanstalk.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - TemplateName: aws.String("ConfigurationTemplateName"), - Tier: &elasticbeanstalk.EnvironmentTier{ - Name: aws.String("String"), - Type: aws.String("String"), - Version: aws.String("String"), - }, - VersionLabel: aws.String("VersionLabel"), - } - resp, err := svc.CreateEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreatePlatformVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.CreatePlatformVersionInput{ - PlatformDefinitionBundle: &elasticbeanstalk.S3Location{ // Required - S3Bucket: aws.String("S3Bucket"), - S3Key: aws.String("S3Key"), - }, - PlatformName: aws.String("PlatformName"), // Required - PlatformVersion: aws.String("PlatformVersion"), // Required - EnvironmentName: aws.String("EnvironmentName"), - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - } - resp, err := svc.CreatePlatformVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_CreateStorageLocation() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - var params *elasticbeanstalk.CreateStorageLocationInput - resp, err := svc.CreateStorageLocation(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DeleteApplication() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DeleteApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - TerminateEnvByForce: aws.Bool(true), - } - resp, err := svc.DeleteApplication(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DeleteApplicationVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DeleteApplicationVersionInput{ - ApplicationName: aws.String("ApplicationName"), // Required - VersionLabel: aws.String("VersionLabel"), // Required - DeleteSourceBundle: aws.Bool(true), - } - resp, err := svc.DeleteApplicationVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DeleteConfigurationTemplate() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DeleteConfigurationTemplateInput{ - ApplicationName: aws.String("ApplicationName"), // Required - TemplateName: aws.String("ConfigurationTemplateName"), // Required - } - resp, err := svc.DeleteConfigurationTemplate(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DeleteEnvironmentConfiguration() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DeleteEnvironmentConfigurationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - EnvironmentName: aws.String("EnvironmentName"), // Required - } - resp, err := svc.DeleteEnvironmentConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DeletePlatformVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DeletePlatformVersionInput{ - PlatformArn: aws.String("PlatformArn"), - } - resp, err := svc.DeletePlatformVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeApplicationVersions() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeApplicationVersionsInput{ - ApplicationName: aws.String("ApplicationName"), - MaxRecords: aws.Int64(1), - NextToken: aws.String("Token"), - VersionLabels: []*string{ - aws.String("VersionLabel"), // Required - // More values... - }, - } - resp, err := svc.DescribeApplicationVersions(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeApplications() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeApplicationsInput{ - ApplicationNames: []*string{ - aws.String("ApplicationName"), // Required - // More values... - }, - } - resp, err := svc.DescribeApplications(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeConfigurationOptions() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeConfigurationOptionsInput{ - ApplicationName: aws.String("ApplicationName"), - EnvironmentName: aws.String("EnvironmentName"), - Options: []*elasticbeanstalk.OptionSpecification{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - }, - // More values... - }, - PlatformArn: aws.String("PlatformArn"), - SolutionStackName: aws.String("SolutionStackName"), - TemplateName: aws.String("ConfigurationTemplateName"), - } - resp, err := svc.DescribeConfigurationOptions(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeConfigurationSettings() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeConfigurationSettingsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - EnvironmentName: aws.String("EnvironmentName"), - TemplateName: aws.String("ConfigurationTemplateName"), - } - resp, err := svc.DescribeConfigurationSettings(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEnvironmentHealth() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEnvironmentHealthInput{ - AttributeNames: []*string{ - aws.String("EnvironmentHealthAttribute"), // Required - // More values... - }, - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.DescribeEnvironmentHealth(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEnvironmentManagedActionHistory() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEnvironmentManagedActionHistoryInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - MaxItems: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeEnvironmentManagedActionHistory(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEnvironmentManagedActions() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEnvironmentManagedActionsInput{ - EnvironmentId: aws.String("String"), - EnvironmentName: aws.String("String"), - Status: aws.String("ActionStatus"), - } - resp, err := svc.DescribeEnvironmentManagedActions(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEnvironmentResources() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEnvironmentResourcesInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.DescribeEnvironmentResources(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEnvironments() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEnvironmentsInput{ - ApplicationName: aws.String("ApplicationName"), - EnvironmentIds: []*string{ - aws.String("EnvironmentId"), // Required - // More values... - }, - EnvironmentNames: []*string{ - aws.String("EnvironmentName"), // Required - // More values... - }, - IncludeDeleted: aws.Bool(true), - IncludedDeletedBackTo: aws.Time(time.Now()), - VersionLabel: aws.String("VersionLabel"), - } - resp, err := svc.DescribeEnvironments(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeEventsInput{ - ApplicationName: aws.String("ApplicationName"), - EndTime: aws.Time(time.Now()), - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - MaxRecords: aws.Int64(1), - NextToken: aws.String("Token"), - PlatformArn: aws.String("PlatformArn"), - RequestId: aws.String("RequestId"), - Severity: aws.String("EventSeverity"), - StartTime: aws.Time(time.Now()), - TemplateName: aws.String("ConfigurationTemplateName"), - VersionLabel: aws.String("VersionLabel"), - } - resp, err := svc.DescribeEvents(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribeInstancesHealth() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribeInstancesHealthInput{ - AttributeNames: []*string{ - aws.String("InstancesHealthAttribute"), // Required - // More values... - }, - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstancesHealth(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_DescribePlatformVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.DescribePlatformVersionInput{ - PlatformArn: aws.String("PlatformArn"), - } - resp, err := svc.DescribePlatformVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_ListAvailableSolutionStacks() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - var params *elasticbeanstalk.ListAvailableSolutionStacksInput - resp, err := svc.ListAvailableSolutionStacks(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_ListPlatformVersions() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.ListPlatformVersionsInput{ - Filters: []*elasticbeanstalk.PlatformFilter{ - { // Required - Operator: aws.String("PlatformFilterOperator"), - Type: aws.String("PlatformFilterType"), - Values: []*string{ - aws.String("PlatformFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxRecords: aws.Int64(1), - NextToken: aws.String("Token"), - } - resp, err := svc.ListPlatformVersions(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_RebuildEnvironment() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.RebuildEnvironmentInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.RebuildEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_RequestEnvironmentInfo() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.RequestEnvironmentInfoInput{ - InfoType: aws.String("EnvironmentInfoType"), // Required - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.RequestEnvironmentInfo(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_RestartAppServer() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.RestartAppServerInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.RestartAppServer(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_RetrieveEnvironmentInfo() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.RetrieveEnvironmentInfoInput{ - InfoType: aws.String("EnvironmentInfoType"), // Required - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.RetrieveEnvironmentInfo(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_SwapEnvironmentCNAMEs() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.SwapEnvironmentCNAMEsInput{ - DestinationEnvironmentId: aws.String("EnvironmentId"), - DestinationEnvironmentName: aws.String("EnvironmentName"), - SourceEnvironmentId: aws.String("EnvironmentId"), - SourceEnvironmentName: aws.String("EnvironmentName"), - } - resp, err := svc.SwapEnvironmentCNAMEs(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_TerminateEnvironment() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.TerminateEnvironmentInput{ - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - ForceTerminate: aws.Bool(true), - TerminateResources: aws.Bool(true), - } - resp, err := svc.TerminateEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_UpdateApplication() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.UpdateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - Description: aws.String("Description"), - } - resp, err := svc.UpdateApplication(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_UpdateApplicationResourceLifecycle() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.UpdateApplicationResourceLifecycleInput{ - ApplicationName: aws.String("ApplicationName"), // Required - ResourceLifecycleConfig: &elasticbeanstalk.ApplicationResourceLifecycleConfig{ // Required - ServiceRole: aws.String("String"), - VersionLifecycleConfig: &elasticbeanstalk.ApplicationVersionLifecycleConfig{ - MaxAgeRule: &elasticbeanstalk.MaxAgeRule{ - Enabled: aws.Bool(true), // Required - DeleteSourceFromS3: aws.Bool(true), - MaxAgeInDays: aws.Int64(1), - }, - MaxCountRule: &elasticbeanstalk.MaxCountRule{ - Enabled: aws.Bool(true), // Required - DeleteSourceFromS3: aws.Bool(true), - MaxCount: aws.Int64(1), - }, - }, - }, - } - resp, err := svc.UpdateApplicationResourceLifecycle(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_UpdateApplicationVersion() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.UpdateApplicationVersionInput{ - ApplicationName: aws.String("ApplicationName"), // Required - VersionLabel: aws.String("VersionLabel"), // Required - Description: aws.String("Description"), - } - resp, err := svc.UpdateApplicationVersion(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_UpdateConfigurationTemplate() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.UpdateConfigurationTemplateInput{ - ApplicationName: aws.String("ApplicationName"), // Required - TemplateName: aws.String("ConfigurationTemplateName"), // Required - Description: aws.String("Description"), - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - OptionsToRemove: []*elasticbeanstalk.OptionSpecification{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - }, - // More values... - }, - } - resp, err := svc.UpdateConfigurationTemplate(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_UpdateEnvironment() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.UpdateEnvironmentInput{ - ApplicationName: aws.String("ApplicationName"), - Description: aws.String("Description"), - EnvironmentId: aws.String("EnvironmentId"), - EnvironmentName: aws.String("EnvironmentName"), - GroupName: aws.String("GroupName"), - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - OptionsToRemove: []*elasticbeanstalk.OptionSpecification{ - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - }, - // More values... - }, - PlatformArn: aws.String("PlatformArn"), - SolutionStackName: aws.String("SolutionStackName"), - TemplateName: aws.String("ConfigurationTemplateName"), - Tier: &elasticbeanstalk.EnvironmentTier{ - Name: aws.String("String"), - Type: aws.String("String"), - Version: aws.String("String"), - }, - VersionLabel: aws.String("VersionLabel"), - } - resp, err := svc.UpdateEnvironment(params) - - if err != nil { - // 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) -} - -func ExampleElasticBeanstalk_ValidateConfigurationSettings() { - sess := session.Must(session.NewSession()) - - svc := elasticbeanstalk.New(sess) - - params := &elasticbeanstalk.ValidateConfigurationSettingsInput{ - ApplicationName: aws.String("ApplicationName"), // Required - OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ // Required - { // Required - Namespace: aws.String("OptionNamespace"), - OptionName: aws.String("ConfigurationOptionName"), - ResourceName: aws.String("ResourceName"), - Value: aws.String("ConfigurationOptionValue"), - }, - // More values... - }, - EnvironmentName: aws.String("EnvironmentName"), - TemplateName: aws.String("ConfigurationTemplateName"), - } - resp, err := svc.ValidateConfigurationSettings(params) - - if err != nil { - // 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) -} diff --git a/service/elasticsearchservice/examples_test.go b/service/elasticsearchservice/examples_test.go deleted file mode 100644 index ae0aa1c4f3d..00000000000 --- a/service/elasticsearchservice/examples_test.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package elasticsearchservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/elasticsearchservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleElasticsearchService_AddTags() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.AddTagsInput{ - ARN: aws.String("ARN"), // Required - TagList: []*elasticsearchservice.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTags(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_CreateElasticsearchDomain() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.CreateElasticsearchDomainInput{ - DomainName: aws.String("DomainName"), // Required - AccessPolicies: aws.String("PolicyDocument"), - AdvancedOptions: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - EBSOptions: &elasticsearchservice.EBSOptions{ - EBSEnabled: aws.Bool(true), - Iops: aws.Int64(1), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - ElasticsearchClusterConfig: &elasticsearchservice.ElasticsearchClusterConfig{ - DedicatedMasterCount: aws.Int64(1), - DedicatedMasterEnabled: aws.Bool(true), - DedicatedMasterType: aws.String("ESPartitionInstanceType"), - InstanceCount: aws.Int64(1), - InstanceType: aws.String("ESPartitionInstanceType"), - ZoneAwarenessEnabled: aws.Bool(true), - }, - ElasticsearchVersion: aws.String("ElasticsearchVersionString"), - SnapshotOptions: &elasticsearchservice.SnapshotOptions{ - AutomatedSnapshotStartHour: aws.Int64(1), - }, - } - resp, err := svc.CreateElasticsearchDomain(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_DeleteElasticsearchDomain() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.DeleteElasticsearchDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DeleteElasticsearchDomain(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_DescribeElasticsearchDomain() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.DescribeElasticsearchDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DescribeElasticsearchDomain(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_DescribeElasticsearchDomainConfig() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.DescribeElasticsearchDomainConfigInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DescribeElasticsearchDomainConfig(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_DescribeElasticsearchDomains() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.DescribeElasticsearchDomainsInput{ - DomainNames: []*string{ // Required - aws.String("DomainName"), // Required - // More values... - }, - } - resp, err := svc.DescribeElasticsearchDomains(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_DescribeElasticsearchInstanceTypeLimits() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.DescribeElasticsearchInstanceTypeLimitsInput{ - ElasticsearchVersion: aws.String("ElasticsearchVersionString"), // Required - InstanceType: aws.String("ESPartitionInstanceType"), // Required - DomainName: aws.String("DomainName"), - } - resp, err := svc.DescribeElasticsearchInstanceTypeLimits(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_ListDomainNames() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - var params *elasticsearchservice.ListDomainNamesInput - resp, err := svc.ListDomainNames(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_ListElasticsearchInstanceTypes() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.ListElasticsearchInstanceTypesInput{ - ElasticsearchVersion: aws.String("ElasticsearchVersionString"), // Required - DomainName: aws.String("DomainName"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListElasticsearchInstanceTypes(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_ListElasticsearchVersions() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.ListElasticsearchVersionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListElasticsearchVersions(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_ListTags() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.ListTagsInput{ - ARN: aws.String("ARN"), // Required - } - resp, err := svc.ListTags(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_RemoveTags() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.RemoveTagsInput{ - ARN: aws.String("ARN"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RemoveTags(params) - - if err != nil { - // 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) -} - -func ExampleElasticsearchService_UpdateElasticsearchDomainConfig() { - sess := session.Must(session.NewSession()) - - svc := elasticsearchservice.New(sess) - - params := &elasticsearchservice.UpdateElasticsearchDomainConfigInput{ - DomainName: aws.String("DomainName"), // Required - AccessPolicies: aws.String("PolicyDocument"), - AdvancedOptions: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - EBSOptions: &elasticsearchservice.EBSOptions{ - EBSEnabled: aws.Bool(true), - Iops: aws.Int64(1), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - ElasticsearchClusterConfig: &elasticsearchservice.ElasticsearchClusterConfig{ - DedicatedMasterCount: aws.Int64(1), - DedicatedMasterEnabled: aws.Bool(true), - DedicatedMasterType: aws.String("ESPartitionInstanceType"), - InstanceCount: aws.Int64(1), - InstanceType: aws.String("ESPartitionInstanceType"), - ZoneAwarenessEnabled: aws.Bool(true), - }, - SnapshotOptions: &elasticsearchservice.SnapshotOptions{ - AutomatedSnapshotStartHour: aws.Int64(1), - }, - } - resp, err := svc.UpdateElasticsearchDomainConfig(params) - - if err != nil { - // 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) -} diff --git a/service/elastictranscoder/examples_test.go b/service/elastictranscoder/examples_test.go deleted file mode 100644 index 309b9dfd7e2..00000000000 --- a/service/elastictranscoder/examples_test.go +++ /dev/null @@ -1,839 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package elastictranscoder_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/elastictranscoder" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleElasticTranscoder_CancelJob() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.CancelJobInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.CancelJob(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_CreateJob() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.CreateJobInput{ - PipelineId: aws.String("Id"), // Required - Input: &elastictranscoder.JobInput{ - AspectRatio: aws.String("AspectRatio"), - Container: aws.String("JobContainer"), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(1), - FileSize: aws.Int64(1), - FrameRate: aws.String("FloatString"), - Height: aws.Int64(1), - Width: aws.Int64(1), - }, - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - FrameRate: aws.String("FrameRate"), - InputCaptions: &elastictranscoder.InputCaptions{ - CaptionSources: []*elastictranscoder.CaptionSource{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("LongKey"), - Label: aws.String("Name"), - Language: aws.String("Key"), - TimeOffset: aws.String("TimeOffset"), - }, - // More values... - }, - MergePolicy: aws.String("CaptionMergePolicy"), - }, - Interlaced: aws.String("Interlaced"), - Key: aws.String("LongKey"), - Resolution: aws.String("Resolution"), - TimeSpan: &elastictranscoder.TimeSpan{ - Duration: aws.String("Time"), - StartTime: aws.String("Time"), - }, - }, - Inputs: []*elastictranscoder.JobInput{ - { // Required - AspectRatio: aws.String("AspectRatio"), - Container: aws.String("JobContainer"), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(1), - FileSize: aws.Int64(1), - FrameRate: aws.String("FloatString"), - Height: aws.Int64(1), - Width: aws.Int64(1), - }, - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - FrameRate: aws.String("FrameRate"), - InputCaptions: &elastictranscoder.InputCaptions{ - CaptionSources: []*elastictranscoder.CaptionSource{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("LongKey"), - Label: aws.String("Name"), - Language: aws.String("Key"), - TimeOffset: aws.String("TimeOffset"), - }, - // More values... - }, - MergePolicy: aws.String("CaptionMergePolicy"), - }, - Interlaced: aws.String("Interlaced"), - Key: aws.String("LongKey"), - Resolution: aws.String("Resolution"), - TimeSpan: &elastictranscoder.TimeSpan{ - Duration: aws.String("Time"), - StartTime: aws.String("Time"), - }, - }, - // More values... - }, - Output: &elastictranscoder.CreateJobOutput{ - AlbumArt: &elastictranscoder.JobAlbumArt{ - Artwork: []*elastictranscoder.Artwork{ - { // Required - AlbumArtFormat: aws.String("JpgOrPng"), - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - InputKey: aws.String("WatermarkKey"), - MaxHeight: aws.String("DigitsOrAuto"), - MaxWidth: aws.String("DigitsOrAuto"), - PaddingPolicy: aws.String("PaddingPolicy"), - SizingPolicy: aws.String("SizingPolicy"), - }, - // More values... - }, - MergePolicy: aws.String("MergePolicy"), - }, - Captions: &elastictranscoder.Captions{ - CaptionFormats: []*elastictranscoder.CaptionFormat{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Format: aws.String("CaptionFormatFormat"), - Pattern: aws.String("CaptionFormatPattern"), - }, - // More values... - }, - CaptionSources: []*elastictranscoder.CaptionSource{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("LongKey"), - Label: aws.String("Name"), - Language: aws.String("Key"), - TimeOffset: aws.String("TimeOffset"), - }, - // More values... - }, - MergePolicy: aws.String("CaptionMergePolicy"), - }, - Composition: []*elastictranscoder.Clip{ - { // Required - TimeSpan: &elastictranscoder.TimeSpan{ - Duration: aws.String("Time"), - StartTime: aws.String("Time"), - }, - }, - // More values... - }, - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("Key"), - PresetId: aws.String("Id"), - Rotate: aws.String("Rotate"), - SegmentDuration: aws.String("FloatString"), - ThumbnailEncryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - ThumbnailPattern: aws.String("ThumbnailPattern"), - Watermarks: []*elastictranscoder.JobWatermark{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - InputKey: aws.String("WatermarkKey"), - PresetWatermarkId: aws.String("PresetWatermarkId"), - }, - // More values... - }, - }, - OutputKeyPrefix: aws.String("Key"), - Outputs: []*elastictranscoder.CreateJobOutput{ - { // Required - AlbumArt: &elastictranscoder.JobAlbumArt{ - Artwork: []*elastictranscoder.Artwork{ - { // Required - AlbumArtFormat: aws.String("JpgOrPng"), - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - InputKey: aws.String("WatermarkKey"), - MaxHeight: aws.String("DigitsOrAuto"), - MaxWidth: aws.String("DigitsOrAuto"), - PaddingPolicy: aws.String("PaddingPolicy"), - SizingPolicy: aws.String("SizingPolicy"), - }, - // More values... - }, - MergePolicy: aws.String("MergePolicy"), - }, - Captions: &elastictranscoder.Captions{ - CaptionFormats: []*elastictranscoder.CaptionFormat{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Format: aws.String("CaptionFormatFormat"), - Pattern: aws.String("CaptionFormatPattern"), - }, - // More values... - }, - CaptionSources: []*elastictranscoder.CaptionSource{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("LongKey"), - Label: aws.String("Name"), - Language: aws.String("Key"), - TimeOffset: aws.String("TimeOffset"), - }, - // More values... - }, - MergePolicy: aws.String("CaptionMergePolicy"), - }, - Composition: []*elastictranscoder.Clip{ - { // Required - TimeSpan: &elastictranscoder.TimeSpan{ - Duration: aws.String("Time"), - StartTime: aws.String("Time"), - }, - }, - // More values... - }, - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - Key: aws.String("Key"), - PresetId: aws.String("Id"), - Rotate: aws.String("Rotate"), - SegmentDuration: aws.String("FloatString"), - ThumbnailEncryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - ThumbnailPattern: aws.String("ThumbnailPattern"), - Watermarks: []*elastictranscoder.JobWatermark{ - { // Required - Encryption: &elastictranscoder.Encryption{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - Mode: aws.String("EncryptionMode"), - }, - InputKey: aws.String("WatermarkKey"), - PresetWatermarkId: aws.String("PresetWatermarkId"), - }, - // More values... - }, - }, - // More values... - }, - Playlists: []*elastictranscoder.CreateJobPlaylist{ - { // Required - Format: aws.String("PlaylistFormat"), - HlsContentProtection: &elastictranscoder.HlsContentProtection{ - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("Base64EncodedString"), - KeyMd5: aws.String("Base64EncodedString"), - KeyStoragePolicy: aws.String("KeyStoragePolicy"), - LicenseAcquisitionUrl: aws.String("ZeroTo512String"), - Method: aws.String("HlsContentProtectionMethod"), - }, - Name: aws.String("Filename"), - OutputKeys: []*string{ - aws.String("Key"), // Required - // More values... - }, - PlayReadyDrm: &elastictranscoder.PlayReadyDrm{ - Format: aws.String("PlayReadyDrmFormatString"), - InitializationVector: aws.String("ZeroTo255String"), - Key: aws.String("NonEmptyBase64EncodedString"), - KeyId: aws.String("KeyIdGuid"), - KeyMd5: aws.String("NonEmptyBase64EncodedString"), - LicenseAcquisitionUrl: aws.String("OneTo512String"), - }, - }, - // More values... - }, - UserMetadata: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateJob(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_CreatePipeline() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.CreatePipelineInput{ - InputBucket: aws.String("BucketName"), // Required - Name: aws.String("Name"), // Required - Role: aws.String("Role"), // Required - AwsKmsKeyArn: aws.String("KeyArn"), - ContentConfig: &elastictranscoder.PipelineOutputConfig{ - Bucket: aws.String("BucketName"), - Permissions: []*elastictranscoder.Permission{ - { // Required - Access: []*string{ - aws.String("AccessControl"), // Required - // More values... - }, - Grantee: aws.String("Grantee"), - GranteeType: aws.String("GranteeType"), - }, - // More values... - }, - StorageClass: aws.String("StorageClass"), - }, - Notifications: &elastictranscoder.Notifications{ - Completed: aws.String("SnsTopic"), - Error: aws.String("SnsTopic"), - Progressing: aws.String("SnsTopic"), - Warning: aws.String("SnsTopic"), - }, - OutputBucket: aws.String("BucketName"), - ThumbnailConfig: &elastictranscoder.PipelineOutputConfig{ - Bucket: aws.String("BucketName"), - Permissions: []*elastictranscoder.Permission{ - { // Required - Access: []*string{ - aws.String("AccessControl"), // Required - // More values... - }, - Grantee: aws.String("Grantee"), - GranteeType: aws.String("GranteeType"), - }, - // More values... - }, - StorageClass: aws.String("StorageClass"), - }, - } - resp, err := svc.CreatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_CreatePreset() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.CreatePresetInput{ - Container: aws.String("PresetContainer"), // Required - Name: aws.String("Name"), // Required - Audio: &elastictranscoder.AudioParameters{ - AudioPackingMode: aws.String("AudioPackingMode"), - BitRate: aws.String("AudioBitRate"), - Channels: aws.String("AudioChannels"), - Codec: aws.String("AudioCodec"), - CodecOptions: &elastictranscoder.AudioCodecOptions{ - BitDepth: aws.String("AudioBitDepth"), - BitOrder: aws.String("AudioBitOrder"), - Profile: aws.String("AudioCodecProfile"), - Signed: aws.String("AudioSigned"), - }, - SampleRate: aws.String("AudioSampleRate"), - }, - Description: aws.String("Description"), - Thumbnails: &elastictranscoder.Thumbnails{ - AspectRatio: aws.String("AspectRatio"), - Format: aws.String("JpgOrPng"), - Interval: aws.String("Digits"), - MaxHeight: aws.String("DigitsOrAuto"), - MaxWidth: aws.String("DigitsOrAuto"), - PaddingPolicy: aws.String("PaddingPolicy"), - Resolution: aws.String("ThumbnailResolution"), - SizingPolicy: aws.String("SizingPolicy"), - }, - Video: &elastictranscoder.VideoParameters{ - AspectRatio: aws.String("AspectRatio"), - BitRate: aws.String("VideoBitRate"), - Codec: aws.String("VideoCodec"), - CodecOptions: map[string]*string{ - "Key": aws.String("CodecOption"), // Required - // More values... - }, - DisplayAspectRatio: aws.String("AspectRatio"), - FixedGOP: aws.String("FixedGOP"), - FrameRate: aws.String("FrameRate"), - KeyframesMaxDist: aws.String("KeyframesMaxDist"), - MaxFrameRate: aws.String("MaxFrameRate"), - MaxHeight: aws.String("DigitsOrAuto"), - MaxWidth: aws.String("DigitsOrAuto"), - PaddingPolicy: aws.String("PaddingPolicy"), - Resolution: aws.String("Resolution"), - SizingPolicy: aws.String("SizingPolicy"), - Watermarks: []*elastictranscoder.PresetWatermark{ - { // Required - HorizontalAlign: aws.String("HorizontalAlign"), - HorizontalOffset: aws.String("PixelsOrPercent"), - Id: aws.String("PresetWatermarkId"), - MaxHeight: aws.String("PixelsOrPercent"), - MaxWidth: aws.String("PixelsOrPercent"), - Opacity: aws.String("Opacity"), - SizingPolicy: aws.String("WatermarkSizingPolicy"), - Target: aws.String("Target"), - VerticalAlign: aws.String("VerticalAlign"), - VerticalOffset: aws.String("PixelsOrPercent"), - }, - // More values... - }, - }, - } - resp, err := svc.CreatePreset(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_DeletePipeline() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.DeletePipelineInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.DeletePipeline(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_DeletePreset() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.DeletePresetInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.DeletePreset(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ListJobsByPipeline() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ListJobsByPipelineInput{ - PipelineId: aws.String("Id"), // Required - Ascending: aws.String("Ascending"), - PageToken: aws.String("Id"), - } - resp, err := svc.ListJobsByPipeline(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ListJobsByStatus() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ListJobsByStatusInput{ - Status: aws.String("JobStatus"), // Required - Ascending: aws.String("Ascending"), - PageToken: aws.String("Id"), - } - resp, err := svc.ListJobsByStatus(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ListPipelines() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ListPipelinesInput{ - Ascending: aws.String("Ascending"), - PageToken: aws.String("Id"), - } - resp, err := svc.ListPipelines(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ListPresets() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ListPresetsInput{ - Ascending: aws.String("Ascending"), - PageToken: aws.String("Id"), - } - resp, err := svc.ListPresets(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ReadJob() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ReadJobInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.ReadJob(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ReadPipeline() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ReadPipelineInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.ReadPipeline(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_ReadPreset() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.ReadPresetInput{ - Id: aws.String("Id"), // Required - } - resp, err := svc.ReadPreset(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_TestRole() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.TestRoleInput{ - InputBucket: aws.String("BucketName"), // Required - OutputBucket: aws.String("BucketName"), // Required - Role: aws.String("Role"), // Required - Topics: []*string{ // Required - aws.String("SnsTopic"), // Required - // More values... - }, - } - resp, err := svc.TestRole(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_UpdatePipeline() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.UpdatePipelineInput{ - Id: aws.String("Id"), // Required - AwsKmsKeyArn: aws.String("KeyArn"), - ContentConfig: &elastictranscoder.PipelineOutputConfig{ - Bucket: aws.String("BucketName"), - Permissions: []*elastictranscoder.Permission{ - { // Required - Access: []*string{ - aws.String("AccessControl"), // Required - // More values... - }, - Grantee: aws.String("Grantee"), - GranteeType: aws.String("GranteeType"), - }, - // More values... - }, - StorageClass: aws.String("StorageClass"), - }, - InputBucket: aws.String("BucketName"), - Name: aws.String("Name"), - Notifications: &elastictranscoder.Notifications{ - Completed: aws.String("SnsTopic"), - Error: aws.String("SnsTopic"), - Progressing: aws.String("SnsTopic"), - Warning: aws.String("SnsTopic"), - }, - Role: aws.String("Role"), - ThumbnailConfig: &elastictranscoder.PipelineOutputConfig{ - Bucket: aws.String("BucketName"), - Permissions: []*elastictranscoder.Permission{ - { // Required - Access: []*string{ - aws.String("AccessControl"), // Required - // More values... - }, - Grantee: aws.String("Grantee"), - GranteeType: aws.String("GranteeType"), - }, - // More values... - }, - StorageClass: aws.String("StorageClass"), - }, - } - resp, err := svc.UpdatePipeline(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_UpdatePipelineNotifications() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.UpdatePipelineNotificationsInput{ - Id: aws.String("Id"), // Required - Notifications: &elastictranscoder.Notifications{ // Required - Completed: aws.String("SnsTopic"), - Error: aws.String("SnsTopic"), - Progressing: aws.String("SnsTopic"), - Warning: aws.String("SnsTopic"), - }, - } - resp, err := svc.UpdatePipelineNotifications(params) - - if err != nil { - // 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) -} - -func ExampleElasticTranscoder_UpdatePipelineStatus() { - sess := session.Must(session.NewSession()) - - svc := elastictranscoder.New(sess) - - params := &elastictranscoder.UpdatePipelineStatusInput{ - Id: aws.String("Id"), // Required - Status: aws.String("PipelineStatus"), // Required - } - resp, err := svc.UpdatePipelineStatus(params) - - if err != nil { - // 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) -} diff --git a/service/elb/examples_test.go b/service/elb/examples_test.go index 7a08f8052c5..d71b24c5743 100644 --- a/service/elb/examples_test.go +++ b/service/elb/examples_test.go @@ -8,793 +8,1492 @@ import ( "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/elb" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleELB_AddTags() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &elb.AddTagsInput{ - LoadBalancerNames: []*string{ // Required - aws.String("AccessPointName"), // Required - // More values... +// To add tags to a load balancer +// +// This example adds two tags to the specified load balancer. +func ExampleELB_AddTags_shared00() { + svc := elb.New(session.New()) + input := &elb.AddTagsInput{ + LoadBalancerNames: []*string{ + aws.String("my-load-balancer"), }, - Tags: []*elb.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), + Tags: []*elb.TagList{ + { + Key: aws.String("project"), + Value: aws.String("lima"), + }, + { + Key: aws.String("department"), + Value: aws.String("digital-media"), }, - // More values... }, } - resp, err := svc.AddTags(params) + result, err := svc.AddTags(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, 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 ExampleELB_ApplySecurityGroupsToLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.ApplySecurityGroupsToLoadBalancerInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - SecurityGroups: []*string{ // Required - aws.String("SecurityGroupId"), // Required - // More values... +// To associate a security group with a load balancer in a VPC +// +// This example associates a security group with the specified load balancer in a VPC. +func ExampleELB_ApplySecurityGroupsToLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.ApplySecurityGroupsToLoadBalancerInput{ + LoadBalancerName: aws.String("my-load-balancer"), + SecurityGroups: []*string{ + aws.String("sg-fc448899"), }, } - resp, err := svc.ApplySecurityGroupsToLoadBalancer(params) + result, err := svc.ApplySecurityGroupsToLoadBalancer(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, 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 ExampleELB_AttachLoadBalancerToSubnets() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.AttachLoadBalancerToSubnetsInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - Subnets: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... +// To attach subnets to a load balancer +// +// This example adds the specified subnet to the set of configured subnets for the specified +// load balancer. +func ExampleELB_AttachLoadBalancerToSubnets_shared00() { + svc := elb.New(session.New()) + input := &elb.AttachLoadBalancerToSubnetsInput{ + LoadBalancerName: aws.String("my-load-balancer"), + Subnets: []*string{ + aws.String("subnet-0ecac448"), }, } - resp, err := svc.AttachLoadBalancerToSubnets(params) + result, err := svc.AttachLoadBalancerToSubnets(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, 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 ExampleELB_ConfigureHealthCheck() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.ConfigureHealthCheckInput{ - HealthCheck: &elb.HealthCheck{ // Required - HealthyThreshold: aws.Int64(1), // Required - Interval: aws.Int64(1), // Required - Target: aws.String("HealthCheckTarget"), // Required - Timeout: aws.Int64(1), // Required - UnhealthyThreshold: aws.Int64(1), // Required +// To specify the health check settings for your backend EC2 instances +// +// This example specifies the health check settings used to evaluate the health of your +// backend EC2 instances. +func ExampleELB_ConfigureHealthCheck_shared00() { + svc := elb.New(session.New()) + input := &elb.ConfigureHealthCheckInput{ + HealthCheck: &elb.HealthCheck{ + HealthyThreshold: aws.Int64(2.000000), + Interval: aws.Int64(30.000000), + Target: aws.String("HTTP:80/png"), + Timeout: aws.Int64(3.000000), + UnhealthyThreshold: aws.Int64(2.000000), }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.ConfigureHealthCheck(params) + result, err := svc.ConfigureHealthCheck(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, 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 ExampleELB_CreateAppCookieStickinessPolicy() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.CreateAppCookieStickinessPolicyInput{ - CookieName: aws.String("CookieName"), // Required - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyName: aws.String("PolicyName"), // Required +// To generate a stickiness policy for your load balancer +// +// This example generates a stickiness policy that follows the sticky session lifetimes +// of the application-generated cookie. +func ExampleELB_CreateAppCookieStickinessPolicy_shared00() { + svc := elb.New(session.New()) + input := &elb.CreateAppCookieStickinessPolicyInput{ + CookieName: aws.String("my-app-cookie"), + LoadBalancerName: aws.String("my-load-balancer"), + PolicyName: aws.String("my-app-cookie-policy"), } - resp, err := svc.CreateAppCookieStickinessPolicy(params) + result, err := svc.CreateAppCookieStickinessPolicy(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicatePolicyNameException: + fmt.Println(elb.ErrCodeDuplicatePolicyNameException, aerr.Error()) + case elb.ErrCodeTooManyPoliciesException: + fmt.Println(elb.ErrCodeTooManyPoliciesException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_CreateLBCookieStickinessPolicy() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.CreateLBCookieStickinessPolicyInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyName: aws.String("PolicyName"), // Required - CookieExpirationPeriod: aws.Int64(1), +// To generate a duration-based stickiness policy for your load balancer +// +// This example generates a stickiness policy with sticky session lifetimes controlled +// by the specified expiration period. +func ExampleELB_CreateLBCookieStickinessPolicy_shared00() { + svc := elb.New(session.New()) + input := &elb.CreateLBCookieStickinessPolicyInput{ + CookieExpirationPeriod: aws.Int64(60.000000), + LoadBalancerName: aws.String("my-load-balancer"), + PolicyName: aws.String("my-duration-cookie-policy"), } - resp, err := svc.CreateLBCookieStickinessPolicy(params) + result, err := svc.CreateLBCookieStickinessPolicy(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicatePolicyNameException: + fmt.Println(elb.ErrCodeDuplicatePolicyNameException, aerr.Error()) + case elb.ErrCodeTooManyPoliciesException: + fmt.Println(elb.ErrCodeTooManyPoliciesException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_CreateLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.CreateLoadBalancerInput{ - Listeners: []*elb.Listener{ // Required - { // Required - InstancePort: aws.Int64(1), // Required - LoadBalancerPort: aws.Int64(1), // Required - Protocol: aws.String("Protocol"), // Required - InstanceProtocol: aws.String("Protocol"), - SSLCertificateId: aws.String("SSLCertificateId"), +// To create an HTTP load balancer in a VPC +// +// This example creates a load balancer with an HTTP listener in a VPC. +func ExampleELB_CreateLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerInput{ + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), }, - // More values... }, - LoadBalancerName: aws.String("AccessPointName"), // Required - AvailabilityZones: []*string{ - aws.String("AvailabilityZone"), // Required - // More values... - }, - Scheme: aws.String("LoadBalancerScheme"), + LoadBalancerName: aws.String("my-load-balancer"), SecurityGroups: []*string{ - aws.String("SecurityGroupId"), // Required - // More values... + aws.String("sg-a61988c3"), }, Subnets: []*string{ - aws.String("SubnetId"), // Required - // More values... - }, - Tags: []*elb.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... + aws.String("subnet-15aaab61"), }, } - resp, err := svc.CreateLoadBalancer(params) + result, err := svc.CreateLoadBalancer(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 elb.ErrCodeDuplicateAccessPointNameException: + fmt.Println(elb.ErrCodeDuplicateAccessPointNameException, aerr.Error()) + case elb.ErrCodeTooManyAccessPointsException: + fmt.Println(elb.ErrCodeTooManyAccessPointsException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elb.ErrCodeInvalidSchemeException: + fmt.Println(elb.ErrCodeInvalidSchemeException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_CreateLoadBalancerListeners() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.CreateLoadBalancerListenersInput{ - Listeners: []*elb.Listener{ // Required - { // Required - InstancePort: aws.Int64(1), // Required - LoadBalancerPort: aws.Int64(1), // Required - Protocol: aws.String("Protocol"), // Required - InstanceProtocol: aws.String("Protocol"), - SSLCertificateId: aws.String("SSLCertificateId"), +// To create an HTTP load balancer in EC2-Classic +// +// This example creates a load balancer with an HTTP listener in EC2-Classic. +func ExampleELB_CreateLoadBalancer_shared01() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerInput{ + AvailabilityZones: []*string{ + aws.String("us-west-2a"), + }, + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), }, - // More values... }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.CreateLoadBalancerListeners(params) + result, err := svc.CreateLoadBalancer(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 elb.ErrCodeDuplicateAccessPointNameException: + fmt.Println(elb.ErrCodeDuplicateAccessPointNameException, aerr.Error()) + case elb.ErrCodeTooManyAccessPointsException: + fmt.Println(elb.ErrCodeTooManyAccessPointsException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elb.ErrCodeInvalidSchemeException: + fmt.Println(elb.ErrCodeInvalidSchemeException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_CreateLoadBalancerPolicy() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.CreateLoadBalancerPolicyInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyName: aws.String("PolicyName"), // Required - PolicyTypeName: aws.String("PolicyTypeName"), // Required - PolicyAttributes: []*elb.PolicyAttribute{ - { // Required - AttributeName: aws.String("AttributeName"), - AttributeValue: aws.String("AttributeValue"), +// To create an HTTPS load balancer in a VPC +// +// This example creates a load balancer with an HTTPS listener in a VPC. +func ExampleELB_CreateLoadBalancer_shared02() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerInput{ + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), + }, + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(443.000000), + Protocol: aws.String("HTTPS"), + SSLCertificateId: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), }, - // More values... + }, + LoadBalancerName: aws.String("my-load-balancer"), + SecurityGroups: []*string{ + aws.String("sg-a61988c3"), + }, + Subnets: []*string{ + aws.String("subnet-15aaab61"), }, } - resp, err := svc.CreateLoadBalancerPolicy(params) + result, err := svc.CreateLoadBalancer(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 elb.ErrCodeDuplicateAccessPointNameException: + fmt.Println(elb.ErrCodeDuplicateAccessPointNameException, aerr.Error()) + case elb.ErrCodeTooManyAccessPointsException: + fmt.Println(elb.ErrCodeTooManyAccessPointsException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elb.ErrCodeInvalidSchemeException: + fmt.Println(elb.ErrCodeInvalidSchemeException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_DeleteLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DeleteLoadBalancerInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required +// To create an HTTPS load balancer in EC2-Classic +// +// This example creates a load balancer with an HTTPS listener in EC2-Classic. +func ExampleELB_CreateLoadBalancer_shared03() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerInput{ + AvailabilityZones: []*string{ + aws.String("us-west-2a"), + }, + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), + }, + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(443.000000), + Protocol: aws.String("HTTPS"), + SSLCertificateId: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), + }, + }, + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.DeleteLoadBalancer(params) + result, err := svc.CreateLoadBalancer(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 elb.ErrCodeDuplicateAccessPointNameException: + fmt.Println(elb.ErrCodeDuplicateAccessPointNameException, aerr.Error()) + case elb.ErrCodeTooManyAccessPointsException: + fmt.Println(elb.ErrCodeTooManyAccessPointsException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elb.ErrCodeInvalidSchemeException: + fmt.Println(elb.ErrCodeInvalidSchemeException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_DeleteLoadBalancerListeners() { - sess := session.Must(session.NewSession()) +// To create an internal load balancer +// +// This example creates an internal load balancer with an HTTP listener in a VPC. +func ExampleELB_CreateLoadBalancer_shared04() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerInput{ + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), + }, + }, + LoadBalancerName: aws.String("my-load-balancer"), + Scheme: aws.String("internal"), + SecurityGroups: []*string{ + aws.String("sg-a61988c3"), + }, + Subnets: []*string{ + aws.String("subnet-15aaab61"), + }, + } + + result, err := svc.CreateLoadBalancer(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeDuplicateAccessPointNameException: + fmt.Println(elb.ErrCodeDuplicateAccessPointNameException, aerr.Error()) + case elb.ErrCodeTooManyAccessPointsException: + fmt.Println(elb.ErrCodeTooManyAccessPointsException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeSubnetNotFoundException: + fmt.Println(elb.ErrCodeSubnetNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidSubnetException: + fmt.Println(elb.ErrCodeInvalidSubnetException, aerr.Error()) + case elb.ErrCodeInvalidSecurityGroupException: + fmt.Println(elb.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elb.ErrCodeInvalidSchemeException: + fmt.Println(elb.ErrCodeInvalidSchemeException, aerr.Error()) + case elb.ErrCodeTooManyTagsException: + fmt.Println(elb.ErrCodeTooManyTagsException, aerr.Error()) + case elb.ErrCodeDuplicateTagKeysException: + fmt.Println(elb.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 + } - svc := elb.New(sess) + fmt.Println(result) +} - params := &elb.DeleteLoadBalancerListenersInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - LoadBalancerPorts: []*int64{ // Required - aws.Int64(1), // Required - // More values... +// To create an HTTP listener for a load balancer +// +// This example creates a listener for your load balancer at port 80 using the HTTP +// protocol. +func ExampleELB_CreateLoadBalancerListeners_shared00() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerListenersInput{ + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(80.000000), + Protocol: aws.String("HTTP"), + }, }, + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.DeleteLoadBalancerListeners(params) + result, err := svc.CreateLoadBalancerListeners(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicateListenerException: + fmt.Println(elb.ErrCodeDuplicateListenerException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_DeleteLoadBalancerPolicy() { - sess := session.Must(session.NewSession()) +// To create an HTTPS listener for a load balancer +// +// This example creates a listener for your load balancer at port 443 using the HTTPS +// protocol. +func ExampleELB_CreateLoadBalancerListeners_shared01() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerListenersInput{ + Listeners: []*elb.Listeners{ + { + InstancePort: aws.Float64(80.000000), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Float64(443.000000), + Protocol: aws.String("HTTPS"), + SSLCertificateId: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), + }, + }, + LoadBalancerName: aws.String("my-load-balancer"), + } - svc := elb.New(sess) + result, err := svc.CreateLoadBalancerListeners(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicateListenerException: + fmt.Println(elb.ErrCodeDuplicateListenerException, aerr.Error()) + case elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 := &elb.DeleteLoadBalancerPolicyInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyName: aws.String("PolicyName"), // Required + fmt.Println(result) +} + +// To create a policy that enables Proxy Protocol on a load balancer +// +// This example creates a policy that enables Proxy Protocol on the specified load balancer. +func ExampleELB_CreateLoadBalancerPolicy_shared00() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerPolicyInput{ + LoadBalancerName: aws.String("my-load-balancer"), + PolicyAttributes: []*elb.PolicyAttributes{ + { + AttributeName: aws.String("ProxyProtocol"), + AttributeValue: aws.String("true"), + }, + }, + PolicyName: aws.String("my-ProxyProtocol-policy"), + PolicyTypeName: aws.String("ProxyProtocolPolicyType"), } - resp, err := svc.DeleteLoadBalancerPolicy(params) + result, err := svc.CreateLoadBalancerPolicy(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyTypeNotFoundException: + fmt.Println(elb.ErrCodePolicyTypeNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicatePolicyNameException: + fmt.Println(elb.ErrCodeDuplicatePolicyNameException, aerr.Error()) + case elb.ErrCodeTooManyPoliciesException: + fmt.Println(elb.ErrCodeTooManyPoliciesException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_DeregisterInstancesFromLoadBalancer() { - sess := session.Must(session.NewSession()) +// To create a public key policy +// +// This example creates a public key policy. +func ExampleELB_CreateLoadBalancerPolicy_shared01() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerPolicyInput{ + LoadBalancerName: aws.String("my-load-balancer"), + PolicyAttributes: []*elb.PolicyAttributes{ + { + AttributeName: aws.String("PublicKey"), + AttributeValue: aws.String("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwAYUjnfyEyXr1pxjhFWBpMlggUcqoi3kl+dS74kj//c6x7ROtusUaeQCTgIUkayttRDWchuqo1pHC1u+n5xxXnBBe2ejbb2WRsKIQ5rXEeixsjFpFsojpSQKkzhVGI6mJVZBJDVKSHmswnwLBdofLhzvllpovBPTHe+o4haAWvDBALJU0pkSI1FecPHcs2hwxf14zHoXy1e2k36A64nXW43wtfx5qcVSIxtCEOjnYRg7RPvybaGfQ+v6Iaxb/+7J5kEvZhTFQId+bSiJImF1FSUT1W1xwzBZPUbcUkkXDj45vC2s3Z8E+Lk7a3uZhvsQHLZnrfuWjBWGWvZ/MhZYgEXAMPLE"), + }, + }, + PolicyName: aws.String("my-PublicKey-policy"), + PolicyTypeName: aws.String("PublicKeyPolicyType"), + } - svc := elb.New(sess) + result, err := svc.CreateLoadBalancerPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyTypeNotFoundException: + fmt.Println(elb.ErrCodePolicyTypeNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicatePolicyNameException: + fmt.Println(elb.ErrCodeDuplicatePolicyNameException, aerr.Error()) + case elb.ErrCodeTooManyPoliciesException: + fmt.Println(elb.ErrCodeTooManyPoliciesException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 := &elb.DeregisterInstancesFromLoadBalancerInput{ - Instances: []*elb.Instance{ // Required - { // Required - InstanceId: aws.String("InstanceId"), + fmt.Println(result) +} + +// To create a backend server authentication policy +// +// This example creates a backend server authentication policy that enables authentication +// on your backend instance using a public key policy. +func ExampleELB_CreateLoadBalancerPolicy_shared02() { + svc := elb.New(session.New()) + input := &elb.CreateLoadBalancerPolicyInput{ + LoadBalancerName: aws.String("my-load-balancer"), + PolicyAttributes: []*elb.PolicyAttributes{ + { + AttributeName: aws.String("PublicKeyPolicyName"), + AttributeValue: aws.String("my-PublicKey-policy"), }, - // More values... }, - LoadBalancerName: aws.String("AccessPointName"), // Required + PolicyName: aws.String("my-authentication-policy"), + PolicyTypeName: aws.String("BackendServerAuthenticationPolicyType"), } - resp, err := svc.DeregisterInstancesFromLoadBalancer(params) + result, err := svc.CreateLoadBalancerPolicy(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyTypeNotFoundException: + fmt.Println(elb.ErrCodePolicyTypeNotFoundException, aerr.Error()) + case elb.ErrCodeDuplicatePolicyNameException: + fmt.Println(elb.ErrCodeDuplicatePolicyNameException, aerr.Error()) + case elb.ErrCodeTooManyPoliciesException: + fmt.Println(elb.ErrCodeTooManyPoliciesException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_DescribeAccountLimits() { - sess := session.Must(session.NewSession()) +// To delete a load balancer +// +// This example deletes the specified load balancer. +func ExampleELB_DeleteLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.DeleteLoadBalancerInput{ + LoadBalancerName: aws.String("my-load-balancer"), + } - svc := elb.New(sess) + result, err := svc.DeleteLoadBalancer(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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 := &elb.DescribeAccountLimitsInput{ - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), + fmt.Println(result) +} + +// To delete a listener from your load balancer +// +// This example deletes the listener for the specified port from the specified load +// balancer. +func ExampleELB_DeleteLoadBalancerListeners_shared00() { + svc := elb.New(session.New()) + input := &elb.DeleteLoadBalancerListenersInput{ + LoadBalancerName: aws.String("my-load-balancer"), + LoadBalancerPorts: []*float64{ + aws.Float64(80.000000), + }, } - resp, err := svc.DescribeAccountLimits(params) + result, err := svc.DeleteLoadBalancerListeners(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, 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 ExampleELB_DescribeInstanceHealth() { - sess := session.Must(session.NewSession()) +// To delete a policy from your load balancer +// +// This example deletes the specified policy from the specified load balancer. The policy +// must not be enabled on any listener. +func ExampleELB_DeleteLoadBalancerPolicy_shared00() { + svc := elb.New(session.New()) + input := &elb.DeleteLoadBalancerPolicyInput{ + LoadBalancerName: aws.String("my-load-balancer"), + PolicyName: aws.String("my-duration-cookie-policy"), + } + + result, err := svc.DeleteLoadBalancerPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 + } - svc := elb.New(sess) + fmt.Println(result) +} - params := &elb.DescribeInstanceHealthInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - Instances: []*elb.Instance{ - { // Required - InstanceId: aws.String("InstanceId"), +// To deregister instances from a load balancer +// +// This example deregisters the specified instance from the specified load balancer. +func ExampleELB_DeregisterInstancesFromLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.DeregisterInstancesFromLoadBalancerInput{ + Instances: []*elb.Instances{ + { + InstanceId: aws.String("i-d6f6fae3"), }, - // More values... }, + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.DescribeInstanceHealth(params) + result, err := svc.DeregisterInstancesFromLoadBalancer(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidEndPointException: + fmt.Println(elb.ErrCodeInvalidEndPointException, 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 ExampleELB_DescribeLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DescribeLoadBalancerAttributesInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required +// To describe the health of the instances for a load balancer +// +// This example describes the health of the instances for the specified load balancer. +func ExampleELB_DescribeInstanceHealth_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeInstanceHealthInput{ + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.DescribeLoadBalancerAttributes(params) + result, err := svc.DescribeInstanceHealth(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidEndPointException: + fmt.Println(elb.ErrCodeInvalidEndPointException, 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 ExampleELB_DescribeLoadBalancerPolicies() { - sess := session.Must(session.NewSession()) +// To describe the attributes of a load balancer +// +// This example describes the attributes of the specified load balancer. +func ExampleELB_DescribeLoadBalancerAttributes_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeLoadBalancerAttributesInput{ + LoadBalancerName: aws.String("my-load-balancer"), + } - svc := elb.New(sess) + result, err := svc.DescribeLoadBalancerAttributes(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeLoadBalancerAttributeNotFoundException: + fmt.Println(elb.ErrCodeLoadBalancerAttributeNotFoundException, 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) +} - params := &elb.DescribeLoadBalancerPoliciesInput{ - LoadBalancerName: aws.String("AccessPointName"), +// To describe a policy associated with a load balancer +// +// This example describes the specified policy associated with the specified load balancer. +func ExampleELB_DescribeLoadBalancerPolicies_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeLoadBalancerPoliciesInput{ + LoadBalancerName: aws.String("my-load-balancer"), PolicyNames: []*string{ - aws.String("PolicyName"), // Required - // More values... + aws.String("my-authentication-policy"), }, } - resp, err := svc.DescribeLoadBalancerPolicies(params) + result, err := svc.DescribeLoadBalancerPolicies(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyNotFoundException: + fmt.Println(elb.ErrCodePolicyNotFoundException, 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 ExampleELB_DescribeLoadBalancerPolicyTypes() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DescribeLoadBalancerPolicyTypesInput{ +// To describe a load balancer policy type defined by Elastic Load Balancing +// +// This example describes the specified load balancer policy type. +func ExampleELB_DescribeLoadBalancerPolicyTypes_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeLoadBalancerPolicyTypesInput{ PolicyTypeNames: []*string{ - aws.String("PolicyTypeName"), // Required - // More values... + aws.String("ProxyProtocolPolicyType"), }, } - resp, err := svc.DescribeLoadBalancerPolicyTypes(params) + result, err := svc.DescribeLoadBalancerPolicyTypes(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 elb.ErrCodePolicyTypeNotFoundException: + fmt.Println(elb.ErrCodePolicyTypeNotFoundException, 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 ExampleELB_DescribeLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DescribeLoadBalancersInput{ +// To describe one of your load balancers +// +// This example describes the specified load balancer. +func ExampleELB_DescribeLoadBalancers_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeLoadBalancersInput{ LoadBalancerNames: []*string{ - aws.String("AccessPointName"), // Required - // More values... + aws.String("my-load-balancer"), }, - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), } - resp, err := svc.DescribeLoadBalancers(params) + result, err := svc.DescribeLoadBalancers(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeDependencyThrottleException: + fmt.Println(elb.ErrCodeDependencyThrottleException, 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 ExampleELB_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DescribeTagsInput{ - LoadBalancerNames: []*string{ // Required - aws.String("AccessPointName"), // Required - // More values... +// To describe the tags for a load balancer +// +// This example describes the tags for the specified load balancer. +func ExampleELB_DescribeTags_shared00() { + svc := elb.New(session.New()) + input := &elb.DescribeTagsInput{ + LoadBalancerNames: []*string{ + aws.String("my-load-balancer"), }, } - resp, err := svc.DescribeTags(params) + result, err := svc.DescribeTags(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, 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 ExampleELB_DetachLoadBalancerFromSubnets() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DetachLoadBalancerFromSubnetsInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - Subnets: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... +// To detach a load balancer from a subnet +// +// This example detaches the specified load balancer from the specified subnet. +func ExampleELB_DetachLoadBalancerFromSubnets_shared00() { + svc := elb.New(session.New()) + input := &elb.DetachLoadBalancerFromSubnetsInput{ + LoadBalancerName: aws.String("my-load-balancer"), + Subnets: []*string{ + aws.String("subnet-0ecac448"), }, } - resp, err := svc.DetachLoadBalancerFromSubnets(params) + result, err := svc.DetachLoadBalancerFromSubnets(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_DisableAvailabilityZonesForLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.DisableAvailabilityZonesForLoadBalancerInput{ - AvailabilityZones: []*string{ // Required - aws.String("AvailabilityZone"), // Required - // More values... +// To disable an Availability Zone for a load balancer +// +// This example removes the specified Availability Zone from the set of Availability +// Zones for the specified load balancer. +func ExampleELB_DisableAvailabilityZonesForLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.DisableAvailabilityZonesForLoadBalancerInput{ + AvailabilityZones: []*string{ + aws.String("us-west-2a"), }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.DisableAvailabilityZonesForLoadBalancer(params) + result, err := svc.DisableAvailabilityZonesForLoadBalancer(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_EnableAvailabilityZonesForLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.EnableAvailabilityZonesForLoadBalancerInput{ - AvailabilityZones: []*string{ // Required - aws.String("AvailabilityZone"), // Required - // More values... +// To enable an Availability Zone for a load balancer +// +// This example adds the specified Availability Zone to the specified load balancer. +func ExampleELB_EnableAvailabilityZonesForLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.EnableAvailabilityZonesForLoadBalancerInput{ + AvailabilityZones: []*string{ + aws.String("us-west-2b"), }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.EnableAvailabilityZonesForLoadBalancer(params) + result, err := svc.EnableAvailabilityZonesForLoadBalancer(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, 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 ExampleELB_ModifyLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.ModifyLoadBalancerAttributesInput{ - LoadBalancerAttributes: &elb.LoadBalancerAttributes{ // Required - AccessLog: &elb.AccessLog{ - Enabled: aws.Bool(true), // Required - EmitInterval: aws.Int64(1), - S3BucketName: aws.String("S3BucketName"), - S3BucketPrefix: aws.String("AccessLogPrefix"), - }, - AdditionalAttributes: []*elb.AdditionalAttribute{ - { // Required - Key: aws.String("AdditionalAttributeKey"), - Value: aws.String("AdditionalAttributeValue"), - }, - // More values... - }, - ConnectionDraining: &elb.ConnectionDraining{ - Enabled: aws.Bool(true), // Required - Timeout: aws.Int64(1), - }, - ConnectionSettings: &elb.ConnectionSettings{ - IdleTimeout: aws.Int64(1), // Required - }, +// To enable cross-zone load balancing +// +// This example enables cross-zone load balancing for the specified load balancer. +func ExampleELB_ModifyLoadBalancerAttributes_shared00() { + svc := elb.New(session.New()) + input := &elb.ModifyLoadBalancerAttributesInput{ + LoadBalancerAttributes: &elb.LoadBalancerAttributes{ CrossZoneLoadBalancing: &elb.CrossZoneLoadBalancing{ - Enabled: aws.Bool(true), // Required + Enabled: aws.Bool(true), }, }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.ModifyLoadBalancerAttributes(params) + result, err := svc.ModifyLoadBalancerAttributes(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeLoadBalancerAttributeNotFoundException: + fmt.Println(elb.ErrCodeLoadBalancerAttributeNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_RegisterInstancesWithLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.RegisterInstancesWithLoadBalancerInput{ - Instances: []*elb.Instance{ // Required - { // Required - InstanceId: aws.String("InstanceId"), +// To enable connection draining +// +// This example enables connection draining for the specified load balancer. +func ExampleELB_ModifyLoadBalancerAttributes_shared01() { + svc := elb.New(session.New()) + input := &elb.ModifyLoadBalancerAttributesInput{ + LoadBalancerAttributes: &elb.LoadBalancerAttributes{ + ConnectionDraining: &elb.ConnectionDraining{ + Enabled: aws.Bool(true), + Timeout: aws.Int64(300.000000), }, - // More values... }, - LoadBalancerName: aws.String("AccessPointName"), // Required + LoadBalancerName: aws.String("my-load-balancer"), } - resp, err := svc.RegisterInstancesWithLoadBalancer(params) + result, err := svc.ModifyLoadBalancerAttributes(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeLoadBalancerAttributeNotFoundException: + fmt.Println(elb.ErrCodeLoadBalancerAttributeNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_RemoveTags() { - sess := session.Must(session.NewSession()) +// To register instances with a load balancer +// +// This example registers the specified instance with the specified load balancer. +func ExampleELB_RegisterInstancesWithLoadBalancer_shared00() { + svc := elb.New(session.New()) + input := &elb.RegisterInstancesWithLoadBalancerInput{ + Instances: []*elb.Instances{ + { + InstanceId: aws.String("i-d6f6fae3"), + }, + }, + LoadBalancerName: aws.String("my-load-balancer"), + } - svc := elb.New(sess) + result, err := svc.RegisterInstancesWithLoadBalancer(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidEndPointException: + fmt.Println(elb.ErrCodeInvalidEndPointException, 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) +} - params := &elb.RemoveTagsInput{ - LoadBalancerNames: []*string{ // Required - aws.String("AccessPointName"), // Required - // More values... +// To remove tags from a load balancer +// +// This example removes the specified tag from the specified load balancer. +func ExampleELB_RemoveTags_shared00() { + svc := elb.New(session.New()) + input := &elb.RemoveTagsInput{ + LoadBalancerNames: []*string{ + aws.String("my-load-balancer"), }, - Tags: []*elb.TagKeyOnly{ // Required - { // Required - Key: aws.String("TagKey"), + Tags: []*elb.TagKeyList{ + { + Key: aws.String("project"), }, - // More values... }, } - resp, err := svc.RemoveTags(params) + result, err := svc.RemoveTags(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, 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 ExampleELB_SetLoadBalancerListenerSSLCertificate() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.SetLoadBalancerListenerSSLCertificateInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - LoadBalancerPort: aws.Int64(1), // Required - SSLCertificateId: aws.String("SSLCertificateId"), // Required +// To update the SSL certificate for an HTTPS listener +// +// This example replaces the existing SSL certificate for the specified HTTPS listener. +func ExampleELB_SetLoadBalancerListenerSSLCertificate_shared00() { + svc := elb.New(session.New()) + input := &elb.SetLoadBalancerListenerSSLCertificateInput{ + LoadBalancerName: aws.String("my-load-balancer"), + LoadBalancerPort: aws.Int64(443.000000), + SSLCertificateId: aws.String("arn:aws:iam::123456789012:server-certificate/new-server-cert"), } - resp, err := svc.SetLoadBalancerListenerSSLCertificate(params) + result, err := svc.SetLoadBalancerListenerSSLCertificate(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 elb.ErrCodeCertificateNotFoundException: + fmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error()) + case elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodeListenerNotFoundException: + fmt.Println(elb.ErrCodeListenerNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elb.ErrCodeUnsupportedProtocolException: + fmt.Println(elb.ErrCodeUnsupportedProtocolException, 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 ExampleELB_SetLoadBalancerPoliciesForBackendServer() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.SetLoadBalancerPoliciesForBackendServerInput{ - InstancePort: aws.Int64(1), // Required - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyNames: []*string{ // Required - aws.String("PolicyName"), // Required - // More values... +// To replace the policies associated with a port for a backend instance +// +// This example replaces the policies that are currently associated with the specified +// port. +func ExampleELB_SetLoadBalancerPoliciesForBackendServer_shared00() { + svc := elb.New(session.New()) + input := &elb.SetLoadBalancerPoliciesForBackendServerInput{ + InstancePort: aws.Int64(80.000000), + LoadBalancerName: aws.String("my-load-balancer"), + PolicyNames: []*string{ + aws.String("my-ProxyProtocol-policy"), }, } - resp, err := svc.SetLoadBalancerPoliciesForBackendServer(params) + result, err := svc.SetLoadBalancerPoliciesForBackendServer(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyNotFoundException: + fmt.Println(elb.ErrCodePolicyNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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 ExampleELB_SetLoadBalancerPoliciesOfListener() { - sess := session.Must(session.NewSession()) - - svc := elb.New(sess) - - params := &elb.SetLoadBalancerPoliciesOfListenerInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - LoadBalancerPort: aws.Int64(1), // Required - PolicyNames: []*string{ // Required - aws.String("PolicyName"), // Required - // More values... +// To replace the policies associated with a listener +// +// This example replaces the policies that are currently associated with the specified +// listener. +func ExampleELB_SetLoadBalancerPoliciesOfListener_shared00() { + svc := elb.New(session.New()) + input := &elb.SetLoadBalancerPoliciesOfListenerInput{ + LoadBalancerName: aws.String("my-load-balancer"), + LoadBalancerPort: aws.Int64(80.000000), + PolicyNames: []*string{ + aws.String("my-SSLNegotiation-policy"), }, } - resp, err := svc.SetLoadBalancerPoliciesOfListener(params) + result, err := svc.SetLoadBalancerPoliciesOfListener(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 elb.ErrCodeAccessPointNotFoundException: + fmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error()) + case elb.ErrCodePolicyNotFoundException: + fmt.Println(elb.ErrCodePolicyNotFoundException, aerr.Error()) + case elb.ErrCodeListenerNotFoundException: + fmt.Println(elb.ErrCodeListenerNotFoundException, aerr.Error()) + case elb.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elb.ErrCodeInvalidConfigurationRequestException, 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) } diff --git a/service/elbv2/examples_test.go b/service/elbv2/examples_test.go index b8e16c8db22..aa9226a0abf 100644 --- a/service/elbv2/examples_test.go +++ b/service/elbv2/examples_test.go @@ -8,872 +8,1469 @@ import ( "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/elbv2" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleELBV2_AddTags() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &elbv2.AddTagsInput{ - ResourceArns: []*string{ // Required - aws.String("ResourceArn"), // Required - // More values... +// To add tags to a load balancer +// +// This example adds the specified tags to the specified load balancer. +func ExampleELBV2_AddTags_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.AddTagsInput{ + ResourceArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), }, - Tags: []*elbv2.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), + Tags: []*elbv2.TagList{ + { + Key: aws.String("project"), + Value: aws.String("lima"), + }, + { + Key: aws.String("department"), + Value: aws.String("digital-media"), }, - // More values... }, } - resp, err := svc.AddTags(params) + result, err := svc.AddTags(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 elbv2.ErrCodeDuplicateTagKeysException: + fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, aerr.Error()) + case elbv2.ErrCodeTooManyTagsException: + fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error()) + case elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 ExampleELBV2_CreateListener() { - sess := session.Must(session.NewSession()) +// To create an HTTP listener +// +// This example creates an HTTP listener for the specified load balancer that forwards +// requests to the specified target group. +func ExampleELBV2_CreateListener_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateListenerInput{ + DefaultActions: []*elbv2.Actions{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Type: aws.String("forward"), + }, + }, + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + Port: aws.Int64(80.000000), + Protocol: aws.String("HTTP"), + } + + result, err := svc.CreateListener(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elbv2.ErrCodeDuplicateListenerException: + fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error()) + case elbv2.ErrCodeTooManyListenersException: + fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error()) + case elbv2.ErrCodeTooManyCertificatesException: + fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error()) + case elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeIncompatibleProtocolsException: + fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error()) + case elbv2.ErrCodeSSLPolicyNotFoundException: + fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error()) + case elbv2.ErrCodeCertificateNotFoundException: + fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error()) + case elbv2.ErrCodeUnsupportedProtocolException: + fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.CreateListenerInput{ - DefaultActions: []*elbv2.Action{ // Required - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required +// To create an HTTPS listener +// +// This example creates an HTTPS listener for the specified load balancer that forwards +// requests to the specified target group. Note that you must specify an SSL certificate +// for an HTTPS listener. You can create and manage certificates using AWS Certificate +// Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get +// the certificate signed by a certificate authority (CA), and upload the certificate +// to AWS Identity and Access Management (IAM). +func ExampleELBV2_CreateListener_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateListenerInput{ + Certificates: []*elbv2.CertificateList{ + { + CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), }, - // More values... }, - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required - Port: aws.Int64(1), // Required - Protocol: aws.String("ProtocolEnum"), // Required - Certificates: []*elbv2.Certificate{ - { // Required - CertificateArn: aws.String("CertificateArn"), + DefaultActions: []*elbv2.Actions{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Type: aws.String("forward"), }, - // More values... }, - SslPolicy: aws.String("SslPolicyName"), + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + Port: aws.Int64(443.000000), + Protocol: aws.String("HTTPS"), + SslPolicy: aws.String("ELBSecurityPolicy-2015-05"), } - resp, err := svc.CreateListener(params) + result, err := svc.CreateListener(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 elbv2.ErrCodeDuplicateListenerException: + fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error()) + case elbv2.ErrCodeTooManyListenersException: + fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error()) + case elbv2.ErrCodeTooManyCertificatesException: + fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error()) + case elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeIncompatibleProtocolsException: + fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error()) + case elbv2.ErrCodeSSLPolicyNotFoundException: + fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error()) + case elbv2.ErrCodeCertificateNotFoundException: + fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error()) + case elbv2.ErrCodeUnsupportedProtocolException: + fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_CreateLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.CreateLoadBalancerInput{ - Name: aws.String("LoadBalancerName"), // Required - Subnets: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... - }, - IpAddressType: aws.String("IpAddressType"), - Scheme: aws.String("LoadBalancerSchemeEnum"), - SecurityGroups: []*string{ - aws.String("SecurityGroupId"), // Required - // More values... - }, - Tags: []*elbv2.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... +// To create an Internet-facing load balancer +// +// This example creates an Internet-facing load balancer and enables the Availability +// Zones for the specified subnets. +func ExampleELBV2_CreateLoadBalancer_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateLoadBalancerInput{ + Name: aws.String("my-load-balancer"), + Subnets: []*string{ + aws.String("subnet-b7d581c0"), + aws.String("subnet-8360a9e7"), }, } - resp, err := svc.CreateLoadBalancer(params) + result, err := svc.CreateLoadBalancer(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 elbv2.ErrCodeDuplicateLoadBalancerNameException: + fmt.Println(elbv2.ErrCodeDuplicateLoadBalancerNameException, aerr.Error()) + case elbv2.ErrCodeTooManyLoadBalancersException: + fmt.Println(elbv2.ErrCodeTooManyLoadBalancersException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeSubnetNotFoundException: + fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidSubnetException: + fmt.Println(elbv2.ErrCodeInvalidSubnetException, aerr.Error()) + case elbv2.ErrCodeInvalidSecurityGroupException: + fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elbv2.ErrCodeInvalidSchemeException: + fmt.Println(elbv2.ErrCodeInvalidSchemeException, aerr.Error()) + case elbv2.ErrCodeTooManyTagsException: + fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error()) + case elbv2.ErrCodeDuplicateTagKeysException: + fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, 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 ExampleELBV2_CreateRule() { - sess := session.Must(session.NewSession()) +// To create an internal load balancer +// +// This example creates an internal load balancer and enables the Availability Zones +// for the specified subnets. +func ExampleELBV2_CreateLoadBalancer_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateLoadBalancerInput{ + Name: aws.String("my-internal-load-balancer"), + Scheme: aws.String("internal"), + Subnets: []*string{ + aws.String("subnet-b7d581c0"), + aws.String("subnet-8360a9e7"), + }, + } + + result, err := svc.CreateLoadBalancer(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elbv2.ErrCodeDuplicateLoadBalancerNameException: + fmt.Println(elbv2.ErrCodeDuplicateLoadBalancerNameException, aerr.Error()) + case elbv2.ErrCodeTooManyLoadBalancersException: + fmt.Println(elbv2.ErrCodeTooManyLoadBalancersException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeSubnetNotFoundException: + fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidSubnetException: + fmt.Println(elbv2.ErrCodeInvalidSubnetException, aerr.Error()) + case elbv2.ErrCodeInvalidSecurityGroupException: + fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, aerr.Error()) + case elbv2.ErrCodeInvalidSchemeException: + fmt.Println(elbv2.ErrCodeInvalidSchemeException, aerr.Error()) + case elbv2.ErrCodeTooManyTagsException: + fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error()) + case elbv2.ErrCodeDuplicateTagKeysException: + fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, 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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.CreateRuleInput{ - Actions: []*elbv2.Action{ // Required - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required +// To create a rule +// +// This example creates a rule that forwards requests to the specified target group +// if the URL contains the specified pattern (for example, /img/*). +func ExampleELBV2_CreateRule_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateRuleInput{ + Actions: []*elbv2.Actions{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Type: aws.String("forward"), }, - // More values... }, - Conditions: []*elbv2.RuleCondition{ // Required - { // Required - Field: aws.String("ConditionFieldName"), + Conditions: []*elbv2.RuleConditionList{ + { + Field: aws.String("path-pattern"), Values: []*string{ - aws.String("StringValue"), // Required - // More values... + aws.String("/img/*"), }, }, - // More values... }, - ListenerArn: aws.String("ListenerArn"), // Required - Priority: aws.Int64(1), // Required + ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), + Priority: aws.Int64(10.000000), } - resp, err := svc.CreateRule(params) + result, err := svc.CreateRule(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 elbv2.ErrCodePriorityInUseException: + fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error()) + case elbv2.ErrCodeTooManyTargetGroupsException: + fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, aerr.Error()) + case elbv2.ErrCodeTooManyRulesException: + fmt.Println(elbv2.ErrCodeTooManyRulesException, aerr.Error()) + case elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_CreateTargetGroup() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.CreateTargetGroupInput{ - Name: aws.String("TargetGroupName"), // Required - Port: aws.Int64(1), // Required - Protocol: aws.String("ProtocolEnum"), // Required - VpcId: aws.String("VpcId"), // Required - HealthCheckIntervalSeconds: aws.Int64(1), - HealthCheckPath: aws.String("Path"), - HealthCheckPort: aws.String("HealthCheckPort"), - HealthCheckProtocol: aws.String("ProtocolEnum"), - HealthCheckTimeoutSeconds: aws.Int64(1), - HealthyThresholdCount: aws.Int64(1), - Matcher: &elbv2.Matcher{ - HttpCode: aws.String("HttpCode"), // Required - }, - UnhealthyThresholdCount: aws.Int64(1), +// To create a target group +// +// This example creates a target group that you can use to route traffic to targets +// using HTTP on port 80. This target group uses the default health check configuration. +func ExampleELBV2_CreateTargetGroup_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.CreateTargetGroupInput{ + Name: aws.String("my-targets"), + Port: aws.Int64(80.000000), + Protocol: aws.String("HTTP"), + VpcId: aws.String("vpc-3ac0fb5f"), } - resp, err := svc.CreateTargetGroup(params) + result, err := svc.CreateTargetGroup(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 elbv2.ErrCodeDuplicateTargetGroupNameException: + fmt.Println(elbv2.ErrCodeDuplicateTargetGroupNameException, aerr.Error()) + case elbv2.ErrCodeTooManyTargetGroupsException: + fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, 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 ExampleELBV2_DeleteListener() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteListenerInput{ - ListenerArn: aws.String("ListenerArn"), // Required +// To delete a listener +// +// This example deletes the specified listener. +func ExampleELBV2_DeleteListener_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DeleteListenerInput{ + ListenerArn: aws.String("arn:aws:elasticloadbalancing:ua-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), } - resp, err := svc.DeleteListener(params) + result, err := svc.DeleteListener(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 elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, 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 ExampleELBV2_DeleteLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteLoadBalancerInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required +// To delete a load balancer +// +// This example deletes the specified load balancer. +func ExampleELBV2_DeleteLoadBalancer_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DeleteLoadBalancerInput{ + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), } - resp, err := svc.DeleteLoadBalancer(params) + result, err := svc.DeleteLoadBalancer(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeOperationNotPermittedException: + fmt.Println(elbv2.ErrCodeOperationNotPermittedException, 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 ExampleELBV2_DeleteRule() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteRuleInput{ - RuleArn: aws.String("RuleArn"), // Required +// To delete a rule +// +// This example deletes the specified rule. +func ExampleELBV2_DeleteRule_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DeleteRuleInput{ + RuleArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3"), } - resp, err := svc.DeleteRule(params) + result, err := svc.DeleteRule(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 elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error()) + case elbv2.ErrCodeOperationNotPermittedException: + fmt.Println(elbv2.ErrCodeOperationNotPermittedException, 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 ExampleELBV2_DeleteTargetGroup() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteTargetGroupInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required +// To delete a target group +// +// This example deletes the specified target group. +func ExampleELBV2_DeleteTargetGroup_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DeleteTargetGroupInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), } - resp, err := svc.DeleteTargetGroup(params) + result, err := svc.DeleteTargetGroup(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 elbv2.ErrCodeResourceInUseException: + fmt.Println(elbv2.ErrCodeResourceInUseException, 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 ExampleELBV2_DeregisterTargets() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeregisterTargetsInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Targets: []*elbv2.TargetDescription{ // Required - { // Required - Id: aws.String("TargetId"), // Required - Port: aws.Int64(1), +// To deregister a target from a target group +// +// This example deregisters the specified instance from the specified target group. +func ExampleELBV2_DeregisterTargets_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DeregisterTargetsInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Targets: []*elbv2.TargetDescriptions{ + { + Id: aws.String("i-0f76fade"), }, - // More values... }, } - resp, err := svc.DeregisterTargets(params) + result, err := svc.DeregisterTargets(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 elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidTargetException: + fmt.Println(elbv2.ErrCodeInvalidTargetException, 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 ExampleELBV2_DescribeAccountLimits() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeAccountLimitsInput{ - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), +// To describe a listener +// +// This example describes the specified listener. +func ExampleELBV2_DescribeListeners_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeListenersInput{ + ListenerArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), + }, } - resp, err := svc.DescribeAccountLimits(params) + result, err := svc.DescribeListeners(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 elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, 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 ExampleELBV2_DescribeListeners() { - sess := session.Must(session.NewSession()) +// To describe load balancer attributes +// +// This example describes the attributes of the specified load balancer. +func ExampleELBV2_DescribeLoadBalancerAttributes_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeLoadBalancerAttributesInput{ + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + } - svc := elbv2.New(sess) + result, err := svc.DescribeLoadBalancerAttributes(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, 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 := &elbv2.DescribeListenersInput{ - ListenerArns: []*string{ - aws.String("ListenerArn"), // Required - // More values... + fmt.Println(result) +} + +// To describe a load balancer +// +// This example describes the specified load balancer. +func ExampleELBV2_DescribeLoadBalancers_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeLoadBalancersInput{ + LoadBalancerArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), }, - LoadBalancerArn: aws.String("LoadBalancerArn"), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), } - resp, err := svc.DescribeListeners(params) + result, err := svc.DescribeLoadBalancers(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, 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 ExampleELBV2_DescribeLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeLoadBalancerAttributesInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required +// To describe a rule +// +// This example describes the specified rule. +func ExampleELBV2_DescribeRules_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeRulesInput{ + RuleArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee"), + }, } - resp, err := svc.DescribeLoadBalancerAttributes(params) + result, err := svc.DescribeRules(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 elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, 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 ExampleELBV2_DescribeLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeLoadBalancersInput{ - LoadBalancerArns: []*string{ - aws.String("LoadBalancerArn"), // Required - // More values... - }, - Marker: aws.String("Marker"), +// To describe a policy used for SSL negotiation +// +// This example describes the specified policy used for SSL negotiation. +func ExampleELBV2_DescribeSSLPolicies_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeSSLPoliciesInput{ Names: []*string{ - aws.String("LoadBalancerName"), // Required - // More values... + aws.String("ELBSecurityPolicy-2015-05"), }, - PageSize: aws.Int64(1), } - resp, err := svc.DescribeLoadBalancers(params) + result, err := svc.DescribeSSLPolicies(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 elbv2.ErrCodeSSLPolicyNotFoundException: + fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, 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 ExampleELBV2_DescribeRules() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeRulesInput{ - ListenerArn: aws.String("ListenerArn"), - RuleArns: []*string{ - aws.String("RuleArn"), // Required - // More values... +// To describe the tags assigned to a load balancer +// +// This example describes the tags assigned to the specified load balancer. +func ExampleELBV2_DescribeTags_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeTagsInput{ + ResourceArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), }, } - resp, err := svc.DescribeRules(params) + result, err := svc.DescribeTags(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, 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 ExampleELBV2_DescribeSSLPolicies() { - sess := session.Must(session.NewSession()) +// To describe target group attributes +// +// This example describes the attributes of the specified target group. +func ExampleELBV2_DescribeTargetGroupAttributes_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeTargetGroupAttributesInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + } - svc := elbv2.New(sess) + result, err := svc.DescribeTargetGroupAttributes(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 := &elbv2.DescribeSSLPoliciesInput{ - Marker: aws.String("Marker"), - Names: []*string{ - aws.String("SslPolicyName"), // Required - // More values... + fmt.Println(result) +} + +// To describe a target group +// +// This example describes the specified target group. +func ExampleELBV2_DescribeTargetGroups_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeTargetGroupsInput{ + TargetGroupArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), }, - PageSize: aws.Int64(1), } - resp, err := svc.DescribeSSLPolicies(params) + result, err := svc.DescribeTargetGroups(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 ExampleELBV2_DescribeTags() { - sess := session.Must(session.NewSession()) +// To describe the health of the targets for a target group +// +// This example describes the health of the targets for the specified target group. +// One target is healthy but the other is not specified in an action, so it can't receive +// traffic from the load balancer. +func ExampleELBV2_DescribeTargetHealth_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeTargetHealthInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + } + + result, err := svc.DescribeTargetHealth(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case elbv2.ErrCodeInvalidTargetException: + fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeHealthUnavailableException: + fmt.Println(elbv2.ErrCodeHealthUnavailableException, 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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.DescribeTagsInput{ - ResourceArns: []*string{ // Required - aws.String("ResourceArn"), // Required - // More values... +// To describe the health of a target +// +// This example describes the health of the specified target. This target is healthy. +func ExampleELBV2_DescribeTargetHealth_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.DescribeTargetHealthInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Targets: []*elbv2.TargetDescriptions{ + { + Id: aws.String("i-0f76fade"), + Port: aws.Float64(80.000000), + }, }, } - resp, err := svc.DescribeTags(params) + result, err := svc.DescribeTargetHealth(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 elbv2.ErrCodeInvalidTargetException: + fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeHealthUnavailableException: + fmt.Println(elbv2.ErrCodeHealthUnavailableException, 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 ExampleELBV2_DescribeTargetGroupAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeTargetGroupAttributesInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required +// To change the default action for a listener +// +// This example changes the default action for the specified listener. +func ExampleELBV2_ModifyListener_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyListenerInput{ + DefaultActions: []*elbv2.Actions{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f"), + Type: aws.String("forward"), + }, + }, + ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), } - resp, err := svc.DescribeTargetGroupAttributes(params) + result, err := svc.ModifyListener(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 elbv2.ErrCodeDuplicateListenerException: + fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error()) + case elbv2.ErrCodeTooManyListenersException: + fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error()) + case elbv2.ErrCodeTooManyCertificatesException: + fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error()) + case elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeIncompatibleProtocolsException: + fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error()) + case elbv2.ErrCodeSSLPolicyNotFoundException: + fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error()) + case elbv2.ErrCodeCertificateNotFoundException: + fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeUnsupportedProtocolException: + fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_DescribeTargetGroups() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeTargetGroupsInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), - Marker: aws.String("Marker"), - Names: []*string{ - aws.String("TargetGroupName"), // Required - // More values... - }, - PageSize: aws.Int64(1), - TargetGroupArns: []*string{ - aws.String("TargetGroupArn"), // Required - // More values... +// To change the server certificate +// +// This example changes the server certificate for the specified HTTPS listener. +func ExampleELBV2_ModifyListener_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyListenerInput{ + Certificates: []*elbv2.CertificateList{ + { + CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-new-server-cert"), + }, }, + ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65"), } - resp, err := svc.DescribeTargetGroups(params) + result, err := svc.ModifyListener(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 elbv2.ErrCodeDuplicateListenerException: + fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error()) + case elbv2.ErrCodeTooManyListenersException: + fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error()) + case elbv2.ErrCodeTooManyCertificatesException: + fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error()) + case elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeIncompatibleProtocolsException: + fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error()) + case elbv2.ErrCodeSSLPolicyNotFoundException: + fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error()) + case elbv2.ErrCodeCertificateNotFoundException: + fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeUnsupportedProtocolException: + fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_DescribeTargetHealth() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeTargetHealthInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Targets: []*elbv2.TargetDescription{ - { // Required - Id: aws.String("TargetId"), // Required - Port: aws.Int64(1), +// To enable deletion protection +// +// This example enables deletion protection for the specified load balancer. +func ExampleELBV2_ModifyLoadBalancerAttributes_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyLoadBalancerAttributesInput{ + Attributes: []*elbv2.LoadBalancerAttributes{ + { + Key: aws.String("deletion_protection.enabled"), + Value: aws.String("true"), }, - // More values... }, + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), } - resp, err := svc.DescribeTargetHealth(params) + result, err := svc.ModifyLoadBalancerAttributes(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, 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 ExampleELBV2_ModifyListener() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.ModifyListenerInput{ - ListenerArn: aws.String("ListenerArn"), // Required - Certificates: []*elbv2.Certificate{ - { // Required - CertificateArn: aws.String("CertificateArn"), +// To change the idle timeout +// +// This example changes the idle timeout value for the specified load balancer. +func ExampleELBV2_ModifyLoadBalancerAttributes_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyLoadBalancerAttributesInput{ + Attributes: []*elbv2.LoadBalancerAttributes{ + { + Key: aws.String("idle_timeout.timeout_seconds"), + Value: aws.String("30"), }, - // More values... }, - DefaultActions: []*elbv2.Action{ - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required - }, - // More values... - }, - Port: aws.Int64(1), - Protocol: aws.String("ProtocolEnum"), - SslPolicy: aws.String("SslPolicyName"), + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), } - resp, err := svc.ModifyListener(params) + result, err := svc.ModifyLoadBalancerAttributes(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, 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 ExampleELBV2_ModifyLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.ModifyLoadBalancerAttributesInput{ - Attributes: []*elbv2.LoadBalancerAttribute{ // Required - { // Required - Key: aws.String("LoadBalancerAttributeKey"), - Value: aws.String("LoadBalancerAttributeValue"), +// To enable access logs +// +// This example enables access logs for the specified load balancer. Note that the S3 +// bucket must exist in the same region as the load balancer and must have a policy +// attached that grants access to the Elastic Load Balancing service. +func ExampleELBV2_ModifyLoadBalancerAttributes_shared02() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyLoadBalancerAttributesInput{ + Attributes: []*elbv2.LoadBalancerAttributes{ + { + Key: aws.String("access_logs.s3.enabled"), + Value: aws.String("true"), + }, + { + Key: aws.String("access_logs.s3.bucket"), + Value: aws.String("my-loadbalancer-logs"), + }, + { + Key: aws.String("access_logs.s3.prefix"), + Value: aws.String("myapp"), }, - // More values... }, - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), } - resp, err := svc.ModifyLoadBalancerAttributes(params) + result, err := svc.ModifyLoadBalancerAttributes(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, 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 ExampleELBV2_ModifyRule() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.ModifyRuleInput{ - RuleArn: aws.String("RuleArn"), // Required - Actions: []*elbv2.Action{ - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required - }, - // More values... - }, - Conditions: []*elbv2.RuleCondition{ - { // Required - Field: aws.String("ConditionFieldName"), +// To modify a rule +// +// This example modifies the condition for the specified rule. +func ExampleELBV2_ModifyRule_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyRuleInput{ + Conditions: []*elbv2.RuleConditionList{ + { + Field: aws.String("path-pattern"), Values: []*string{ - aws.String("StringValue"), // Required - // More values... + aws.String("/images/*"), }, }, - // More values... }, + RuleArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee"), } - resp, err := svc.ModifyRule(params) + result, err := svc.ModifyRule(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 elbv2.ErrCodeTargetGroupAssociationLimitException: + fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error()) + case elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error()) + case elbv2.ErrCodeOperationNotPermittedException: + fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_ModifyTargetGroup() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.ModifyTargetGroupInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required - HealthCheckIntervalSeconds: aws.Int64(1), - HealthCheckPath: aws.String("Path"), - HealthCheckPort: aws.String("HealthCheckPort"), - HealthCheckProtocol: aws.String("ProtocolEnum"), - HealthCheckTimeoutSeconds: aws.Int64(1), - HealthyThresholdCount: aws.Int64(1), - Matcher: &elbv2.Matcher{ - HttpCode: aws.String("HttpCode"), // Required - }, - UnhealthyThresholdCount: aws.Int64(1), +// To modify the health check configuration for a target group +// +// This example changes the configuration of the health checks used to evaluate the +// health of the targets for the specified target group. +func ExampleELBV2_ModifyTargetGroup_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyTargetGroupInput{ + HealthCheckPort: aws.String("443"), + HealthCheckProtocol: aws.String("HTTPS"), + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f"), } - resp, err := svc.ModifyTargetGroup(params) + result, err := svc.ModifyTargetGroup(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 elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 ExampleELBV2_ModifyTargetGroupAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.ModifyTargetGroupAttributesInput{ - Attributes: []*elbv2.TargetGroupAttribute{ // Required - { // Required - Key: aws.String("TargetGroupAttributeKey"), - Value: aws.String("TargetGroupAttributeValue"), +// To modify the deregistration delay timeout +// +// This example sets the deregistration delay timeout to the specified value for the +// specified target group. +func ExampleELBV2_ModifyTargetGroupAttributes_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.ModifyTargetGroupAttributesInput{ + Attributes: []*elbv2.TargetGroupAttributes{ + { + Key: aws.String("deregistration_delay.timeout_seconds"), + Value: aws.String("600"), }, - // More values... }, - TargetGroupArn: aws.String("TargetGroupArn"), // Required + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), } - resp, err := svc.ModifyTargetGroupAttributes(params) + result, err := svc.ModifyTargetGroupAttributes(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 elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 ExampleELBV2_RegisterTargets() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.RegisterTargetsInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Targets: []*elbv2.TargetDescription{ // Required - { // Required - Id: aws.String("TargetId"), // Required - Port: aws.Int64(1), +// To register targets with a target group +// +// This example registers the specified instances with the specified target group. +func ExampleELBV2_RegisterTargets_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.RegisterTargetsInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Targets: []*elbv2.TargetDescriptions{ + { + Id: aws.String("i-80c8dd94"), + }, + { + Id: aws.String("i-ceddcd4d"), }, - // More values... }, } - resp, err := svc.RegisterTargets(params) + result, err := svc.RegisterTargets(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 elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTooManyTargetsException: + fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error()) + case elbv2.ErrCodeInvalidTargetException: + fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_RemoveTags() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.RemoveTagsInput{ - ResourceArns: []*string{ // Required - aws.String("ResourceArn"), // Required - // More values... - }, - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... +// To register targets with a target group using port overrides +// +// This example registers the specified instance with the specified target group using +// multiple ports. This enables you to register ECS containers on the same instance +// as targets in the target group. +func ExampleELBV2_RegisterTargets_shared01() { + svc := elbv2.New(session.New()) + input := &elbv2.RegisterTargetsInput{ + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9"), + Targets: []*elbv2.TargetDescriptions{ + { + Id: aws.String("i-80c8dd94"), + Port: aws.Float64(80.000000), + }, + { + Id: aws.String("i-80c8dd94"), + Port: aws.Float64(766.000000), + }, }, } - resp, err := svc.RemoveTags(params) + result, err := svc.RegisterTargets(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 elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeTooManyTargetsException: + fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error()) + case elbv2.ErrCodeInvalidTargetException: + fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error()) + case elbv2.ErrCodeTooManyRegistrationsForTargetIdException: + fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, 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 ExampleELBV2_SetIpAddressType() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.SetIpAddressTypeInput{ - IpAddressType: aws.String("IpAddressType"), // Required - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required +// To remove tags from a load balancer +// +// This example removes the specified tags from the specified load balancer. +func ExampleELBV2_RemoveTags_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.RemoveTagsInput{ + ResourceArns: []*string{ + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + }, + TagKeys: []*string{ + aws.String("project"), + aws.String("department"), + }, } - resp, err := svc.SetIpAddressType(params) + result, err := svc.RemoveTags(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeTargetGroupNotFoundException: + fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) + case elbv2.ErrCodeListenerNotFoundException: + fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) + case elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error()) + case elbv2.ErrCodeTooManyTagsException: + fmt.Println(elbv2.ErrCodeTooManyTagsException, 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 ExampleELBV2_SetRulePriorities() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.SetRulePrioritiesInput{ - RulePriorities: []*elbv2.RulePriorityPair{ // Required - { // Required - Priority: aws.Int64(1), - RuleArn: aws.String("RuleArn"), +// To set the rule priority +// +// This example sets the priority of the specified rule. +func ExampleELBV2_SetRulePriorities_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.SetRulePrioritiesInput{ + RulePriorities: []*elbv2.RulePriorityList{ + { + Priority: aws.Float64(5.000000), + RuleArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3"), }, - // More values... }, } - resp, err := svc.SetRulePriorities(params) + result, err := svc.SetRulePriorities(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 elbv2.ErrCodeRuleNotFoundException: + fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error()) + case elbv2.ErrCodePriorityInUseException: + fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error()) + case elbv2.ErrCodeOperationNotPermittedException: + fmt.Println(elbv2.ErrCodeOperationNotPermittedException, 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 ExampleELBV2_SetSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.SetSecurityGroupsInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required - SecurityGroups: []*string{ // Required - aws.String("SecurityGroupId"), // Required - // More values... +// To associate a security group with a load balancer +// +// This example associates the specified security group with the specified load balancer. +func ExampleELBV2_SetSecurityGroups_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.SetSecurityGroupsInput{ + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + SecurityGroups: []*string{ + aws.String("sg-5943793c"), }, } - resp, err := svc.SetSecurityGroups(params) + result, err := svc.SetSecurityGroups(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeInvalidSecurityGroupException: + fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, 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 ExampleELBV2_SetSubnets() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.SetSubnetsInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required - Subnets: []*string{ // Required - aws.String("SubnetId"), // Required - // More values... +// To enable Availability Zones for a load balancer +// +// This example enables the Availability Zones for the specified subnets for the specified +// load balancer. +func ExampleELBV2_SetSubnets_shared00() { + svc := elbv2.New(session.New()) + input := &elbv2.SetSubnetsInput{ + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + Subnets: []*string{ + aws.String("subnet-8360a9e7"), + aws.String("subnet-b7d581c0"), }, } - resp, err := svc.SetSubnets(params) + result, err := svc.SetSubnets(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 elbv2.ErrCodeLoadBalancerNotFoundException: + fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidConfigurationRequestException: + fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error()) + case elbv2.ErrCodeSubnetNotFoundException: + fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error()) + case elbv2.ErrCodeInvalidSubnetException: + fmt.Println(elbv2.ErrCodeInvalidSubnetException, 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) } diff --git a/service/emr/examples_test.go b/service/emr/examples_test.go deleted file mode 100644 index 3430fe1c9d0..00000000000 --- a/service/emr/examples_test.go +++ /dev/null @@ -1,1127 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package emr_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/emr" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleEMR_AddInstanceFleet() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.AddInstanceFleetInput{ - ClusterId: aws.String("XmlStringMaxLen256"), // Required - InstanceFleet: &emr.InstanceFleetConfig{ // Required - InstanceFleetType: aws.String("InstanceFleetType"), // Required - InstanceTypeConfigs: []*emr.InstanceTypeConfig{ - { // Required - InstanceType: aws.String("InstanceType"), // Required - BidPrice: aws.String("XmlStringMaxLen256"), - BidPriceAsPercentageOfOnDemandPrice: aws.Float64(1.0), - Configurations: []*emr.Configuration{ - { // Required - Classification: aws.String("String"), - Configurations: []*emr.Configuration{ - // Recursive values... - }, - Properties: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - EbsConfiguration: &emr.EbsConfiguration{ - EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{ - { // Required - VolumeSpecification: &emr.VolumeSpecification{ // Required - SizeInGB: aws.Int64(1), // Required - VolumeType: aws.String("String"), // Required - Iops: aws.Int64(1), - }, - VolumesPerInstance: aws.Int64(1), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), - }, - WeightedCapacity: aws.Int64(1), - }, - // More values... - }, - LaunchSpecifications: &emr.InstanceFleetProvisioningSpecifications{ - SpotSpecification: &emr.SpotProvisioningSpecification{ // Required - TimeoutAction: aws.String("SpotProvisioningTimeoutAction"), // Required - TimeoutDurationMinutes: aws.Int64(1), // Required - BlockDurationMinutes: aws.Int64(1), - }, - }, - Name: aws.String("XmlStringMaxLen256"), - TargetOnDemandCapacity: aws.Int64(1), - TargetSpotCapacity: aws.Int64(1), - }, - } - resp, err := svc.AddInstanceFleet(params) - - if err != nil { - // 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) -} - -func ExampleEMR_AddInstanceGroups() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.AddInstanceGroupsInput{ - InstanceGroups: []*emr.InstanceGroupConfig{ // Required - { // Required - InstanceCount: aws.Int64(1), // Required - InstanceRole: aws.String("InstanceRoleType"), // Required - InstanceType: aws.String("InstanceType"), // Required - AutoScalingPolicy: &emr.AutoScalingPolicy{ - Constraints: &emr.ScalingConstraints{ // Required - MaxCapacity: aws.Int64(1), // Required - MinCapacity: aws.Int64(1), // Required - }, - Rules: []*emr.ScalingRule{ // Required - { // Required - Action: &emr.ScalingAction{ // Required - SimpleScalingPolicyConfiguration: &emr.SimpleScalingPolicyConfiguration{ // Required - ScalingAdjustment: aws.Int64(1), // Required - AdjustmentType: aws.String("AdjustmentType"), - CoolDown: aws.Int64(1), - }, - Market: aws.String("MarketType"), - }, - Name: aws.String("String"), // Required - Trigger: &emr.ScalingTrigger{ // Required - CloudWatchAlarmDefinition: &emr.CloudWatchAlarmDefinition{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - MetricName: aws.String("String"), // Required - Period: aws.Int64(1), // Required - Threshold: aws.Float64(1.0), // Required - Dimensions: []*emr.MetricDimension{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - EvaluationPeriods: aws.Int64(1), - Namespace: aws.String("String"), - Statistic: aws.String("Statistic"), - Unit: aws.String("Unit"), - }, - }, - Description: aws.String("String"), - }, - // More values... - }, - }, - BidPrice: aws.String("XmlStringMaxLen256"), - Configurations: []*emr.Configuration{ - { // Required - Classification: aws.String("String"), - Configurations: []*emr.Configuration{ - // Recursive values... - }, - Properties: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - EbsConfiguration: &emr.EbsConfiguration{ - EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{ - { // Required - VolumeSpecification: &emr.VolumeSpecification{ // Required - SizeInGB: aws.Int64(1), // Required - VolumeType: aws.String("String"), // Required - Iops: aws.Int64(1), - }, - VolumesPerInstance: aws.Int64(1), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), - }, - Market: aws.String("MarketType"), - Name: aws.String("XmlStringMaxLen256"), - }, - // More values... - }, - JobFlowId: aws.String("XmlStringMaxLen256"), // Required - } - resp, err := svc.AddInstanceGroups(params) - - if err != nil { - // 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) -} - -func ExampleEMR_AddJobFlowSteps() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.AddJobFlowStepsInput{ - JobFlowId: aws.String("XmlStringMaxLen256"), // Required - Steps: []*emr.StepConfig{ // Required - { // Required - HadoopJarStep: &emr.HadoopJarStepConfig{ // Required - Jar: aws.String("XmlString"), // Required - Args: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - MainClass: aws.String("XmlString"), - Properties: []*emr.KeyValue{ - { // Required - Key: aws.String("XmlString"), - Value: aws.String("XmlString"), - }, - // More values... - }, - }, - Name: aws.String("XmlStringMaxLen256"), // Required - ActionOnFailure: aws.String("ActionOnFailure"), - }, - // More values... - }, - } - resp, err := svc.AddJobFlowSteps(params) - - if err != nil { - // 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) -} - -func ExampleEMR_AddTags() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.AddTagsInput{ - ResourceId: aws.String("ResourceId"), // Required - Tags: []*emr.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.AddTags(params) - - if err != nil { - // 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) -} - -func ExampleEMR_CancelSteps() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.CancelStepsInput{ - ClusterId: aws.String("XmlStringMaxLen256"), - StepIds: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - } - resp, err := svc.CancelSteps(params) - - if err != nil { - // 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) -} - -func ExampleEMR_CreateSecurityConfiguration() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.CreateSecurityConfigurationInput{ - Name: aws.String("XmlString"), // Required - SecurityConfiguration: aws.String("String"), // Required - } - resp, err := svc.CreateSecurityConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleEMR_DeleteSecurityConfiguration() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.DeleteSecurityConfigurationInput{ - Name: aws.String("XmlString"), // Required - } - resp, err := svc.DeleteSecurityConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleEMR_DescribeCluster() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.DescribeClusterInput{ - ClusterId: aws.String("ClusterId"), // Required - } - resp, err := svc.DescribeCluster(params) - - if err != nil { - // 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) -} - -func ExampleEMR_DescribeJobFlows() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.DescribeJobFlowsInput{ - CreatedAfter: aws.Time(time.Now()), - CreatedBefore: aws.Time(time.Now()), - JobFlowIds: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - JobFlowStates: []*string{ - aws.String("JobFlowExecutionState"), // Required - // More values... - }, - } - resp, err := svc.DescribeJobFlows(params) - - if err != nil { - // 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) -} - -func ExampleEMR_DescribeSecurityConfiguration() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.DescribeSecurityConfigurationInput{ - Name: aws.String("XmlString"), // Required - } - resp, err := svc.DescribeSecurityConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleEMR_DescribeStep() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.DescribeStepInput{ - ClusterId: aws.String("ClusterId"), // Required - StepId: aws.String("StepId"), // Required - } - resp, err := svc.DescribeStep(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListBootstrapActions() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListBootstrapActionsInput{ - ClusterId: aws.String("ClusterId"), // Required - Marker: aws.String("Marker"), - } - resp, err := svc.ListBootstrapActions(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListClusters() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListClustersInput{ - ClusterStates: []*string{ - aws.String("ClusterState"), // Required - // More values... - }, - CreatedAfter: aws.Time(time.Now()), - CreatedBefore: aws.Time(time.Now()), - Marker: aws.String("Marker"), - } - resp, err := svc.ListClusters(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListInstanceFleets() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListInstanceFleetsInput{ - ClusterId: aws.String("ClusterId"), // Required - Marker: aws.String("Marker"), - } - resp, err := svc.ListInstanceFleets(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListInstanceGroups() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListInstanceGroupsInput{ - ClusterId: aws.String("ClusterId"), // Required - Marker: aws.String("Marker"), - } - resp, err := svc.ListInstanceGroups(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListInstances() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListInstancesInput{ - ClusterId: aws.String("ClusterId"), // Required - InstanceFleetId: aws.String("InstanceFleetId"), - InstanceFleetType: aws.String("InstanceFleetType"), - InstanceGroupId: aws.String("InstanceGroupId"), - InstanceGroupTypes: []*string{ - aws.String("InstanceGroupType"), // Required - // More values... - }, - InstanceStates: []*string{ - aws.String("InstanceState"), // Required - // More values... - }, - Marker: aws.String("Marker"), - } - resp, err := svc.ListInstances(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListSecurityConfigurations() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListSecurityConfigurationsInput{ - Marker: aws.String("Marker"), - } - resp, err := svc.ListSecurityConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ListSteps() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ListStepsInput{ - ClusterId: aws.String("ClusterId"), // Required - Marker: aws.String("Marker"), - StepIds: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - StepStates: []*string{ - aws.String("StepState"), // Required - // More values... - }, - } - resp, err := svc.ListSteps(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ModifyInstanceFleet() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ModifyInstanceFleetInput{ - ClusterId: aws.String("ClusterId"), // Required - InstanceFleet: &emr.InstanceFleetModifyConfig{ // Required - InstanceFleetId: aws.String("InstanceFleetId"), // Required - TargetOnDemandCapacity: aws.Int64(1), - TargetSpotCapacity: aws.Int64(1), - }, - } - resp, err := svc.ModifyInstanceFleet(params) - - if err != nil { - // 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) -} - -func ExampleEMR_ModifyInstanceGroups() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.ModifyInstanceGroupsInput{ - ClusterId: aws.String("ClusterId"), - InstanceGroups: []*emr.InstanceGroupModifyConfig{ - { // Required - InstanceGroupId: aws.String("XmlStringMaxLen256"), // Required - EC2InstanceIdsToTerminate: []*string{ - aws.String("InstanceId"), // Required - // More values... - }, - InstanceCount: aws.Int64(1), - ShrinkPolicy: &emr.ShrinkPolicy{ - DecommissionTimeout: aws.Int64(1), - InstanceResizePolicy: &emr.InstanceResizePolicy{ - InstanceTerminationTimeout: aws.Int64(1), - InstancesToProtect: []*string{ - aws.String("InstanceId"), // Required - // More values... - }, - InstancesToTerminate: []*string{ - aws.String("InstanceId"), // Required - // More values... - }, - }, - }, - }, - // More values... - }, - } - resp, err := svc.ModifyInstanceGroups(params) - - if err != nil { - // 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) -} - -func ExampleEMR_PutAutoScalingPolicy() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.PutAutoScalingPolicyInput{ - AutoScalingPolicy: &emr.AutoScalingPolicy{ // Required - Constraints: &emr.ScalingConstraints{ // Required - MaxCapacity: aws.Int64(1), // Required - MinCapacity: aws.Int64(1), // Required - }, - Rules: []*emr.ScalingRule{ // Required - { // Required - Action: &emr.ScalingAction{ // Required - SimpleScalingPolicyConfiguration: &emr.SimpleScalingPolicyConfiguration{ // Required - ScalingAdjustment: aws.Int64(1), // Required - AdjustmentType: aws.String("AdjustmentType"), - CoolDown: aws.Int64(1), - }, - Market: aws.String("MarketType"), - }, - Name: aws.String("String"), // Required - Trigger: &emr.ScalingTrigger{ // Required - CloudWatchAlarmDefinition: &emr.CloudWatchAlarmDefinition{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - MetricName: aws.String("String"), // Required - Period: aws.Int64(1), // Required - Threshold: aws.Float64(1.0), // Required - Dimensions: []*emr.MetricDimension{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - EvaluationPeriods: aws.Int64(1), - Namespace: aws.String("String"), - Statistic: aws.String("Statistic"), - Unit: aws.String("Unit"), - }, - }, - Description: aws.String("String"), - }, - // More values... - }, - }, - ClusterId: aws.String("ClusterId"), // Required - InstanceGroupId: aws.String("InstanceGroupId"), // Required - } - resp, err := svc.PutAutoScalingPolicy(params) - - if err != nil { - // 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) -} - -func ExampleEMR_RemoveAutoScalingPolicy() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.RemoveAutoScalingPolicyInput{ - ClusterId: aws.String("ClusterId"), // Required - InstanceGroupId: aws.String("InstanceGroupId"), // Required - } - resp, err := svc.RemoveAutoScalingPolicy(params) - - if err != nil { - // 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) -} - -func ExampleEMR_RemoveTags() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.RemoveTagsInput{ - ResourceId: aws.String("ResourceId"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RemoveTags(params) - - if err != nil { - // 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) -} - -func ExampleEMR_RunJobFlow() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.RunJobFlowInput{ - Instances: &emr.JobFlowInstancesConfig{ // Required - AdditionalMasterSecurityGroups: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - AdditionalSlaveSecurityGroups: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - Ec2KeyName: aws.String("XmlStringMaxLen256"), - Ec2SubnetId: aws.String("XmlStringMaxLen256"), - Ec2SubnetIds: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - EmrManagedMasterSecurityGroup: aws.String("XmlStringMaxLen256"), - EmrManagedSlaveSecurityGroup: aws.String("XmlStringMaxLen256"), - HadoopVersion: aws.String("XmlStringMaxLen256"), - InstanceCount: aws.Int64(1), - InstanceFleets: []*emr.InstanceFleetConfig{ - { // Required - InstanceFleetType: aws.String("InstanceFleetType"), // Required - InstanceTypeConfigs: []*emr.InstanceTypeConfig{ - { // Required - InstanceType: aws.String("InstanceType"), // Required - BidPrice: aws.String("XmlStringMaxLen256"), - BidPriceAsPercentageOfOnDemandPrice: aws.Float64(1.0), - Configurations: []*emr.Configuration{ - { // Required - Classification: aws.String("String"), - Configurations: []*emr.Configuration{ - // Recursive values... - }, - Properties: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - EbsConfiguration: &emr.EbsConfiguration{ - EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{ - { // Required - VolumeSpecification: &emr.VolumeSpecification{ // Required - SizeInGB: aws.Int64(1), // Required - VolumeType: aws.String("String"), // Required - Iops: aws.Int64(1), - }, - VolumesPerInstance: aws.Int64(1), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), - }, - WeightedCapacity: aws.Int64(1), - }, - // More values... - }, - LaunchSpecifications: &emr.InstanceFleetProvisioningSpecifications{ - SpotSpecification: &emr.SpotProvisioningSpecification{ // Required - TimeoutAction: aws.String("SpotProvisioningTimeoutAction"), // Required - TimeoutDurationMinutes: aws.Int64(1), // Required - BlockDurationMinutes: aws.Int64(1), - }, - }, - Name: aws.String("XmlStringMaxLen256"), - TargetOnDemandCapacity: aws.Int64(1), - TargetSpotCapacity: aws.Int64(1), - }, - // More values... - }, - InstanceGroups: []*emr.InstanceGroupConfig{ - { // Required - InstanceCount: aws.Int64(1), // Required - InstanceRole: aws.String("InstanceRoleType"), // Required - InstanceType: aws.String("InstanceType"), // Required - AutoScalingPolicy: &emr.AutoScalingPolicy{ - Constraints: &emr.ScalingConstraints{ // Required - MaxCapacity: aws.Int64(1), // Required - MinCapacity: aws.Int64(1), // Required - }, - Rules: []*emr.ScalingRule{ // Required - { // Required - Action: &emr.ScalingAction{ // Required - SimpleScalingPolicyConfiguration: &emr.SimpleScalingPolicyConfiguration{ // Required - ScalingAdjustment: aws.Int64(1), // Required - AdjustmentType: aws.String("AdjustmentType"), - CoolDown: aws.Int64(1), - }, - Market: aws.String("MarketType"), - }, - Name: aws.String("String"), // Required - Trigger: &emr.ScalingTrigger{ // Required - CloudWatchAlarmDefinition: &emr.CloudWatchAlarmDefinition{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - MetricName: aws.String("String"), // Required - Period: aws.Int64(1), // Required - Threshold: aws.Float64(1.0), // Required - Dimensions: []*emr.MetricDimension{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - EvaluationPeriods: aws.Int64(1), - Namespace: aws.String("String"), - Statistic: aws.String("Statistic"), - Unit: aws.String("Unit"), - }, - }, - Description: aws.String("String"), - }, - // More values... - }, - }, - BidPrice: aws.String("XmlStringMaxLen256"), - Configurations: []*emr.Configuration{ - { // Required - Classification: aws.String("String"), - Configurations: []*emr.Configuration{ - // Recursive values... - }, - Properties: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - EbsConfiguration: &emr.EbsConfiguration{ - EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{ - { // Required - VolumeSpecification: &emr.VolumeSpecification{ // Required - SizeInGB: aws.Int64(1), // Required - VolumeType: aws.String("String"), // Required - Iops: aws.Int64(1), - }, - VolumesPerInstance: aws.Int64(1), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), - }, - Market: aws.String("MarketType"), - Name: aws.String("XmlStringMaxLen256"), - }, - // More values... - }, - KeepJobFlowAliveWhenNoSteps: aws.Bool(true), - MasterInstanceType: aws.String("InstanceType"), - Placement: &emr.PlacementType{ - AvailabilityZone: aws.String("XmlString"), - AvailabilityZones: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - }, - ServiceAccessSecurityGroup: aws.String("XmlStringMaxLen256"), - SlaveInstanceType: aws.String("InstanceType"), - TerminationProtected: aws.Bool(true), - }, - Name: aws.String("XmlStringMaxLen256"), // Required - AdditionalInfo: aws.String("XmlString"), - AmiVersion: aws.String("XmlStringMaxLen256"), - Applications: []*emr.Application{ - { // Required - AdditionalInfo: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - Args: []*string{ - aws.String("String"), // Required - // More values... - }, - Name: aws.String("String"), - Version: aws.String("String"), - }, - // More values... - }, - AutoScalingRole: aws.String("XmlString"), - BootstrapActions: []*emr.BootstrapActionConfig{ - { // Required - Name: aws.String("XmlStringMaxLen256"), // Required - ScriptBootstrapAction: &emr.ScriptBootstrapActionConfig{ // Required - Path: aws.String("XmlString"), // Required - Args: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - }, - }, - // More values... - }, - Configurations: []*emr.Configuration{ - { // Required - Classification: aws.String("String"), - Configurations: []*emr.Configuration{ - // Recursive values... - }, - Properties: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - JobFlowRole: aws.String("XmlString"), - LogUri: aws.String("XmlString"), - NewSupportedProducts: []*emr.SupportedProductConfig{ - { // Required - Args: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - Name: aws.String("XmlStringMaxLen256"), - }, - // More values... - }, - ReleaseLabel: aws.String("XmlStringMaxLen256"), - ScaleDownBehavior: aws.String("ScaleDownBehavior"), - SecurityConfiguration: aws.String("XmlString"), - ServiceRole: aws.String("XmlString"), - Steps: []*emr.StepConfig{ - { // Required - HadoopJarStep: &emr.HadoopJarStepConfig{ // Required - Jar: aws.String("XmlString"), // Required - Args: []*string{ - aws.String("XmlString"), // Required - // More values... - }, - MainClass: aws.String("XmlString"), - Properties: []*emr.KeyValue{ - { // Required - Key: aws.String("XmlString"), - Value: aws.String("XmlString"), - }, - // More values... - }, - }, - Name: aws.String("XmlStringMaxLen256"), // Required - ActionOnFailure: aws.String("ActionOnFailure"), - }, - // More values... - }, - SupportedProducts: []*string{ - aws.String("XmlStringMaxLen256"), // Required - // More values... - }, - Tags: []*emr.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - VisibleToAllUsers: aws.Bool(true), - } - resp, err := svc.RunJobFlow(params) - - if err != nil { - // 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) -} - -func ExampleEMR_SetTerminationProtection() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.SetTerminationProtectionInput{ - JobFlowIds: []*string{ // Required - aws.String("XmlString"), // Required - // More values... - }, - TerminationProtected: aws.Bool(true), // Required - } - resp, err := svc.SetTerminationProtection(params) - - if err != nil { - // 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) -} - -func ExampleEMR_SetVisibleToAllUsers() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.SetVisibleToAllUsersInput{ - JobFlowIds: []*string{ // Required - aws.String("XmlString"), // Required - // More values... - }, - VisibleToAllUsers: aws.Bool(true), // Required - } - resp, err := svc.SetVisibleToAllUsers(params) - - if err != nil { - // 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) -} - -func ExampleEMR_TerminateJobFlows() { - sess := session.Must(session.NewSession()) - - svc := emr.New(sess) - - params := &emr.TerminateJobFlowsInput{ - JobFlowIds: []*string{ // Required - aws.String("XmlString"), // Required - // More values... - }, - } - resp, err := svc.TerminateJobFlows(params) - - if err != nil { - // 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) -} diff --git a/service/firehose/examples_test.go b/service/firehose/examples_test.go deleted file mode 100644 index 194e29c683d..00000000000 --- a/service/firehose/examples_test.go +++ /dev/null @@ -1,606 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package firehose_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/firehose" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleFirehose_CreateDeliveryStream() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.CreateDeliveryStreamInput{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - ElasticsearchDestinationConfiguration: &firehose.ElasticsearchDestinationConfiguration{ - DomainARN: aws.String("ElasticsearchDomainARN"), // Required - IndexName: aws.String("ElasticsearchIndexName"), // Required - RoleARN: aws.String("RoleARN"), // Required - S3Configuration: &firehose.S3DestinationConfiguration{ // Required - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - }, - TypeName: aws.String("ElasticsearchTypeName"), // Required - BufferingHints: &firehose.ElasticsearchBufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - IndexRotationPeriod: aws.String("ElasticsearchIndexRotationPeriod"), - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - RetryOptions: &firehose.ElasticsearchRetryOptions{ - DurationInSeconds: aws.Int64(1), - }, - S3BackupMode: aws.String("ElasticsearchS3BackupMode"), - }, - ExtendedS3DestinationConfiguration: &firehose.ExtendedS3DestinationConfiguration{ - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - S3BackupConfiguration: &firehose.S3DestinationConfiguration{ - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - }, - S3BackupMode: aws.String("S3BackupMode"), - }, - RedshiftDestinationConfiguration: &firehose.RedshiftDestinationConfiguration{ - ClusterJDBCURL: aws.String("ClusterJDBCURL"), // Required - CopyCommand: &firehose.CopyCommand{ // Required - DataTableName: aws.String("DataTableName"), // Required - CopyOptions: aws.String("CopyOptions"), - DataTableColumns: aws.String("DataTableColumns"), - }, - Password: aws.String("Password"), // Required - RoleARN: aws.String("RoleARN"), // Required - S3Configuration: &firehose.S3DestinationConfiguration{ // Required - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - }, - Username: aws.String("Username"), // Required - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - RetryOptions: &firehose.RedshiftRetryOptions{ - DurationInSeconds: aws.Int64(1), - }, - S3BackupConfiguration: &firehose.S3DestinationConfiguration{ - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - }, - S3BackupMode: aws.String("RedshiftS3BackupMode"), - }, - S3DestinationConfiguration: &firehose.S3DestinationConfiguration{ - BucketARN: aws.String("BucketARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - }, - } - resp, err := svc.CreateDeliveryStream(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_DeleteDeliveryStream() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.DeleteDeliveryStreamInput{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - } - resp, err := svc.DeleteDeliveryStream(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_DescribeDeliveryStream() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.DescribeDeliveryStreamInput{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - ExclusiveStartDestinationId: aws.String("DestinationId"), - Limit: aws.Int64(1), - } - resp, err := svc.DescribeDeliveryStream(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_ListDeliveryStreams() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.ListDeliveryStreamsInput{ - ExclusiveStartDeliveryStreamName: aws.String("DeliveryStreamName"), - Limit: aws.Int64(1), - } - resp, err := svc.ListDeliveryStreams(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_PutRecord() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.PutRecordInput{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - Record: &firehose.Record{ // Required - Data: []byte("PAYLOAD"), // Required - }, - } - resp, err := svc.PutRecord(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_PutRecordBatch() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.PutRecordBatchInput{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - Records: []*firehose.Record{ // Required - { // Required - Data: []byte("PAYLOAD"), // Required - }, - // More values... - }, - } - resp, err := svc.PutRecordBatch(params) - - if err != nil { - // 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) -} - -func ExampleFirehose_UpdateDestination() { - sess := session.Must(session.NewSession()) - - svc := firehose.New(sess) - - params := &firehose.UpdateDestinationInput{ - CurrentDeliveryStreamVersionId: aws.String("DeliveryStreamVersionId"), // Required - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - DestinationId: aws.String("DestinationId"), // Required - ElasticsearchDestinationUpdate: &firehose.ElasticsearchDestinationUpdate{ - BufferingHints: &firehose.ElasticsearchBufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - DomainARN: aws.String("ElasticsearchDomainARN"), - IndexName: aws.String("ElasticsearchIndexName"), - IndexRotationPeriod: aws.String("ElasticsearchIndexRotationPeriod"), - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - RetryOptions: &firehose.ElasticsearchRetryOptions{ - DurationInSeconds: aws.Int64(1), - }, - RoleARN: aws.String("RoleARN"), - S3Update: &firehose.S3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - RoleARN: aws.String("RoleARN"), - }, - TypeName: aws.String("ElasticsearchTypeName"), - }, - ExtendedS3DestinationUpdate: &firehose.ExtendedS3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - RoleARN: aws.String("RoleARN"), - S3BackupMode: aws.String("S3BackupMode"), - S3BackupUpdate: &firehose.S3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - RoleARN: aws.String("RoleARN"), - }, - }, - RedshiftDestinationUpdate: &firehose.RedshiftDestinationUpdate{ - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - ClusterJDBCURL: aws.String("ClusterJDBCURL"), - CopyCommand: &firehose.CopyCommand{ - DataTableName: aws.String("DataTableName"), // Required - CopyOptions: aws.String("CopyOptions"), - DataTableColumns: aws.String("DataTableColumns"), - }, - Password: aws.String("Password"), - ProcessingConfiguration: &firehose.ProcessingConfiguration{ - Enabled: aws.Bool(true), - Processors: []*firehose.Processor{ - { // Required - Type: aws.String("ProcessorType"), // Required - Parameters: []*firehose.ProcessorParameter{ - { // Required - ParameterName: aws.String("ProcessorParameterName"), // Required - ParameterValue: aws.String("ProcessorParameterValue"), // Required - }, - // More values... - }, - }, - // More values... - }, - }, - RetryOptions: &firehose.RedshiftRetryOptions{ - DurationInSeconds: aws.Int64(1), - }, - RoleARN: aws.String("RoleARN"), - S3BackupMode: aws.String("RedshiftS3BackupMode"), - S3BackupUpdate: &firehose.S3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - RoleARN: aws.String("RoleARN"), - }, - S3Update: &firehose.S3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - RoleARN: aws.String("RoleARN"), - }, - Username: aws.String("Username"), - }, - S3DestinationUpdate: &firehose.S3DestinationUpdate{ - BucketARN: aws.String("BucketARN"), - BufferingHints: &firehose.BufferingHints{ - IntervalInSeconds: aws.Int64(1), - SizeInMBs: aws.Int64(1), - }, - CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{ - Enabled: aws.Bool(true), - LogGroupName: aws.String("LogGroupName"), - LogStreamName: aws.String("LogStreamName"), - }, - CompressionFormat: aws.String("CompressionFormat"), - EncryptionConfiguration: &firehose.EncryptionConfiguration{ - KMSEncryptionConfig: &firehose.KMSEncryptionConfig{ - AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required - }, - NoEncryptionConfig: aws.String("NoEncryptionConfig"), - }, - Prefix: aws.String("Prefix"), - RoleARN: aws.String("RoleARN"), - }, - } - resp, err := svc.UpdateDestination(params) - - if err != nil { - // 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) -} diff --git a/service/gamelift/examples_test.go b/service/gamelift/examples_test.go deleted file mode 100644 index c871a86d7cd..00000000000 --- a/service/gamelift/examples_test.go +++ /dev/null @@ -1,1254 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package gamelift_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/gamelift" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleGameLift_CreateAlias() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreateAliasInput{ - Name: aws.String("NonBlankAndLengthConstraintString"), // Required - RoutingStrategy: &gamelift.RoutingStrategy{ // Required - FleetId: aws.String("FleetId"), - Message: aws.String("FreeText"), - Type: aws.String("RoutingStrategyType"), - }, - Description: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.CreateAlias(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreateBuild() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreateBuildInput{ - Name: aws.String("NonZeroAndMaxString"), - OperatingSystem: aws.String("OperatingSystem"), - StorageLocation: &gamelift.S3Location{ - Bucket: aws.String("NonEmptyString"), - Key: aws.String("NonEmptyString"), - RoleArn: aws.String("NonEmptyString"), - }, - Version: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.CreateBuild(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreateFleet() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreateFleetInput{ - BuildId: aws.String("BuildId"), // Required - EC2InstanceType: aws.String("EC2InstanceType"), // Required - Name: aws.String("NonZeroAndMaxString"), // Required - Description: aws.String("NonZeroAndMaxString"), - EC2InboundPermissions: []*gamelift.IpPermission{ - { // Required - FromPort: aws.Int64(1), // Required - IpRange: aws.String("NonBlankString"), // Required - Protocol: aws.String("IpProtocol"), // Required - ToPort: aws.Int64(1), // Required - }, - // More values... - }, - LogPaths: []*string{ - aws.String("NonZeroAndMaxString"), // Required - // More values... - }, - MetricGroups: []*string{ - aws.String("MetricGroup"), // Required - // More values... - }, - NewGameSessionProtectionPolicy: aws.String("ProtectionPolicy"), - ResourceCreationLimitPolicy: &gamelift.ResourceCreationLimitPolicy{ - NewGameSessionsPerCreator: aws.Int64(1), - PolicyPeriodInMinutes: aws.Int64(1), - }, - RuntimeConfiguration: &gamelift.RuntimeConfiguration{ - GameSessionActivationTimeoutSeconds: aws.Int64(1), - MaxConcurrentGameSessionActivations: aws.Int64(1), - ServerProcesses: []*gamelift.ServerProcess{ - { // Required - ConcurrentExecutions: aws.Int64(1), // Required - LaunchPath: aws.String("NonZeroAndMaxString"), // Required - Parameters: aws.String("NonZeroAndMaxString"), - }, - // More values... - }, - }, - ServerLaunchParameters: aws.String("NonZeroAndMaxString"), - ServerLaunchPath: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.CreateFleet(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreateGameSession() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreateGameSessionInput{ - MaximumPlayerSessionCount: aws.Int64(1), // Required - AliasId: aws.String("AliasId"), - CreatorId: aws.String("NonZeroAndMaxString"), - FleetId: aws.String("FleetId"), - GameProperties: []*gamelift.GameProperty{ - { // Required - Key: aws.String("GamePropertyKey"), // Required - Value: aws.String("GamePropertyValue"), // Required - }, - // More values... - }, - GameSessionId: aws.String("IdStringModel"), - IdempotencyToken: aws.String("IdStringModel"), - Name: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.CreateGameSession(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreateGameSessionQueue() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreateGameSessionQueueInput{ - Name: aws.String("GameSessionQueueName"), // Required - Destinations: []*gamelift.GameSessionQueueDestination{ - { // Required - DestinationArn: aws.String("ArnStringModel"), - }, - // More values... - }, - PlayerLatencyPolicies: []*gamelift.PlayerLatencyPolicy{ - { // Required - MaximumIndividualPlayerLatencyMilliseconds: aws.Int64(1), - PolicyDurationSeconds: aws.Int64(1), - }, - // More values... - }, - TimeoutInSeconds: aws.Int64(1), - } - resp, err := svc.CreateGameSessionQueue(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreatePlayerSession() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreatePlayerSessionInput{ - GameSessionId: aws.String("ArnStringModel"), // Required - PlayerId: aws.String("NonZeroAndMaxString"), // Required - PlayerData: aws.String("PlayerData"), - } - resp, err := svc.CreatePlayerSession(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_CreatePlayerSessions() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.CreatePlayerSessionsInput{ - GameSessionId: aws.String("ArnStringModel"), // Required - PlayerIds: []*string{ // Required - aws.String("NonZeroAndMaxString"), // Required - // More values... - }, - PlayerDataMap: map[string]*string{ - "Key": aws.String("PlayerData"), // Required - // More values... - }, - } - resp, err := svc.CreatePlayerSessions(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DeleteAlias() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DeleteAliasInput{ - AliasId: aws.String("AliasId"), // Required - } - resp, err := svc.DeleteAlias(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DeleteBuild() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DeleteBuildInput{ - BuildId: aws.String("BuildId"), // Required - } - resp, err := svc.DeleteBuild(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DeleteFleet() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DeleteFleetInput{ - FleetId: aws.String("FleetId"), // Required - } - resp, err := svc.DeleteFleet(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DeleteGameSessionQueue() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DeleteGameSessionQueueInput{ - Name: aws.String("GameSessionQueueName"), // Required - } - resp, err := svc.DeleteGameSessionQueue(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DeleteScalingPolicy() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DeleteScalingPolicyInput{ - FleetId: aws.String("FleetId"), // Required - Name: aws.String("NonZeroAndMaxString"), // Required - } - resp, err := svc.DeleteScalingPolicy(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeAlias() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeAliasInput{ - AliasId: aws.String("AliasId"), // Required - } - resp, err := svc.DescribeAlias(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeBuild() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeBuildInput{ - BuildId: aws.String("BuildId"), // Required - } - resp, err := svc.DescribeBuild(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeEC2InstanceLimits() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeEC2InstanceLimitsInput{ - EC2InstanceType: aws.String("EC2InstanceType"), - } - resp, err := svc.DescribeEC2InstanceLimits(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeFleetAttributes() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeFleetAttributesInput{ - FleetIds: []*string{ - aws.String("FleetId"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeFleetAttributes(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeFleetCapacity() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeFleetCapacityInput{ - FleetIds: []*string{ - aws.String("FleetId"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeFleetCapacity(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeFleetEvents() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeFleetEventsInput{ - FleetId: aws.String("FleetId"), // Required - EndTime: aws.Time(time.Now()), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.DescribeFleetEvents(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeFleetPortSettings() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeFleetPortSettingsInput{ - FleetId: aws.String("FleetId"), // Required - } - resp, err := svc.DescribeFleetPortSettings(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeFleetUtilization() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeFleetUtilizationInput{ - FleetIds: []*string{ - aws.String("FleetId"), // Required - // More values... - }, - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeFleetUtilization(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeGameSessionDetails() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeGameSessionDetailsInput{ - AliasId: aws.String("AliasId"), - FleetId: aws.String("FleetId"), - GameSessionId: aws.String("ArnStringModel"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - StatusFilter: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeGameSessionDetails(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeGameSessionPlacement() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeGameSessionPlacementInput{ - PlacementId: aws.String("IdStringModel"), // Required - } - resp, err := svc.DescribeGameSessionPlacement(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeGameSessionQueues() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeGameSessionQueuesInput{ - Limit: aws.Int64(1), - Names: []*string{ - aws.String("GameSessionQueueName"), // Required - // More values... - }, - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeGameSessionQueues(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeGameSessions() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeGameSessionsInput{ - AliasId: aws.String("AliasId"), - FleetId: aws.String("FleetId"), - GameSessionId: aws.String("ArnStringModel"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - StatusFilter: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeGameSessions(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeInstances() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeInstancesInput{ - FleetId: aws.String("FleetId"), // Required - InstanceId: aws.String("InstanceId"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribeInstances(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribePlayerSessions() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribePlayerSessionsInput{ - GameSessionId: aws.String("ArnStringModel"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - PlayerId: aws.String("NonZeroAndMaxString"), - PlayerSessionId: aws.String("PlayerSessionId"), - PlayerSessionStatusFilter: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.DescribePlayerSessions(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeRuntimeConfiguration() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeRuntimeConfigurationInput{ - FleetId: aws.String("FleetId"), // Required - } - resp, err := svc.DescribeRuntimeConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_DescribeScalingPolicies() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.DescribeScalingPoliciesInput{ - FleetId: aws.String("FleetId"), // Required - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - StatusFilter: aws.String("ScalingStatusType"), - } - resp, err := svc.DescribeScalingPolicies(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_GetGameSessionLogUrl() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.GetGameSessionLogUrlInput{ - GameSessionId: aws.String("ArnStringModel"), // Required - } - resp, err := svc.GetGameSessionLogUrl(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_GetInstanceAccess() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.GetInstanceAccessInput{ - FleetId: aws.String("FleetId"), // Required - InstanceId: aws.String("InstanceId"), // Required - } - resp, err := svc.GetInstanceAccess(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_ListAliases() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.ListAliasesInput{ - Limit: aws.Int64(1), - Name: aws.String("NonEmptyString"), - NextToken: aws.String("NonEmptyString"), - RoutingStrategyType: aws.String("RoutingStrategyType"), - } - resp, err := svc.ListAliases(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_ListBuilds() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.ListBuildsInput{ - Limit: aws.Int64(1), - NextToken: aws.String("NonEmptyString"), - Status: aws.String("BuildStatus"), - } - resp, err := svc.ListBuilds(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_ListFleets() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.ListFleetsInput{ - BuildId: aws.String("BuildId"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.ListFleets(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_PutScalingPolicy() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.PutScalingPolicyInput{ - ComparisonOperator: aws.String("ComparisonOperatorType"), // Required - EvaluationPeriods: aws.Int64(1), // Required - FleetId: aws.String("FleetId"), // Required - MetricName: aws.String("MetricName"), // Required - Name: aws.String("NonZeroAndMaxString"), // Required - ScalingAdjustment: aws.Int64(1), // Required - ScalingAdjustmentType: aws.String("ScalingAdjustmentType"), // Required - Threshold: aws.Float64(1.0), // Required - } - resp, err := svc.PutScalingPolicy(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_RequestUploadCredentials() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.RequestUploadCredentialsInput{ - BuildId: aws.String("BuildId"), // Required - } - resp, err := svc.RequestUploadCredentials(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_ResolveAlias() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.ResolveAliasInput{ - AliasId: aws.String("AliasId"), // Required - } - resp, err := svc.ResolveAlias(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_SearchGameSessions() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.SearchGameSessionsInput{ - AliasId: aws.String("AliasId"), - FilterExpression: aws.String("NonZeroAndMaxString"), - FleetId: aws.String("FleetId"), - Limit: aws.Int64(1), - NextToken: aws.String("NonZeroAndMaxString"), - SortExpression: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.SearchGameSessions(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_StartGameSessionPlacement() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.StartGameSessionPlacementInput{ - GameSessionQueueName: aws.String("GameSessionQueueName"), // Required - MaximumPlayerSessionCount: aws.Int64(1), // Required - PlacementId: aws.String("IdStringModel"), // Required - DesiredPlayerSessions: []*gamelift.DesiredPlayerSession{ - { // Required - PlayerData: aws.String("PlayerData"), - PlayerId: aws.String("NonZeroAndMaxString"), - }, - // More values... - }, - GameProperties: []*gamelift.GameProperty{ - { // Required - Key: aws.String("GamePropertyKey"), // Required - Value: aws.String("GamePropertyValue"), // Required - }, - // More values... - }, - GameSessionName: aws.String("NonZeroAndMaxString"), - PlayerLatencies: []*gamelift.PlayerLatency{ - { // Required - LatencyInMilliseconds: aws.Float64(1.0), - PlayerId: aws.String("NonZeroAndMaxString"), - RegionIdentifier: aws.String("NonZeroAndMaxString"), - }, - // More values... - }, - } - resp, err := svc.StartGameSessionPlacement(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_StopGameSessionPlacement() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.StopGameSessionPlacementInput{ - PlacementId: aws.String("IdStringModel"), // Required - } - resp, err := svc.StopGameSessionPlacement(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateAlias() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateAliasInput{ - AliasId: aws.String("AliasId"), // Required - Description: aws.String("NonZeroAndMaxString"), - Name: aws.String("NonBlankAndLengthConstraintString"), - RoutingStrategy: &gamelift.RoutingStrategy{ - FleetId: aws.String("FleetId"), - Message: aws.String("FreeText"), - Type: aws.String("RoutingStrategyType"), - }, - } - resp, err := svc.UpdateAlias(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateBuild() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateBuildInput{ - BuildId: aws.String("BuildId"), // Required - Name: aws.String("NonZeroAndMaxString"), - Version: aws.String("NonZeroAndMaxString"), - } - resp, err := svc.UpdateBuild(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateFleetAttributes() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateFleetAttributesInput{ - FleetId: aws.String("FleetId"), // Required - Description: aws.String("NonZeroAndMaxString"), - MetricGroups: []*string{ - aws.String("MetricGroup"), // Required - // More values... - }, - Name: aws.String("NonZeroAndMaxString"), - NewGameSessionProtectionPolicy: aws.String("ProtectionPolicy"), - ResourceCreationLimitPolicy: &gamelift.ResourceCreationLimitPolicy{ - NewGameSessionsPerCreator: aws.Int64(1), - PolicyPeriodInMinutes: aws.Int64(1), - }, - } - resp, err := svc.UpdateFleetAttributes(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateFleetCapacity() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateFleetCapacityInput{ - FleetId: aws.String("FleetId"), // Required - DesiredInstances: aws.Int64(1), - MaxSize: aws.Int64(1), - MinSize: aws.Int64(1), - } - resp, err := svc.UpdateFleetCapacity(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateFleetPortSettings() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateFleetPortSettingsInput{ - FleetId: aws.String("FleetId"), // Required - InboundPermissionAuthorizations: []*gamelift.IpPermission{ - { // Required - FromPort: aws.Int64(1), // Required - IpRange: aws.String("NonBlankString"), // Required - Protocol: aws.String("IpProtocol"), // Required - ToPort: aws.Int64(1), // Required - }, - // More values... - }, - InboundPermissionRevocations: []*gamelift.IpPermission{ - { // Required - FromPort: aws.Int64(1), // Required - IpRange: aws.String("NonBlankString"), // Required - Protocol: aws.String("IpProtocol"), // Required - ToPort: aws.Int64(1), // Required - }, - // More values... - }, - } - resp, err := svc.UpdateFleetPortSettings(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateGameSession() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateGameSessionInput{ - GameSessionId: aws.String("ArnStringModel"), // Required - MaximumPlayerSessionCount: aws.Int64(1), - Name: aws.String("NonZeroAndMaxString"), - PlayerSessionCreationPolicy: aws.String("PlayerSessionCreationPolicy"), - ProtectionPolicy: aws.String("ProtectionPolicy"), - } - resp, err := svc.UpdateGameSession(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateGameSessionQueue() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateGameSessionQueueInput{ - Name: aws.String("GameSessionQueueName"), // Required - Destinations: []*gamelift.GameSessionQueueDestination{ - { // Required - DestinationArn: aws.String("ArnStringModel"), - }, - // More values... - }, - PlayerLatencyPolicies: []*gamelift.PlayerLatencyPolicy{ - { // Required - MaximumIndividualPlayerLatencyMilliseconds: aws.Int64(1), - PolicyDurationSeconds: aws.Int64(1), - }, - // More values... - }, - TimeoutInSeconds: aws.Int64(1), - } - resp, err := svc.UpdateGameSessionQueue(params) - - if err != nil { - // 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) -} - -func ExampleGameLift_UpdateRuntimeConfiguration() { - sess := session.Must(session.NewSession()) - - svc := gamelift.New(sess) - - params := &gamelift.UpdateRuntimeConfigurationInput{ - FleetId: aws.String("FleetId"), // Required - RuntimeConfiguration: &gamelift.RuntimeConfiguration{ // Required - GameSessionActivationTimeoutSeconds: aws.Int64(1), - MaxConcurrentGameSessionActivations: aws.Int64(1), - ServerProcesses: []*gamelift.ServerProcess{ - { // Required - ConcurrentExecutions: aws.Int64(1), // Required - LaunchPath: aws.String("NonZeroAndMaxString"), // Required - Parameters: aws.String("NonZeroAndMaxString"), - }, - // More values... - }, - }, - } - resp, err := svc.UpdateRuntimeConfiguration(params) - - if err != nil { - // 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) -} diff --git a/service/glacier/examples_test.go b/service/glacier/examples_test.go index b629458c055..fbd8b8d487e 100644 --- a/service/glacier/examples_test.go +++ b/service/glacier/examples_test.go @@ -8,804 +8,1267 @@ import ( "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/glacier" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleGlacier_AbortMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &glacier.AbortMultipartUploadInput{ - AccountId: aws.String("string"), // Required - UploadId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To abort a multipart upload identified by the upload ID +// +// The example deletes an in-progress multipart upload to a vault named my-vault: +func ExampleGlacier_AbortMultipartUpload_shared00() { + svc := glacier.New(session.New()) + input := &glacier.AbortMultipartUploadInput{ + AccountId: aws.String("-"), + UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"), + VaultName: aws.String("my-vault"), } - resp, err := svc.AbortMultipartUpload(params) + result, err := svc.AbortMultipartUpload(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_AbortVaultLock() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.AbortVaultLockInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To abort a vault lock +// +// The example aborts the vault locking process if the vault lock is not in the Locked +// state for the vault named examplevault. +func ExampleGlacier_AbortVaultLock_shared00() { + svc := glacier.New(session.New()) + input := &glacier.AbortVaultLockInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.AbortVaultLock(params) + result, err := svc.AbortVaultLock(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_AddTagsToVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.AddTagsToVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To add tags to a vault +// +// The example adds two tags to a my-vault. +func ExampleGlacier_AddTagsToVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.AddTagsToVaultInput{ Tags: map[string]*string{ - "Key": aws.String("TagValue"), // Required - // More values... + "examplekey1": aws.String("examplevalue1"), + "examplekey2": aws.String("examplevalue2"), }, + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.AddTagsToVault(params) + result, err := svc.AddTagsToVault(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeLimitExceededException: + fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_CompleteMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.CompleteMultipartUploadInput{ - AccountId: aws.String("string"), // Required - UploadId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - ArchiveSize: aws.String("string"), - Checksum: aws.String("string"), +// To complete a multipart upload +// +// The example completes a multipart upload for a 3 MiB archive. +func ExampleGlacier_CompleteMultipartUpload_shared00() { + svc := glacier.New(session.New()) + input := &glacier.CompleteMultipartUploadInput{ + AccountId: aws.String("-"), + ArchiveSize: aws.String("3145728"), + Checksum: aws.String("9628195fcdbcbbe76cdde456d4646fa7de5f219fb39823836d81f0cc0e18aa67"), + UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"), + VaultName: aws.String("my-vault"), } - resp, err := svc.CompleteMultipartUpload(params) + result, err := svc.CompleteMultipartUpload(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_CompleteVaultLock() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.CompleteVaultLockInput{ - AccountId: aws.String("string"), // Required - LockId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To complete a vault lock +// +// The example completes the vault locking process by transitioning the vault lock from +// the InProgress state to the Locked state. +func ExampleGlacier_CompleteVaultLock_shared00() { + svc := glacier.New(session.New()) + input := &glacier.CompleteVaultLockInput{ + AccountId: aws.String("-"), + LockId: aws.String("AE863rKkWZU53SLW5be4DUcW"), + VaultName: aws.String("example-vault"), } - resp, err := svc.CompleteVaultLock(params) + result, err := svc.CompleteVaultLock(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_CreateVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.CreateVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To create a new vault +// +// The following example creates a new vault named my-vault. +func ExampleGlacier_CreateVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.CreateVaultInput{ + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.CreateVault(params) + result, err := svc.CreateVault(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error()) + case glacier.ErrCodeLimitExceededException: + fmt.Println(glacier.ErrCodeLimitExceededException, 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 ExampleGlacier_DeleteArchive() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DeleteArchiveInput{ - AccountId: aws.String("string"), // Required - ArchiveId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To delete an archive +// +// The example deletes the archive specified by the archive ID. +func ExampleGlacier_DeleteArchive_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DeleteArchiveInput{ + AccountId: aws.String("-"), + ArchiveId: aws.String("NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId"), + VaultName: aws.String("examplevault"), } - resp, err := svc.DeleteArchive(params) + result, err := svc.DeleteArchive(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_DeleteVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DeleteVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To delete a vault +// +// The example deletes a vault named my-vault: +func ExampleGlacier_DeleteVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DeleteVaultInput{ + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.DeleteVault(params) + result, err := svc.DeleteVault(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_DeleteVaultAccessPolicy() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DeleteVaultAccessPolicyInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To delete the vault access policy +// +// The example deletes the access policy associated with the vault named examplevault. +func ExampleGlacier_DeleteVaultAccessPolicy_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DeleteVaultAccessPolicyInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.DeleteVaultAccessPolicy(params) + result, err := svc.DeleteVaultAccessPolicy(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_DeleteVaultNotifications() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DeleteVaultNotificationsInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To delete the notification configuration set for a vault +// +// The example deletes the notification configuration set for the vault named examplevault. +func ExampleGlacier_DeleteVaultNotifications_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DeleteVaultNotificationsInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.DeleteVaultNotifications(params) + result, err := svc.DeleteVaultNotifications(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_DescribeJob() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DescribeJobInput{ - AccountId: aws.String("string"), // Required - JobId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To get information about a previously initiated job +// +// The example returns information about the previously initiated job specified by the +// job ID. +func ExampleGlacier_DescribeJob_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DescribeJobInput{ + AccountId: aws.String("-"), + JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4Cn"), + VaultName: aws.String("my-vault"), } - resp, err := svc.DescribeJob(params) + result, err := svc.DescribeJob(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_DescribeVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.DescribeVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To retrieve information about a vault +// +// The example retrieves data about a vault named my-vault. +func ExampleGlacier_DescribeVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.DescribeVaultInput{ + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.DescribeVault(params) + result, err := svc.DescribeVault(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_GetDataRetrievalPolicy() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.GetDataRetrievalPolicyInput{ - AccountId: aws.String("string"), // Required +// To get the current data retrieval policy for an account +// +// The example returns the current data retrieval policy for the account. +func ExampleGlacier_GetDataRetrievalPolicy_shared00() { + svc := glacier.New(session.New()) + input := &glacier.GetDataRetrievalPolicyInput{ + AccountId: aws.String("-"), } - resp, err := svc.GetDataRetrievalPolicy(params) + result, err := svc.GetDataRetrievalPolicy(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_GetJobOutput() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.GetJobOutputInput{ - AccountId: aws.String("string"), // Required - JobId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - Range: aws.String("string"), +// To get the output of a previously initiated job +// +// The example downloads the output of a previously initiated inventory retrieval job +// that is identified by the job ID. +func ExampleGlacier_GetJobOutput_shared00() { + svc := glacier.New(session.New()) + input := &glacier.GetJobOutputInput{ + AccountId: aws.String("-"), + JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW"), + Range: aws.String(""), + VaultName: aws.String("my-vaul"), } - resp, err := svc.GetJobOutput(params) + result, err := svc.GetJobOutput(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_GetVaultAccessPolicy() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.GetVaultAccessPolicyInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To get the access-policy set on the vault +// +// The example retrieves the access-policy set on the vault named example-vault. +func ExampleGlacier_GetVaultAccessPolicy_shared00() { + svc := glacier.New(session.New()) + input := &glacier.GetVaultAccessPolicyInput{ + AccountId: aws.String("-"), + VaultName: aws.String("example-vault"), } - resp, err := svc.GetVaultAccessPolicy(params) + result, err := svc.GetVaultAccessPolicy(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_GetVaultLock() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.GetVaultLockInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To retrieve vault lock-policy related attributes that are set on a vault +// +// The example retrieves the attributes from the lock-policy subresource set on the +// vault named examplevault. +func ExampleGlacier_GetVaultLock_shared00() { + svc := glacier.New(session.New()) + input := &glacier.GetVaultLockInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.GetVaultLock(params) + result, err := svc.GetVaultLock(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_GetVaultNotifications() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.GetVaultNotificationsInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To get the notification-configuration for the specified vault +// +// The example retrieves the notification-configuration for the vault named my-vault. +func ExampleGlacier_GetVaultNotifications_shared00() { + svc := glacier.New(session.New()) + input := &glacier.GetVaultNotificationsInput{ + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.GetVaultNotifications(params) + result, err := svc.GetVaultNotifications(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_InitiateJob() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.InitiateJobInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To initiate an inventory-retrieval job +// +// The example initiates an inventory-retrieval job for the vault named examplevault. +func ExampleGlacier_InitiateJob_shared00() { + svc := glacier.New(session.New()) + input := &glacier.InitiateJobInput{ + AccountId: aws.String("-"), JobParameters: &glacier.JobParameters{ - ArchiveId: aws.String("string"), - Description: aws.String("string"), - Format: aws.String("string"), - InventoryRetrievalParameters: &glacier.InventoryRetrievalJobInput{ - EndDate: aws.String("string"), - Limit: aws.String("string"), - Marker: aws.String("string"), - StartDate: aws.String("string"), - }, - RetrievalByteRange: aws.String("string"), - SNSTopic: aws.String("string"), - Tier: aws.String("string"), - Type: aws.String("string"), + Description: aws.String("My inventory job"), + Format: aws.String("CSV"), + SNSTopic: aws.String("arn:aws:sns:us-west-2:111111111111:Glacier-InventoryRetrieval-topic-Example"), + Type: aws.String("inventory-retrieval"), }, + VaultName: aws.String("examplevault"), } - resp, err := svc.InitiateJob(params) + result, err := svc.InitiateJob(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodePolicyEnforcedException: + fmt.Println(glacier.ErrCodePolicyEnforcedException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeInsufficientCapacityException: + fmt.Println(glacier.ErrCodeInsufficientCapacityException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_InitiateMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.InitiateMultipartUploadInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - ArchiveDescription: aws.String("string"), - PartSize: aws.String("string"), +// To initiate a multipart upload +// +// The example initiates a multipart upload to a vault named my-vault with a part size +// of 1 MiB (1024 x 1024 bytes) per file. +func ExampleGlacier_InitiateMultipartUpload_shared00() { + svc := glacier.New(session.New()) + input := &glacier.InitiateMultipartUploadInput{ + AccountId: aws.String("-"), + PartSize: aws.String("1048576"), + VaultName: aws.String("my-vault"), } - resp, err := svc.InitiateMultipartUpload(params) + result, err := svc.InitiateMultipartUpload(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_InitiateVaultLock() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.InitiateVaultLockInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To initiate the vault locking process +// +// The example initiates the vault locking process for the vault named my-vault. +func ExampleGlacier_InitiateVaultLock_shared00() { + svc := glacier.New(session.New()) + input := &glacier.InitiateVaultLockInput{ + AccountId: aws.String("-"), Policy: &glacier.VaultLockPolicy{ - Policy: aws.String("string"), + Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Define-vault-lock\",\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"arn:aws:iam::999999999999:root\"},\"Action\":\"glacier:DeleteArchive\",\"Resource\":\"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault\",\"Condition\":{\"NumericLessThanEquals\":{\"glacier:ArchiveAgeinDays\":\"365\"}}}]}"), }, + VaultName: aws.String("my-vault"), } - resp, err := svc.InitiateVaultLock(params) + result, err := svc.InitiateVaultLock(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListJobs() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListJobsInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - Completed: aws.String("string"), - Limit: aws.String("string"), - Marker: aws.String("string"), - Statuscode: aws.String("string"), +// To list jobs for a vault +// +// The example lists jobs for the vault named my-vault. +func ExampleGlacier_ListJobs_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListJobsInput{ + AccountId: aws.String("-"), + VaultName: aws.String("my-vault"), } - resp, err := svc.ListJobs(params) + result, err := svc.ListJobs(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListMultipartUploads() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListMultipartUploadsInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - Limit: aws.String("string"), - Marker: aws.String("string"), +// To list all the in-progress multipart uploads for a vault +// +// The example lists all the in-progress multipart uploads for the vault named examplevault. +func ExampleGlacier_ListMultipartUploads_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListMultipartUploadsInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.ListMultipartUploads(params) + result, err := svc.ListMultipartUploads(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListParts() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListPartsInput{ - AccountId: aws.String("string"), // Required - UploadId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - Limit: aws.String("string"), - Marker: aws.String("string"), +// To list the parts of an archive that have been uploaded in a multipart upload +// +// The example lists all the parts of a multipart upload. +func ExampleGlacier_ListParts_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListPartsInput{ + AccountId: aws.String("-"), + UploadId: aws.String("OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE"), + VaultName: aws.String("examplevault"), } - resp, err := svc.ListParts(params) + result, err := svc.ListParts(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListProvisionedCapacity() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListProvisionedCapacityInput{ - AccountId: aws.String("string"), // Required +// To list the provisioned capacity units for an account +// +// The example lists the provisioned capacity units for an account. +func ExampleGlacier_ListProvisionedCapacity_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListProvisionedCapacityInput{ + AccountId: aws.String("-"), } - resp, err := svc.ListProvisionedCapacity(params) + result, err := svc.ListProvisionedCapacity(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListTagsForVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListTagsForVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To list the tags for a vault +// +// The example lists all the tags attached to the vault examplevault. +func ExampleGlacier_ListTagsForVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListTagsForVaultInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.ListTagsForVault(params) + result, err := svc.ListTagsForVault(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_ListVaults() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.ListVaultsInput{ - AccountId: aws.String("string"), // Required - Limit: aws.String("string"), - Marker: aws.String("string"), +// To list all vaults owned by the calling user's account +// +// The example lists all vaults owned by the specified AWS account. +func ExampleGlacier_ListVaults_shared00() { + svc := glacier.New(session.New()) + input := &glacier.ListVaultsInput{ + AccountId: aws.String("-"), + Limit: aws.String(""), + Marker: aws.String(""), } - resp, err := svc.ListVaults(params) + result, err := svc.ListVaults(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_PurchaseProvisionedCapacity() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.PurchaseProvisionedCapacityInput{ - AccountId: aws.String("string"), // Required +// To purchases a provisioned capacity unit for an AWS account +// +// The example purchases provisioned capacity unit for an AWS account. +func ExampleGlacier_PurchaseProvisionedCapacity_shared00() { + svc := glacier.New(session.New()) + input := &glacier.PurchaseProvisionedCapacityInput{ + AccountId: aws.String("-"), } - resp, err := svc.PurchaseProvisionedCapacity(params) + result, err := svc.PurchaseProvisionedCapacity(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeLimitExceededException: + fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_RemoveTagsFromVault() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.RemoveTagsFromVaultInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To remove tags from a vault +// +// The example removes two tags from the vault named examplevault. +func ExampleGlacier_RemoveTagsFromVault_shared00() { + svc := glacier.New(session.New()) + input := &glacier.RemoveTagsFromVaultInput{ TagKeys: []*string{ - aws.String("string"), // Required - // More values... + aws.String("examplekey1"), + aws.String("examplekey2"), }, + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), } - resp, err := svc.RemoveTagsFromVault(params) + result, err := svc.RemoveTagsFromVault(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_SetDataRetrievalPolicy() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.SetDataRetrievalPolicyInput{ - AccountId: aws.String("string"), // Required +// To set and then enact a data retrieval policy +// +// The example sets and then enacts a data retrieval policy. +func ExampleGlacier_SetDataRetrievalPolicy_shared00() { + svc := glacier.New(session.New()) + input := &glacier.SetDataRetrievalPolicyInput{ Policy: &glacier.DataRetrievalPolicy{ - Rules: []*glacier.DataRetrievalRule{ - { // Required - BytesPerHour: aws.Int64(1), - Strategy: aws.String("string"), + Rules: []*glacier.DataRetrievalRulesList{ + { + BytesPerHour: aws.Float64(10737418240.000000), + Strategy: aws.String("BytesPerHour"), }, - // More values... }, }, + AccountId: aws.String("-"), } - resp, err := svc.SetDataRetrievalPolicy(params) + result, err := svc.SetDataRetrievalPolicy(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 glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_SetVaultAccessPolicy() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.SetVaultAccessPolicyInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To set the access-policy on a vault +// +// The example configures an access policy for the vault named examplevault. +func ExampleGlacier_SetVaultAccessPolicy_shared00() { + svc := glacier.New(session.New()) + input := &glacier.SetVaultAccessPolicyInput{ + AccountId: aws.String("-"), Policy: &glacier.VaultAccessPolicy{ - Policy: aws.String("string"), + Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Define-owner-access-rights\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::999999999999:root\"},\"Action\":\"glacier:DeleteArchive\",\"Resource\":\"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault\"}]}"), }, + VaultName: aws.String("examplevault"), } - resp, err := svc.SetVaultAccessPolicy(params) + result, err := svc.SetVaultAccessPolicy(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_SetVaultNotifications() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.SetVaultNotificationsInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required +// To configure a vault to post a message to an Amazon SNS topic when jobs complete +// +// The example sets the examplevault notification configuration. +func ExampleGlacier_SetVaultNotifications_shared00() { + svc := glacier.New(session.New()) + input := &glacier.SetVaultNotificationsInput{ + AccountId: aws.String("-"), + VaultName: aws.String("examplevault"), VaultNotificationConfig: &glacier.VaultNotificationConfig{ Events: []*string{ - aws.String("string"), // Required - // More values... + aws.String("ArchiveRetrievalCompleted"), + aws.String("InventoryRetrievalCompleted"), }, - SNSTopic: aws.String("string"), + SNSTopic: aws.String("arn:aws:sns:us-west-2:012345678901:mytopic"), }, } - resp, err := svc.SetVaultNotifications(params) + result, err := svc.SetVaultNotifications(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_UploadArchive() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.UploadArchiveInput{ - AccountId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - ArchiveDescription: aws.String("string"), - Body: bytes.NewReader([]byte("PAYLOAD")), - Checksum: aws.String("string"), +// To upload an archive +// +// The example adds an archive to a vault. +func ExampleGlacier_UploadArchive_shared00() { + svc := glacier.New(session.New()) + input := &glacier.UploadArchiveInput{ + AccountId: aws.String("-"), + ArchiveDescription: aws.String(""), + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("example-data-to-upload"))), + Checksum: aws.String(""), + VaultName: aws.String("my-vault"), } - resp, err := svc.UploadArchive(params) + result, err := svc.UploadArchive(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeRequestTimeoutException: + fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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 ExampleGlacier_UploadMultipartPart() { - sess := session.Must(session.NewSession()) - - svc := glacier.New(sess) - - params := &glacier.UploadMultipartPartInput{ - AccountId: aws.String("string"), // Required - UploadId: aws.String("string"), // Required - VaultName: aws.String("string"), // Required - Body: bytes.NewReader([]byte("PAYLOAD")), - Checksum: aws.String("string"), - Range: aws.String("string"), - } - resp, err := svc.UploadMultipartPart(params) - +// To upload the first part of an archive +// +// The example uploads the first 1 MiB (1024 x 1024 bytes) part of an archive. +func ExampleGlacier_UploadMultipartPart_shared00() { + svc := glacier.New(session.New()) + input := &glacier.UploadMultipartPartInput{ + AccountId: aws.String("-"), + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("part1"))), + Checksum: aws.String("c06f7cd4baacb087002a99a5f48bf953"), + Range: aws.String("bytes 0-1048575/*"), + UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"), + VaultName: aws.String("examplevault"), + } + + result, err := svc.UploadMultipartPart(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 glacier.ErrCodeResourceNotFoundException: + fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error()) + case glacier.ErrCodeInvalidParameterValueException: + fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error()) + case glacier.ErrCodeMissingParameterValueException: + fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error()) + case glacier.ErrCodeRequestTimeoutException: + fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error()) + case glacier.ErrCodeServiceUnavailableException: + fmt.Println(glacier.ErrCodeServiceUnavailableException, 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) } diff --git a/service/health/examples_test.go b/service/health/examples_test.go deleted file mode 100644 index c123110944a..00000000000 --- a/service/health/examples_test.go +++ /dev/null @@ -1,335 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package health_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/health" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleHealth_DescribeAffectedEntities() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeAffectedEntitiesInput{ - Filter: &health.EntityFilter{ // Required - EventArns: []*string{ // Required - aws.String("eventArn"), // Required - // More values... - }, - EntityArns: []*string{ - aws.String("entityArn"), // Required - // More values... - }, - EntityValues: []*string{ - aws.String("entityValue"), // Required - // More values... - }, - LastUpdatedTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - StatusCodes: []*string{ - aws.String("entityStatusCode"), // Required - // More values... - }, - Tags: []map[string]*string{ - { // Required - "Key": aws.String("tagValue"), // Required - // More values... - }, - // More values... - }, - }, - Locale: aws.String("locale"), - MaxResults: aws.Int64(1), - NextToken: aws.String("nextToken"), - } - resp, err := svc.DescribeAffectedEntities(params) - - if err != nil { - // 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) -} - -func ExampleHealth_DescribeEntityAggregates() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeEntityAggregatesInput{ - EventArns: []*string{ - aws.String("eventArn"), // Required - // More values... - }, - } - resp, err := svc.DescribeEntityAggregates(params) - - if err != nil { - // 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) -} - -func ExampleHealth_DescribeEventAggregates() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeEventAggregatesInput{ - AggregateField: aws.String("eventAggregateField"), // Required - Filter: &health.EventFilter{ - AvailabilityZones: []*string{ - aws.String("availabilityZone"), // Required - // More values... - }, - EndTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - EntityArns: []*string{ - aws.String("entityArn"), // Required - // More values... - }, - EntityValues: []*string{ - aws.String("entityValue"), // Required - // More values... - }, - EventArns: []*string{ - aws.String("eventArn"), // Required - // More values... - }, - EventStatusCodes: []*string{ - aws.String("eventStatusCode"), // Required - // More values... - }, - EventTypeCategories: []*string{ - aws.String("eventTypeCategory"), // Required - // More values... - }, - EventTypeCodes: []*string{ - aws.String("eventType"), // Required - // More values... - }, - LastUpdatedTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - Regions: []*string{ - aws.String("region"), // Required - // More values... - }, - Services: []*string{ - aws.String("service"), // Required - // More values... - }, - StartTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - Tags: []map[string]*string{ - { // Required - "Key": aws.String("tagValue"), // Required - // More values... - }, - // More values... - }, - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("nextToken"), - } - resp, err := svc.DescribeEventAggregates(params) - - if err != nil { - // 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) -} - -func ExampleHealth_DescribeEventDetails() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeEventDetailsInput{ - EventArns: []*string{ // Required - aws.String("eventArn"), // Required - // More values... - }, - Locale: aws.String("locale"), - } - resp, err := svc.DescribeEventDetails(params) - - if err != nil { - // 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) -} - -func ExampleHealth_DescribeEventTypes() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeEventTypesInput{ - Filter: &health.EventTypeFilter{ - EventTypeCategories: []*string{ - aws.String("eventTypeCategory"), // Required - // More values... - }, - EventTypeCodes: []*string{ - aws.String("eventTypeCode"), // Required - // More values... - }, - Services: []*string{ - aws.String("service"), // Required - // More values... - }, - }, - Locale: aws.String("locale"), - MaxResults: aws.Int64(1), - NextToken: aws.String("nextToken"), - } - resp, err := svc.DescribeEventTypes(params) - - if err != nil { - // 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) -} - -func ExampleHealth_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := health.New(sess) - - params := &health.DescribeEventsInput{ - Filter: &health.EventFilter{ - AvailabilityZones: []*string{ - aws.String("availabilityZone"), // Required - // More values... - }, - EndTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - EntityArns: []*string{ - aws.String("entityArn"), // Required - // More values... - }, - EntityValues: []*string{ - aws.String("entityValue"), // Required - // More values... - }, - EventArns: []*string{ - aws.String("eventArn"), // Required - // More values... - }, - EventStatusCodes: []*string{ - aws.String("eventStatusCode"), // Required - // More values... - }, - EventTypeCategories: []*string{ - aws.String("eventTypeCategory"), // Required - // More values... - }, - EventTypeCodes: []*string{ - aws.String("eventType"), // Required - // More values... - }, - LastUpdatedTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - Regions: []*string{ - aws.String("region"), // Required - // More values... - }, - Services: []*string{ - aws.String("service"), // Required - // More values... - }, - StartTimes: []*health.DateTimeRange{ - { // Required - From: aws.Time(time.Now()), - To: aws.Time(time.Now()), - }, - // More values... - }, - Tags: []map[string]*string{ - { // Required - "Key": aws.String("tagValue"), // Required - // More values... - }, - // More values... - }, - }, - Locale: aws.String("locale"), - MaxResults: aws.Int64(1), - NextToken: aws.String("nextToken"), - } - resp, err := svc.DescribeEvents(params) - - if err != nil { - // 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) -} diff --git a/service/iam/examples_test.go b/service/iam/examples_test.go index 5bf65b42fc6..1e978a36186 100644 --- a/service/iam/examples_test.go +++ b/service/iam/examples_test.go @@ -8,2742 +8,1936 @@ import ( "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/iam" ) var _ time.Duration var _ bytes.Buffer - -func ExampleIAM_AddClientIDToOpenIDConnectProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AddClientIDToOpenIDConnectProviderInput{ - ClientID: aws.String("clientIDType"), // Required - OpenIDConnectProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.AddClientIDToOpenIDConnectProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_AddRoleToInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AddRoleToInstanceProfileInput{ - InstanceProfileName: aws.String("instanceProfileNameType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.AddRoleToInstanceProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_AddUserToGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AddUserToGroupInput{ - GroupName: aws.String("groupNameType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.AddUserToGroup(params) - - if err != nil { - // 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) -} - -func ExampleIAM_AttachGroupPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AttachGroupPolicyInput{ - GroupName: aws.String("groupNameType"), // Required - PolicyArn: aws.String("arnType"), // Required - } - resp, err := svc.AttachGroupPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_AttachRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AttachRolePolicyInput{ - PolicyArn: aws.String("arnType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.AttachRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_AttachUserPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.AttachUserPolicyInput{ - PolicyArn: aws.String("arnType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.AttachUserPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ChangePassword() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ChangePasswordInput{ - NewPassword: aws.String("passwordType"), // Required - OldPassword: aws.String("passwordType"), // Required - } - resp, err := svc.ChangePassword(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateAccessKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateAccessKeyInput{ - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.CreateAccessKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateAccountAlias() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateAccountAliasInput{ - AccountAlias: aws.String("accountAliasType"), // Required - } - resp, err := svc.CreateAccountAlias(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateGroupInput{ - GroupName: aws.String("groupNameType"), // Required - Path: aws.String("pathType"), - } - resp, err := svc.CreateGroup(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateInstanceProfileInput{ - InstanceProfileName: aws.String("instanceProfileNameType"), // Required - Path: aws.String("pathType"), - } - resp, err := svc.CreateInstanceProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateLoginProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateLoginProfileInput{ - Password: aws.String("passwordType"), // Required - UserName: aws.String("userNameType"), // Required +var _ aws.Config + +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} + +// To add a client ID (audience) to an Open-ID Connect (OIDC) provider +// +// The following add-client-id-to-open-id-connect-provider command adds the client ID +// my-application-ID to the OIDC provider named server.example.com: +func ExampleIAM_AddClientIDToOpenIDConnectProvider_shared00() { + svc := iam.New(session.New()) + input := &iam.AddClientIDToOpenIDConnectProviderInput{ + ClientID: aws.String("my-application-ID"), + OpenIDConnectProviderArn: aws.String("arn:aws:iam::123456789012:oidc-provider/server.example.com"), + } + + result, err := svc.AddClientIDToOpenIDConnectProvider(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To add a role to an instance profile +// +// The following command adds the role named S3Access to the instance profile named +// Webserver: +func ExampleIAM_AddRoleToInstanceProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.AddRoleToInstanceProfileInput{ + InstanceProfileName: aws.String("Webserver"), + RoleName: aws.String("S3Access"), + } + + result, err := svc.AddRoleToInstanceProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To add a user to an IAM group +// +// The following command adds an IAM user named Bob to the IAM group named Admins: +func ExampleIAM_AddUserToGroup_shared00() { + svc := iam.New(session.New()) + input := &iam.AddUserToGroupInput{ + GroupName: aws.String("Admins"), + UserName: aws.String("Bob"), + } + + result, err := svc.AddUserToGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To attach a managed policy to an IAM group +// +// The following command attaches the AWS managed policy named ReadOnlyAccess to the +// IAM group named Finance. +func ExampleIAM_AttachGroupPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.AttachGroupPolicyInput{ + GroupName: aws.String("Finance"), + PolicyArn: aws.String("arn:aws:iam::aws:policy/ReadOnlyAccess"), + } + + result, err := svc.AttachGroupPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To attach a managed policy to an IAM role +// +// The following command attaches the AWS managed policy named ReadOnlyAccess to the +// IAM role named ReadOnlyRole. +func ExampleIAM_AttachRolePolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.AttachRolePolicyInput{ + PolicyArn: aws.String("arn:aws:iam::aws:policy/ReadOnlyAccess"), + RoleName: aws.String("ReadOnlyRole"), + } + + result, err := svc.AttachRolePolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To attach a managed policy to an IAM user +// +// The following command attaches the AWS managed policy named AdministratorAccess to +// the IAM user named Alice. +func ExampleIAM_AttachUserPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.AttachUserPolicyInput{ + PolicyArn: aws.String("arn:aws:iam::aws:policy/AdministratorAccess"), + UserName: aws.String("Alice"), + } + + result, err := svc.AttachUserPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To change the password for your IAM user +// +// The following command changes the password for the current IAM user. +func ExampleIAM_ChangePassword_shared00() { + svc := iam.New(session.New()) + input := &iam.ChangePasswordInput{ + NewPassword: aws.String("]35d/{pB9Fo9wJ"), + OldPassword: aws.String("3s0K_;xh4~8XXI"), + } + + result, err := svc.ChangePassword(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeInvalidUserTypeException: + fmt.Println(iam.ErrCodeInvalidUserTypeException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityTemporarilyUnmodifiableException: + fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error()) + case iam.ErrCodePasswordPolicyViolationException: + fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an access key for an IAM user +// +// The following command creates an access key (access key ID and secret access key) +// for the IAM user named Bob. +func ExampleIAM_CreateAccessKey_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateAccessKeyInput{ + UserName: aws.String("Bob"), + } + + result, err := svc.CreateAccessKey(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an account alias +// +// The following command associates the alias examplecorp to your AWS account. +func ExampleIAM_CreateAccountAlias_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateAccountAliasInput{ + AccountAlias: aws.String("examplecorp"), + } + + result, err := svc.CreateAccountAlias(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an IAM group +// +// The following command creates an IAM group named Admins. +func ExampleIAM_CreateGroup_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateGroupInput{ + GroupName: aws.String("Admins"), + } + + result, err := svc.CreateGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an instance profile +// +// The following command creates an instance profile named Webserver that is ready to +// have a role attached and then be associated with an EC2 instance. +func ExampleIAM_CreateInstanceProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateInstanceProfileInput{ + InstanceProfileName: aws.String("Webserver"), + } + + result, err := svc.CreateInstanceProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an instance profile +// +// The following command changes IAM user Bob's password and sets the flag that required +// Bob to change the password the next time he signs in. +func ExampleIAM_CreateLoginProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateLoginProfileInput{ + Password: aws.String("h]6EszR}vJ*m"), PasswordResetRequired: aws.Bool(true), - } - resp, err := svc.CreateLoginProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateOpenIDConnectProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateOpenIDConnectProviderInput{ - ThumbprintList: []*string{ // Required - aws.String("thumbprintType"), // Required - // More values... - }, - Url: aws.String("OpenIDConnectProviderUrlType"), // Required + UserName: aws.String("Bob"), + } + + result, err := svc.CreateLoginProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodePasswordPolicyViolationException: + fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an instance profile +// +// The following example defines a new OIDC provider in IAM with a client ID of my-application-id +// and pointing at the server with a URL of https://server.example.com. +func ExampleIAM_CreateOpenIDConnectProvider_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateOpenIDConnectProviderInput{ ClientIDList: []*string{ - aws.String("clientIDType"), // Required - // More values... + aws.String("my-application-id"), }, - } - resp, err := svc.CreateOpenIDConnectProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreatePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreatePolicyInput{ - PolicyDocument: aws.String("policyDocumentType"), // Required - PolicyName: aws.String("policyNameType"), // Required - Description: aws.String("policyDescriptionType"), - Path: aws.String("policyPathType"), - } - resp, err := svc.CreatePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreatePolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreatePolicyVersionInput{ - PolicyArn: aws.String("arnType"), // Required - PolicyDocument: aws.String("policyDocumentType"), // Required - SetAsDefault: aws.Bool(true), - } - resp, err := svc.CreatePolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateRole() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateRoleInput{ - AssumeRolePolicyDocument: aws.String("policyDocumentType"), // Required - RoleName: aws.String("roleNameType"), // Required - Description: aws.String("roleDescriptionType"), - Path: aws.String("pathType"), - } - resp, err := svc.CreateRole(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateSAMLProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateSAMLProviderInput{ - Name: aws.String("SAMLProviderNameType"), // Required - SAMLMetadataDocument: aws.String("SAMLMetadataDocumentType"), // Required - } - resp, err := svc.CreateSAMLProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateServiceLinkedRole() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateServiceLinkedRoleInput{ - AWSServiceName: aws.String("groupNameType"), // Required - CustomSuffix: aws.String("customSuffixType"), - Description: aws.String("roleDescriptionType"), - } - resp, err := svc.CreateServiceLinkedRole(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateServiceSpecificCredential() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateServiceSpecificCredentialInput{ - ServiceName: aws.String("serviceName"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.CreateServiceSpecificCredential(params) - - if err != nil { - // 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) -} - -func ExampleIAM_CreateUser() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateUserInput{ - UserName: aws.String("userNameType"), // Required - Path: aws.String("pathType"), - } - resp, err := svc.CreateUser(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + ThumbprintList: []*string{ + aws.String("3768084dfb3d2b68b7897bf5f565da8efEXAMPLE"), + }, + Url: aws.String("https://server.example.com"), + } + + result, err := svc.CreateOpenIDConnectProvider(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an IAM role +// +// The following command creates a role named Test-Role and attaches a trust policy +// to it that is provided as a URL-encoded JSON string. +func ExampleIAM_CreateRole_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateRoleInput{ + AssumeRolePolicyDocument: aws.String(""), + Path: aws.String("/"), + RoleName: aws.String("Test-Role"), + } + + result, err := svc.CreateRole(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeInvalidInputException: + fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To create an IAM user +// +// The following create-user command creates an IAM user named Bob in the current account. +func ExampleIAM_CreateUser_shared00() { + svc := iam.New(session.New()) + input := &iam.CreateUserInput{ + UserName: aws.String("Bob"), + } + + result, err := svc.CreateUser(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete an access key for an IAM user +// +// The following command deletes one access key (access key ID and secret access key) +// assigned to the IAM user named Bob. +func ExampleIAM_DeleteAccessKey_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteAccessKeyInput{ + AccessKeyId: aws.String("AKIDPMS9RO4H3FEXAMPLE"), + UserName: aws.String("Bob"), + } + + result, err := svc.DeleteAccessKey(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete an account alias +// +// The following command removes the alias mycompany from the current AWS account: +func ExampleIAM_DeleteAccountAlias_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteAccountAliasInput{ + AccountAlias: aws.String("mycompany"), + } + + result, err := svc.DeleteAccountAlias(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete the current account password policy +// +// The following command removes the password policy from the current AWS account: +func ExampleIAM_DeleteAccountPasswordPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteAccountPasswordPolicyInput{} + + result, err := svc.DeleteAccountPasswordPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete a policy from an IAM group +// +// The following command deletes the policy named ExamplePolicy from the group named +// Admins: +func ExampleIAM_DeleteGroupPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteGroupPolicyInput{ + GroupName: aws.String("Admins"), + PolicyName: aws.String("ExamplePolicy"), + } + + result, err := svc.DeleteGroupPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete an instance profile +// +// The following command deletes the instance profile named ExampleInstanceProfile +func ExampleIAM_DeleteInstanceProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteInstanceProfileInput{ + InstanceProfileName: aws.String("ExampleInstanceProfile"), + } + + result, err := svc.DeleteInstanceProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeDeleteConflictException: + fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete a password for an IAM user +// +// The following command deletes the password for the IAM user named Bob. +func ExampleIAM_DeleteLoginProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteLoginProfileInput{ + UserName: aws.String("Bob"), + } + + result, err := svc.DeleteLoginProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeEntityTemporarilyUnmodifiableException: + fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete an IAM role +// +// The following command removes the role named Test-Role. +func ExampleIAM_DeleteRole_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteRoleInput{ + RoleName: aws.String("Test-Role"), + } + + result, err := svc.DeleteRole(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeDeleteConflictException: + fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To remove a policy from an IAM role +// +// The following command removes the policy named ExamplePolicy from the role named +// Test-Role. +func ExampleIAM_DeleteRolePolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteRolePolicyInput{ + PolicyName: aws.String("ExamplePolicy"), + RoleName: aws.String("Test-Role"), + } + + result, err := svc.DeleteRolePolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete a signing certificate for an IAM user +// +// The following command deletes the specified signing certificate for the IAM user +// named Anika. +func ExampleIAM_DeleteSigningCertificate_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteSigningCertificateInput{ + CertificateId: aws.String("TA7SMP42TDN5Z26OBPJE7EXAMPLE"), + UserName: aws.String("Anika"), + } + + result, err := svc.DeleteSigningCertificate(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To delete an IAM user +// +// The following command removes the IAM user named Bob from the current account. +func ExampleIAM_DeleteUser_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteUserInput{ + UserName: aws.String("Bob"), + } + + result, err := svc.DeleteUser(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeDeleteConflictException: + fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To remove a policy from an IAM user +// +// The following delete-user-policy command removes the specified policy from the IAM +// user named Juan: +func ExampleIAM_DeleteUserPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteUserPolicyInput{ + PolicyName: aws.String("ExamplePolicy"), + UserName: aws.String("Juan"), + } + + result, err := svc.DeleteUserPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To remove a virtual MFA device +// +// The following delete-virtual-mfa-device command removes the specified MFA device +// from the current AWS account. +func ExampleIAM_DeleteVirtualMFADevice_shared00() { + svc := iam.New(session.New()) + input := &iam.DeleteVirtualMFADeviceInput{ + SerialNumber: aws.String("arn:aws:iam::123456789012:mfa/ExampleName"), + } + + result, err := svc.DeleteVirtualMFADevice(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeDeleteConflictException: + fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To see the current account password policy +// +// The following command displays details about the password policy for the current +// AWS account. +func ExampleIAM_GetAccountPasswordPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.GetAccountPasswordPolicyInput{} + + result, err := svc.GetAccountPasswordPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) -} - -func ExampleIAM_CreateVirtualMFADevice() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.CreateVirtualMFADeviceInput{ - VirtualMFADeviceName: aws.String("virtualMFADeviceName"), // Required - Path: aws.String("pathType"), - } - resp, err := svc.CreateVirtualMFADevice(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + } + + fmt.Println(result) +} + +// To get information about IAM entity quotas and usage in the current account +// +// The following command returns information about the IAM entity quotas and usage in +// the current AWS account. +func ExampleIAM_GetAccountSummary_shared00() { + svc := iam.New(session.New()) + input := &iam.GetAccountSummaryInput{} + + result, err := svc.GetAccountSummary(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeactivateMFADevice() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeactivateMFADeviceInput{ - SerialNumber: aws.String("serialNumberType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.DeactivateMFADevice(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) +// To get information about an instance profile +// +// The following command gets information about the instance profile named ExampleInstanceProfile. +func ExampleIAM_GetInstanceProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.GetInstanceProfileInput{ + InstanceProfileName: aws.String("ExampleInstanceProfile"), + } + + result, err := svc.GetInstanceProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteAccessKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteAccessKeyInput{ - AccessKeyId: aws.String("accessKeyIdType"), // Required - UserName: aws.String("existingUserNameType"), +// To get password information for an IAM user +// +// The following command gets information about the password for the IAM user named +// Anika. +func ExampleIAM_GetLoginProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.GetLoginProfileInput{ + UserName: aws.String("Anika"), } - resp, err := svc.DeleteAccessKey(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.GetLoginProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteAccountAlias() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteAccountAliasInput{ - AccountAlias: aws.String("accountAliasType"), // Required - } - resp, err := svc.DeleteAccountAlias(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) - return +// To get information about an IAM role +// +// The following command gets information about the role named Test-Role. +func ExampleIAM_GetRole_shared00() { + svc := iam.New(session.New()) + input := &iam.GetRoleInput{ + RoleName: aws.String("Test-Role"), } - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleIAM_DeleteAccountPasswordPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.DeleteAccountPasswordPolicyInput - resp, err := svc.DeleteAccountPasswordPolicy(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.GetRole(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteGroupInput{ - GroupName: aws.String("groupNameType"), // Required +// To get information about an IAM user +// +// The following command gets information about the IAM user named Bob. +func ExampleIAM_GetUser_shared00() { + svc := iam.New(session.New()) + input := &iam.GetUserInput{ + UserName: aws.String("Bob"), } - resp, err := svc.DeleteGroup(params) + result, err := svc.GetUser(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 iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteGroupPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteGroupPolicyInput{ - GroupName: aws.String("groupNameType"), // Required - PolicyName: aws.String("policyNameType"), // Required - } - resp, err := svc.DeleteGroupPolicy(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) +// To list the access key IDs for an IAM user +// +// The following command lists the access keys IDs for the IAM user named Alice. +func ExampleIAM_ListAccessKeys_shared00() { + svc := iam.New(session.New()) + input := &iam.ListAccessKeysInput{ + UserName: aws.String("Alice"), + } + + result, err := svc.ListAccessKeys(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteInstanceProfileInput{ - InstanceProfileName: aws.String("instanceProfileNameType"), // Required - } - resp, err := svc.DeleteInstanceProfile(params) +// To list account aliases +// +// The following command lists the aliases for the current account. +func ExampleIAM_ListAccountAliases_shared00() { + svc := iam.New(session.New()) + input := &iam.ListAccountAliasesInput{} - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.ListAccountAliases(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteLoginProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteLoginProfileInput{ - UserName: aws.String("userNameType"), // Required +// To list the in-line policies for an IAM group +// +// The following command lists the names of in-line policies that are embedded in the +// IAM group named Admins. +func ExampleIAM_ListGroupPolicies_shared00() { + svc := iam.New(session.New()) + input := &iam.ListGroupPoliciesInput{ + GroupName: aws.String("Admins"), } - resp, err := svc.DeleteLoginProfile(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.ListGroupPolicies(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteOpenIDConnectProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteOpenIDConnectProviderInput{ - OpenIDConnectProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.DeleteOpenIDConnectProvider(params) +// To list the IAM groups for the current account +// +// The following command lists the IAM groups in the current account: +func ExampleIAM_ListGroups_shared00() { + svc := iam.New(session.New()) + input := &iam.ListGroupsInput{} + result, err := svc.ListGroups(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 iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeletePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeletePolicyInput{ - PolicyArn: aws.String("arnType"), // Required +// To list the groups that an IAM user belongs to +// +// The following command displays the groups that the IAM user named Bob belongs to. +func ExampleIAM_ListGroupsForUser_shared00() { + svc := iam.New(session.New()) + input := &iam.ListGroupsForUserInput{ + UserName: aws.String("Bob"), } - resp, err := svc.DeletePolicy(params) + result, err := svc.ListGroupsForUser(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 iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeletePolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeletePolicyVersionInput{ - PolicyArn: aws.String("arnType"), // Required - VersionId: aws.String("policyVersionIdType"), // Required +// To list the signing certificates for an IAM user +// +// The following command lists the signing certificates for the IAM user named Bob. +func ExampleIAM_ListSigningCertificates_shared00() { + svc := iam.New(session.New()) + input := &iam.ListSigningCertificatesInput{ + UserName: aws.String("Bob"), } - resp, err := svc.DeletePolicyVersion(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.ListSigningCertificates(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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 ExampleIAM_DeleteRole() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteRoleInput{ - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.DeleteRole(params) +// To list IAM users +// +// The following command lists the IAM users in the current account. +func ExampleIAM_ListUsers_shared00() { + svc := iam.New(session.New()) + input := &iam.ListUsersInput{} + result, err := svc.ListUsers(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()) - return - } - - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleIAM_DeleteRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteRolePolicyInput{ - PolicyName: aws.String("policyNameType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.DeleteRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteSAMLProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteSAMLProviderInput{ - SAMLProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.DeleteSAMLProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteSSHPublicKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteSSHPublicKeyInput{ - SSHPublicKeyId: aws.String("publicKeyIdType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.DeleteSSHPublicKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteServerCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteServerCertificateInput{ - ServerCertificateName: aws.String("serverCertificateNameType"), // Required - } - resp, err := svc.DeleteServerCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteServiceSpecificCredential() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteServiceSpecificCredentialInput{ - ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required - UserName: aws.String("userNameType"), - } - resp, err := svc.DeleteServiceSpecificCredential(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteSigningCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteSigningCertificateInput{ - CertificateId: aws.String("certificateIdType"), // Required - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.DeleteSigningCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteUser() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteUserInput{ - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.DeleteUser(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteUserPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteUserPolicyInput{ - PolicyName: aws.String("policyNameType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.DeleteUserPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DeleteVirtualMFADevice() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DeleteVirtualMFADeviceInput{ - SerialNumber: aws.String("serialNumberType"), // Required - } - resp, err := svc.DeleteVirtualMFADevice(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DetachGroupPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DetachGroupPolicyInput{ - GroupName: aws.String("groupNameType"), // Required - PolicyArn: aws.String("arnType"), // Required - } - resp, err := svc.DetachGroupPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DetachRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DetachRolePolicyInput{ - PolicyArn: aws.String("arnType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.DetachRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_DetachUserPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.DetachUserPolicyInput{ - PolicyArn: aws.String("arnType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.DetachUserPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_EnableMFADevice() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.EnableMFADeviceInput{ - AuthenticationCode1: aws.String("authenticationCodeType"), // Required - AuthenticationCode2: aws.String("authenticationCodeType"), // Required - SerialNumber: aws.String("serialNumberType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.EnableMFADevice(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GenerateCredentialReport() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.GenerateCredentialReportInput - resp, err := svc.GenerateCredentialReport(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetAccessKeyLastUsed() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetAccessKeyLastUsedInput{ - AccessKeyId: aws.String("accessKeyIdType"), // Required - } - resp, err := svc.GetAccessKeyLastUsed(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetAccountAuthorizationDetails() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetAccountAuthorizationDetailsInput{ - Filter: []*string{ - aws.String("EntityType"), // Required - // More values... - }, - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.GetAccountAuthorizationDetails(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetAccountPasswordPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.GetAccountPasswordPolicyInput - resp, err := svc.GetAccountPasswordPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetAccountSummary() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.GetAccountSummaryInput - resp, err := svc.GetAccountSummary(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetContextKeysForCustomPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetContextKeysForCustomPolicyInput{ - PolicyInputList: []*string{ // Required - aws.String("policyDocumentType"), // Required - // More values... - }, - } - resp, err := svc.GetContextKeysForCustomPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetContextKeysForPrincipalPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetContextKeysForPrincipalPolicyInput{ - PolicySourceArn: aws.String("arnType"), // Required - PolicyInputList: []*string{ - aws.String("policyDocumentType"), // Required - // More values... - }, - } - resp, err := svc.GetContextKeysForPrincipalPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetCredentialReport() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.GetCredentialReportInput - resp, err := svc.GetCredentialReport(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetGroupInput{ - GroupName: aws.String("groupNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.GetGroup(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetGroupPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetGroupPolicyInput{ - GroupName: aws.String("groupNameType"), // Required - PolicyName: aws.String("policyNameType"), // Required - } - resp, err := svc.GetGroupPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetInstanceProfileInput{ - InstanceProfileName: aws.String("instanceProfileNameType"), // Required - } - resp, err := svc.GetInstanceProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetLoginProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetLoginProfileInput{ - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.GetLoginProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetOpenIDConnectProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetOpenIDConnectProviderInput{ - OpenIDConnectProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.GetOpenIDConnectProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetPolicyInput{ - PolicyArn: aws.String("arnType"), // Required - } - resp, err := svc.GetPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetPolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetPolicyVersionInput{ - PolicyArn: aws.String("arnType"), // Required - VersionId: aws.String("policyVersionIdType"), // Required - } - resp, err := svc.GetPolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetRole() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetRoleInput{ - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.GetRole(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetRolePolicyInput{ - PolicyName: aws.String("policyNameType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.GetRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetSAMLProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetSAMLProviderInput{ - SAMLProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.GetSAMLProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetSSHPublicKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetSSHPublicKeyInput{ - Encoding: aws.String("encodingType"), // Required - SSHPublicKeyId: aws.String("publicKeyIdType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.GetSSHPublicKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetServerCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetServerCertificateInput{ - ServerCertificateName: aws.String("serverCertificateNameType"), // Required - } - resp, err := svc.GetServerCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetUser() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetUserInput{ - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.GetUser(params) - - if err != nil { - // 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) -} - -func ExampleIAM_GetUserPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.GetUserPolicyInput{ - PolicyName: aws.String("policyNameType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.GetUserPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListAccessKeys() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListAccessKeysInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.ListAccessKeys(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListAccountAliases() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListAccountAliasesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListAccountAliases(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListAttachedGroupPolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListAttachedGroupPoliciesInput{ - GroupName: aws.String("groupNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("policyPathType"), - } - resp, err := svc.ListAttachedGroupPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListAttachedRolePolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListAttachedRolePoliciesInput{ - RoleName: aws.String("roleNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("policyPathType"), - } - resp, err := svc.ListAttachedRolePolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListAttachedUserPolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListAttachedUserPoliciesInput{ - UserName: aws.String("userNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("policyPathType"), - } - resp, err := svc.ListAttachedUserPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListEntitiesForPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListEntitiesForPolicyInput{ - PolicyArn: aws.String("arnType"), // Required - EntityFilter: aws.String("EntityType"), - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathType"), - } - resp, err := svc.ListEntitiesForPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListGroupPolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListGroupPoliciesInput{ - GroupName: aws.String("groupNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListGroupPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListGroups() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListGroupsInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathPrefixType"), - } - resp, err := svc.ListGroups(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListGroupsForUser() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListGroupsForUserInput{ - UserName: aws.String("existingUserNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListGroupsForUser(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListInstanceProfiles() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListInstanceProfilesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathPrefixType"), - } - resp, err := svc.ListInstanceProfiles(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListInstanceProfilesForRole() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListInstanceProfilesForRoleInput{ - RoleName: aws.String("roleNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListInstanceProfilesForRole(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListMFADevices() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListMFADevicesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.ListMFADevices(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListOpenIDConnectProviders() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.ListOpenIDConnectProvidersInput - resp, err := svc.ListOpenIDConnectProviders(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListPolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListPoliciesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - OnlyAttached: aws.Bool(true), - PathPrefix: aws.String("policyPathType"), - Scope: aws.String("policyScopeType"), - } - resp, err := svc.ListPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListPolicyVersions() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListPolicyVersionsInput{ - PolicyArn: aws.String("arnType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListPolicyVersions(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListRolePolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListRolePoliciesInput{ - RoleName: aws.String("roleNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListRolePolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListRoles() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListRolesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathPrefixType"), - } - resp, err := svc.ListRoles(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListSAMLProviders() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - var params *iam.ListSAMLProvidersInput - resp, err := svc.ListSAMLProviders(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListSSHPublicKeys() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListSSHPublicKeysInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - UserName: aws.String("userNameType"), - } - resp, err := svc.ListSSHPublicKeys(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListServerCertificates() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListServerCertificatesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathPrefixType"), - } - resp, err := svc.ListServerCertificates(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListServiceSpecificCredentials() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListServiceSpecificCredentialsInput{ - ServiceName: aws.String("serviceName"), - UserName: aws.String("userNameType"), - } - resp, err := svc.ListServiceSpecificCredentials(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListSigningCertificates() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListSigningCertificatesInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.ListSigningCertificates(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListUserPolicies() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListUserPoliciesInput{ - UserName: aws.String("existingUserNameType"), // Required - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListUserPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListUsers() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListUsersInput{ - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PathPrefix: aws.String("pathPrefixType"), - } - resp, err := svc.ListUsers(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ListVirtualMFADevices() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ListVirtualMFADevicesInput{ - AssignmentStatus: aws.String("assignmentStatusType"), - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListVirtualMFADevices(params) - - if err != nil { - // 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) -} - -func ExampleIAM_PutGroupPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.PutGroupPolicyInput{ - GroupName: aws.String("groupNameType"), // Required - PolicyDocument: aws.String("policyDocumentType"), // Required - PolicyName: aws.String("policyNameType"), // Required - } - resp, err := svc.PutGroupPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_PutRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.PutRolePolicyInput{ - PolicyDocument: aws.String("policyDocumentType"), // Required - PolicyName: aws.String("policyNameType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.PutRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_PutUserPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.PutUserPolicyInput{ - PolicyDocument: aws.String("policyDocumentType"), // Required - PolicyName: aws.String("policyNameType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.PutUserPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_RemoveClientIDFromOpenIDConnectProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.RemoveClientIDFromOpenIDConnectProviderInput{ - ClientID: aws.String("clientIDType"), // Required - OpenIDConnectProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.RemoveClientIDFromOpenIDConnectProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_RemoveRoleFromInstanceProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.RemoveRoleFromInstanceProfileInput{ - InstanceProfileName: aws.String("instanceProfileNameType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.RemoveRoleFromInstanceProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_RemoveUserFromGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.RemoveUserFromGroupInput{ - GroupName: aws.String("groupNameType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.RemoveUserFromGroup(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ResetServiceSpecificCredential() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ResetServiceSpecificCredentialInput{ - ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required - UserName: aws.String("userNameType"), - } - resp, err := svc.ResetServiceSpecificCredential(params) - - if err != nil { - // 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) -} - -func ExampleIAM_ResyncMFADevice() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.ResyncMFADeviceInput{ - AuthenticationCode1: aws.String("authenticationCodeType"), // Required - AuthenticationCode2: aws.String("authenticationCodeType"), // Required - SerialNumber: aws.String("serialNumberType"), // Required - UserName: aws.String("existingUserNameType"), // Required - } - resp, err := svc.ResyncMFADevice(params) - - if err != nil { - // 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) -} - -func ExampleIAM_SetDefaultPolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.SetDefaultPolicyVersionInput{ - PolicyArn: aws.String("arnType"), // Required - VersionId: aws.String("policyVersionIdType"), // Required - } - resp, err := svc.SetDefaultPolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIAM_SimulateCustomPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.SimulateCustomPolicyInput{ - ActionNames: []*string{ // Required - aws.String("ActionNameType"), // Required - // More values... - }, - PolicyInputList: []*string{ // Required - aws.String("policyDocumentType"), // Required - // More values... - }, - CallerArn: aws.String("ResourceNameType"), - ContextEntries: []*iam.ContextEntry{ - { // Required - ContextKeyName: aws.String("ContextKeyNameType"), - ContextKeyType: aws.String("ContextKeyTypeEnum"), - ContextKeyValues: []*string{ - aws.String("ContextKeyValueType"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - ResourceArns: []*string{ - aws.String("ResourceNameType"), // Required - // More values... - }, - ResourceHandlingOption: aws.String("ResourceHandlingOptionType"), - ResourceOwner: aws.String("ResourceNameType"), - ResourcePolicy: aws.String("policyDocumentType"), - } - resp, err := svc.SimulateCustomPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_SimulatePrincipalPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.SimulatePrincipalPolicyInput{ - ActionNames: []*string{ // Required - aws.String("ActionNameType"), // Required - // More values... - }, - PolicySourceArn: aws.String("arnType"), // Required - CallerArn: aws.String("ResourceNameType"), - ContextEntries: []*iam.ContextEntry{ - { // Required - ContextKeyName: aws.String("ContextKeyNameType"), - ContextKeyType: aws.String("ContextKeyTypeEnum"), - ContextKeyValues: []*string{ - aws.String("ContextKeyValueType"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("markerType"), - MaxItems: aws.Int64(1), - PolicyInputList: []*string{ - aws.String("policyDocumentType"), // Required - // More values... - }, - ResourceArns: []*string{ - aws.String("ResourceNameType"), // Required - // More values... - }, - ResourceHandlingOption: aws.String("ResourceHandlingOptionType"), - ResourceOwner: aws.String("ResourceNameType"), - ResourcePolicy: aws.String("policyDocumentType"), - } - resp, err := svc.SimulatePrincipalPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateAccessKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateAccessKeyInput{ - AccessKeyId: aws.String("accessKeyIdType"), // Required - Status: aws.String("statusType"), // Required - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.UpdateAccessKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateAccountPasswordPolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateAccountPasswordPolicyInput{ - AllowUsersToChangePassword: aws.Bool(true), - HardExpiry: aws.Bool(true), - MaxPasswordAge: aws.Int64(1), - MinimumPasswordLength: aws.Int64(1), - PasswordReusePrevention: aws.Int64(1), - RequireLowercaseCharacters: aws.Bool(true), - RequireNumbers: aws.Bool(true), - RequireSymbols: aws.Bool(true), - RequireUppercaseCharacters: aws.Bool(true), - } - resp, err := svc.UpdateAccountPasswordPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateAssumeRolePolicy() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateAssumeRolePolicyInput{ - PolicyDocument: aws.String("policyDocumentType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.UpdateAssumeRolePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateGroup() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateGroupInput{ - GroupName: aws.String("groupNameType"), // Required - NewGroupName: aws.String("groupNameType"), - NewPath: aws.String("pathType"), - } - resp, err := svc.UpdateGroup(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateLoginProfile() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateLoginProfileInput{ - UserName: aws.String("userNameType"), // Required - Password: aws.String("passwordType"), - PasswordResetRequired: aws.Bool(true), - } - resp, err := svc.UpdateLoginProfile(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateOpenIDConnectProviderThumbprint() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateOpenIDConnectProviderThumbprintInput{ - OpenIDConnectProviderArn: aws.String("arnType"), // Required - ThumbprintList: []*string{ // Required - aws.String("thumbprintType"), // Required - // More values... - }, - } - resp, err := svc.UpdateOpenIDConnectProviderThumbprint(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateRoleDescription() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateRoleDescriptionInput{ - Description: aws.String("roleDescriptionType"), // Required - RoleName: aws.String("roleNameType"), // Required - } - resp, err := svc.UpdateRoleDescription(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateSAMLProvider() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateSAMLProviderInput{ - SAMLMetadataDocument: aws.String("SAMLMetadataDocumentType"), // Required - SAMLProviderArn: aws.String("arnType"), // Required - } - resp, err := svc.UpdateSAMLProvider(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateSSHPublicKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateSSHPublicKeyInput{ - SSHPublicKeyId: aws.String("publicKeyIdType"), // Required - Status: aws.String("statusType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.UpdateSSHPublicKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateServerCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateServerCertificateInput{ - ServerCertificateName: aws.String("serverCertificateNameType"), // Required - NewPath: aws.String("pathType"), - NewServerCertificateName: aws.String("serverCertificateNameType"), - } - resp, err := svc.UpdateServerCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateServiceSpecificCredential() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateServiceSpecificCredentialInput{ - ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required - Status: aws.String("statusType"), // Required - UserName: aws.String("userNameType"), - } - resp, err := svc.UpdateServiceSpecificCredential(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateSigningCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateSigningCertificateInput{ - CertificateId: aws.String("certificateIdType"), // Required - Status: aws.String("statusType"), // Required - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.UpdateSigningCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UpdateUser() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UpdateUserInput{ - UserName: aws.String("existingUserNameType"), // Required - NewPath: aws.String("pathType"), - NewUserName: aws.String("userNameType"), - } - resp, err := svc.UpdateUser(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UploadSSHPublicKey() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UploadSSHPublicKeyInput{ - SSHPublicKeyBody: aws.String("publicKeyMaterialType"), // Required - UserName: aws.String("userNameType"), // Required - } - resp, err := svc.UploadSSHPublicKey(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UploadServerCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UploadServerCertificateInput{ - CertificateBody: aws.String("certificateBodyType"), // Required - PrivateKey: aws.String("privateKeyType"), // Required - ServerCertificateName: aws.String("serverCertificateNameType"), // Required - CertificateChain: aws.String("certificateChainType"), - Path: aws.String("pathType"), - } - resp, err := svc.UploadServerCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIAM_UploadSigningCertificate() { - sess := session.Must(session.NewSession()) - - svc := iam.New(sess) - - params := &iam.UploadSigningCertificateInput{ - CertificateBody: aws.String("certificateBodyType"), // Required - UserName: aws.String("existingUserNameType"), - } - resp, err := svc.UploadSigningCertificate(params) - - if err != nil { - // 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) + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To list virtual MFA devices +// +// The following command lists the virtual MFA devices that have been configured for +// the current account. +func ExampleIAM_ListVirtualMFADevices_shared00() { + svc := iam.New(session.New()) + input := &iam.ListVirtualMFADevicesInput{} + + result, err := svc.ListVirtualMFADevices(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} + +// To add a policy to a group +// +// The following command adds a policy named AllPerms to the IAM group named Admins. +func ExampleIAM_PutGroupPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.PutGroupPolicyInput{ + GroupName: aws.String("Admins"), + PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}"), + PolicyName: aws.String("AllPerms"), + } + + result, err := svc.PutGroupPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To attach a permissions policy to an IAM role +// +// The following command adds a permissions policy to the role named Test-Role. +func ExampleIAM_PutRolePolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.PutRolePolicyInput{ + PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}}"), + PolicyName: aws.String("S3AccessPolicy"), + RoleName: aws.String("S3Access"), + } + + result, err := svc.PutRolePolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To attach a policy to an IAM user +// +// The following command attaches a policy to the IAM user named Bob. +func ExampleIAM_PutUserPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.PutUserPolicyInput{ + PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}"), + PolicyName: aws.String("AllAccessPolicy"), + UserName: aws.String("Bob"), + } + + result, err := svc.PutUserPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To remove a role from an instance profile +// +// The following command removes the role named Test-Role from the instance profile +// named ExampleInstanceProfile. +func ExampleIAM_RemoveRoleFromInstanceProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.RemoveRoleFromInstanceProfileInput{ + InstanceProfileName: aws.String("ExampleInstanceProfile"), + RoleName: aws.String("Test-Role"), + } + + result, err := svc.RemoveRoleFromInstanceProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To remove a user from an IAM group +// +// The following command removes the user named Bob from the IAM group named Admins. +func ExampleIAM_RemoveUserFromGroup_shared00() { + svc := iam.New(session.New()) + input := &iam.RemoveUserFromGroupInput{ + GroupName: aws.String("Admins"), + UserName: aws.String("Bob"), + } + + result, err := svc.RemoveUserFromGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To activate or deactivate an access key for an IAM user +// +// The following command deactivates the specified access key (access key ID and secret +// access key) for the IAM user named Bob. +func ExampleIAM_UpdateAccessKey_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateAccessKeyInput{ + AccessKeyId: aws.String("AKIAIOSFODNN7EXAMPLE"), + Status: aws.String("Inactive"), + UserName: aws.String("Bob"), + } + + result, err := svc.UpdateAccessKey(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To set or change the current account password policy +// +// The following command sets the password policy to require a minimum length of eight +// characters and to require one or more numbers in the password: +func ExampleIAM_UpdateAccountPasswordPolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateAccountPasswordPolicyInput{ + MinimumPasswordLength: aws.Int64(8.000000), + RequireNumbers: aws.Bool(true), + } + + result, err := svc.UpdateAccountPasswordPolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To update the trust policy for an IAM role +// +// The following command updates the role trust policy for the role named Test-Role: +func ExampleIAM_UpdateAssumeRolePolicy_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateAssumeRolePolicyInput{ + PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}"), + RoleName: aws.String("S3AccessForEC2Instances"), + } + + result, err := svc.UpdateAssumeRolePolicy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeMalformedPolicyDocumentException: + fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeUnmodifiableEntityException: + fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To rename an IAM group +// +// The following command changes the name of the IAM group Test to Test-1. +func ExampleIAM_UpdateGroup_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateGroupInput{ + GroupName: aws.String("Test"), + NewGroupName: aws.String("Test-1"), + } + + result, err := svc.UpdateGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To change the password for an IAM user +// +// The following command creates or changes the password for the IAM user named Bob. +func ExampleIAM_UpdateLoginProfile_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateLoginProfileInput{ + Password: aws.String("SomeKindOfPassword123!@#"), + UserName: aws.String("Bob"), + } + + result, err := svc.UpdateLoginProfile(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeEntityTemporarilyUnmodifiableException: + fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodePasswordPolicyViolationException: + fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To change the active status of a signing certificate for an IAM user +// +// The following command changes the status of a signing certificate for a user named +// Bob to Inactive. +func ExampleIAM_UpdateSigningCertificate_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateSigningCertificateInput{ + CertificateId: aws.String("TA7SMP42TDN5Z26OBPJE7EXAMPLE"), + Status: aws.String("Inactive"), + UserName: aws.String("Bob"), + } + + result, err := svc.UpdateSigningCertificate(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To change an IAM user's name +// +// The following command changes the name of the IAM user Bob to Robert. It does not +// change the user's path. +func ExampleIAM_UpdateUser_shared00() { + svc := iam.New(session.New()) + input := &iam.UpdateUserInput{ + NewUserName: aws.String("Robert"), + UserName: aws.String("Bob"), + } + + result, err := svc.UpdateUser(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeEntityTemporarilyUnmodifiableException: + fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To upload a server certificate to your AWS account +// +// The following upload-server-certificate command uploads a server certificate to your +// AWS account: +func ExampleIAM_UploadServerCertificate_shared00() { + svc := iam.New(session.New()) + input := &iam.UploadServerCertificateInput{ + CertificateBody: aws.String("-----BEGIN CERTIFICATE----------END CERTIFICATE-----"), + Path: aws.String("/company/servercerts/"), + PrivateKey: aws.String("-----BEGIN DSA PRIVATE KEY----------END DSA PRIVATE KEY-----"), + ServerCertificateName: aws.String("ProdServerCert"), + } + + result, err := svc.UploadServerCertificate(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeMalformedCertificateException: + fmt.Println(iam.ErrCodeMalformedCertificateException, aerr.Error()) + case iam.ErrCodeKeyPairMismatchException: + fmt.Println(iam.ErrCodeKeyPairMismatchException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) +} + +// To upload a signing certificate for an IAM user +// +// The following command uploads a signing certificate for the IAM user named Bob. +func ExampleIAM_UploadSigningCertificate_shared00() { + svc := iam.New(session.New()) + input := &iam.UploadSigningCertificateInput{ + CertificateBody: aws.String("-----BEGIN CERTIFICATE----------END CERTIFICATE-----"), + UserName: aws.String("Bob"), + } + + result, err := svc.UploadSigningCertificate(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case iam.ErrCodeLimitExceededException: + fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error()) + case iam.ErrCodeEntityAlreadyExistsException: + fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error()) + case iam.ErrCodeMalformedCertificateException: + fmt.Println(iam.ErrCodeMalformedCertificateException, aerr.Error()) + case iam.ErrCodeInvalidCertificateException: + fmt.Println(iam.ErrCodeInvalidCertificateException, aerr.Error()) + case iam.ErrCodeDuplicateCertificateException: + fmt.Println(iam.ErrCodeDuplicateCertificateException, aerr.Error()) + case iam.ErrCodeNoSuchEntityException: + fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error()) + case iam.ErrCodeServiceFailureException: + fmt.Println(iam.ErrCodeServiceFailureException, 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) } diff --git a/service/inspector/examples_test.go b/service/inspector/examples_test.go deleted file mode 100644 index 3f4b2a6bccd..00000000000 --- a/service/inspector/examples_test.go +++ /dev/null @@ -1,894 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package inspector_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/inspector" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleInspector_AddAttributesToFindings() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.AddAttributesToFindingsInput{ - Attributes: []*inspector.Attribute{ // Required - { // Required - Key: aws.String("AttributeKey"), // Required - Value: aws.String("AttributeValue"), - }, - // More values... - }, - FindingArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.AddAttributesToFindings(params) - - if err != nil { - // 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) -} - -func ExampleInspector_CreateAssessmentTarget() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.CreateAssessmentTargetInput{ - AssessmentTargetName: aws.String("AssessmentTargetName"), // Required - ResourceGroupArn: aws.String("Arn"), // Required - } - resp, err := svc.CreateAssessmentTarget(params) - - if err != nil { - // 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) -} - -func ExampleInspector_CreateAssessmentTemplate() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.CreateAssessmentTemplateInput{ - AssessmentTargetArn: aws.String("Arn"), // Required - AssessmentTemplateName: aws.String("AssessmentTemplateName"), // Required - DurationInSeconds: aws.Int64(1), // Required - RulesPackageArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - UserAttributesForFindings: []*inspector.Attribute{ - { // Required - Key: aws.String("AttributeKey"), // Required - Value: aws.String("AttributeValue"), - }, - // More values... - }, - } - resp, err := svc.CreateAssessmentTemplate(params) - - if err != nil { - // 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) -} - -func ExampleInspector_CreateResourceGroup() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.CreateResourceGroupInput{ - ResourceGroupTags: []*inspector.ResourceGroupTag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.CreateResourceGroup(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DeleteAssessmentRun() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DeleteAssessmentRunInput{ - AssessmentRunArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteAssessmentRun(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DeleteAssessmentTarget() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DeleteAssessmentTargetInput{ - AssessmentTargetArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteAssessmentTarget(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DeleteAssessmentTemplate() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DeleteAssessmentTemplateInput{ - AssessmentTemplateArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteAssessmentTemplate(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeAssessmentRuns() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeAssessmentRunsInput{ - AssessmentRunArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.DescribeAssessmentRuns(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeAssessmentTargets() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeAssessmentTargetsInput{ - AssessmentTargetArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.DescribeAssessmentTargets(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeAssessmentTemplates() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeAssessmentTemplatesInput{ - AssessmentTemplateArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.DescribeAssessmentTemplates(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeCrossAccountAccessRole() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - var params *inspector.DescribeCrossAccountAccessRoleInput - resp, err := svc.DescribeCrossAccountAccessRole(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeFindings() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeFindingsInput{ - FindingArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - Locale: aws.String("Locale"), - } - resp, err := svc.DescribeFindings(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeResourceGroups() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeResourceGroupsInput{ - ResourceGroupArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.DescribeResourceGroups(params) - - if err != nil { - // 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) -} - -func ExampleInspector_DescribeRulesPackages() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.DescribeRulesPackagesInput{ - RulesPackageArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - Locale: aws.String("Locale"), - } - resp, err := svc.DescribeRulesPackages(params) - - if err != nil { - // 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) -} - -func ExampleInspector_GetAssessmentReport() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.GetAssessmentReportInput{ - AssessmentRunArn: aws.String("Arn"), // Required - ReportFileFormat: aws.String("ReportFileFormat"), // Required - ReportType: aws.String("ReportType"), // Required - } - resp, err := svc.GetAssessmentReport(params) - - if err != nil { - // 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) -} - -func ExampleInspector_GetTelemetryMetadata() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.GetTelemetryMetadataInput{ - AssessmentRunArn: aws.String("Arn"), // Required - } - resp, err := svc.GetTelemetryMetadata(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListAssessmentRunAgents() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListAssessmentRunAgentsInput{ - AssessmentRunArn: aws.String("Arn"), // Required - Filter: &inspector.AgentFilter{ - AgentHealthCodes: []*string{ // Required - aws.String("AgentHealthCode"), // Required - // More values... - }, - AgentHealths: []*string{ // Required - aws.String("AgentHealth"), // Required - // More values... - }, - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListAssessmentRunAgents(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListAssessmentRuns() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListAssessmentRunsInput{ - AssessmentTemplateArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - Filter: &inspector.AssessmentRunFilter{ - CompletionTimeRange: &inspector.TimestampRange{ - BeginDate: aws.Time(time.Now()), - EndDate: aws.Time(time.Now()), - }, - DurationRange: &inspector.DurationRange{ - MaxSeconds: aws.Int64(1), - MinSeconds: aws.Int64(1), - }, - NamePattern: aws.String("NamePattern"), - RulesPackageArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - StartTimeRange: &inspector.TimestampRange{ - BeginDate: aws.Time(time.Now()), - EndDate: aws.Time(time.Now()), - }, - StateChangeTimeRange: &inspector.TimestampRange{ - BeginDate: aws.Time(time.Now()), - EndDate: aws.Time(time.Now()), - }, - States: []*string{ - aws.String("AssessmentRunState"), // Required - // More values... - }, - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListAssessmentRuns(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListAssessmentTargets() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListAssessmentTargetsInput{ - Filter: &inspector.AssessmentTargetFilter{ - AssessmentTargetNamePattern: aws.String("NamePattern"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListAssessmentTargets(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListAssessmentTemplates() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListAssessmentTemplatesInput{ - AssessmentTargetArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - Filter: &inspector.AssessmentTemplateFilter{ - DurationRange: &inspector.DurationRange{ - MaxSeconds: aws.Int64(1), - MinSeconds: aws.Int64(1), - }, - NamePattern: aws.String("NamePattern"), - RulesPackageArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListAssessmentTemplates(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListEventSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListEventSubscriptionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - ResourceArn: aws.String("Arn"), - } - resp, err := svc.ListEventSubscriptions(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListFindings() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListFindingsInput{ - AssessmentRunArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - Filter: &inspector.FindingFilter{ - AgentIds: []*string{ - aws.String("AgentId"), // Required - // More values... - }, - Attributes: []*inspector.Attribute{ - { // Required - Key: aws.String("AttributeKey"), // Required - Value: aws.String("AttributeValue"), - }, - // More values... - }, - AutoScalingGroups: []*string{ - aws.String("AutoScalingGroup"), // Required - // More values... - }, - CreationTimeRange: &inspector.TimestampRange{ - BeginDate: aws.Time(time.Now()), - EndDate: aws.Time(time.Now()), - }, - RuleNames: []*string{ - aws.String("RuleName"), // Required - // More values... - }, - RulesPackageArns: []*string{ - aws.String("Arn"), // Required - // More values... - }, - Severities: []*string{ - aws.String("Severity"), // Required - // More values... - }, - UserAttributes: []*inspector.Attribute{ - { // Required - Key: aws.String("AttributeKey"), // Required - Value: aws.String("AttributeValue"), - }, - // More values... - }, - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListFindings(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListRulesPackages() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListRulesPackagesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListRulesPackages(params) - - if err != nil { - // 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) -} - -func ExampleInspector_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.ListTagsForResourceInput{ - ResourceArn: aws.String("Arn"), // Required - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleInspector_PreviewAgents() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.PreviewAgentsInput{ - PreviewAgentsArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.PreviewAgents(params) - - if err != nil { - // 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) -} - -func ExampleInspector_RegisterCrossAccountAccessRole() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.RegisterCrossAccountAccessRoleInput{ - RoleArn: aws.String("Arn"), // Required - } - resp, err := svc.RegisterCrossAccountAccessRole(params) - - if err != nil { - // 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) -} - -func ExampleInspector_RemoveAttributesFromFindings() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.RemoveAttributesFromFindingsInput{ - AttributeKeys: []*string{ // Required - aws.String("AttributeKey"), // Required - // More values... - }, - FindingArns: []*string{ // Required - aws.String("Arn"), // Required - // More values... - }, - } - resp, err := svc.RemoveAttributesFromFindings(params) - - if err != nil { - // 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) -} - -func ExampleInspector_SetTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.SetTagsForResourceInput{ - ResourceArn: aws.String("Arn"), // Required - Tags: []*inspector.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.SetTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleInspector_StartAssessmentRun() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.StartAssessmentRunInput{ - AssessmentTemplateArn: aws.String("Arn"), // Required - AssessmentRunName: aws.String("AssessmentRunName"), - } - resp, err := svc.StartAssessmentRun(params) - - if err != nil { - // 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) -} - -func ExampleInspector_StopAssessmentRun() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.StopAssessmentRunInput{ - AssessmentRunArn: aws.String("Arn"), // Required - } - resp, err := svc.StopAssessmentRun(params) - - if err != nil { - // 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) -} - -func ExampleInspector_SubscribeToEvent() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.SubscribeToEventInput{ - Event: aws.String("Event"), // Required - ResourceArn: aws.String("Arn"), // Required - TopicArn: aws.String("Arn"), // Required - } - resp, err := svc.SubscribeToEvent(params) - - if err != nil { - // 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) -} - -func ExampleInspector_UnsubscribeFromEvent() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.UnsubscribeFromEventInput{ - Event: aws.String("Event"), // Required - ResourceArn: aws.String("Arn"), // Required - TopicArn: aws.String("Arn"), // Required - } - resp, err := svc.UnsubscribeFromEvent(params) - - if err != nil { - // 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) -} - -func ExampleInspector_UpdateAssessmentTarget() { - sess := session.Must(session.NewSession()) - - svc := inspector.New(sess) - - params := &inspector.UpdateAssessmentTargetInput{ - AssessmentTargetArn: aws.String("Arn"), // Required - AssessmentTargetName: aws.String("AssessmentTargetName"), // Required - ResourceGroupArn: aws.String("Arn"), // Required - } - resp, err := svc.UpdateAssessmentTarget(params) - - if err != nil { - // 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) -} diff --git a/service/iot/examples_test.go b/service/iot/examples_test.go deleted file mode 100644 index d857dc3c4a6..00000000000 --- a/service/iot/examples_test.go +++ /dev/null @@ -1,1453 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package iot_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/iot" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleIoT_AcceptCertificateTransfer() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.AcceptCertificateTransferInput{ - CertificateId: aws.String("CertificateId"), // Required - SetAsActive: aws.Bool(true), - } - resp, err := svc.AcceptCertificateTransfer(params) - - if err != nil { - // 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) -} - -func ExampleIoT_AttachPrincipalPolicy() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.AttachPrincipalPolicyInput{ - PolicyName: aws.String("PolicyName"), // Required - Principal: aws.String("Principal"), // Required - } - resp, err := svc.AttachPrincipalPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIoT_AttachThingPrincipal() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.AttachThingPrincipalInput{ - Principal: aws.String("Principal"), // Required - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.AttachThingPrincipal(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CancelCertificateTransfer() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CancelCertificateTransferInput{ - CertificateId: aws.String("CertificateId"), // Required - } - resp, err := svc.CancelCertificateTransfer(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreateCertificateFromCsr() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreateCertificateFromCsrInput{ - CertificateSigningRequest: aws.String("CertificateSigningRequest"), // Required - SetAsActive: aws.Bool(true), - } - resp, err := svc.CreateCertificateFromCsr(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreateKeysAndCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreateKeysAndCertificateInput{ - SetAsActive: aws.Bool(true), - } - resp, err := svc.CreateKeysAndCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreatePolicy() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreatePolicyInput{ - PolicyDocument: aws.String("PolicyDocument"), // Required - PolicyName: aws.String("PolicyName"), // Required - } - resp, err := svc.CreatePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreatePolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreatePolicyVersionInput{ - PolicyDocument: aws.String("PolicyDocument"), // Required - PolicyName: aws.String("PolicyName"), // Required - SetAsDefault: aws.Bool(true), - } - resp, err := svc.CreatePolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreateThing() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreateThingInput{ - ThingName: aws.String("ThingName"), // Required - AttributePayload: &iot.AttributePayload{ - Attributes: map[string]*string{ - "Key": aws.String("AttributeValue"), // Required - // More values... - }, - Merge: aws.Bool(true), - }, - ThingTypeName: aws.String("ThingTypeName"), - } - resp, err := svc.CreateThing(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreateThingType() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreateThingTypeInput{ - ThingTypeName: aws.String("ThingTypeName"), // Required - ThingTypeProperties: &iot.ThingTypeProperties{ - SearchableAttributes: []*string{ - aws.String("AttributeName"), // Required - // More values... - }, - ThingTypeDescription: aws.String("ThingTypeDescription"), - }, - } - resp, err := svc.CreateThingType(params) - - if err != nil { - // 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) -} - -func ExampleIoT_CreateTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.CreateTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - TopicRulePayload: &iot.TopicRulePayload{ // Required - Actions: []*iot.Action{ // Required - { // Required - CloudwatchAlarm: &iot.CloudwatchAlarmAction{ - AlarmName: aws.String("AlarmName"), // Required - RoleArn: aws.String("AwsArn"), // Required - StateReason: aws.String("StateReason"), // Required - StateValue: aws.String("StateValue"), // Required - }, - CloudwatchMetric: &iot.CloudwatchMetricAction{ - MetricName: aws.String("MetricName"), // Required - MetricNamespace: aws.String("MetricNamespace"), // Required - MetricUnit: aws.String("MetricUnit"), // Required - MetricValue: aws.String("MetricValue"), // Required - RoleArn: aws.String("AwsArn"), // Required - MetricTimestamp: aws.String("MetricTimestamp"), - }, - DynamoDB: &iot.DynamoDBAction{ - HashKeyField: aws.String("HashKeyField"), // Required - HashKeyValue: aws.String("HashKeyValue"), // Required - RoleArn: aws.String("AwsArn"), // Required - TableName: aws.String("TableName"), // Required - HashKeyType: aws.String("DynamoKeyType"), - Operation: aws.String("DynamoOperation"), - PayloadField: aws.String("PayloadField"), - RangeKeyField: aws.String("RangeKeyField"), - RangeKeyType: aws.String("DynamoKeyType"), - RangeKeyValue: aws.String("RangeKeyValue"), - }, - DynamoDBv2: &iot.DynamoDBv2Action{ - PutItem: &iot.PutItemInput{ - TableName: aws.String("TableName"), // Required - }, - RoleArn: aws.String("AwsArn"), - }, - Elasticsearch: &iot.ElasticsearchAction{ - Endpoint: aws.String("ElasticsearchEndpoint"), // Required - Id: aws.String("ElasticsearchId"), // Required - Index: aws.String("ElasticsearchIndex"), // Required - RoleArn: aws.String("AwsArn"), // Required - Type: aws.String("ElasticsearchType"), // Required - }, - Firehose: &iot.FirehoseAction{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - RoleArn: aws.String("AwsArn"), // Required - Separator: aws.String("FirehoseSeparator"), - }, - Kinesis: &iot.KinesisAction{ - RoleArn: aws.String("AwsArn"), // Required - StreamName: aws.String("StreamName"), // Required - PartitionKey: aws.String("PartitionKey"), - }, - Lambda: &iot.LambdaAction{ - FunctionArn: aws.String("FunctionArn"), // Required - }, - Republish: &iot.RepublishAction{ - RoleArn: aws.String("AwsArn"), // Required - Topic: aws.String("TopicPattern"), // Required - }, - S3: &iot.S3Action{ - BucketName: aws.String("BucketName"), // Required - Key: aws.String("Key"), // Required - RoleArn: aws.String("AwsArn"), // Required - CannedAcl: aws.String("CannedAccessControlList"), - }, - Sns: &iot.SnsAction{ - RoleArn: aws.String("AwsArn"), // Required - TargetArn: aws.String("AwsArn"), // Required - MessageFormat: aws.String("MessageFormat"), - }, - Sqs: &iot.SqsAction{ - QueueUrl: aws.String("QueueUrl"), // Required - RoleArn: aws.String("AwsArn"), // Required - UseBase64: aws.Bool(true), - }, - }, - // More values... - }, - Sql: aws.String("SQL"), // Required - AwsIotSqlVersion: aws.String("AwsIotSqlVersion"), - Description: aws.String("Description"), - RuleDisabled: aws.Bool(true), - }, - } - resp, err := svc.CreateTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteCACertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeleteCACertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - } - resp, err := svc.DeleteCACertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeleteCertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - } - resp, err := svc.DeleteCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeletePolicy() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeletePolicyInput{ - PolicyName: aws.String("PolicyName"), // Required - } - resp, err := svc.DeletePolicy(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeletePolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeletePolicyVersionInput{ - PolicyName: aws.String("PolicyName"), // Required - PolicyVersionId: aws.String("PolicyVersionId"), // Required - } - resp, err := svc.DeletePolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteRegistrationCode() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - var params *iot.DeleteRegistrationCodeInput - resp, err := svc.DeleteRegistrationCode(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteThing() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeleteThingInput{ - ThingName: aws.String("ThingName"), // Required - ExpectedVersion: aws.Int64(1), - } - resp, err := svc.DeleteThing(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteThingType() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeleteThingTypeInput{ - ThingTypeName: aws.String("ThingTypeName"), // Required - } - resp, err := svc.DeleteThingType(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeleteTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeleteTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - } - resp, err := svc.DeleteTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DeprecateThingType() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DeprecateThingTypeInput{ - ThingTypeName: aws.String("ThingTypeName"), // Required - UndoDeprecate: aws.Bool(true), - } - resp, err := svc.DeprecateThingType(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DescribeCACertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DescribeCACertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - } - resp, err := svc.DescribeCACertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DescribeCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DescribeCertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - } - resp, err := svc.DescribeCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DescribeEndpoint() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - var params *iot.DescribeEndpointInput - resp, err := svc.DescribeEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DescribeThing() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DescribeThingInput{ - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.DescribeThing(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DescribeThingType() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DescribeThingTypeInput{ - ThingTypeName: aws.String("ThingTypeName"), // Required - } - resp, err := svc.DescribeThingType(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DetachPrincipalPolicy() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DetachPrincipalPolicyInput{ - PolicyName: aws.String("PolicyName"), // Required - Principal: aws.String("Principal"), // Required - } - resp, err := svc.DetachPrincipalPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DetachThingPrincipal() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DetachThingPrincipalInput{ - Principal: aws.String("Principal"), // Required - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.DetachThingPrincipal(params) - - if err != nil { - // 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) -} - -func ExampleIoT_DisableTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.DisableTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - } - resp, err := svc.DisableTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_EnableTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.EnableTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - } - resp, err := svc.EnableTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_GetLoggingOptions() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - var params *iot.GetLoggingOptionsInput - resp, err := svc.GetLoggingOptions(params) - - if err != nil { - // 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) -} - -func ExampleIoT_GetPolicy() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.GetPolicyInput{ - PolicyName: aws.String("PolicyName"), // Required - } - resp, err := svc.GetPolicy(params) - - if err != nil { - // 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) -} - -func ExampleIoT_GetPolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.GetPolicyVersionInput{ - PolicyName: aws.String("PolicyName"), // Required - PolicyVersionId: aws.String("PolicyVersionId"), // Required - } - resp, err := svc.GetPolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIoT_GetRegistrationCode() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - var params *iot.GetRegistrationCodeInput - resp, err := svc.GetRegistrationCode(params) - - if err != nil { - // 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) -} - -func ExampleIoT_GetTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.GetTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - } - resp, err := svc.GetTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListCACertificates() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListCACertificatesInput{ - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListCACertificates(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListCertificates() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListCertificatesInput{ - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListCertificates(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListCertificatesByCA() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListCertificatesByCAInput{ - CaCertificateId: aws.String("CertificateId"), // Required - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListCertificatesByCA(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListOutgoingCertificates() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListOutgoingCertificatesInput{ - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListOutgoingCertificates(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListPolicies() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListPoliciesInput{ - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListPolicyPrincipals() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListPolicyPrincipalsInput{ - PolicyName: aws.String("PolicyName"), // Required - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListPolicyPrincipals(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListPolicyVersions() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListPolicyVersionsInput{ - PolicyName: aws.String("PolicyName"), // Required - } - resp, err := svc.ListPolicyVersions(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListPrincipalPolicies() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListPrincipalPoliciesInput{ - Principal: aws.String("Principal"), // Required - AscendingOrder: aws.Bool(true), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), - } - resp, err := svc.ListPrincipalPolicies(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListPrincipalThings() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListPrincipalThingsInput{ - Principal: aws.String("Principal"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPrincipalThings(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListThingPrincipals() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListThingPrincipalsInput{ - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.ListThingPrincipals(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListThingTypes() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListThingTypesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ThingTypeName: aws.String("ThingTypeName"), - } - resp, err := svc.ListThingTypes(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListThings() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListThingsInput{ - AttributeName: aws.String("AttributeName"), - AttributeValue: aws.String("AttributeValue"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ThingTypeName: aws.String("ThingTypeName"), - } - resp, err := svc.ListThings(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ListTopicRules() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ListTopicRulesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - RuleDisabled: aws.Bool(true), - Topic: aws.String("Topic"), - } - resp, err := svc.ListTopicRules(params) - - if err != nil { - // 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) -} - -func ExampleIoT_RegisterCACertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.RegisterCACertificateInput{ - CaCertificate: aws.String("CertificatePem"), // Required - VerificationCertificate: aws.String("CertificatePem"), // Required - AllowAutoRegistration: aws.Bool(true), - SetAsActive: aws.Bool(true), - } - resp, err := svc.RegisterCACertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_RegisterCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.RegisterCertificateInput{ - CertificatePem: aws.String("CertificatePem"), // Required - CaCertificatePem: aws.String("CertificatePem"), - SetAsActive: aws.Bool(true), - Status: aws.String("CertificateStatus"), - } - resp, err := svc.RegisterCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_RejectCertificateTransfer() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.RejectCertificateTransferInput{ - CertificateId: aws.String("CertificateId"), // Required - RejectReason: aws.String("Message"), - } - resp, err := svc.RejectCertificateTransfer(params) - - if err != nil { - // 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) -} - -func ExampleIoT_ReplaceTopicRule() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.ReplaceTopicRuleInput{ - RuleName: aws.String("RuleName"), // Required - TopicRulePayload: &iot.TopicRulePayload{ // Required - Actions: []*iot.Action{ // Required - { // Required - CloudwatchAlarm: &iot.CloudwatchAlarmAction{ - AlarmName: aws.String("AlarmName"), // Required - RoleArn: aws.String("AwsArn"), // Required - StateReason: aws.String("StateReason"), // Required - StateValue: aws.String("StateValue"), // Required - }, - CloudwatchMetric: &iot.CloudwatchMetricAction{ - MetricName: aws.String("MetricName"), // Required - MetricNamespace: aws.String("MetricNamespace"), // Required - MetricUnit: aws.String("MetricUnit"), // Required - MetricValue: aws.String("MetricValue"), // Required - RoleArn: aws.String("AwsArn"), // Required - MetricTimestamp: aws.String("MetricTimestamp"), - }, - DynamoDB: &iot.DynamoDBAction{ - HashKeyField: aws.String("HashKeyField"), // Required - HashKeyValue: aws.String("HashKeyValue"), // Required - RoleArn: aws.String("AwsArn"), // Required - TableName: aws.String("TableName"), // Required - HashKeyType: aws.String("DynamoKeyType"), - Operation: aws.String("DynamoOperation"), - PayloadField: aws.String("PayloadField"), - RangeKeyField: aws.String("RangeKeyField"), - RangeKeyType: aws.String("DynamoKeyType"), - RangeKeyValue: aws.String("RangeKeyValue"), - }, - DynamoDBv2: &iot.DynamoDBv2Action{ - PutItem: &iot.PutItemInput{ - TableName: aws.String("TableName"), // Required - }, - RoleArn: aws.String("AwsArn"), - }, - Elasticsearch: &iot.ElasticsearchAction{ - Endpoint: aws.String("ElasticsearchEndpoint"), // Required - Id: aws.String("ElasticsearchId"), // Required - Index: aws.String("ElasticsearchIndex"), // Required - RoleArn: aws.String("AwsArn"), // Required - Type: aws.String("ElasticsearchType"), // Required - }, - Firehose: &iot.FirehoseAction{ - DeliveryStreamName: aws.String("DeliveryStreamName"), // Required - RoleArn: aws.String("AwsArn"), // Required - Separator: aws.String("FirehoseSeparator"), - }, - Kinesis: &iot.KinesisAction{ - RoleArn: aws.String("AwsArn"), // Required - StreamName: aws.String("StreamName"), // Required - PartitionKey: aws.String("PartitionKey"), - }, - Lambda: &iot.LambdaAction{ - FunctionArn: aws.String("FunctionArn"), // Required - }, - Republish: &iot.RepublishAction{ - RoleArn: aws.String("AwsArn"), // Required - Topic: aws.String("TopicPattern"), // Required - }, - S3: &iot.S3Action{ - BucketName: aws.String("BucketName"), // Required - Key: aws.String("Key"), // Required - RoleArn: aws.String("AwsArn"), // Required - CannedAcl: aws.String("CannedAccessControlList"), - }, - Sns: &iot.SnsAction{ - RoleArn: aws.String("AwsArn"), // Required - TargetArn: aws.String("AwsArn"), // Required - MessageFormat: aws.String("MessageFormat"), - }, - Sqs: &iot.SqsAction{ - QueueUrl: aws.String("QueueUrl"), // Required - RoleArn: aws.String("AwsArn"), // Required - UseBase64: aws.Bool(true), - }, - }, - // More values... - }, - Sql: aws.String("SQL"), // Required - AwsIotSqlVersion: aws.String("AwsIotSqlVersion"), - Description: aws.String("Description"), - RuleDisabled: aws.Bool(true), - }, - } - resp, err := svc.ReplaceTopicRule(params) - - if err != nil { - // 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) -} - -func ExampleIoT_SetDefaultPolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.SetDefaultPolicyVersionInput{ - PolicyName: aws.String("PolicyName"), // Required - PolicyVersionId: aws.String("PolicyVersionId"), // Required - } - resp, err := svc.SetDefaultPolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleIoT_SetLoggingOptions() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.SetLoggingOptionsInput{ - LoggingOptionsPayload: &iot.LoggingOptionsPayload{ // Required - RoleArn: aws.String("AwsArn"), // Required - LogLevel: aws.String("LogLevel"), - }, - } - resp, err := svc.SetLoggingOptions(params) - - if err != nil { - // 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) -} - -func ExampleIoT_TransferCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.TransferCertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - TargetAwsAccount: aws.String("AwsAccountId"), // Required - TransferMessage: aws.String("Message"), - } - resp, err := svc.TransferCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_UpdateCACertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.UpdateCACertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - NewAutoRegistrationStatus: aws.String("AutoRegistrationStatus"), - NewStatus: aws.String("CACertificateStatus"), - } - resp, err := svc.UpdateCACertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_UpdateCertificate() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.UpdateCertificateInput{ - CertificateId: aws.String("CertificateId"), // Required - NewStatus: aws.String("CertificateStatus"), // Required - } - resp, err := svc.UpdateCertificate(params) - - if err != nil { - // 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) -} - -func ExampleIoT_UpdateThing() { - sess := session.Must(session.NewSession()) - - svc := iot.New(sess) - - params := &iot.UpdateThingInput{ - ThingName: aws.String("ThingName"), // Required - AttributePayload: &iot.AttributePayload{ - Attributes: map[string]*string{ - "Key": aws.String("AttributeValue"), // Required - // More values... - }, - Merge: aws.Bool(true), - }, - ExpectedVersion: aws.Int64(1), - RemoveThingType: aws.Bool(true), - ThingTypeName: aws.String("ThingTypeName"), - } - resp, err := svc.UpdateThing(params) - - if err != nil { - // 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) -} diff --git a/service/iotdataplane/examples_test.go b/service/iotdataplane/examples_test.go deleted file mode 100644 index a43d59f27c9..00000000000 --- a/service/iotdataplane/examples_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package iotdataplane_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/iotdataplane" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleIoTDataPlane_DeleteThingShadow() { - sess := session.Must(session.NewSession()) - - svc := iotdataplane.New(sess) - - params := &iotdataplane.DeleteThingShadowInput{ - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.DeleteThingShadow(params) - - if err != nil { - // 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) -} - -func ExampleIoTDataPlane_GetThingShadow() { - sess := session.Must(session.NewSession()) - - svc := iotdataplane.New(sess) - - params := &iotdataplane.GetThingShadowInput{ - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.GetThingShadow(params) - - if err != nil { - // 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) -} - -func ExampleIoTDataPlane_Publish() { - sess := session.Must(session.NewSession()) - - svc := iotdataplane.New(sess) - - params := &iotdataplane.PublishInput{ - Topic: aws.String("Topic"), // Required - Payload: []byte("PAYLOAD"), - Qos: aws.Int64(1), - } - resp, err := svc.Publish(params) - - if err != nil { - // 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) -} - -func ExampleIoTDataPlane_UpdateThingShadow() { - sess := session.Must(session.NewSession()) - - svc := iotdataplane.New(sess) - - params := &iotdataplane.UpdateThingShadowInput{ - Payload: []byte("PAYLOAD"), // Required - ThingName: aws.String("ThingName"), // Required - } - resp, err := svc.UpdateThingShadow(params) - - if err != nil { - // 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) -} diff --git a/service/kinesis/examples_test.go b/service/kinesis/examples_test.go deleted file mode 100644 index 9464a36dc0f..00000000000 --- a/service/kinesis/examples_test.go +++ /dev/null @@ -1,460 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package kinesis_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/kinesis" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleKinesis_AddTagsToStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.AddTagsToStreamInput{ - StreamName: aws.String("StreamName"), // Required - Tags: map[string]*string{ // Required - "Key": aws.String("TagValue"), // Required - // More values... - }, - } - resp, err := svc.AddTagsToStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_CreateStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.CreateStreamInput{ - ShardCount: aws.Int64(1), // Required - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.CreateStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_DecreaseStreamRetentionPeriod() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.DecreaseStreamRetentionPeriodInput{ - RetentionPeriodHours: aws.Int64(1), // Required - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.DecreaseStreamRetentionPeriod(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_DeleteStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.DeleteStreamInput{ - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.DeleteStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_DescribeLimits() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - var params *kinesis.DescribeLimitsInput - resp, err := svc.DescribeLimits(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_DescribeStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.DescribeStreamInput{ - StreamName: aws.String("StreamName"), // Required - ExclusiveStartShardId: aws.String("ShardId"), - Limit: aws.Int64(1), - } - resp, err := svc.DescribeStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_DisableEnhancedMonitoring() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.DisableEnhancedMonitoringInput{ - ShardLevelMetrics: []*string{ // Required - aws.String("MetricsName"), // Required - // More values... - }, - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.DisableEnhancedMonitoring(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_EnableEnhancedMonitoring() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.EnableEnhancedMonitoringInput{ - ShardLevelMetrics: []*string{ // Required - aws.String("MetricsName"), // Required - // More values... - }, - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.EnableEnhancedMonitoring(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_GetRecords() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.GetRecordsInput{ - ShardIterator: aws.String("ShardIterator"), // Required - Limit: aws.Int64(1), - } - resp, err := svc.GetRecords(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_GetShardIterator() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.GetShardIteratorInput{ - ShardId: aws.String("ShardId"), // Required - ShardIteratorType: aws.String("ShardIteratorType"), // Required - StreamName: aws.String("StreamName"), // Required - StartingSequenceNumber: aws.String("SequenceNumber"), - Timestamp: aws.Time(time.Now()), - } - resp, err := svc.GetShardIterator(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_IncreaseStreamRetentionPeriod() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.IncreaseStreamRetentionPeriodInput{ - RetentionPeriodHours: aws.Int64(1), // Required - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.IncreaseStreamRetentionPeriod(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_ListStreams() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.ListStreamsInput{ - ExclusiveStartStreamName: aws.String("StreamName"), - Limit: aws.Int64(1), - } - resp, err := svc.ListStreams(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_ListTagsForStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.ListTagsForStreamInput{ - StreamName: aws.String("StreamName"), // Required - ExclusiveStartTagKey: aws.String("TagKey"), - Limit: aws.Int64(1), - } - resp, err := svc.ListTagsForStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_MergeShards() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.MergeShardsInput{ - AdjacentShardToMerge: aws.String("ShardId"), // Required - ShardToMerge: aws.String("ShardId"), // Required - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.MergeShards(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_PutRecord() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.PutRecordInput{ - Data: []byte("PAYLOAD"), // Required - PartitionKey: aws.String("PartitionKey"), // Required - StreamName: aws.String("StreamName"), // Required - ExplicitHashKey: aws.String("HashKey"), - SequenceNumberForOrdering: aws.String("SequenceNumber"), - } - resp, err := svc.PutRecord(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_PutRecords() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.PutRecordsInput{ - Records: []*kinesis.PutRecordsRequestEntry{ // Required - { // Required - Data: []byte("PAYLOAD"), // Required - PartitionKey: aws.String("PartitionKey"), // Required - ExplicitHashKey: aws.String("HashKey"), - }, - // More values... - }, - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.PutRecords(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_RemoveTagsFromStream() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.RemoveTagsFromStreamInput{ - StreamName: aws.String("StreamName"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromStream(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_SplitShard() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.SplitShardInput{ - NewStartingHashKey: aws.String("HashKey"), // Required - ShardToSplit: aws.String("ShardId"), // Required - StreamName: aws.String("StreamName"), // Required - } - resp, err := svc.SplitShard(params) - - if err != nil { - // 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) -} - -func ExampleKinesis_UpdateShardCount() { - sess := session.Must(session.NewSession()) - - svc := kinesis.New(sess) - - params := &kinesis.UpdateShardCountInput{ - ScalingType: aws.String("ScalingType"), // Required - StreamName: aws.String("StreamName"), // Required - TargetShardCount: aws.Int64(1), // Required - } - resp, err := svc.UpdateShardCount(params) - - if err != nil { - // 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) -} diff --git a/service/kinesisanalytics/examples_test.go b/service/kinesisanalytics/examples_test.go deleted file mode 100644 index 70e74d5d5f1..00000000000 --- a/service/kinesisanalytics/examples_test.go +++ /dev/null @@ -1,550 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package kinesisanalytics_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/kinesisanalytics" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleKinesisAnalytics_AddApplicationInput() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.AddApplicationInputInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentApplicationVersionId: aws.Int64(1), // Required - Input: &kinesisanalytics.Input{ // Required - InputSchema: &kinesisanalytics.SourceSchema{ // Required - RecordColumns: []*kinesisanalytics.RecordColumn{ // Required - { // Required - Name: aws.String("RecordColumnName"), // Required - SqlType: aws.String("RecordColumnSqlType"), // Required - Mapping: aws.String("RecordColumnMapping"), - }, - // More values... - }, - RecordFormat: &kinesisanalytics.RecordFormat{ // Required - RecordFormatType: aws.String("RecordFormatType"), // Required - MappingParameters: &kinesisanalytics.MappingParameters{ - CSVMappingParameters: &kinesisanalytics.CSVMappingParameters{ - RecordColumnDelimiter: aws.String("RecordColumnDelimiter"), // Required - RecordRowDelimiter: aws.String("RecordRowDelimiter"), // Required - }, - JSONMappingParameters: &kinesisanalytics.JSONMappingParameters{ - RecordRowPath: aws.String("RecordRowPath"), // Required - }, - }, - }, - RecordEncoding: aws.String("RecordEncoding"), - }, - NamePrefix: aws.String("InAppStreamName"), // Required - InputParallelism: &kinesisanalytics.InputParallelism{ - Count: aws.Int64(1), - }, - KinesisFirehoseInput: &kinesisanalytics.KinesisFirehoseInput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - KinesisStreamsInput: &kinesisanalytics.KinesisStreamsInput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - }, - } - resp, err := svc.AddApplicationInput(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_AddApplicationOutput() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.AddApplicationOutputInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentApplicationVersionId: aws.Int64(1), // Required - Output: &kinesisanalytics.Output{ // Required - DestinationSchema: &kinesisanalytics.DestinationSchema{ // Required - RecordFormatType: aws.String("RecordFormatType"), - }, - Name: aws.String("InAppStreamName"), // Required - KinesisFirehoseOutput: &kinesisanalytics.KinesisFirehoseOutput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - KinesisStreamsOutput: &kinesisanalytics.KinesisStreamsOutput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - }, - } - resp, err := svc.AddApplicationOutput(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_AddApplicationReferenceDataSource() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.AddApplicationReferenceDataSourceInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentApplicationVersionId: aws.Int64(1), // Required - ReferenceDataSource: &kinesisanalytics.ReferenceDataSource{ // Required - ReferenceSchema: &kinesisanalytics.SourceSchema{ // Required - RecordColumns: []*kinesisanalytics.RecordColumn{ // Required - { // Required - Name: aws.String("RecordColumnName"), // Required - SqlType: aws.String("RecordColumnSqlType"), // Required - Mapping: aws.String("RecordColumnMapping"), - }, - // More values... - }, - RecordFormat: &kinesisanalytics.RecordFormat{ // Required - RecordFormatType: aws.String("RecordFormatType"), // Required - MappingParameters: &kinesisanalytics.MappingParameters{ - CSVMappingParameters: &kinesisanalytics.CSVMappingParameters{ - RecordColumnDelimiter: aws.String("RecordColumnDelimiter"), // Required - RecordRowDelimiter: aws.String("RecordRowDelimiter"), // Required - }, - JSONMappingParameters: &kinesisanalytics.JSONMappingParameters{ - RecordRowPath: aws.String("RecordRowPath"), // Required - }, - }, - }, - RecordEncoding: aws.String("RecordEncoding"), - }, - TableName: aws.String("InAppTableName"), // Required - S3ReferenceDataSource: &kinesisanalytics.S3ReferenceDataSource{ - BucketARN: aws.String("BucketARN"), // Required - FileKey: aws.String("FileKey"), // Required - ReferenceRoleARN: aws.String("RoleARN"), // Required - }, - }, - } - resp, err := svc.AddApplicationReferenceDataSource(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_CreateApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.CreateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - ApplicationCode: aws.String("ApplicationCode"), - ApplicationDescription: aws.String("ApplicationDescription"), - Inputs: []*kinesisanalytics.Input{ - { // Required - InputSchema: &kinesisanalytics.SourceSchema{ // Required - RecordColumns: []*kinesisanalytics.RecordColumn{ // Required - { // Required - Name: aws.String("RecordColumnName"), // Required - SqlType: aws.String("RecordColumnSqlType"), // Required - Mapping: aws.String("RecordColumnMapping"), - }, - // More values... - }, - RecordFormat: &kinesisanalytics.RecordFormat{ // Required - RecordFormatType: aws.String("RecordFormatType"), // Required - MappingParameters: &kinesisanalytics.MappingParameters{ - CSVMappingParameters: &kinesisanalytics.CSVMappingParameters{ - RecordColumnDelimiter: aws.String("RecordColumnDelimiter"), // Required - RecordRowDelimiter: aws.String("RecordRowDelimiter"), // Required - }, - JSONMappingParameters: &kinesisanalytics.JSONMappingParameters{ - RecordRowPath: aws.String("RecordRowPath"), // Required - }, - }, - }, - RecordEncoding: aws.String("RecordEncoding"), - }, - NamePrefix: aws.String("InAppStreamName"), // Required - InputParallelism: &kinesisanalytics.InputParallelism{ - Count: aws.Int64(1), - }, - KinesisFirehoseInput: &kinesisanalytics.KinesisFirehoseInput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - KinesisStreamsInput: &kinesisanalytics.KinesisStreamsInput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - }, - // More values... - }, - Outputs: []*kinesisanalytics.Output{ - { // Required - DestinationSchema: &kinesisanalytics.DestinationSchema{ // Required - RecordFormatType: aws.String("RecordFormatType"), - }, - Name: aws.String("InAppStreamName"), // Required - KinesisFirehoseOutput: &kinesisanalytics.KinesisFirehoseOutput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - KinesisStreamsOutput: &kinesisanalytics.KinesisStreamsOutput{ - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.CreateApplication(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_DeleteApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.DeleteApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CreateTimestamp: aws.Time(time.Now()), // Required - } - resp, err := svc.DeleteApplication(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_DeleteApplicationOutput() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.DeleteApplicationOutputInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentApplicationVersionId: aws.Int64(1), // Required - OutputId: aws.String("Id"), // Required - } - resp, err := svc.DeleteApplicationOutput(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_DeleteApplicationReferenceDataSource() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.DeleteApplicationReferenceDataSourceInput{ - ApplicationName: aws.String("ApplicationName"), // Required - CurrentApplicationVersionId: aws.Int64(1), // Required - ReferenceId: aws.String("Id"), // Required - } - resp, err := svc.DeleteApplicationReferenceDataSource(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_DescribeApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.DescribeApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - } - resp, err := svc.DescribeApplication(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_DiscoverInputSchema() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.DiscoverInputSchemaInput{ - InputStartingPositionConfiguration: &kinesisanalytics.InputStartingPositionConfiguration{ // Required - InputStartingPosition: aws.String("InputStartingPosition"), - }, - ResourceARN: aws.String("ResourceARN"), // Required - RoleARN: aws.String("RoleARN"), // Required - } - resp, err := svc.DiscoverInputSchema(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_ListApplications() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.ListApplicationsInput{ - ExclusiveStartApplicationName: aws.String("ApplicationName"), - Limit: aws.Int64(1), - } - resp, err := svc.ListApplications(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_StartApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.StartApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - InputConfigurations: []*kinesisanalytics.InputConfiguration{ // Required - { // Required - Id: aws.String("Id"), // Required - InputStartingPositionConfiguration: &kinesisanalytics.InputStartingPositionConfiguration{ // Required - InputStartingPosition: aws.String("InputStartingPosition"), - }, - }, - // More values... - }, - } - resp, err := svc.StartApplication(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_StopApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.StopApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - } - resp, err := svc.StopApplication(params) - - if err != nil { - // 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) -} - -func ExampleKinesisAnalytics_UpdateApplication() { - sess := session.Must(session.NewSession()) - - svc := kinesisanalytics.New(sess) - - params := &kinesisanalytics.UpdateApplicationInput{ - ApplicationName: aws.String("ApplicationName"), // Required - ApplicationUpdate: &kinesisanalytics.ApplicationUpdate{ // Required - ApplicationCodeUpdate: aws.String("ApplicationCode"), - InputUpdates: []*kinesisanalytics.InputUpdate{ - { // Required - InputId: aws.String("Id"), // Required - InputParallelismUpdate: &kinesisanalytics.InputParallelismUpdate{ - CountUpdate: aws.Int64(1), - }, - InputSchemaUpdate: &kinesisanalytics.InputSchemaUpdate{ - RecordColumnUpdates: []*kinesisanalytics.RecordColumn{ - { // Required - Name: aws.String("RecordColumnName"), // Required - SqlType: aws.String("RecordColumnSqlType"), // Required - Mapping: aws.String("RecordColumnMapping"), - }, - // More values... - }, - RecordEncodingUpdate: aws.String("RecordEncoding"), - RecordFormatUpdate: &kinesisanalytics.RecordFormat{ - RecordFormatType: aws.String("RecordFormatType"), // Required - MappingParameters: &kinesisanalytics.MappingParameters{ - CSVMappingParameters: &kinesisanalytics.CSVMappingParameters{ - RecordColumnDelimiter: aws.String("RecordColumnDelimiter"), // Required - RecordRowDelimiter: aws.String("RecordRowDelimiter"), // Required - }, - JSONMappingParameters: &kinesisanalytics.JSONMappingParameters{ - RecordRowPath: aws.String("RecordRowPath"), // Required - }, - }, - }, - }, - KinesisFirehoseInputUpdate: &kinesisanalytics.KinesisFirehoseInputUpdate{ - ResourceARNUpdate: aws.String("ResourceARN"), - RoleARNUpdate: aws.String("RoleARN"), - }, - KinesisStreamsInputUpdate: &kinesisanalytics.KinesisStreamsInputUpdate{ - ResourceARNUpdate: aws.String("ResourceARN"), - RoleARNUpdate: aws.String("RoleARN"), - }, - NamePrefixUpdate: aws.String("InAppStreamName"), - }, - // More values... - }, - OutputUpdates: []*kinesisanalytics.OutputUpdate{ - { // Required - OutputId: aws.String("Id"), // Required - DestinationSchemaUpdate: &kinesisanalytics.DestinationSchema{ - RecordFormatType: aws.String("RecordFormatType"), - }, - KinesisFirehoseOutputUpdate: &kinesisanalytics.KinesisFirehoseOutputUpdate{ - ResourceARNUpdate: aws.String("ResourceARN"), - RoleARNUpdate: aws.String("RoleARN"), - }, - KinesisStreamsOutputUpdate: &kinesisanalytics.KinesisStreamsOutputUpdate{ - ResourceARNUpdate: aws.String("ResourceARN"), - RoleARNUpdate: aws.String("RoleARN"), - }, - NameUpdate: aws.String("InAppStreamName"), - }, - // More values... - }, - ReferenceDataSourceUpdates: []*kinesisanalytics.ReferenceDataSourceUpdate{ - { // Required - ReferenceId: aws.String("Id"), // Required - ReferenceSchemaUpdate: &kinesisanalytics.SourceSchema{ - RecordColumns: []*kinesisanalytics.RecordColumn{ // Required - { // Required - Name: aws.String("RecordColumnName"), // Required - SqlType: aws.String("RecordColumnSqlType"), // Required - Mapping: aws.String("RecordColumnMapping"), - }, - // More values... - }, - RecordFormat: &kinesisanalytics.RecordFormat{ // Required - RecordFormatType: aws.String("RecordFormatType"), // Required - MappingParameters: &kinesisanalytics.MappingParameters{ - CSVMappingParameters: &kinesisanalytics.CSVMappingParameters{ - RecordColumnDelimiter: aws.String("RecordColumnDelimiter"), // Required - RecordRowDelimiter: aws.String("RecordRowDelimiter"), // Required - }, - JSONMappingParameters: &kinesisanalytics.JSONMappingParameters{ - RecordRowPath: aws.String("RecordRowPath"), // Required - }, - }, - }, - RecordEncoding: aws.String("RecordEncoding"), - }, - S3ReferenceDataSourceUpdate: &kinesisanalytics.S3ReferenceDataSourceUpdate{ - BucketARNUpdate: aws.String("BucketARN"), - FileKeyUpdate: aws.String("FileKey"), - ReferenceRoleARNUpdate: aws.String("RoleARN"), - }, - TableNameUpdate: aws.String("InAppTableName"), - }, - // More values... - }, - }, - CurrentApplicationVersionId: aws.Int64(1), // Required - } - resp, err := svc.UpdateApplication(params) - - if err != nil { - // 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) -} diff --git a/service/kms/examples_test.go b/service/kms/examples_test.go deleted file mode 100644 index 165b2839efb..00000000000 --- a/service/kms/examples_test.go +++ /dev/null @@ -1,875 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package kms_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/kms" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleKMS_CancelKeyDeletion() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.CancelKeyDeletionInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.CancelKeyDeletion(params) - - if err != nil { - // 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) -} - -func ExampleKMS_CreateAlias() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.CreateAliasInput{ - AliasName: aws.String("AliasNameType"), // Required - TargetKeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.CreateAlias(params) - - if err != nil { - // 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) -} - -func ExampleKMS_CreateGrant() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.CreateGrantInput{ - GranteePrincipal: aws.String("PrincipalIdType"), // Required - KeyId: aws.String("KeyIdType"), // Required - Constraints: &kms.GrantConstraints{ - EncryptionContextEquals: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - EncryptionContextSubset: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - Name: aws.String("GrantNameType"), - Operations: []*string{ - aws.String("GrantOperation"), // Required - // More values... - }, - RetiringPrincipal: aws.String("PrincipalIdType"), - } - resp, err := svc.CreateGrant(params) - - if err != nil { - // 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) -} - -func ExampleKMS_CreateKey() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.CreateKeyInput{ - BypassPolicyLockoutSafetyCheck: aws.Bool(true), - Description: aws.String("DescriptionType"), - KeyUsage: aws.String("KeyUsageType"), - Origin: aws.String("OriginType"), - Policy: aws.String("PolicyType"), - Tags: []*kms.Tag{ - { // Required - TagKey: aws.String("TagKeyType"), // Required - TagValue: aws.String("TagValueType"), // Required - }, - // More values... - }, - } - resp, err := svc.CreateKey(params) - - if err != nil { - // 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) -} - -func ExampleKMS_Decrypt() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DecryptInput{ - CiphertextBlob: []byte("PAYLOAD"), // Required - EncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - } - resp, err := svc.Decrypt(params) - - if err != nil { - // 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) -} - -func ExampleKMS_DeleteAlias() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DeleteAliasInput{ - AliasName: aws.String("AliasNameType"), // Required - } - resp, err := svc.DeleteAlias(params) - - if err != nil { - // 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) -} - -func ExampleKMS_DeleteImportedKeyMaterial() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DeleteImportedKeyMaterialInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.DeleteImportedKeyMaterial(params) - - if err != nil { - // 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) -} - -func ExampleKMS_DescribeKey() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DescribeKeyInput{ - KeyId: aws.String("KeyIdType"), // Required - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - } - resp, err := svc.DescribeKey(params) - - if err != nil { - // 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) -} - -func ExampleKMS_DisableKey() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DisableKeyInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.DisableKey(params) - - if err != nil { - // 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) -} - -func ExampleKMS_DisableKeyRotation() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.DisableKeyRotationInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.DisableKeyRotation(params) - - if err != nil { - // 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) -} - -func ExampleKMS_EnableKey() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.EnableKeyInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.EnableKey(params) - - if err != nil { - // 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) -} - -func ExampleKMS_EnableKeyRotation() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.EnableKeyRotationInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.EnableKeyRotation(params) - - if err != nil { - // 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) -} - -func ExampleKMS_Encrypt() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.EncryptInput{ - KeyId: aws.String("KeyIdType"), // Required - Plaintext: []byte("PAYLOAD"), // Required - EncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - } - resp, err := svc.Encrypt(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GenerateDataKey() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GenerateDataKeyInput{ - KeyId: aws.String("KeyIdType"), // Required - EncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - KeySpec: aws.String("DataKeySpec"), - NumberOfBytes: aws.Int64(1), - } - resp, err := svc.GenerateDataKey(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GenerateDataKeyWithoutPlaintext() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GenerateDataKeyWithoutPlaintextInput{ - KeyId: aws.String("KeyIdType"), // Required - EncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - KeySpec: aws.String("DataKeySpec"), - NumberOfBytes: aws.Int64(1), - } - resp, err := svc.GenerateDataKeyWithoutPlaintext(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GenerateRandom() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GenerateRandomInput{ - NumberOfBytes: aws.Int64(1), - } - resp, err := svc.GenerateRandom(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GetKeyPolicy() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GetKeyPolicyInput{ - KeyId: aws.String("KeyIdType"), // Required - PolicyName: aws.String("PolicyNameType"), // Required - } - resp, err := svc.GetKeyPolicy(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GetKeyRotationStatus() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GetKeyRotationStatusInput{ - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.GetKeyRotationStatus(params) - - if err != nil { - // 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) -} - -func ExampleKMS_GetParametersForImport() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.GetParametersForImportInput{ - KeyId: aws.String("KeyIdType"), // Required - WrappingAlgorithm: aws.String("AlgorithmSpec"), // Required - WrappingKeySpec: aws.String("WrappingKeySpec"), // Required - } - resp, err := svc.GetParametersForImport(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ImportKeyMaterial() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ImportKeyMaterialInput{ - EncryptedKeyMaterial: []byte("PAYLOAD"), // Required - ImportToken: []byte("PAYLOAD"), // Required - KeyId: aws.String("KeyIdType"), // Required - ExpirationModel: aws.String("ExpirationModelType"), - ValidTo: aws.Time(time.Now()), - } - resp, err := svc.ImportKeyMaterial(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListAliases() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListAliasesInput{ - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListAliases(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListGrants() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListGrantsInput{ - KeyId: aws.String("KeyIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListGrants(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListKeyPolicies() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListKeyPoliciesInput{ - KeyId: aws.String("KeyIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListKeyPolicies(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListKeys() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListKeysInput{ - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListKeys(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListResourceTags() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListResourceTagsInput{ - KeyId: aws.String("KeyIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListResourceTags(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ListRetirableGrants() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ListRetirableGrantsInput{ - RetiringPrincipal: aws.String("PrincipalIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("MarkerType"), - } - resp, err := svc.ListRetirableGrants(params) - - if err != nil { - // 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) -} - -func ExampleKMS_PutKeyPolicy() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.PutKeyPolicyInput{ - KeyId: aws.String("KeyIdType"), // Required - Policy: aws.String("PolicyType"), // Required - PolicyName: aws.String("PolicyNameType"), // Required - BypassPolicyLockoutSafetyCheck: aws.Bool(true), - } - resp, err := svc.PutKeyPolicy(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ReEncrypt() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ReEncryptInput{ - CiphertextBlob: []byte("PAYLOAD"), // Required - DestinationKeyId: aws.String("KeyIdType"), // Required - DestinationEncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - GrantTokens: []*string{ - aws.String("GrantTokenType"), // Required - // More values... - }, - SourceEncryptionContext: map[string]*string{ - "Key": aws.String("EncryptionContextValue"), // Required - // More values... - }, - } - resp, err := svc.ReEncrypt(params) - - if err != nil { - // 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) -} - -func ExampleKMS_RetireGrant() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.RetireGrantInput{ - GrantId: aws.String("GrantIdType"), - GrantToken: aws.String("GrantTokenType"), - KeyId: aws.String("KeyIdType"), - } - resp, err := svc.RetireGrant(params) - - if err != nil { - // 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) -} - -func ExampleKMS_RevokeGrant() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.RevokeGrantInput{ - GrantId: aws.String("GrantIdType"), // Required - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.RevokeGrant(params) - - if err != nil { - // 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) -} - -func ExampleKMS_ScheduleKeyDeletion() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.ScheduleKeyDeletionInput{ - KeyId: aws.String("KeyIdType"), // Required - PendingWindowInDays: aws.Int64(1), - } - resp, err := svc.ScheduleKeyDeletion(params) - - if err != nil { - // 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) -} - -func ExampleKMS_TagResource() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.TagResourceInput{ - KeyId: aws.String("KeyIdType"), // Required - Tags: []*kms.Tag{ // Required - { // Required - TagKey: aws.String("TagKeyType"), // Required - TagValue: aws.String("TagValueType"), // Required - }, - // More values... - }, - } - resp, err := svc.TagResource(params) - - if err != nil { - // 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) -} - -func ExampleKMS_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.UntagResourceInput{ - KeyId: aws.String("KeyIdType"), // Required - TagKeys: []*string{ // Required - aws.String("TagKeyType"), // Required - // More values... - }, - } - resp, err := svc.UntagResource(params) - - if err != nil { - // 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) -} - -func ExampleKMS_UpdateAlias() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.UpdateAliasInput{ - AliasName: aws.String("AliasNameType"), // Required - TargetKeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.UpdateAlias(params) - - if err != nil { - // 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) -} - -func ExampleKMS_UpdateKeyDescription() { - sess := session.Must(session.NewSession()) - - svc := kms.New(sess) - - params := &kms.UpdateKeyDescriptionInput{ - Description: aws.String("DescriptionType"), // Required - KeyId: aws.String("KeyIdType"), // Required - } - resp, err := svc.UpdateKeyDescription(params) - - if err != nil { - // 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) -} diff --git a/service/lambda/examples_test.go b/service/lambda/examples_test.go deleted file mode 100644 index cab0d99645f..00000000000 --- a/service/lambda/examples_test.go +++ /dev/null @@ -1,731 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package lambda_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/lambda" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleLambda_AddPermission() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.AddPermissionInput{ - Action: aws.String("Action"), // Required - FunctionName: aws.String("FunctionName"), // Required - Principal: aws.String("Principal"), // Required - StatementId: aws.String("StatementId"), // Required - EventSourceToken: aws.String("EventSourceToken"), - Qualifier: aws.String("Qualifier"), - SourceAccount: aws.String("SourceOwner"), - SourceArn: aws.String("Arn"), - } - resp, err := svc.AddPermission(params) - - if err != nil { - // 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) -} - -func ExampleLambda_CreateAlias() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.CreateAliasInput{ - FunctionName: aws.String("FunctionName"), // Required - FunctionVersion: aws.String("Version"), // Required - Name: aws.String("Alias"), // Required - Description: aws.String("Description"), - } - resp, err := svc.CreateAlias(params) - - if err != nil { - // 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) -} - -func ExampleLambda_CreateEventSourceMapping() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.CreateEventSourceMappingInput{ - EventSourceArn: aws.String("Arn"), // Required - FunctionName: aws.String("FunctionName"), // Required - StartingPosition: aws.String("EventSourcePosition"), // Required - BatchSize: aws.Int64(1), - Enabled: aws.Bool(true), - StartingPositionTimestamp: aws.Time(time.Now()), - } - resp, err := svc.CreateEventSourceMapping(params) - - if err != nil { - // 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) -} - -func ExampleLambda_CreateFunction() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.CreateFunctionInput{ - Code: &lambda.FunctionCode{ // Required - S3Bucket: aws.String("S3Bucket"), - S3Key: aws.String("S3Key"), - S3ObjectVersion: aws.String("S3ObjectVersion"), - ZipFile: []byte("PAYLOAD"), - }, - FunctionName: aws.String("FunctionName"), // Required - Handler: aws.String("Handler"), // Required - Role: aws.String("RoleArn"), // Required - Runtime: aws.String("Runtime"), // Required - DeadLetterConfig: &lambda.DeadLetterConfig{ - TargetArn: aws.String("ResourceArn"), - }, - Description: aws.String("Description"), - Environment: &lambda.Environment{ - Variables: map[string]*string{ - "Key": aws.String("EnvironmentVariableValue"), // Required - // More values... - }, - }, - KMSKeyArn: aws.String("KMSKeyArn"), - MemorySize: aws.Int64(1), - Publish: aws.Bool(true), - Tags: map[string]*string{ - "Key": aws.String("TagValue"), // Required - // More values... - }, - Timeout: aws.Int64(1), - TracingConfig: &lambda.TracingConfig{ - Mode: aws.String("TracingMode"), - }, - VpcConfig: &lambda.VpcConfig{ - SecurityGroupIds: []*string{ - aws.String("SecurityGroupId"), // Required - // More values... - }, - SubnetIds: []*string{ - aws.String("SubnetId"), // Required - // More values... - }, - }, - } - resp, err := svc.CreateFunction(params) - - if err != nil { - // 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) -} - -func ExampleLambda_DeleteAlias() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.DeleteAliasInput{ - FunctionName: aws.String("FunctionName"), // Required - Name: aws.String("Alias"), // Required - } - resp, err := svc.DeleteAlias(params) - - if err != nil { - // 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) -} - -func ExampleLambda_DeleteEventSourceMapping() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.DeleteEventSourceMappingInput{ - UUID: aws.String("String"), // Required - } - resp, err := svc.DeleteEventSourceMapping(params) - - if err != nil { - // 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) -} - -func ExampleLambda_DeleteFunction() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.DeleteFunctionInput{ - FunctionName: aws.String("FunctionName"), // Required - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.DeleteFunction(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetAccountSettings() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - var params *lambda.GetAccountSettingsInput - resp, err := svc.GetAccountSettings(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetAlias() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.GetAliasInput{ - FunctionName: aws.String("FunctionName"), // Required - Name: aws.String("Alias"), // Required - } - resp, err := svc.GetAlias(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetEventSourceMapping() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.GetEventSourceMappingInput{ - UUID: aws.String("String"), // Required - } - resp, err := svc.GetEventSourceMapping(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetFunction() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.GetFunctionInput{ - FunctionName: aws.String("FunctionName"), // Required - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.GetFunction(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetFunctionConfiguration() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.GetFunctionConfigurationInput{ - FunctionName: aws.String("FunctionName"), // Required - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.GetFunctionConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleLambda_GetPolicy() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.GetPolicyInput{ - FunctionName: aws.String("FunctionName"), // Required - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.GetPolicy(params) - - if err != nil { - // 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) -} - -func ExampleLambda_Invoke() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.InvokeInput{ - FunctionName: aws.String("FunctionName"), // Required - ClientContext: aws.String("String"), - InvocationType: aws.String("InvocationType"), - LogType: aws.String("LogType"), - Payload: []byte("PAYLOAD"), - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.Invoke(params) - - if err != nil { - // 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) -} - -func ExampleLambda_InvokeAsync() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.InvokeAsyncInput{ - FunctionName: aws.String("FunctionName"), // Required - InvokeArgs: bytes.NewReader([]byte("PAYLOAD")), // Required - } - resp, err := svc.InvokeAsync(params) - - if err != nil { - // 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) -} - -func ExampleLambda_ListAliases() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.ListAliasesInput{ - FunctionName: aws.String("FunctionName"), // Required - FunctionVersion: aws.String("Version"), - Marker: aws.String("String"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListAliases(params) - - if err != nil { - // 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) -} - -func ExampleLambda_ListEventSourceMappings() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.ListEventSourceMappingsInput{ - EventSourceArn: aws.String("Arn"), - FunctionName: aws.String("FunctionName"), - Marker: aws.String("String"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListEventSourceMappings(params) - - if err != nil { - // 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) -} - -func ExampleLambda_ListFunctions() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.ListFunctionsInput{ - Marker: aws.String("String"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListFunctions(params) - - if err != nil { - // 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) -} - -func ExampleLambda_ListTags() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.ListTagsInput{ - Resource: aws.String("FunctionArn"), // Required - } - resp, err := svc.ListTags(params) - - if err != nil { - // 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) -} - -func ExampleLambda_ListVersionsByFunction() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.ListVersionsByFunctionInput{ - FunctionName: aws.String("FunctionName"), // Required - Marker: aws.String("String"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListVersionsByFunction(params) - - if err != nil { - // 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) -} - -func ExampleLambda_PublishVersion() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.PublishVersionInput{ - FunctionName: aws.String("FunctionName"), // Required - CodeSha256: aws.String("String"), - Description: aws.String("Description"), - } - resp, err := svc.PublishVersion(params) - - if err != nil { - // 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) -} - -func ExampleLambda_RemovePermission() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.RemovePermissionInput{ - FunctionName: aws.String("FunctionName"), // Required - StatementId: aws.String("StatementId"), // Required - Qualifier: aws.String("Qualifier"), - } - resp, err := svc.RemovePermission(params) - - if err != nil { - // 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) -} - -func ExampleLambda_TagResource() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.TagResourceInput{ - Resource: aws.String("FunctionArn"), // Required - Tags: map[string]*string{ // Required - "Key": aws.String("TagValue"), // Required - // More values... - }, - } - resp, err := svc.TagResource(params) - - if err != nil { - // 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) -} - -func ExampleLambda_UntagResource() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.UntagResourceInput{ - Resource: aws.String("FunctionArn"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UntagResource(params) - - if err != nil { - // 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) -} - -func ExampleLambda_UpdateAlias() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.UpdateAliasInput{ - FunctionName: aws.String("FunctionName"), // Required - Name: aws.String("Alias"), // Required - Description: aws.String("Description"), - FunctionVersion: aws.String("Version"), - } - resp, err := svc.UpdateAlias(params) - - if err != nil { - // 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) -} - -func ExampleLambda_UpdateEventSourceMapping() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.UpdateEventSourceMappingInput{ - UUID: aws.String("String"), // Required - BatchSize: aws.Int64(1), - Enabled: aws.Bool(true), - FunctionName: aws.String("FunctionName"), - } - resp, err := svc.UpdateEventSourceMapping(params) - - if err != nil { - // 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) -} - -func ExampleLambda_UpdateFunctionCode() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.UpdateFunctionCodeInput{ - FunctionName: aws.String("FunctionName"), // Required - DryRun: aws.Bool(true), - Publish: aws.Bool(true), - S3Bucket: aws.String("S3Bucket"), - S3Key: aws.String("S3Key"), - S3ObjectVersion: aws.String("S3ObjectVersion"), - ZipFile: []byte("PAYLOAD"), - } - resp, err := svc.UpdateFunctionCode(params) - - if err != nil { - // 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) -} - -func ExampleLambda_UpdateFunctionConfiguration() { - sess := session.Must(session.NewSession()) - - svc := lambda.New(sess) - - params := &lambda.UpdateFunctionConfigurationInput{ - FunctionName: aws.String("FunctionName"), // Required - DeadLetterConfig: &lambda.DeadLetterConfig{ - TargetArn: aws.String("ResourceArn"), - }, - Description: aws.String("Description"), - Environment: &lambda.Environment{ - Variables: map[string]*string{ - "Key": aws.String("EnvironmentVariableValue"), // Required - // More values... - }, - }, - Handler: aws.String("Handler"), - KMSKeyArn: aws.String("KMSKeyArn"), - MemorySize: aws.Int64(1), - Role: aws.String("RoleArn"), - Runtime: aws.String("Runtime"), - Timeout: aws.Int64(1), - TracingConfig: &lambda.TracingConfig{ - Mode: aws.String("TracingMode"), - }, - VpcConfig: &lambda.VpcConfig{ - SecurityGroupIds: []*string{ - aws.String("SecurityGroupId"), // Required - // More values... - }, - SubnetIds: []*string{ - aws.String("SubnetId"), // Required - // More values... - }, - }, - } - resp, err := svc.UpdateFunctionConfiguration(params) - - if err != nil { - // 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) -} diff --git a/service/lexmodelbuildingservice/examples_test.go b/service/lexmodelbuildingservice/examples_test.go deleted file mode 100644 index 2ccfd9bff2d..00000000000 --- a/service/lexmodelbuildingservice/examples_test.go +++ /dev/null @@ -1,901 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package lexmodelbuildingservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/lexmodelbuildingservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleLexModelBuildingService_CreateBotVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.CreateBotVersionInput{ - Name: aws.String("BotName"), // Required - Checksum: aws.String("String"), - } - resp, err := svc.CreateBotVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_CreateIntentVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.CreateIntentVersionInput{ - Name: aws.String("IntentName"), // Required - Checksum: aws.String("String"), - } - resp, err := svc.CreateIntentVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_CreateSlotTypeVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.CreateSlotTypeVersionInput{ - Name: aws.String("SlotTypeName"), // Required - Checksum: aws.String("String"), - } - resp, err := svc.CreateSlotTypeVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteBot() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteBotInput{ - Name: aws.String("BotName"), // Required - } - resp, err := svc.DeleteBot(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteBotAlias() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteBotAliasInput{ - BotName: aws.String("BotName"), // Required - Name: aws.String("AliasName"), // Required - } - resp, err := svc.DeleteBotAlias(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteBotChannelAssociation() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteBotChannelAssociationInput{ - BotAlias: aws.String("AliasName"), // Required - BotName: aws.String("BotName"), // Required - Name: aws.String("BotChannelName"), // Required - } - resp, err := svc.DeleteBotChannelAssociation(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteBotVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteBotVersionInput{ - Name: aws.String("BotName"), // Required - Version: aws.String("NumericalVersion"), // Required - } - resp, err := svc.DeleteBotVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteIntent() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteIntentInput{ - Name: aws.String("IntentName"), // Required - } - resp, err := svc.DeleteIntent(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteIntentVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteIntentVersionInput{ - Name: aws.String("IntentName"), // Required - Version: aws.String("NumericalVersion"), // Required - } - resp, err := svc.DeleteIntentVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteSlotType() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteSlotTypeInput{ - Name: aws.String("SlotTypeName"), // Required - } - resp, err := svc.DeleteSlotType(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteSlotTypeVersion() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteSlotTypeVersionInput{ - Name: aws.String("SlotTypeName"), // Required - Version: aws.String("NumericalVersion"), // Required - } - resp, err := svc.DeleteSlotTypeVersion(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_DeleteUtterances() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.DeleteUtterancesInput{ - BotName: aws.String("BotName"), // Required - UserId: aws.String("UserId"), // Required - } - resp, err := svc.DeleteUtterances(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBot() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotInput{ - Name: aws.String("BotName"), // Required - VersionOrAlias: aws.String("String"), // Required - } - resp, err := svc.GetBot(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBotAlias() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotAliasInput{ - BotName: aws.String("BotName"), // Required - Name: aws.String("AliasName"), // Required - } - resp, err := svc.GetBotAlias(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBotAliases() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotAliasesInput{ - BotName: aws.String("BotName"), // Required - MaxResults: aws.Int64(1), - NameContains: aws.String("AliasName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetBotAliases(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBotChannelAssociation() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotChannelAssociationInput{ - BotAlias: aws.String("AliasName"), // Required - BotName: aws.String("BotName"), // Required - Name: aws.String("BotChannelName"), // Required - } - resp, err := svc.GetBotChannelAssociation(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBotChannelAssociations() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotChannelAssociationsInput{ - BotAlias: aws.String("AliasNameOrListAll"), // Required - BotName: aws.String("BotName"), // Required - MaxResults: aws.Int64(1), - NameContains: aws.String("BotChannelName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetBotChannelAssociations(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBotVersions() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotVersionsInput{ - Name: aws.String("BotName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetBotVersions(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBots() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBotsInput{ - MaxResults: aws.Int64(1), - NameContains: aws.String("BotName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetBots(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBuiltinIntent() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBuiltinIntentInput{ - Signature: aws.String("BuiltinIntentSignature"), // Required - } - resp, err := svc.GetBuiltinIntent(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBuiltinIntents() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBuiltinIntentsInput{ - Locale: aws.String("Locale"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - SignatureContains: aws.String("String"), - } - resp, err := svc.GetBuiltinIntents(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetBuiltinSlotTypes() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetBuiltinSlotTypesInput{ - Locale: aws.String("Locale"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - SignatureContains: aws.String("String"), - } - resp, err := svc.GetBuiltinSlotTypes(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetIntent() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetIntentInput{ - Name: aws.String("IntentName"), // Required - Version: aws.String("Version"), // Required - } - resp, err := svc.GetIntent(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetIntentVersions() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetIntentVersionsInput{ - Name: aws.String("IntentName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetIntentVersions(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetIntents() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetIntentsInput{ - MaxResults: aws.Int64(1), - NameContains: aws.String("IntentName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetIntents(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetSlotType() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetSlotTypeInput{ - Name: aws.String("SlotTypeName"), // Required - Version: aws.String("Version"), // Required - } - resp, err := svc.GetSlotType(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetSlotTypeVersions() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetSlotTypeVersionsInput{ - Name: aws.String("SlotTypeName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetSlotTypeVersions(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetSlotTypes() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetSlotTypesInput{ - MaxResults: aws.Int64(1), - NameContains: aws.String("SlotTypeName"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetSlotTypes(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_GetUtterancesView() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.GetUtterancesViewInput{ - BotName: aws.String("BotName"), // Required - BotVersions: []*string{ // Required - aws.String("Version"), // Required - // More values... - }, - StatusType: aws.String("StatusType"), // Required - } - resp, err := svc.GetUtterancesView(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_PutBot() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.PutBotInput{ - ChildDirected: aws.Bool(true), // Required - Locale: aws.String("Locale"), // Required - Name: aws.String("BotName"), // Required - AbortStatement: &lexmodelbuildingservice.Statement{ - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - Checksum: aws.String("String"), - ClarificationPrompt: &lexmodelbuildingservice.Prompt{ - MaxAttempts: aws.Int64(1), // Required - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - Description: aws.String("Description"), - IdleSessionTTLInSeconds: aws.Int64(1), - Intents: []*lexmodelbuildingservice.Intent{ - { // Required - IntentName: aws.String("IntentName"), // Required - IntentVersion: aws.String("Version"), // Required - }, - // More values... - }, - ProcessBehavior: aws.String("ProcessBehavior"), - VoiceId: aws.String("String"), - } - resp, err := svc.PutBot(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_PutBotAlias() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.PutBotAliasInput{ - BotName: aws.String("BotName"), // Required - BotVersion: aws.String("Version"), // Required - Name: aws.String("AliasName"), // Required - Checksum: aws.String("String"), - Description: aws.String("Description"), - } - resp, err := svc.PutBotAlias(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_PutIntent() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.PutIntentInput{ - Name: aws.String("IntentName"), // Required - Checksum: aws.String("String"), - ConclusionStatement: &lexmodelbuildingservice.Statement{ - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - ConfirmationPrompt: &lexmodelbuildingservice.Prompt{ - MaxAttempts: aws.Int64(1), // Required - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - Description: aws.String("Description"), - DialogCodeHook: &lexmodelbuildingservice.CodeHook{ - MessageVersion: aws.String("MessageVersion"), // Required - Uri: aws.String("LambdaARN"), // Required - }, - FollowUpPrompt: &lexmodelbuildingservice.FollowUpPrompt{ - Prompt: &lexmodelbuildingservice.Prompt{ // Required - MaxAttempts: aws.Int64(1), // Required - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - RejectionStatement: &lexmodelbuildingservice.Statement{ // Required - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - }, - FulfillmentActivity: &lexmodelbuildingservice.FulfillmentActivity{ - Type: aws.String("FulfillmentActivityType"), // Required - CodeHook: &lexmodelbuildingservice.CodeHook{ - MessageVersion: aws.String("MessageVersion"), // Required - Uri: aws.String("LambdaARN"), // Required - }, - }, - ParentIntentSignature: aws.String("BuiltinIntentSignature"), - RejectionStatement: &lexmodelbuildingservice.Statement{ - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - SampleUtterances: []*string{ - aws.String("Utterance"), // Required - // More values... - }, - Slots: []*lexmodelbuildingservice.Slot{ - { // Required - Name: aws.String("SlotName"), // Required - SlotConstraint: aws.String("SlotConstraint"), // Required - Description: aws.String("Description"), - Priority: aws.Int64(1), - ResponseCard: aws.String("ResponseCard"), - SampleUtterances: []*string{ - aws.String("Utterance"), // Required - // More values... - }, - SlotType: aws.String("CustomOrBuiltinSlotTypeName"), - SlotTypeVersion: aws.String("Version"), - ValueElicitationPrompt: &lexmodelbuildingservice.Prompt{ - MaxAttempts: aws.Int64(1), // Required - Messages: []*lexmodelbuildingservice.Message{ // Required - { // Required - Content: aws.String("ContentString"), // Required - ContentType: aws.String("ContentType"), // Required - }, - // More values... - }, - ResponseCard: aws.String("ResponseCard"), - }, - }, - // More values... - }, - } - resp, err := svc.PutIntent(params) - - if err != nil { - // 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) -} - -func ExampleLexModelBuildingService_PutSlotType() { - sess := session.Must(session.NewSession()) - - svc := lexmodelbuildingservice.New(sess) - - params := &lexmodelbuildingservice.PutSlotTypeInput{ - Name: aws.String("SlotTypeName"), // Required - Checksum: aws.String("String"), - Description: aws.String("Description"), - EnumerationValues: []*lexmodelbuildingservice.EnumerationValue{ - { // Required - Value: aws.String("Value"), // Required - }, - // More values... - }, - } - resp, err := svc.PutSlotType(params) - - if err != nil { - // 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) -} diff --git a/service/lexruntimeservice/examples_test.go b/service/lexruntimeservice/examples_test.go deleted file mode 100644 index b02dfe831bc..00000000000 --- a/service/lexruntimeservice/examples_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package lexruntimeservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/lexruntimeservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleLexRuntimeService_PostContent() { - sess := session.Must(session.NewSession()) - - svc := lexruntimeservice.New(sess) - - params := &lexruntimeservice.PostContentInput{ - BotAlias: aws.String("BotAlias"), // Required - BotName: aws.String("BotName"), // Required - ContentType: aws.String("HttpContentType"), // Required - InputStream: bytes.NewReader([]byte("PAYLOAD")), // Required - UserId: aws.String("UserId"), // Required - Accept: aws.String("Accept"), - SessionAttributes: aws.JSONValue{"key": "value"}, - } - resp, err := svc.PostContent(params) - - if err != nil { - // 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) -} - -func ExampleLexRuntimeService_PostText() { - sess := session.Must(session.NewSession()) - - svc := lexruntimeservice.New(sess) - - params := &lexruntimeservice.PostTextInput{ - BotAlias: aws.String("BotAlias"), // Required - BotName: aws.String("BotName"), // Required - InputText: aws.String("Text"), // Required - UserId: aws.String("UserId"), // Required - SessionAttributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.PostText(params) - - if err != nil { - // 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) -} diff --git a/service/lightsail/examples_test.go b/service/lightsail/examples_test.go deleted file mode 100644 index f648047e3bb..00000000000 --- a/service/lightsail/examples_test.go +++ /dev/null @@ -1,1097 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package lightsail_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/lightsail" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleLightsail_AllocateStaticIp() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.AllocateStaticIpInput{ - StaticIpName: aws.String("ResourceName"), // Required - } - resp, err := svc.AllocateStaticIp(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_AttachStaticIp() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.AttachStaticIpInput{ - InstanceName: aws.String("ResourceName"), // Required - StaticIpName: aws.String("ResourceName"), // Required - } - resp, err := svc.AttachStaticIp(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CloseInstancePublicPorts() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CloseInstancePublicPortsInput{ - InstanceName: aws.String("ResourceName"), // Required - PortInfo: &lightsail.PortInfo{ // Required - FromPort: aws.Int64(1), - Protocol: aws.String("NetworkProtocol"), - ToPort: aws.Int64(1), - }, - } - resp, err := svc.CloseInstancePublicPorts(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateDomain() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.CreateDomain(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateDomainEntry() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateDomainEntryInput{ - DomainEntry: &lightsail.DomainEntry{ // Required - Id: aws.String("NonEmptyString"), - Name: aws.String("DomainName"), - Options: map[string]*string{ - "Key": aws.String("string"), // Required - // More values... - }, - Target: aws.String("string"), - Type: aws.String("DomainEntryType"), - }, - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.CreateDomainEntry(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateInstanceSnapshot() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateInstanceSnapshotInput{ - InstanceName: aws.String("ResourceName"), // Required - InstanceSnapshotName: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateInstanceSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateInstances() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateInstancesInput{ - AvailabilityZone: aws.String("string"), // Required - BlueprintId: aws.String("NonEmptyString"), // Required - BundleId: aws.String("NonEmptyString"), // Required - InstanceNames: []*string{ // Required - aws.String("string"), // Required - // More values... - }, - CustomImageName: aws.String("ResourceName"), - KeyPairName: aws.String("ResourceName"), - UserData: aws.String("string"), - } - resp, err := svc.CreateInstances(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateInstancesFromSnapshot() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateInstancesFromSnapshotInput{ - AvailabilityZone: aws.String("string"), // Required - BundleId: aws.String("NonEmptyString"), // Required - InstanceNames: []*string{ // Required - aws.String("string"), // Required - // More values... - }, - InstanceSnapshotName: aws.String("ResourceName"), // Required - KeyPairName: aws.String("ResourceName"), - UserData: aws.String("string"), - } - resp, err := svc.CreateInstancesFromSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_CreateKeyPair() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.CreateKeyPairInput{ - KeyPairName: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DeleteDomain() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DeleteDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DeleteDomain(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DeleteDomainEntry() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DeleteDomainEntryInput{ - DomainEntry: &lightsail.DomainEntry{ // Required - Id: aws.String("NonEmptyString"), - Name: aws.String("DomainName"), - Options: map[string]*string{ - "Key": aws.String("string"), // Required - // More values... - }, - Target: aws.String("string"), - Type: aws.String("DomainEntryType"), - }, - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DeleteDomainEntry(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DeleteInstance() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DeleteInstanceInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.DeleteInstance(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DeleteInstanceSnapshot() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DeleteInstanceSnapshotInput{ - InstanceSnapshotName: aws.String("ResourceName"), // Required - } - resp, err := svc.DeleteInstanceSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DeleteKeyPair() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DeleteKeyPairInput{ - KeyPairName: aws.String("ResourceName"), // Required - } - resp, err := svc.DeleteKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DetachStaticIp() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.DetachStaticIpInput{ - StaticIpName: aws.String("ResourceName"), // Required - } - resp, err := svc.DetachStaticIp(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_DownloadDefaultKeyPair() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - var params *lightsail.DownloadDefaultKeyPairInput - resp, err := svc.DownloadDefaultKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetActiveNames() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetActiveNamesInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetActiveNames(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetBlueprints() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetBlueprintsInput{ - IncludeInactive: aws.Bool(true), - PageToken: aws.String("string"), - } - resp, err := svc.GetBlueprints(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetBundles() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetBundlesInput{ - IncludeInactive: aws.Bool(true), - PageToken: aws.String("string"), - } - resp, err := svc.GetBundles(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetDomain() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.GetDomain(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetDomains() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetDomainsInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetDomains(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstance() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetInstance(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstanceAccessDetails() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceAccessDetailsInput{ - InstanceName: aws.String("ResourceName"), // Required - Protocol: aws.String("InstanceAccessProtocol"), - } - resp, err := svc.GetInstanceAccessDetails(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstanceMetricData() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceMetricDataInput{ - EndTime: aws.Time(time.Now()), // Required - InstanceName: aws.String("ResourceName"), // Required - MetricName: aws.String("InstanceMetricName"), // Required - Period: aws.Int64(1), // Required - StartTime: aws.Time(time.Now()), // Required - Statistics: []*string{ // Required - aws.String("MetricStatistic"), // Required - // More values... - }, - Unit: aws.String("MetricUnit"), // Required - } - resp, err := svc.GetInstanceMetricData(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstancePortStates() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstancePortStatesInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetInstancePortStates(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstanceSnapshot() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceSnapshotInput{ - InstanceSnapshotName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetInstanceSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstanceSnapshots() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceSnapshotsInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetInstanceSnapshots(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstanceState() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstanceStateInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetInstanceState(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetInstances() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetInstancesInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetInstances(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetKeyPair() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetKeyPairInput{ - KeyPairName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetKeyPairs() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetKeyPairsInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetKeyPairs(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetOperation() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetOperationInput{ - OperationId: aws.String("NonEmptyString"), // Required - } - resp, err := svc.GetOperation(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetOperations() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetOperationsInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetOperations(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetOperationsForResource() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetOperationsForResourceInput{ - ResourceName: aws.String("ResourceName"), // Required - PageToken: aws.String("string"), - } - resp, err := svc.GetOperationsForResource(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetRegions() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetRegionsInput{ - IncludeAvailabilityZones: aws.Bool(true), - } - resp, err := svc.GetRegions(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetStaticIp() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetStaticIpInput{ - StaticIpName: aws.String("ResourceName"), // Required - } - resp, err := svc.GetStaticIp(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_GetStaticIps() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.GetStaticIpsInput{ - PageToken: aws.String("string"), - } - resp, err := svc.GetStaticIps(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_ImportKeyPair() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.ImportKeyPairInput{ - KeyPairName: aws.String("ResourceName"), // Required - PublicKeyBase64: aws.String("Base64"), // Required - } - resp, err := svc.ImportKeyPair(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_IsVpcPeered() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - var params *lightsail.IsVpcPeeredInput - resp, err := svc.IsVpcPeered(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_OpenInstancePublicPorts() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.OpenInstancePublicPortsInput{ - InstanceName: aws.String("ResourceName"), // Required - PortInfo: &lightsail.PortInfo{ // Required - FromPort: aws.Int64(1), - Protocol: aws.String("NetworkProtocol"), - ToPort: aws.Int64(1), - }, - } - resp, err := svc.OpenInstancePublicPorts(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_PeerVpc() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - var params *lightsail.PeerVpcInput - resp, err := svc.PeerVpc(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_PutInstancePublicPorts() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.PutInstancePublicPortsInput{ - InstanceName: aws.String("ResourceName"), // Required - PortInfos: []*lightsail.PortInfo{ // Required - { // Required - FromPort: aws.Int64(1), - Protocol: aws.String("NetworkProtocol"), - ToPort: aws.Int64(1), - }, - // More values... - }, - } - resp, err := svc.PutInstancePublicPorts(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_RebootInstance() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.RebootInstanceInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.RebootInstance(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_ReleaseStaticIp() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.ReleaseStaticIpInput{ - StaticIpName: aws.String("ResourceName"), // Required - } - resp, err := svc.ReleaseStaticIp(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_StartInstance() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.StartInstanceInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.StartInstance(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_StopInstance() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.StopInstanceInput{ - InstanceName: aws.String("ResourceName"), // Required - } - resp, err := svc.StopInstance(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_UnpeerVpc() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - var params *lightsail.UnpeerVpcInput - resp, err := svc.UnpeerVpc(params) - - if err != nil { - // 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) -} - -func ExampleLightsail_UpdateDomainEntry() { - sess := session.Must(session.NewSession()) - - svc := lightsail.New(sess) - - params := &lightsail.UpdateDomainEntryInput{ - DomainEntry: &lightsail.DomainEntry{ // Required - Id: aws.String("NonEmptyString"), - Name: aws.String("DomainName"), - Options: map[string]*string{ - "Key": aws.String("string"), // Required - // More values... - }, - Target: aws.String("string"), - Type: aws.String("DomainEntryType"), - }, - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.UpdateDomainEntry(params) - - if err != nil { - // 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) -} diff --git a/service/machinelearning/examples_test.go b/service/machinelearning/examples_test.go deleted file mode 100644 index a3ef7af0cdf..00000000000 --- a/service/machinelearning/examples_test.go +++ /dev/null @@ -1,737 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package machinelearning_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/machinelearning" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMachineLearning_AddTags() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.AddTagsInput{ - ResourceId: aws.String("EntityId"), // Required - ResourceType: aws.String("TaggableResourceType"), // Required - Tags: []*machinelearning.Tag{ // Required - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.AddTags(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateBatchPrediction() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateBatchPredictionInput{ - BatchPredictionDataSourceId: aws.String("EntityId"), // Required - BatchPredictionId: aws.String("EntityId"), // Required - MLModelId: aws.String("EntityId"), // Required - OutputUri: aws.String("S3Url"), // Required - BatchPredictionName: aws.String("EntityName"), - } - resp, err := svc.CreateBatchPrediction(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateDataSourceFromRDS() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateDataSourceFromRDSInput{ - DataSourceId: aws.String("EntityId"), // Required - RDSData: &machinelearning.RDSDataSpec{ // Required - DatabaseCredentials: &machinelearning.RDSDatabaseCredentials{ // Required - Password: aws.String("RDSDatabasePassword"), // Required - Username: aws.String("RDSDatabaseUsername"), // Required - }, - DatabaseInformation: &machinelearning.RDSDatabase{ // Required - DatabaseName: aws.String("RDSDatabaseName"), // Required - InstanceIdentifier: aws.String("RDSInstanceIdentifier"), // Required - }, - ResourceRole: aws.String("EDPResourceRole"), // Required - S3StagingLocation: aws.String("S3Url"), // Required - SecurityGroupIds: []*string{ // Required - aws.String("EDPSecurityGroupId"), // Required - // More values... - }, - SelectSqlQuery: aws.String("RDSSelectSqlQuery"), // Required - ServiceRole: aws.String("EDPServiceRole"), // Required - SubnetId: aws.String("EDPSubnetId"), // Required - DataRearrangement: aws.String("DataRearrangement"), - DataSchema: aws.String("DataSchema"), - DataSchemaUri: aws.String("S3Url"), - }, - RoleARN: aws.String("RoleARN"), // Required - ComputeStatistics: aws.Bool(true), - DataSourceName: aws.String("EntityName"), - } - resp, err := svc.CreateDataSourceFromRDS(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateDataSourceFromRedshift() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateDataSourceFromRedshiftInput{ - DataSourceId: aws.String("EntityId"), // Required - DataSpec: &machinelearning.RedshiftDataSpec{ // Required - DatabaseCredentials: &machinelearning.RedshiftDatabaseCredentials{ // Required - Password: aws.String("RedshiftDatabasePassword"), // Required - Username: aws.String("RedshiftDatabaseUsername"), // Required - }, - DatabaseInformation: &machinelearning.RedshiftDatabase{ // Required - ClusterIdentifier: aws.String("RedshiftClusterIdentifier"), // Required - DatabaseName: aws.String("RedshiftDatabaseName"), // Required - }, - S3StagingLocation: aws.String("S3Url"), // Required - SelectSqlQuery: aws.String("RedshiftSelectSqlQuery"), // Required - DataRearrangement: aws.String("DataRearrangement"), - DataSchema: aws.String("DataSchema"), - DataSchemaUri: aws.String("S3Url"), - }, - RoleARN: aws.String("RoleARN"), // Required - ComputeStatistics: aws.Bool(true), - DataSourceName: aws.String("EntityName"), - } - resp, err := svc.CreateDataSourceFromRedshift(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateDataSourceFromS3() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateDataSourceFromS3Input{ - DataSourceId: aws.String("EntityId"), // Required - DataSpec: &machinelearning.S3DataSpec{ // Required - DataLocationS3: aws.String("S3Url"), // Required - DataRearrangement: aws.String("DataRearrangement"), - DataSchema: aws.String("DataSchema"), - DataSchemaLocationS3: aws.String("S3Url"), - }, - ComputeStatistics: aws.Bool(true), - DataSourceName: aws.String("EntityName"), - } - resp, err := svc.CreateDataSourceFromS3(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateEvaluation() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateEvaluationInput{ - EvaluationDataSourceId: aws.String("EntityId"), // Required - EvaluationId: aws.String("EntityId"), // Required - MLModelId: aws.String("EntityId"), // Required - EvaluationName: aws.String("EntityName"), - } - resp, err := svc.CreateEvaluation(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateMLModel() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateMLModelInput{ - MLModelId: aws.String("EntityId"), // Required - MLModelType: aws.String("MLModelType"), // Required - TrainingDataSourceId: aws.String("EntityId"), // Required - MLModelName: aws.String("EntityName"), - Parameters: map[string]*string{ - "Key": aws.String("StringType"), // Required - // More values... - }, - Recipe: aws.String("Recipe"), - RecipeUri: aws.String("S3Url"), - } - resp, err := svc.CreateMLModel(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_CreateRealtimeEndpoint() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.CreateRealtimeEndpointInput{ - MLModelId: aws.String("EntityId"), // Required - } - resp, err := svc.CreateRealtimeEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteBatchPrediction() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteBatchPredictionInput{ - BatchPredictionId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteBatchPrediction(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteDataSource() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteDataSourceInput{ - DataSourceId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteDataSource(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteEvaluation() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteEvaluationInput{ - EvaluationId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteEvaluation(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteMLModel() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteMLModelInput{ - MLModelId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteMLModel(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteRealtimeEndpoint() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteRealtimeEndpointInput{ - MLModelId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteRealtimeEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DeleteTagsInput{ - ResourceId: aws.String("EntityId"), // Required - ResourceType: aws.String("TaggableResourceType"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.DeleteTags(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DescribeBatchPredictions() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DescribeBatchPredictionsInput{ - EQ: aws.String("ComparatorValue"), - FilterVariable: aws.String("BatchPredictionFilterVariable"), - GE: aws.String("ComparatorValue"), - GT: aws.String("ComparatorValue"), - LE: aws.String("ComparatorValue"), - LT: aws.String("ComparatorValue"), - Limit: aws.Int64(1), - NE: aws.String("ComparatorValue"), - NextToken: aws.String("StringType"), - Prefix: aws.String("ComparatorValue"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.DescribeBatchPredictions(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DescribeDataSources() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DescribeDataSourcesInput{ - EQ: aws.String("ComparatorValue"), - FilterVariable: aws.String("DataSourceFilterVariable"), - GE: aws.String("ComparatorValue"), - GT: aws.String("ComparatorValue"), - LE: aws.String("ComparatorValue"), - LT: aws.String("ComparatorValue"), - Limit: aws.Int64(1), - NE: aws.String("ComparatorValue"), - NextToken: aws.String("StringType"), - Prefix: aws.String("ComparatorValue"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.DescribeDataSources(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DescribeEvaluations() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DescribeEvaluationsInput{ - EQ: aws.String("ComparatorValue"), - FilterVariable: aws.String("EvaluationFilterVariable"), - GE: aws.String("ComparatorValue"), - GT: aws.String("ComparatorValue"), - LE: aws.String("ComparatorValue"), - LT: aws.String("ComparatorValue"), - Limit: aws.Int64(1), - NE: aws.String("ComparatorValue"), - NextToken: aws.String("StringType"), - Prefix: aws.String("ComparatorValue"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.DescribeEvaluations(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DescribeMLModels() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DescribeMLModelsInput{ - EQ: aws.String("ComparatorValue"), - FilterVariable: aws.String("MLModelFilterVariable"), - GE: aws.String("ComparatorValue"), - GT: aws.String("ComparatorValue"), - LE: aws.String("ComparatorValue"), - LT: aws.String("ComparatorValue"), - Limit: aws.Int64(1), - NE: aws.String("ComparatorValue"), - NextToken: aws.String("StringType"), - Prefix: aws.String("ComparatorValue"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.DescribeMLModels(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.DescribeTagsInput{ - ResourceId: aws.String("EntityId"), // Required - ResourceType: aws.String("TaggableResourceType"), // Required - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_GetBatchPrediction() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.GetBatchPredictionInput{ - BatchPredictionId: aws.String("EntityId"), // Required - } - resp, err := svc.GetBatchPrediction(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_GetDataSource() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.GetDataSourceInput{ - DataSourceId: aws.String("EntityId"), // Required - Verbose: aws.Bool(true), - } - resp, err := svc.GetDataSource(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_GetEvaluation() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.GetEvaluationInput{ - EvaluationId: aws.String("EntityId"), // Required - } - resp, err := svc.GetEvaluation(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_GetMLModel() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.GetMLModelInput{ - MLModelId: aws.String("EntityId"), // Required - Verbose: aws.Bool(true), - } - resp, err := svc.GetMLModel(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_Predict() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.PredictInput{ - MLModelId: aws.String("EntityId"), // Required - PredictEndpoint: aws.String("VipURL"), // Required - Record: map[string]*string{ // Required - "Key": aws.String("VariableValue"), // Required - // More values... - }, - } - resp, err := svc.Predict(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_UpdateBatchPrediction() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.UpdateBatchPredictionInput{ - BatchPredictionId: aws.String("EntityId"), // Required - BatchPredictionName: aws.String("EntityName"), // Required - } - resp, err := svc.UpdateBatchPrediction(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_UpdateDataSource() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.UpdateDataSourceInput{ - DataSourceId: aws.String("EntityId"), // Required - DataSourceName: aws.String("EntityName"), // Required - } - resp, err := svc.UpdateDataSource(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_UpdateEvaluation() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.UpdateEvaluationInput{ - EvaluationId: aws.String("EntityId"), // Required - EvaluationName: aws.String("EntityName"), // Required - } - resp, err := svc.UpdateEvaluation(params) - - if err != nil { - // 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) -} - -func ExampleMachineLearning_UpdateMLModel() { - sess := session.Must(session.NewSession()) - - svc := machinelearning.New(sess) - - params := &machinelearning.UpdateMLModelInput{ - MLModelId: aws.String("EntityId"), // Required - MLModelName: aws.String("EntityName"), - ScoreThreshold: aws.Float64(1.0), - } - resp, err := svc.UpdateMLModel(params) - - if err != nil { - // 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) -} diff --git a/service/marketplacecommerceanalytics/examples_test.go b/service/marketplacecommerceanalytics/examples_test.go deleted file mode 100644 index a479538caf5..00000000000 --- a/service/marketplacecommerceanalytics/examples_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package marketplacecommerceanalytics_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/marketplacecommerceanalytics" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMarketplaceCommerceAnalytics_GenerateDataSet() { - sess := session.Must(session.NewSession()) - - svc := marketplacecommerceanalytics.New(sess) - - params := &marketplacecommerceanalytics.GenerateDataSetInput{ - DataSetPublicationDate: aws.Time(time.Now()), // Required - DataSetType: aws.String("DataSetType"), // Required - DestinationS3BucketName: aws.String("DestinationS3BucketName"), // Required - RoleNameArn: aws.String("RoleNameArn"), // Required - SnsTopicArn: aws.String("SnsTopicArn"), // Required - CustomerDefinedValues: map[string]*string{ - "Key": aws.String("OptionalValue"), // Required - // More values... - }, - DestinationS3Prefix: aws.String("DestinationS3Prefix"), - } - resp, err := svc.GenerateDataSet(params) - - if err != nil { - // 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) -} - -func ExampleMarketplaceCommerceAnalytics_StartSupportDataExport() { - sess := session.Must(session.NewSession()) - - svc := marketplacecommerceanalytics.New(sess) - - params := &marketplacecommerceanalytics.StartSupportDataExportInput{ - DataSetType: aws.String("SupportDataSetType"), // Required - DestinationS3BucketName: aws.String("DestinationS3BucketName"), // Required - FromDate: aws.Time(time.Now()), // Required - RoleNameArn: aws.String("RoleNameArn"), // Required - SnsTopicArn: aws.String("SnsTopicArn"), // Required - CustomerDefinedValues: map[string]*string{ - "Key": aws.String("OptionalValue"), // Required - // More values... - }, - DestinationS3Prefix: aws.String("DestinationS3Prefix"), - } - resp, err := svc.StartSupportDataExport(params) - - if err != nil { - // 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) -} diff --git a/service/marketplaceentitlementservice/examples_test.go b/service/marketplaceentitlementservice/examples_test.go deleted file mode 100644 index 101c882e0fc..00000000000 --- a/service/marketplaceentitlementservice/examples_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package marketplaceentitlementservice_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/marketplaceentitlementservice" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMarketplaceEntitlementService_GetEntitlements() { - sess := session.Must(session.NewSession()) - - svc := marketplaceentitlementservice.New(sess) - - params := &marketplaceentitlementservice.GetEntitlementsInput{ - ProductCode: aws.String("ProductCode"), // Required - Filter: map[string][]*string{ - "Key": { // Required - aws.String("FilterValue"), // Required - // More values... - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NonEmptyString"), - } - resp, err := svc.GetEntitlements(params) - - if err != nil { - // 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) -} diff --git a/service/marketplacemetering/examples_test.go b/service/marketplacemetering/examples_test.go deleted file mode 100644 index 4862a599cf6..00000000000 --- a/service/marketplacemetering/examples_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package marketplacemetering_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/marketplacemetering" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMarketplaceMetering_BatchMeterUsage() { - sess := session.Must(session.NewSession()) - - svc := marketplacemetering.New(sess) - - params := &marketplacemetering.BatchMeterUsageInput{ - ProductCode: aws.String("ProductCode"), // Required - UsageRecords: []*marketplacemetering.UsageRecord{ // Required - { // Required - CustomerIdentifier: aws.String("CustomerIdentifier"), // Required - Dimension: aws.String("UsageDimension"), // Required - Quantity: aws.Int64(1), // Required - Timestamp: aws.Time(time.Now()), // Required - }, - // More values... - }, - } - resp, err := svc.BatchMeterUsage(params) - - if err != nil { - // 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) -} - -func ExampleMarketplaceMetering_MeterUsage() { - sess := session.Must(session.NewSession()) - - svc := marketplacemetering.New(sess) - - params := &marketplacemetering.MeterUsageInput{ - DryRun: aws.Bool(true), // Required - ProductCode: aws.String("ProductCode"), // Required - Timestamp: aws.Time(time.Now()), // Required - UsageDimension: aws.String("UsageDimension"), // Required - UsageQuantity: aws.Int64(1), // Required - } - resp, err := svc.MeterUsage(params) - - if err != nil { - // 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) -} - -func ExampleMarketplaceMetering_ResolveCustomer() { - sess := session.Must(session.NewSession()) - - svc := marketplacemetering.New(sess) - - params := &marketplacemetering.ResolveCustomerInput{ - RegistrationToken: aws.String("NonEmptyString"), // Required - } - resp, err := svc.ResolveCustomer(params) - - if err != nil { - // 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) -} diff --git a/service/mobileanalytics/examples_test.go b/service/mobileanalytics/examples_test.go deleted file mode 100644 index 14d0a86f344..00000000000 --- a/service/mobileanalytics/examples_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package mobileanalytics_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/mobileanalytics" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMobileAnalytics_PutEvents() { - sess := session.Must(session.NewSession()) - - svc := mobileanalytics.New(sess) - - params := &mobileanalytics.PutEventsInput{ - ClientContext: aws.String("String"), // Required - Events: []*mobileanalytics.Event{ // Required - { // Required - EventType: aws.String("String50Chars"), // Required - Timestamp: aws.String("ISO8601Timestamp"), // Required - Attributes: map[string]*string{ - "Key": aws.String("String0to1000Chars"), // Required - // More values... - }, - Metrics: map[string]*float64{ - "Key": aws.Float64(1.0), // Required - // More values... - }, - Session: &mobileanalytics.Session{ - Duration: aws.Int64(1), - Id: aws.String("String50Chars"), - StartTimestamp: aws.String("ISO8601Timestamp"), - StopTimestamp: aws.String("ISO8601Timestamp"), - }, - Version: aws.String("String10Chars"), - }, - // More values... - }, - ClientContextEncoding: aws.String("String"), - } - resp, err := svc.PutEvents(params) - - if err != nil { - // 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) -} diff --git a/service/mturk/examples_test.go b/service/mturk/examples_test.go deleted file mode 100644 index ecb6ca4d316..00000000000 --- a/service/mturk/examples_test.go +++ /dev/null @@ -1,1096 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package mturk_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/mturk" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleMTurk_AcceptQualificationRequest() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.AcceptQualificationRequestInput{ - QualificationRequestId: aws.String("String"), // Required - IntegerValue: aws.Int64(1), - } - resp, err := svc.AcceptQualificationRequest(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ApproveAssignment() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ApproveAssignmentInput{ - AssignmentId: aws.String("EntityId"), // Required - OverrideRejection: aws.Bool(true), - RequesterFeedback: aws.String("String"), - } - resp, err := svc.ApproveAssignment(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_AssociateQualificationWithWorker() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.AssociateQualificationWithWorkerInput{ - QualificationTypeId: aws.String("EntityId"), // Required - WorkerId: aws.String("CustomerId"), // Required - IntegerValue: aws.Int64(1), - SendNotification: aws.Bool(true), - } - resp, err := svc.AssociateQualificationWithWorker(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateAdditionalAssignmentsForHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateAdditionalAssignmentsForHITInput{ - HITId: aws.String("EntityId"), // Required - NumberOfAdditionalAssignments: aws.Int64(1), - UniqueRequestToken: aws.String("IdempotencyToken"), - } - resp, err := svc.CreateAdditionalAssignmentsForHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateHITInput{ - AssignmentDurationInSeconds: aws.Int64(1), // Required - Description: aws.String("String"), // Required - LifetimeInSeconds: aws.Int64(1), // Required - Reward: aws.String("NumericValue"), // Required - Title: aws.String("String"), // Required - AssignmentReviewPolicy: &mturk.ReviewPolicy{ - Parameters: []*mturk.PolicyParameter{ - { // Required - Key: aws.String("String"), - MapEntries: []*mturk.ParameterMapEntry{ - { // Required - Key: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - PolicyName: aws.String("String"), - }, - AutoApprovalDelayInSeconds: aws.Int64(1), - HITLayoutId: aws.String("EntityId"), - HITLayoutParameters: []*mturk.HITLayoutParameter{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - HITReviewPolicy: &mturk.ReviewPolicy{ - Parameters: []*mturk.PolicyParameter{ - { // Required - Key: aws.String("String"), - MapEntries: []*mturk.ParameterMapEntry{ - { // Required - Key: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - PolicyName: aws.String("String"), - }, - Keywords: aws.String("String"), - MaxAssignments: aws.Int64(1), - QualificationRequirements: []*mturk.QualificationRequirement{ - { // Required - Comparator: aws.String("Comparator"), // Required - QualificationTypeId: aws.String("String"), // Required - IntegerValues: []*int64{ - aws.Int64(1), // Required - // More values... - }, - LocaleValues: []*mturk.Locale{ - { // Required - Country: aws.String("CountryParameters"), // Required - Subdivision: aws.String("CountryParameters"), - }, - // More values... - }, - RequiredToPreview: aws.Bool(true), - }, - // More values... - }, - Question: aws.String("String"), - RequesterAnnotation: aws.String("String"), - UniqueRequestToken: aws.String("IdempotencyToken"), - } - resp, err := svc.CreateHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateHITType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateHITTypeInput{ - AssignmentDurationInSeconds: aws.Int64(1), // Required - Description: aws.String("String"), // Required - Reward: aws.String("NumericValue"), // Required - Title: aws.String("String"), // Required - AutoApprovalDelayInSeconds: aws.Int64(1), - Keywords: aws.String("String"), - QualificationRequirements: []*mturk.QualificationRequirement{ - { // Required - Comparator: aws.String("Comparator"), // Required - QualificationTypeId: aws.String("String"), // Required - IntegerValues: []*int64{ - aws.Int64(1), // Required - // More values... - }, - LocaleValues: []*mturk.Locale{ - { // Required - Country: aws.String("CountryParameters"), // Required - Subdivision: aws.String("CountryParameters"), - }, - // More values... - }, - RequiredToPreview: aws.Bool(true), - }, - // More values... - }, - } - resp, err := svc.CreateHITType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateHITWithHITType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateHITWithHITTypeInput{ - HITTypeId: aws.String("EntityId"), // Required - LifetimeInSeconds: aws.Int64(1), // Required - AssignmentReviewPolicy: &mturk.ReviewPolicy{ - Parameters: []*mturk.PolicyParameter{ - { // Required - Key: aws.String("String"), - MapEntries: []*mturk.ParameterMapEntry{ - { // Required - Key: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - PolicyName: aws.String("String"), - }, - HITLayoutId: aws.String("EntityId"), - HITLayoutParameters: []*mturk.HITLayoutParameter{ - { // Required - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - HITReviewPolicy: &mturk.ReviewPolicy{ - Parameters: []*mturk.PolicyParameter{ - { // Required - Key: aws.String("String"), - MapEntries: []*mturk.ParameterMapEntry{ - { // Required - Key: aws.String("String"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - PolicyName: aws.String("String"), - }, - MaxAssignments: aws.Int64(1), - Question: aws.String("String"), - RequesterAnnotation: aws.String("String"), - UniqueRequestToken: aws.String("IdempotencyToken"), - } - resp, err := svc.CreateHITWithHITType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateQualificationTypeInput{ - Description: aws.String("String"), // Required - Name: aws.String("String"), // Required - QualificationTypeStatus: aws.String("QualificationTypeStatus"), // Required - AnswerKey: aws.String("String"), - AutoGranted: aws.Bool(true), - AutoGrantedValue: aws.Int64(1), - Keywords: aws.String("String"), - RetryDelayInSeconds: aws.Int64(1), - Test: aws.String("String"), - TestDurationInSeconds: aws.Int64(1), - } - resp, err := svc.CreateQualificationType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_CreateWorkerBlock() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.CreateWorkerBlockInput{ - Reason: aws.String("String"), // Required - WorkerId: aws.String("CustomerId"), // Required - } - resp, err := svc.CreateWorkerBlock(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_DeleteHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.DeleteHITInput{ - HITId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_DeleteQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.DeleteQualificationTypeInput{ - QualificationTypeId: aws.String("EntityId"), // Required - } - resp, err := svc.DeleteQualificationType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_DeleteWorkerBlock() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.DeleteWorkerBlockInput{ - WorkerId: aws.String("CustomerId"), // Required - Reason: aws.String("String"), - } - resp, err := svc.DeleteWorkerBlock(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_DisassociateQualificationFromWorker() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.DisassociateQualificationFromWorkerInput{ - QualificationTypeId: aws.String("EntityId"), // Required - WorkerId: aws.String("CustomerId"), // Required - Reason: aws.String("String"), - } - resp, err := svc.DisassociateQualificationFromWorker(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetAccountBalance() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - var params *mturk.GetAccountBalanceInput - resp, err := svc.GetAccountBalance(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetAssignment() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.GetAssignmentInput{ - AssignmentId: aws.String("EntityId"), // Required - } - resp, err := svc.GetAssignment(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetFileUploadURL() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.GetFileUploadURLInput{ - AssignmentId: aws.String("EntityId"), // Required - QuestionIdentifier: aws.String("String"), // Required - } - resp, err := svc.GetFileUploadURL(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.GetHITInput{ - HITId: aws.String("EntityId"), // Required - } - resp, err := svc.GetHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetQualificationScore() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.GetQualificationScoreInput{ - QualificationTypeId: aws.String("EntityId"), // Required - WorkerId: aws.String("CustomerId"), // Required - } - resp, err := svc.GetQualificationScore(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_GetQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.GetQualificationTypeInput{ - QualificationTypeId: aws.String("EntityId"), // Required - } - resp, err := svc.GetQualificationType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListAssignmentsForHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListAssignmentsForHITInput{ - HITId: aws.String("EntityId"), // Required - AssignmentStatuses: []*string{ - aws.String("AssignmentStatus"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListAssignmentsForHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListBonusPayments() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListBonusPaymentsInput{ - AssignmentId: aws.String("EntityId"), - HITId: aws.String("EntityId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListBonusPayments(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListHITs() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListHITsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListHITs(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListHITsForQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListHITsForQualificationTypeInput{ - QualificationTypeId: aws.String("EntityId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListHITsForQualificationType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListQualificationRequests() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListQualificationRequestsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - QualificationTypeId: aws.String("EntityId"), - } - resp, err := svc.ListQualificationRequests(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListQualificationTypes() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListQualificationTypesInput{ - MustBeRequestable: aws.Bool(true), // Required - MaxResults: aws.Int64(1), - MustBeOwnedByCaller: aws.Bool(true), - NextToken: aws.String("PaginationToken"), - Query: aws.String("String"), - } - resp, err := svc.ListQualificationTypes(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListReviewPolicyResultsForHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListReviewPolicyResultsForHITInput{ - HITId: aws.String("EntityId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - PolicyLevels: []*string{ - aws.String("ReviewPolicyLevel"), // Required - // More values... - }, - RetrieveActions: aws.Bool(true), - RetrieveResults: aws.Bool(true), - } - resp, err := svc.ListReviewPolicyResultsForHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListReviewableHITs() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListReviewableHITsInput{ - HITTypeId: aws.String("EntityId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - Status: aws.String("ReviewableHITStatus"), - } - resp, err := svc.ListReviewableHITs(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListWorkerBlocks() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListWorkerBlocksInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListWorkerBlocks(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_ListWorkersWithQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.ListWorkersWithQualificationTypeInput{ - QualificationTypeId: aws.String("EntityId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - Status: aws.String("QualificationStatus"), - } - resp, err := svc.ListWorkersWithQualificationType(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_NotifyWorkers() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.NotifyWorkersInput{ - MessageText: aws.String("String"), // Required - Subject: aws.String("String"), // Required - WorkerIds: []*string{ // Required - aws.String("CustomerId"), // Required - // More values... - }, - } - resp, err := svc.NotifyWorkers(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_RejectAssignment() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.RejectAssignmentInput{ - AssignmentId: aws.String("EntityId"), // Required - RequesterFeedback: aws.String("String"), - } - resp, err := svc.RejectAssignment(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_RejectQualificationRequest() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.RejectQualificationRequestInput{ - QualificationRequestId: aws.String("String"), // Required - Reason: aws.String("String"), - } - resp, err := svc.RejectQualificationRequest(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_SendBonus() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.SendBonusInput{ - AssignmentId: aws.String("EntityId"), // Required - BonusAmount: aws.String("NumericValue"), // Required - WorkerId: aws.String("CustomerId"), // Required - Reason: aws.String("String"), - UniqueRequestToken: aws.String("IdempotencyToken"), - } - resp, err := svc.SendBonus(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_SendTestEventNotification() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.SendTestEventNotificationInput{ - Notification: &mturk.NotificationSpecification{ // Required - Destination: aws.String("String"), // Required - Transport: aws.String("NotificationTransport"), // Required - EventTypes: []*string{ - aws.String("EventType"), // Required - // More values... - }, - Version: aws.String("String"), - }, - TestEventType: aws.String("EventType"), // Required - } - resp, err := svc.SendTestEventNotification(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_UpdateExpirationForHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.UpdateExpirationForHITInput{ - HITId: aws.String("EntityId"), // Required - ExpireAt: aws.Time(time.Now()), - } - resp, err := svc.UpdateExpirationForHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_UpdateHITReviewStatus() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.UpdateHITReviewStatusInput{ - HITId: aws.String("EntityId"), // Required - Revert: aws.Bool(true), - } - resp, err := svc.UpdateHITReviewStatus(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_UpdateHITTypeOfHIT() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.UpdateHITTypeOfHITInput{ - HITId: aws.String("EntityId"), // Required - HITTypeId: aws.String("EntityId"), // Required - } - resp, err := svc.UpdateHITTypeOfHIT(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_UpdateNotificationSettings() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.UpdateNotificationSettingsInput{ - HITTypeId: aws.String("EntityId"), // Required - Active: aws.Bool(true), - Notification: &mturk.NotificationSpecification{ - Destination: aws.String("String"), // Required - Transport: aws.String("NotificationTransport"), // Required - EventTypes: []*string{ - aws.String("EventType"), // Required - // More values... - }, - Version: aws.String("String"), - }, - } - resp, err := svc.UpdateNotificationSettings(params) - - if err != nil { - // 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) -} - -func ExampleMTurk_UpdateQualificationType() { - sess := session.Must(session.NewSession()) - - svc := mturk.New(sess) - - params := &mturk.UpdateQualificationTypeInput{ - QualificationTypeId: aws.String("EntityId"), // Required - AnswerKey: aws.String("String"), - AutoGranted: aws.Bool(true), - AutoGrantedValue: aws.Int64(1), - Description: aws.String("String"), - QualificationTypeStatus: aws.String("QualificationTypeStatus"), - RetryDelayInSeconds: aws.Int64(1), - Test: aws.String("String"), - TestDurationInSeconds: aws.Int64(1), - } - resp, err := svc.UpdateQualificationType(params) - - if err != nil { - // 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) -} diff --git a/service/opsworks/examples_test.go b/service/opsworks/examples_test.go deleted file mode 100644 index 4aa9e3bfed5..00000000000 --- a/service/opsworks/examples_test.go +++ /dev/null @@ -1,2073 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package opsworks_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/opsworks" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleOpsWorks_AssignInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.AssignInstanceInput{ - InstanceId: aws.String("String"), // Required - LayerIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.AssignInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_AssignVolume() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.AssignVolumeInput{ - VolumeId: aws.String("String"), // Required - InstanceId: aws.String("String"), - } - resp, err := svc.AssignVolume(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_AssociateElasticIp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.AssociateElasticIpInput{ - ElasticIp: aws.String("String"), // Required - InstanceId: aws.String("String"), - } - resp, err := svc.AssociateElasticIp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_AttachElasticLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.AttachElasticLoadBalancerInput{ - ElasticLoadBalancerName: aws.String("String"), // Required - LayerId: aws.String("String"), // Required - } - resp, err := svc.AttachElasticLoadBalancer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CloneStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CloneStackInput{ - ServiceRoleArn: aws.String("String"), // Required - SourceStackId: aws.String("String"), // Required - AgentVersion: aws.String("String"), - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - ChefConfiguration: &opsworks.ChefConfiguration{ - BerkshelfVersion: aws.String("String"), - ManageBerkshelf: aws.Bool(true), - }, - CloneAppIds: []*string{ - aws.String("String"), // Required - // More values... - }, - ClonePermissions: aws.Bool(true), - ConfigurationManager: &opsworks.StackConfigurationManager{ - Name: aws.String("String"), - Version: aws.String("String"), - }, - CustomCookbooksSource: &opsworks.Source{ - Password: aws.String("String"), - Revision: aws.String("String"), - SshKey: aws.String("String"), - Type: aws.String("SourceType"), - Url: aws.String("String"), - Username: aws.String("String"), - }, - CustomJson: aws.String("String"), - DefaultAvailabilityZone: aws.String("String"), - DefaultInstanceProfileArn: aws.String("String"), - DefaultOs: aws.String("String"), - DefaultRootDeviceType: aws.String("RootDeviceType"), - DefaultSshKeyName: aws.String("String"), - DefaultSubnetId: aws.String("String"), - HostnameTheme: aws.String("String"), - Name: aws.String("String"), - Region: aws.String("String"), - UseCustomCookbooks: aws.Bool(true), - UseOpsworksSecurityGroups: aws.Bool(true), - VpcId: aws.String("String"), - } - resp, err := svc.CloneStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateApp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateAppInput{ - Name: aws.String("String"), // Required - StackId: aws.String("String"), // Required - Type: aws.String("AppType"), // Required - AppSource: &opsworks.Source{ - Password: aws.String("String"), - Revision: aws.String("String"), - SshKey: aws.String("String"), - Type: aws.String("SourceType"), - Url: aws.String("String"), - Username: aws.String("String"), - }, - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - DataSources: []*opsworks.DataSource{ - { // Required - Arn: aws.String("String"), - DatabaseName: aws.String("String"), - Type: aws.String("String"), - }, - // More values... - }, - Description: aws.String("String"), - Domains: []*string{ - aws.String("String"), // Required - // More values... - }, - EnableSsl: aws.Bool(true), - Environment: []*opsworks.EnvironmentVariable{ - { // Required - Key: aws.String("String"), // Required - Value: aws.String("String"), // Required - Secure: aws.Bool(true), - }, - // More values... - }, - Shortname: aws.String("String"), - SslConfiguration: &opsworks.SslConfiguration{ - Certificate: aws.String("String"), // Required - PrivateKey: aws.String("String"), // Required - Chain: aws.String("String"), - }, - } - resp, err := svc.CreateApp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateDeployment() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateDeploymentInput{ - Command: &opsworks.DeploymentCommand{ // Required - Name: aws.String("DeploymentCommandName"), // Required - Args: map[string][]*string{ - "Key": { // Required - aws.String("String"), // Required - // More values... - }, - // More values... - }, - }, - StackId: aws.String("String"), // Required - AppId: aws.String("String"), - Comment: aws.String("String"), - CustomJson: aws.String("String"), - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - LayerIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateDeployment(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateInstanceInput{ - InstanceType: aws.String("String"), // Required - LayerIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), // Required - AgentVersion: aws.String("String"), - AmiId: aws.String("String"), - Architecture: aws.String("Architecture"), - AutoScalingType: aws.String("AutoScalingType"), - AvailabilityZone: aws.String("String"), - BlockDeviceMappings: []*opsworks.BlockDeviceMapping{ - { // Required - DeviceName: aws.String("String"), - Ebs: &opsworks.EbsBlockDevice{ - DeleteOnTermination: aws.Bool(true), - Iops: aws.Int64(1), - SnapshotId: aws.String("String"), - VolumeSize: aws.Int64(1), - VolumeType: aws.String("VolumeType"), - }, - NoDevice: aws.String("String"), - VirtualName: aws.String("String"), - }, - // More values... - }, - EbsOptimized: aws.Bool(true), - Hostname: aws.String("String"), - InstallUpdatesOnBoot: aws.Bool(true), - Os: aws.String("String"), - RootDeviceType: aws.String("RootDeviceType"), - SshKeyName: aws.String("String"), - SubnetId: aws.String("String"), - Tenancy: aws.String("String"), - VirtualizationType: aws.String("String"), - } - resp, err := svc.CreateInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateLayer() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateLayerInput{ - Name: aws.String("String"), // Required - Shortname: aws.String("String"), // Required - StackId: aws.String("String"), // Required - Type: aws.String("LayerType"), // Required - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - AutoAssignElasticIps: aws.Bool(true), - AutoAssignPublicIps: aws.Bool(true), - CloudWatchLogsConfiguration: &opsworks.CloudWatchLogsConfiguration{ - Enabled: aws.Bool(true), - LogStreams: []*opsworks.CloudWatchLogsLogStream{ - { // Required - BatchCount: aws.Int64(1), - BatchSize: aws.Int64(1), - BufferDuration: aws.Int64(1), - DatetimeFormat: aws.String("String"), - Encoding: aws.String("CloudWatchLogsEncoding"), - File: aws.String("String"), - FileFingerprintLines: aws.String("String"), - InitialPosition: aws.String("CloudWatchLogsInitialPosition"), - LogGroupName: aws.String("String"), - MultiLineStartPattern: aws.String("String"), - TimeZone: aws.String("CloudWatchLogsTimeZone"), - }, - // More values... - }, - }, - CustomInstanceProfileArn: aws.String("String"), - CustomJson: aws.String("String"), - CustomRecipes: &opsworks.Recipes{ - Configure: []*string{ - aws.String("String"), // Required - // More values... - }, - Deploy: []*string{ - aws.String("String"), // Required - // More values... - }, - Setup: []*string{ - aws.String("String"), // Required - // More values... - }, - Shutdown: []*string{ - aws.String("String"), // Required - // More values... - }, - Undeploy: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - CustomSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - EnableAutoHealing: aws.Bool(true), - InstallUpdatesOnBoot: aws.Bool(true), - LifecycleEventConfiguration: &opsworks.LifecycleEventConfiguration{ - Shutdown: &opsworks.ShutdownEventConfiguration{ - DelayUntilElbConnectionsDrained: aws.Bool(true), - ExecutionTimeout: aws.Int64(1), - }, - }, - Packages: []*string{ - aws.String("String"), // Required - // More values... - }, - UseEbsOptimizedInstances: aws.Bool(true), - VolumeConfigurations: []*opsworks.VolumeConfiguration{ - { // Required - MountPoint: aws.String("String"), // Required - NumberOfDisks: aws.Int64(1), // Required - Size: aws.Int64(1), // Required - Iops: aws.Int64(1), - RaidLevel: aws.Int64(1), - VolumeType: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateLayer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateStackInput{ - DefaultInstanceProfileArn: aws.String("String"), // Required - Name: aws.String("String"), // Required - Region: aws.String("String"), // Required - ServiceRoleArn: aws.String("String"), // Required - AgentVersion: aws.String("String"), - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - ChefConfiguration: &opsworks.ChefConfiguration{ - BerkshelfVersion: aws.String("String"), - ManageBerkshelf: aws.Bool(true), - }, - ConfigurationManager: &opsworks.StackConfigurationManager{ - Name: aws.String("String"), - Version: aws.String("String"), - }, - CustomCookbooksSource: &opsworks.Source{ - Password: aws.String("String"), - Revision: aws.String("String"), - SshKey: aws.String("String"), - Type: aws.String("SourceType"), - Url: aws.String("String"), - Username: aws.String("String"), - }, - CustomJson: aws.String("String"), - DefaultAvailabilityZone: aws.String("String"), - DefaultOs: aws.String("String"), - DefaultRootDeviceType: aws.String("RootDeviceType"), - DefaultSshKeyName: aws.String("String"), - DefaultSubnetId: aws.String("String"), - HostnameTheme: aws.String("String"), - UseCustomCookbooks: aws.Bool(true), - UseOpsworksSecurityGroups: aws.Bool(true), - VpcId: aws.String("String"), - } - resp, err := svc.CreateStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_CreateUserProfile() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.CreateUserProfileInput{ - IamUserArn: aws.String("String"), // Required - AllowSelfManagement: aws.Bool(true), - SshPublicKey: aws.String("String"), - SshUsername: aws.String("String"), - } - resp, err := svc.CreateUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeleteApp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeleteAppInput{ - AppId: aws.String("String"), // Required - } - resp, err := svc.DeleteApp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeleteInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeleteInstanceInput{ - InstanceId: aws.String("String"), // Required - DeleteElasticIp: aws.Bool(true), - DeleteVolumes: aws.Bool(true), - } - resp, err := svc.DeleteInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeleteLayer() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeleteLayerInput{ - LayerId: aws.String("String"), // Required - } - resp, err := svc.DeleteLayer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeleteStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeleteStackInput{ - StackId: aws.String("String"), // Required - } - resp, err := svc.DeleteStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeleteUserProfile() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeleteUserProfileInput{ - IamUserArn: aws.String("String"), // Required - } - resp, err := svc.DeleteUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeregisterEcsCluster() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeregisterEcsClusterInput{ - EcsClusterArn: aws.String("String"), // Required - } - resp, err := svc.DeregisterEcsCluster(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeregisterElasticIp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeregisterElasticIpInput{ - ElasticIp: aws.String("String"), // Required - } - resp, err := svc.DeregisterElasticIp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeregisterInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeregisterInstanceInput{ - InstanceId: aws.String("String"), // Required - } - resp, err := svc.DeregisterInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeregisterRdsDbInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeregisterRdsDbInstanceInput{ - RdsDbInstanceArn: aws.String("String"), // Required - } - resp, err := svc.DeregisterRdsDbInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DeregisterVolume() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DeregisterVolumeInput{ - VolumeId: aws.String("String"), // Required - } - resp, err := svc.DeregisterVolume(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeAgentVersions() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeAgentVersionsInput{ - ConfigurationManager: &opsworks.StackConfigurationManager{ - Name: aws.String("String"), - Version: aws.String("String"), - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeAgentVersions(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeApps() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeAppsInput{ - AppIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeApps(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeCommands() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeCommandsInput{ - CommandIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DeploymentId: aws.String("String"), - InstanceId: aws.String("String"), - } - resp, err := svc.DescribeCommands(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeDeployments() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeDeploymentsInput{ - AppId: aws.String("String"), - DeploymentIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeDeployments(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeEcsClusters() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeEcsClustersInput{ - EcsClusterArns: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - StackId: aws.String("String"), - } - resp, err := svc.DescribeEcsClusters(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeElasticIps() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeElasticIpsInput{ - InstanceId: aws.String("String"), - Ips: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeElasticIps(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeElasticLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeElasticLoadBalancersInput{ - LayerIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeElasticLoadBalancers(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeInstances() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeInstancesInput{ - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - LayerId: aws.String("String"), - StackId: aws.String("String"), - } - resp, err := svc.DescribeInstances(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeLayers() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeLayersInput{ - LayerIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeLayers(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeLoadBasedAutoScaling() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeLoadBasedAutoScalingInput{ - LayerIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeLoadBasedAutoScaling(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeMyUserProfile() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - var params *opsworks.DescribeMyUserProfileInput - resp, err := svc.DescribeMyUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribePermissions() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribePermissionsInput{ - IamUserArn: aws.String("String"), - StackId: aws.String("String"), - } - resp, err := svc.DescribePermissions(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeRaidArrays() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeRaidArraysInput{ - InstanceId: aws.String("String"), - RaidArrayIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeRaidArrays(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeRdsDbInstances() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeRdsDbInstancesInput{ - StackId: aws.String("String"), // Required - RdsDbInstanceArns: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeRdsDbInstances(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeServiceErrors() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeServiceErrorsInput{ - InstanceId: aws.String("String"), - ServiceErrorIds: []*string{ - aws.String("String"), // Required - // More values... - }, - StackId: aws.String("String"), - } - resp, err := svc.DescribeServiceErrors(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeStackProvisioningParameters() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeStackProvisioningParametersInput{ - StackId: aws.String("String"), // Required - } - resp, err := svc.DescribeStackProvisioningParameters(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeStackSummary() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeStackSummaryInput{ - StackId: aws.String("String"), // Required - } - resp, err := svc.DescribeStackSummary(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeStacks() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeStacksInput{ - StackIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeStacks(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeTimeBasedAutoScaling() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeTimeBasedAutoScalingInput{ - InstanceIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeTimeBasedAutoScaling(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeUserProfiles() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeUserProfilesInput{ - IamUserArns: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeUserProfiles(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DescribeVolumes() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DescribeVolumesInput{ - InstanceId: aws.String("String"), - RaidArrayId: aws.String("String"), - StackId: aws.String("String"), - VolumeIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeVolumes(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DetachElasticLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DetachElasticLoadBalancerInput{ - ElasticLoadBalancerName: aws.String("String"), // Required - LayerId: aws.String("String"), // Required - } - resp, err := svc.DetachElasticLoadBalancer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_DisassociateElasticIp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.DisassociateElasticIpInput{ - ElasticIp: aws.String("String"), // Required - } - resp, err := svc.DisassociateElasticIp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_GetHostnameSuggestion() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.GetHostnameSuggestionInput{ - LayerId: aws.String("String"), // Required - } - resp, err := svc.GetHostnameSuggestion(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_GrantAccess() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.GrantAccessInput{ - InstanceId: aws.String("String"), // Required - ValidForInMinutes: aws.Int64(1), - } - resp, err := svc.GrantAccess(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RebootInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RebootInstanceInput{ - InstanceId: aws.String("String"), // Required - } - resp, err := svc.RebootInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RegisterEcsCluster() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RegisterEcsClusterInput{ - EcsClusterArn: aws.String("String"), // Required - StackId: aws.String("String"), // Required - } - resp, err := svc.RegisterEcsCluster(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RegisterElasticIp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RegisterElasticIpInput{ - ElasticIp: aws.String("String"), // Required - StackId: aws.String("String"), // Required - } - resp, err := svc.RegisterElasticIp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RegisterInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RegisterInstanceInput{ - StackId: aws.String("String"), // Required - Hostname: aws.String("String"), - InstanceIdentity: &opsworks.InstanceIdentity{ - Document: aws.String("String"), - Signature: aws.String("String"), - }, - PrivateIp: aws.String("String"), - PublicIp: aws.String("String"), - RsaPublicKey: aws.String("String"), - RsaPublicKeyFingerprint: aws.String("String"), - } - resp, err := svc.RegisterInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RegisterRdsDbInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RegisterRdsDbInstanceInput{ - DbPassword: aws.String("String"), // Required - DbUser: aws.String("String"), // Required - RdsDbInstanceArn: aws.String("String"), // Required - StackId: aws.String("String"), // Required - } - resp, err := svc.RegisterRdsDbInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_RegisterVolume() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.RegisterVolumeInput{ - StackId: aws.String("String"), // Required - Ec2VolumeId: aws.String("String"), - } - resp, err := svc.RegisterVolume(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_SetLoadBasedAutoScaling() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.SetLoadBasedAutoScalingInput{ - LayerId: aws.String("String"), // Required - DownScaling: &opsworks.AutoScalingThresholds{ - Alarms: []*string{ - aws.String("String"), // Required - // More values... - }, - CpuThreshold: aws.Float64(1.0), - IgnoreMetricsTime: aws.Int64(1), - InstanceCount: aws.Int64(1), - LoadThreshold: aws.Float64(1.0), - MemoryThreshold: aws.Float64(1.0), - ThresholdsWaitTime: aws.Int64(1), - }, - Enable: aws.Bool(true), - UpScaling: &opsworks.AutoScalingThresholds{ - Alarms: []*string{ - aws.String("String"), // Required - // More values... - }, - CpuThreshold: aws.Float64(1.0), - IgnoreMetricsTime: aws.Int64(1), - InstanceCount: aws.Int64(1), - LoadThreshold: aws.Float64(1.0), - MemoryThreshold: aws.Float64(1.0), - ThresholdsWaitTime: aws.Int64(1), - }, - } - resp, err := svc.SetLoadBasedAutoScaling(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_SetPermission() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.SetPermissionInput{ - IamUserArn: aws.String("String"), // Required - StackId: aws.String("String"), // Required - AllowSsh: aws.Bool(true), - AllowSudo: aws.Bool(true), - Level: aws.String("String"), - } - resp, err := svc.SetPermission(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_SetTimeBasedAutoScaling() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.SetTimeBasedAutoScalingInput{ - InstanceId: aws.String("String"), // Required - AutoScalingSchedule: &opsworks.WeeklyAutoScalingSchedule{ - Friday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Monday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Saturday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Sunday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Thursday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Tuesday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - Wednesday: map[string]*string{ - "Key": aws.String("Switch"), // Required - // More values... - }, - }, - } - resp, err := svc.SetTimeBasedAutoScaling(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_StartInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.StartInstanceInput{ - InstanceId: aws.String("String"), // Required - } - resp, err := svc.StartInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_StartStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.StartStackInput{ - StackId: aws.String("String"), // Required - } - resp, err := svc.StartStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_StopInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.StopInstanceInput{ - InstanceId: aws.String("String"), // Required - } - resp, err := svc.StopInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_StopStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.StopStackInput{ - StackId: aws.String("String"), // Required - } - resp, err := svc.StopStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UnassignInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UnassignInstanceInput{ - InstanceId: aws.String("String"), // Required - } - resp, err := svc.UnassignInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UnassignVolume() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UnassignVolumeInput{ - VolumeId: aws.String("String"), // Required - } - resp, err := svc.UnassignVolume(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateApp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateAppInput{ - AppId: aws.String("String"), // Required - AppSource: &opsworks.Source{ - Password: aws.String("String"), - Revision: aws.String("String"), - SshKey: aws.String("String"), - Type: aws.String("SourceType"), - Url: aws.String("String"), - Username: aws.String("String"), - }, - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - DataSources: []*opsworks.DataSource{ - { // Required - Arn: aws.String("String"), - DatabaseName: aws.String("String"), - Type: aws.String("String"), - }, - // More values... - }, - Description: aws.String("String"), - Domains: []*string{ - aws.String("String"), // Required - // More values... - }, - EnableSsl: aws.Bool(true), - Environment: []*opsworks.EnvironmentVariable{ - { // Required - Key: aws.String("String"), // Required - Value: aws.String("String"), // Required - Secure: aws.Bool(true), - }, - // More values... - }, - Name: aws.String("String"), - SslConfiguration: &opsworks.SslConfiguration{ - Certificate: aws.String("String"), // Required - PrivateKey: aws.String("String"), // Required - Chain: aws.String("String"), - }, - Type: aws.String("AppType"), - } - resp, err := svc.UpdateApp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateElasticIp() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateElasticIpInput{ - ElasticIp: aws.String("String"), // Required - Name: aws.String("String"), - } - resp, err := svc.UpdateElasticIp(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateInstanceInput{ - InstanceId: aws.String("String"), // Required - AgentVersion: aws.String("String"), - AmiId: aws.String("String"), - Architecture: aws.String("Architecture"), - AutoScalingType: aws.String("AutoScalingType"), - EbsOptimized: aws.Bool(true), - Hostname: aws.String("String"), - InstallUpdatesOnBoot: aws.Bool(true), - InstanceType: aws.String("String"), - LayerIds: []*string{ - aws.String("String"), // Required - // More values... - }, - Os: aws.String("String"), - SshKeyName: aws.String("String"), - } - resp, err := svc.UpdateInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateLayer() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateLayerInput{ - LayerId: aws.String("String"), // Required - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - AutoAssignElasticIps: aws.Bool(true), - AutoAssignPublicIps: aws.Bool(true), - CloudWatchLogsConfiguration: &opsworks.CloudWatchLogsConfiguration{ - Enabled: aws.Bool(true), - LogStreams: []*opsworks.CloudWatchLogsLogStream{ - { // Required - BatchCount: aws.Int64(1), - BatchSize: aws.Int64(1), - BufferDuration: aws.Int64(1), - DatetimeFormat: aws.String("String"), - Encoding: aws.String("CloudWatchLogsEncoding"), - File: aws.String("String"), - FileFingerprintLines: aws.String("String"), - InitialPosition: aws.String("CloudWatchLogsInitialPosition"), - LogGroupName: aws.String("String"), - MultiLineStartPattern: aws.String("String"), - TimeZone: aws.String("CloudWatchLogsTimeZone"), - }, - // More values... - }, - }, - CustomInstanceProfileArn: aws.String("String"), - CustomJson: aws.String("String"), - CustomRecipes: &opsworks.Recipes{ - Configure: []*string{ - aws.String("String"), // Required - // More values... - }, - Deploy: []*string{ - aws.String("String"), // Required - // More values... - }, - Setup: []*string{ - aws.String("String"), // Required - // More values... - }, - Shutdown: []*string{ - aws.String("String"), // Required - // More values... - }, - Undeploy: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - CustomSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - EnableAutoHealing: aws.Bool(true), - InstallUpdatesOnBoot: aws.Bool(true), - LifecycleEventConfiguration: &opsworks.LifecycleEventConfiguration{ - Shutdown: &opsworks.ShutdownEventConfiguration{ - DelayUntilElbConnectionsDrained: aws.Bool(true), - ExecutionTimeout: aws.Int64(1), - }, - }, - Name: aws.String("String"), - Packages: []*string{ - aws.String("String"), // Required - // More values... - }, - Shortname: aws.String("String"), - UseEbsOptimizedInstances: aws.Bool(true), - VolumeConfigurations: []*opsworks.VolumeConfiguration{ - { // Required - MountPoint: aws.String("String"), // Required - NumberOfDisks: aws.Int64(1), // Required - Size: aws.Int64(1), // Required - Iops: aws.Int64(1), - RaidLevel: aws.Int64(1), - VolumeType: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.UpdateLayer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateMyUserProfile() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateMyUserProfileInput{ - SshPublicKey: aws.String("String"), - } - resp, err := svc.UpdateMyUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateRdsDbInstance() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateRdsDbInstanceInput{ - RdsDbInstanceArn: aws.String("String"), // Required - DbPassword: aws.String("String"), - DbUser: aws.String("String"), - } - resp, err := svc.UpdateRdsDbInstance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateStack() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateStackInput{ - StackId: aws.String("String"), // Required - AgentVersion: aws.String("String"), - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - ChefConfiguration: &opsworks.ChefConfiguration{ - BerkshelfVersion: aws.String("String"), - ManageBerkshelf: aws.Bool(true), - }, - ConfigurationManager: &opsworks.StackConfigurationManager{ - Name: aws.String("String"), - Version: aws.String("String"), - }, - CustomCookbooksSource: &opsworks.Source{ - Password: aws.String("String"), - Revision: aws.String("String"), - SshKey: aws.String("String"), - Type: aws.String("SourceType"), - Url: aws.String("String"), - Username: aws.String("String"), - }, - CustomJson: aws.String("String"), - DefaultAvailabilityZone: aws.String("String"), - DefaultInstanceProfileArn: aws.String("String"), - DefaultOs: aws.String("String"), - DefaultRootDeviceType: aws.String("RootDeviceType"), - DefaultSshKeyName: aws.String("String"), - DefaultSubnetId: aws.String("String"), - HostnameTheme: aws.String("String"), - Name: aws.String("String"), - ServiceRoleArn: aws.String("String"), - UseCustomCookbooks: aws.Bool(true), - UseOpsworksSecurityGroups: aws.Bool(true), - } - resp, err := svc.UpdateStack(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateUserProfile() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateUserProfileInput{ - IamUserArn: aws.String("String"), // Required - AllowSelfManagement: aws.Bool(true), - SshPublicKey: aws.String("String"), - SshUsername: aws.String("String"), - } - resp, err := svc.UpdateUserProfile(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorks_UpdateVolume() { - sess := session.Must(session.NewSession()) - - svc := opsworks.New(sess) - - params := &opsworks.UpdateVolumeInput{ - VolumeId: aws.String("String"), // Required - MountPoint: aws.String("String"), - Name: aws.String("String"), - } - resp, err := svc.UpdateVolume(params) - - if err != nil { - // 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) -} diff --git a/service/opsworkscm/examples_test.go b/service/opsworkscm/examples_test.go deleted file mode 100644 index 3e1edcffe2b..00000000000 --- a/service/opsworkscm/examples_test.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package opsworkscm_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/opsworkscm" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleOpsWorksCM_AssociateNode() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.AssociateNodeInput{ - EngineAttributes: []*opsworkscm.EngineAttribute{ // Required - { // Required - Name: aws.String("EngineAttributeName"), - Value: aws.String("EngineAttributeValue"), - }, - // More values... - }, - NodeName: aws.String("NodeName"), // Required - ServerName: aws.String("ServerName"), // Required - } - resp, err := svc.AssociateNode(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_CreateBackup() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.CreateBackupInput{ - ServerName: aws.String("ServerName"), // Required - Description: aws.String("String"), - } - resp, err := svc.CreateBackup(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_CreateServer() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.CreateServerInput{ - InstanceProfileArn: aws.String("InstanceProfileArn"), // Required - InstanceType: aws.String("String"), // Required - ServerName: aws.String("ServerName"), // Required - ServiceRoleArn: aws.String("ServiceRoleArn"), // Required - AssociatePublicIpAddress: aws.Bool(true), - BackupId: aws.String("BackupId"), - BackupRetentionCount: aws.Int64(1), - DisableAutomatedBackup: aws.Bool(true), - Engine: aws.String("String"), - EngineAttributes: []*opsworkscm.EngineAttribute{ - { // Required - Name: aws.String("EngineAttributeName"), - Value: aws.String("EngineAttributeValue"), - }, - // More values... - }, - EngineModel: aws.String("String"), - EngineVersion: aws.String("String"), - KeyPair: aws.String("KeyPair"), - PreferredBackupWindow: aws.String("TimeWindowDefinition"), - PreferredMaintenanceWindow: aws.String("TimeWindowDefinition"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SubnetIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateServer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DeleteBackup() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DeleteBackupInput{ - BackupId: aws.String("BackupId"), // Required - } - resp, err := svc.DeleteBackup(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DeleteServer() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DeleteServerInput{ - ServerName: aws.String("ServerName"), // Required - } - resp, err := svc.DeleteServer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DescribeAccountAttributes() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - var params *opsworkscm.DescribeAccountAttributesInput - resp, err := svc.DescribeAccountAttributes(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DescribeBackups() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DescribeBackupsInput{ - BackupId: aws.String("BackupId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ServerName: aws.String("ServerName"), - } - resp, err := svc.DescribeBackups(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DescribeEventsInput{ - ServerName: aws.String("ServerName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeEvents(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DescribeNodeAssociationStatus() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DescribeNodeAssociationStatusInput{ - NodeAssociationStatusToken: aws.String("NodeAssociationStatusToken"), // Required - ServerName: aws.String("ServerName"), // Required - } - resp, err := svc.DescribeNodeAssociationStatus(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DescribeServers() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DescribeServersInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ServerName: aws.String("ServerName"), - } - resp, err := svc.DescribeServers(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_DisassociateNode() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.DisassociateNodeInput{ - NodeName: aws.String("NodeName"), // Required - ServerName: aws.String("ServerName"), // Required - EngineAttributes: []*opsworkscm.EngineAttribute{ - { // Required - Name: aws.String("EngineAttributeName"), - Value: aws.String("EngineAttributeValue"), - }, - // More values... - }, - } - resp, err := svc.DisassociateNode(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_RestoreServer() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.RestoreServerInput{ - BackupId: aws.String("BackupId"), // Required - ServerName: aws.String("ServerName"), // Required - InstanceType: aws.String("String"), - KeyPair: aws.String("KeyPair"), - } - resp, err := svc.RestoreServer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_StartMaintenance() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.StartMaintenanceInput{ - ServerName: aws.String("ServerName"), // Required - } - resp, err := svc.StartMaintenance(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_UpdateServer() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.UpdateServerInput{ - ServerName: aws.String("ServerName"), // Required - BackupRetentionCount: aws.Int64(1), - DisableAutomatedBackup: aws.Bool(true), - PreferredBackupWindow: aws.String("TimeWindowDefinition"), - PreferredMaintenanceWindow: aws.String("TimeWindowDefinition"), - } - resp, err := svc.UpdateServer(params) - - if err != nil { - // 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) -} - -func ExampleOpsWorksCM_UpdateServerEngineAttributes() { - sess := session.Must(session.NewSession()) - - svc := opsworkscm.New(sess) - - params := &opsworkscm.UpdateServerEngineAttributesInput{ - AttributeName: aws.String("AttributeName"), // Required - ServerName: aws.String("ServerName"), // Required - AttributeValue: aws.String("AttributeValue"), - } - resp, err := svc.UpdateServerEngineAttributes(params) - - if err != nil { - // 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) -} diff --git a/service/organizations/examples_test.go b/service/organizations/examples_test.go deleted file mode 100644 index 6104e2144d9..00000000000 --- a/service/organizations/examples_test.go +++ /dev/null @@ -1,881 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package organizations_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/organizations" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleOrganizations_AcceptHandshake() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.AcceptHandshakeInput{ - HandshakeId: aws.String("HandshakeId"), // Required - } - resp, err := svc.AcceptHandshake(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_AttachPolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.AttachPolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - TargetId: aws.String("PolicyTargetId"), // Required - } - resp, err := svc.AttachPolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_CancelHandshake() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.CancelHandshakeInput{ - HandshakeId: aws.String("HandshakeId"), // Required - } - resp, err := svc.CancelHandshake(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_CreateAccount() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.CreateAccountInput{ - AccountName: aws.String("AccountName"), // Required - Email: aws.String("Email"), // Required - IamUserAccessToBilling: aws.String("IAMUserAccessToBilling"), - RoleName: aws.String("RoleName"), - } - resp, err := svc.CreateAccount(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_CreateOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.CreateOrganizationInput{ - FeatureSet: aws.String("OrganizationFeatureSet"), - } - resp, err := svc.CreateOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_CreateOrganizationalUnit() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.CreateOrganizationalUnitInput{ - Name: aws.String("OrganizationalUnitName"), // Required - ParentId: aws.String("ParentId"), // Required - } - resp, err := svc.CreateOrganizationalUnit(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_CreatePolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.CreatePolicyInput{ - Content: aws.String("PolicyContent"), // Required - Description: aws.String("PolicyDescription"), // Required - Name: aws.String("PolicyName"), // Required - Type: aws.String("PolicyType"), // Required - } - resp, err := svc.CreatePolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DeclineHandshake() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DeclineHandshakeInput{ - HandshakeId: aws.String("HandshakeId"), // Required - } - resp, err := svc.DeclineHandshake(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DeleteOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - var params *organizations.DeleteOrganizationInput - resp, err := svc.DeleteOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DeleteOrganizationalUnit() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DeleteOrganizationalUnitInput{ - OrganizationalUnitId: aws.String("OrganizationalUnitId"), // Required - } - resp, err := svc.DeleteOrganizationalUnit(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DeletePolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DeletePolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - } - resp, err := svc.DeletePolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribeAccount() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DescribeAccountInput{ - AccountId: aws.String("AccountId"), // Required - } - resp, err := svc.DescribeAccount(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribeCreateAccountStatus() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DescribeCreateAccountStatusInput{ - CreateAccountRequestId: aws.String("CreateAccountRequestId"), // Required - } - resp, err := svc.DescribeCreateAccountStatus(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribeHandshake() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DescribeHandshakeInput{ - HandshakeId: aws.String("HandshakeId"), // Required - } - resp, err := svc.DescribeHandshake(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribeOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - var params *organizations.DescribeOrganizationInput - resp, err := svc.DescribeOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribeOrganizationalUnit() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DescribeOrganizationalUnitInput{ - OrganizationalUnitId: aws.String("OrganizationalUnitId"), // Required - } - resp, err := svc.DescribeOrganizationalUnit(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DescribePolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DescribePolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - } - resp, err := svc.DescribePolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DetachPolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DetachPolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - TargetId: aws.String("PolicyTargetId"), // Required - } - resp, err := svc.DetachPolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_DisablePolicyType() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.DisablePolicyTypeInput{ - PolicyType: aws.String("PolicyType"), // Required - RootId: aws.String("RootId"), // Required - } - resp, err := svc.DisablePolicyType(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_EnableAllFeatures() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - var params *organizations.EnableAllFeaturesInput - resp, err := svc.EnableAllFeatures(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_EnablePolicyType() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.EnablePolicyTypeInput{ - PolicyType: aws.String("PolicyType"), // Required - RootId: aws.String("RootId"), // Required - } - resp, err := svc.EnablePolicyType(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_InviteAccountToOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.InviteAccountToOrganizationInput{ - Target: &organizations.HandshakeParty{ // Required - Id: aws.String("HandshakePartyId"), - Type: aws.String("HandshakePartyType"), - }, - Notes: aws.String("HandshakeNotes"), - } - resp, err := svc.InviteAccountToOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_LeaveOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - var params *organizations.LeaveOrganizationInput - resp, err := svc.LeaveOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListAccounts() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListAccountsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListAccounts(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListAccountsForParent() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListAccountsForParentInput{ - ParentId: aws.String("ParentId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListAccountsForParent(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListChildren() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListChildrenInput{ - ChildType: aws.String("ChildType"), // Required - ParentId: aws.String("ParentId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListChildren(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListCreateAccountStatus() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListCreateAccountStatusInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - States: []*string{ - aws.String("CreateAccountState"), // Required - // More values... - }, - } - resp, err := svc.ListCreateAccountStatus(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListHandshakesForAccount() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListHandshakesForAccountInput{ - Filter: &organizations.HandshakeFilter{ - ActionType: aws.String("ActionType"), - ParentHandshakeId: aws.String("HandshakeId"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListHandshakesForAccount(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListHandshakesForOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListHandshakesForOrganizationInput{ - Filter: &organizations.HandshakeFilter{ - ActionType: aws.String("ActionType"), - ParentHandshakeId: aws.String("HandshakeId"), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListHandshakesForOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListOrganizationalUnitsForParent() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListOrganizationalUnitsForParentInput{ - ParentId: aws.String("ParentId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListOrganizationalUnitsForParent(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListParents() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListParentsInput{ - ChildId: aws.String("ChildId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListParents(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListPolicies() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListPoliciesInput{ - Filter: aws.String("PolicyType"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPolicies(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListPoliciesForTarget() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListPoliciesForTargetInput{ - Filter: aws.String("PolicyType"), // Required - TargetId: aws.String("PolicyTargetId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListPoliciesForTarget(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListRoots() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListRootsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListRoots(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_ListTargetsForPolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.ListTargetsForPolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListTargetsForPolicy(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_MoveAccount() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.MoveAccountInput{ - AccountId: aws.String("AccountId"), // Required - DestinationParentId: aws.String("ParentId"), // Required - SourceParentId: aws.String("ParentId"), // Required - } - resp, err := svc.MoveAccount(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_RemoveAccountFromOrganization() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.RemoveAccountFromOrganizationInput{ - AccountId: aws.String("AccountId"), // Required - } - resp, err := svc.RemoveAccountFromOrganization(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_UpdateOrganizationalUnit() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.UpdateOrganizationalUnitInput{ - OrganizationalUnitId: aws.String("OrganizationalUnitId"), // Required - Name: aws.String("OrganizationalUnitName"), - } - resp, err := svc.UpdateOrganizationalUnit(params) - - if err != nil { - // 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) -} - -func ExampleOrganizations_UpdatePolicy() { - sess := session.Must(session.NewSession()) - - svc := organizations.New(sess) - - params := &organizations.UpdatePolicyInput{ - PolicyId: aws.String("PolicyId"), // Required - Content: aws.String("PolicyContent"), - Description: aws.String("PolicyDescription"), - Name: aws.String("PolicyName"), - } - resp, err := svc.UpdatePolicy(params) - - if err != nil { - // 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) -} diff --git a/service/pinpoint/examples_test.go b/service/pinpoint/examples_test.go deleted file mode 100644 index cd562123416..00000000000 --- a/service/pinpoint/examples_test.go +++ /dev/null @@ -1,1254 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package pinpoint_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/pinpoint" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExamplePinpoint_CreateCampaign() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.CreateCampaignInput{ - ApplicationId: aws.String("__string"), // Required - WriteCampaignRequest: &pinpoint.WriteCampaignRequest{ // Required - AdditionalTreatments: []*pinpoint.WriteTreatmentResource{ - { // Required - MessageConfiguration: &pinpoint.MessageConfiguration{ - APNSMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - DefaultMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - GCMMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - }, - Schedule: &pinpoint.Schedule{ - EndTime: aws.String("__string"), - Frequency: aws.String("Frequency"), - IsLocalTime: aws.Bool(true), - QuietTime: &pinpoint.QuietTime{ - End: aws.String("__string"), - Start: aws.String("__string"), - }, - StartTime: aws.String("__string"), - Timezone: aws.String("__string"), - }, - SizePercent: aws.Int64(1), - TreatmentDescription: aws.String("__string"), - TreatmentName: aws.String("__string"), - }, - // More values... - }, - Description: aws.String("__string"), - HoldoutPercent: aws.Int64(1), - IsPaused: aws.Bool(true), - Limits: &pinpoint.CampaignLimits{ - Daily: aws.Int64(1), - Total: aws.Int64(1), - }, - MessageConfiguration: &pinpoint.MessageConfiguration{ - APNSMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - DefaultMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - GCMMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - }, - Name: aws.String("__string"), - Schedule: &pinpoint.Schedule{ - EndTime: aws.String("__string"), - Frequency: aws.String("Frequency"), - IsLocalTime: aws.Bool(true), - QuietTime: &pinpoint.QuietTime{ - End: aws.String("__string"), - Start: aws.String("__string"), - }, - StartTime: aws.String("__string"), - Timezone: aws.String("__string"), - }, - SegmentId: aws.String("__string"), - SegmentVersion: aws.Int64(1), - TreatmentDescription: aws.String("__string"), - TreatmentName: aws.String("__string"), - }, - } - resp, err := svc.CreateCampaign(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_CreateImportJob() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.CreateImportJobInput{ - ApplicationId: aws.String("__string"), // Required - ImportJobRequest: &pinpoint.ImportJobRequest{ // Required - DefineSegment: aws.Bool(true), - ExternalId: aws.String("__string"), - Format: aws.String("Format"), - RegisterEndpoints: aws.Bool(true), - RoleArn: aws.String("__string"), - S3Url: aws.String("__string"), - SegmentId: aws.String("__string"), - SegmentName: aws.String("__string"), - }, - } - resp, err := svc.CreateImportJob(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_CreateSegment() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.CreateSegmentInput{ - ApplicationId: aws.String("__string"), // Required - WriteSegmentRequest: &pinpoint.WriteSegmentRequest{ // Required - Dimensions: &pinpoint.SegmentDimensions{ - Attributes: map[string]*pinpoint.AttributeDimension{ - "Key": { // Required - AttributeType: aws.String("AttributeType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - // More values... - }, - Behavior: &pinpoint.SegmentBehaviors{ - Recency: &pinpoint.RecencyDimension{ - Duration: aws.String("Duration"), - RecencyType: aws.String("RecencyType"), - }, - }, - Demographic: &pinpoint.SegmentDemographics{ - AppVersion: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - DeviceType: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Make: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Model: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Platform: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - }, - Location: &pinpoint.SegmentLocation{ - Country: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - }, - UserAttributes: map[string]*pinpoint.AttributeDimension{ - "Key": { // Required - AttributeType: aws.String("AttributeType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - // More values... - }, - }, - Name: aws.String("__string"), - }, - } - resp, err := svc.CreateSegment(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_DeleteApnsChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.DeleteApnsChannelInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.DeleteApnsChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_DeleteCampaign() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.DeleteCampaignInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - } - resp, err := svc.DeleteCampaign(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_DeleteEventStream() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.DeleteEventStreamInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.DeleteEventStream(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_DeleteGcmChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.DeleteGcmChannelInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.DeleteGcmChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_DeleteSegment() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.DeleteSegmentInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - } - resp, err := svc.DeleteSegment(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetApnsChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetApnsChannelInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.GetApnsChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetApplicationSettings() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetApplicationSettingsInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.GetApplicationSettings(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetCampaign() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetCampaignInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - } - resp, err := svc.GetCampaign(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetCampaignActivities() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetCampaignActivitiesInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetCampaignActivities(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetCampaignVersion() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetCampaignVersionInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - Version: aws.String("__string"), // Required - } - resp, err := svc.GetCampaignVersion(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetCampaignVersions() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetCampaignVersionsInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetCampaignVersions(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetCampaigns() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetCampaignsInput{ - ApplicationId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetCampaigns(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetEndpoint() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetEndpointInput{ - ApplicationId: aws.String("__string"), // Required - EndpointId: aws.String("__string"), // Required - } - resp, err := svc.GetEndpoint(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetEventStream() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetEventStreamInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.GetEventStream(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetGcmChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetGcmChannelInput{ - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.GetGcmChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetImportJob() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetImportJobInput{ - ApplicationId: aws.String("__string"), // Required - JobId: aws.String("__string"), // Required - } - resp, err := svc.GetImportJob(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetImportJobs() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetImportJobsInput{ - ApplicationId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetImportJobs(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetSegment() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetSegmentInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - } - resp, err := svc.GetSegment(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetSegmentImportJobs() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetSegmentImportJobsInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetSegmentImportJobs(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetSegmentVersion() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetSegmentVersionInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - Version: aws.String("__string"), // Required - } - resp, err := svc.GetSegmentVersion(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetSegmentVersions() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetSegmentVersionsInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetSegmentVersions(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_GetSegments() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.GetSegmentsInput{ - ApplicationId: aws.String("__string"), // Required - PageSize: aws.String("__string"), - Token: aws.String("__string"), - } - resp, err := svc.GetSegments(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_PutEventStream() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.PutEventStreamInput{ - ApplicationId: aws.String("__string"), // Required - WriteEventStream: &pinpoint.WriteEventStream{ // Required - DestinationStreamArn: aws.String("__string"), - ExternalId: aws.String("__string"), - RoleArn: aws.String("__string"), - }, - } - resp, err := svc.PutEventStream(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateApnsChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateApnsChannelInput{ - APNSChannelRequest: &pinpoint.APNSChannelRequest{ // Required - Certificate: aws.String("__string"), - PrivateKey: aws.String("__string"), - }, - ApplicationId: aws.String("__string"), // Required - } - resp, err := svc.UpdateApnsChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateApplicationSettings() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateApplicationSettingsInput{ - ApplicationId: aws.String("__string"), // Required - WriteApplicationSettingsRequest: &pinpoint.WriteApplicationSettingsRequest{ // Required - Limits: &pinpoint.CampaignLimits{ - Daily: aws.Int64(1), - Total: aws.Int64(1), - }, - QuietTime: &pinpoint.QuietTime{ - End: aws.String("__string"), - Start: aws.String("__string"), - }, - }, - } - resp, err := svc.UpdateApplicationSettings(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateCampaign() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateCampaignInput{ - ApplicationId: aws.String("__string"), // Required - CampaignId: aws.String("__string"), // Required - WriteCampaignRequest: &pinpoint.WriteCampaignRequest{ // Required - AdditionalTreatments: []*pinpoint.WriteTreatmentResource{ - { // Required - MessageConfiguration: &pinpoint.MessageConfiguration{ - APNSMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - DefaultMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - GCMMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - }, - Schedule: &pinpoint.Schedule{ - EndTime: aws.String("__string"), - Frequency: aws.String("Frequency"), - IsLocalTime: aws.Bool(true), - QuietTime: &pinpoint.QuietTime{ - End: aws.String("__string"), - Start: aws.String("__string"), - }, - StartTime: aws.String("__string"), - Timezone: aws.String("__string"), - }, - SizePercent: aws.Int64(1), - TreatmentDescription: aws.String("__string"), - TreatmentName: aws.String("__string"), - }, - // More values... - }, - Description: aws.String("__string"), - HoldoutPercent: aws.Int64(1), - IsPaused: aws.Bool(true), - Limits: &pinpoint.CampaignLimits{ - Daily: aws.Int64(1), - Total: aws.Int64(1), - }, - MessageConfiguration: &pinpoint.MessageConfiguration{ - APNSMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - DefaultMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - GCMMessage: &pinpoint.Message{ - Action: aws.String("Action"), - Body: aws.String("__string"), - ImageIconUrl: aws.String("__string"), - ImageUrl: aws.String("__string"), - JsonBody: aws.String("__string"), - MediaUrl: aws.String("__string"), - SilentPush: aws.Bool(true), - Title: aws.String("__string"), - Url: aws.String("__string"), - }, - }, - Name: aws.String("__string"), - Schedule: &pinpoint.Schedule{ - EndTime: aws.String("__string"), - Frequency: aws.String("Frequency"), - IsLocalTime: aws.Bool(true), - QuietTime: &pinpoint.QuietTime{ - End: aws.String("__string"), - Start: aws.String("__string"), - }, - StartTime: aws.String("__string"), - Timezone: aws.String("__string"), - }, - SegmentId: aws.String("__string"), - SegmentVersion: aws.Int64(1), - TreatmentDescription: aws.String("__string"), - TreatmentName: aws.String("__string"), - }, - } - resp, err := svc.UpdateCampaign(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateEndpoint() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateEndpointInput{ - ApplicationId: aws.String("__string"), // Required - EndpointId: aws.String("__string"), // Required - EndpointRequest: &pinpoint.EndpointRequest{ // Required - Address: aws.String("__string"), - Attributes: map[string][]*string{ - "Key": { // Required - aws.String("__string"), // Required - // More values... - }, - // More values... - }, - ChannelType: aws.String("ChannelType"), - Demographic: &pinpoint.EndpointDemographic{ - AppVersion: aws.String("__string"), - Locale: aws.String("__string"), - Make: aws.String("__string"), - Model: aws.String("__string"), - ModelVersion: aws.String("__string"), - Platform: aws.String("__string"), - PlatformVersion: aws.String("__string"), - Timezone: aws.String("__string"), - }, - EffectiveDate: aws.String("__string"), - EndpointStatus: aws.String("__string"), - Location: &pinpoint.EndpointLocation{ - City: aws.String("__string"), - Country: aws.String("__string"), - Latitude: aws.Float64(1.0), - Longitude: aws.Float64(1.0), - PostalCode: aws.String("__string"), - Region: aws.String("__string"), - }, - Metrics: map[string]*float64{ - "Key": aws.Float64(1.0), // Required - // More values... - }, - OptOut: aws.String("__string"), - RequestId: aws.String("__string"), - User: &pinpoint.EndpointUser{ - UserAttributes: map[string][]*string{ - "Key": { // Required - aws.String("__string"), // Required - // More values... - }, - // More values... - }, - UserId: aws.String("__string"), - }, - }, - } - resp, err := svc.UpdateEndpoint(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateEndpointsBatch() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateEndpointsBatchInput{ - ApplicationId: aws.String("__string"), // Required - EndpointBatchRequest: &pinpoint.EndpointBatchRequest{ // Required - Item: []*pinpoint.EndpointBatchItem{ - { // Required - Address: aws.String("__string"), - Attributes: map[string][]*string{ - "Key": { // Required - aws.String("__string"), // Required - // More values... - }, - // More values... - }, - ChannelType: aws.String("ChannelType"), - Demographic: &pinpoint.EndpointDemographic{ - AppVersion: aws.String("__string"), - Locale: aws.String("__string"), - Make: aws.String("__string"), - Model: aws.String("__string"), - ModelVersion: aws.String("__string"), - Platform: aws.String("__string"), - PlatformVersion: aws.String("__string"), - Timezone: aws.String("__string"), - }, - EffectiveDate: aws.String("__string"), - EndpointStatus: aws.String("__string"), - Id: aws.String("__string"), - Location: &pinpoint.EndpointLocation{ - City: aws.String("__string"), - Country: aws.String("__string"), - Latitude: aws.Float64(1.0), - Longitude: aws.Float64(1.0), - PostalCode: aws.String("__string"), - Region: aws.String("__string"), - }, - Metrics: map[string]*float64{ - "Key": aws.Float64(1.0), // Required - // More values... - }, - OptOut: aws.String("__string"), - RequestId: aws.String("__string"), - User: &pinpoint.EndpointUser{ - UserAttributes: map[string][]*string{ - "Key": { // Required - aws.String("__string"), // Required - // More values... - }, - // More values... - }, - UserId: aws.String("__string"), - }, - }, - // More values... - }, - }, - } - resp, err := svc.UpdateEndpointsBatch(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateGcmChannel() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateGcmChannelInput{ - ApplicationId: aws.String("__string"), // Required - GCMChannelRequest: &pinpoint.GCMChannelRequest{ // Required - ApiKey: aws.String("__string"), - }, - } - resp, err := svc.UpdateGcmChannel(params) - - if err != nil { - // 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) -} - -func ExamplePinpoint_UpdateSegment() { - sess := session.Must(session.NewSession()) - - svc := pinpoint.New(sess) - - params := &pinpoint.UpdateSegmentInput{ - ApplicationId: aws.String("__string"), // Required - SegmentId: aws.String("__string"), // Required - WriteSegmentRequest: &pinpoint.WriteSegmentRequest{ // Required - Dimensions: &pinpoint.SegmentDimensions{ - Attributes: map[string]*pinpoint.AttributeDimension{ - "Key": { // Required - AttributeType: aws.String("AttributeType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - // More values... - }, - Behavior: &pinpoint.SegmentBehaviors{ - Recency: &pinpoint.RecencyDimension{ - Duration: aws.String("Duration"), - RecencyType: aws.String("RecencyType"), - }, - }, - Demographic: &pinpoint.SegmentDemographics{ - AppVersion: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - DeviceType: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Make: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Model: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - Platform: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - }, - Location: &pinpoint.SegmentLocation{ - Country: &pinpoint.SetDimension{ - DimensionType: aws.String("DimensionType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - }, - UserAttributes: map[string]*pinpoint.AttributeDimension{ - "Key": { // Required - AttributeType: aws.String("AttributeType"), - Values: []*string{ - aws.String("__string"), // Required - // More values... - }, - }, - // More values... - }, - }, - Name: aws.String("__string"), - }, - } - resp, err := svc.UpdateSegment(params) - - if err != nil { - // 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) -} diff --git a/service/polly/examples_test.go b/service/polly/examples_test.go deleted file mode 100644 index 27cfccd7bac..00000000000 --- a/service/polly/examples_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package polly_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/polly" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExamplePolly_DeleteLexicon() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.DeleteLexiconInput{ - Name: aws.String("LexiconName"), // Required - } - resp, err := svc.DeleteLexicon(params) - - if err != nil { - // 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) -} - -func ExamplePolly_DescribeVoices() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.DescribeVoicesInput{ - LanguageCode: aws.String("LanguageCode"), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeVoices(params) - - if err != nil { - // 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) -} - -func ExamplePolly_GetLexicon() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.GetLexiconInput{ - Name: aws.String("LexiconName"), // Required - } - resp, err := svc.GetLexicon(params) - - if err != nil { - // 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) -} - -func ExamplePolly_ListLexicons() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.ListLexiconsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListLexicons(params) - - if err != nil { - // 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) -} - -func ExamplePolly_PutLexicon() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.PutLexiconInput{ - Content: aws.String("LexiconContent"), // Required - Name: aws.String("LexiconName"), // Required - } - resp, err := svc.PutLexicon(params) - - if err != nil { - // 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) -} - -func ExamplePolly_SynthesizeSpeech() { - sess := session.Must(session.NewSession()) - - svc := polly.New(sess) - - params := &polly.SynthesizeSpeechInput{ - OutputFormat: aws.String("OutputFormat"), // Required - Text: aws.String("Text"), // Required - VoiceId: aws.String("VoiceId"), // Required - LexiconNames: []*string{ - aws.String("LexiconName"), // Required - // More values... - }, - SampleRate: aws.String("SampleRate"), - SpeechMarkTypes: []*string{ - aws.String("SpeechMarkType"), // Required - // More values... - }, - TextType: aws.String("TextType"), - } - resp, err := svc.SynthesizeSpeech(params) - - if err != nil { - // 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) -} diff --git a/service/rds/examples_test.go b/service/rds/examples_test.go index df8dfcc4715..82215d0442c 100644 --- a/service/rds/examples_test.go +++ b/service/rds/examples_test.go @@ -8,2791 +8,3040 @@ import ( "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/rds" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleRDS_AddRoleToDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.AddRoleToDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - RoleArn: aws.String("String"), // Required - } - resp, err := svc.AddRoleToDBCluster(params) - - if err != nil { - // 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) -} - -func ExampleRDS_AddSourceIdentifierToSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.AddSourceIdentifierToSubscriptionInput{ - SourceIdentifier: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required - } - resp, err := svc.AddSourceIdentifierToSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRDS_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.AddTagsToResourceInput{ - ResourceName: aws.String("String"), // Required - Tags: []*rds.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleRDS_ApplyPendingMaintenanceAction() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ApplyPendingMaintenanceActionInput{ - ApplyAction: aws.String("String"), // Required - OptInType: aws.String("String"), // Required - ResourceIdentifier: aws.String("String"), // Required - } - resp, err := svc.ApplyPendingMaintenanceAction(params) - - if err != nil { - // 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) -} - -func ExampleRDS_AuthorizeDBSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.AuthorizeDBSecurityGroupIngressInput{ - DBSecurityGroupName: aws.String("String"), // Required - CIDRIP: aws.String("String"), - EC2SecurityGroupId: aws.String("String"), - EC2SecurityGroupName: aws.String("String"), - EC2SecurityGroupOwnerId: aws.String("String"), - } - resp, err := svc.AuthorizeDBSecurityGroupIngress(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CopyDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CopyDBClusterParameterGroupInput{ - SourceDBClusterParameterGroupIdentifier: aws.String("String"), // Required - TargetDBClusterParameterGroupDescription: aws.String("String"), // Required - TargetDBClusterParameterGroupIdentifier: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CopyDBClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CopyDBClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CopyDBClusterSnapshotInput{ - SourceDBClusterSnapshotIdentifier: aws.String("String"), // Required - TargetDBClusterSnapshotIdentifier: aws.String("String"), // Required - CopyTags: aws.Bool(true), - DestinationRegion: aws.String("String"), - KmsKeyId: aws.String("String"), - PreSignedUrl: aws.String("String"), - SourceRegion: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CopyDBClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CopyDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CopyDBParameterGroupInput{ - SourceDBParameterGroupIdentifier: aws.String("String"), // Required - TargetDBParameterGroupDescription: aws.String("String"), // Required - TargetDBParameterGroupIdentifier: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CopyDBParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CopyDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CopyDBSnapshotInput{ - SourceDBSnapshotIdentifier: aws.String("String"), // Required - TargetDBSnapshotIdentifier: aws.String("String"), // Required - CopyTags: aws.Bool(true), - DestinationRegion: aws.String("String"), - KmsKeyId: aws.String("String"), - PreSignedUrl: aws.String("String"), - SourceRegion: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CopyDBSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CopyOptionGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CopyOptionGroupInput{ - SourceOptionGroupIdentifier: aws.String("String"), // Required - TargetOptionGroupDescription: aws.String("String"), // Required - TargetOptionGroupIdentifier: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CopyOptionGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - Engine: aws.String("String"), // Required - AvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... - }, - BackupRetentionPeriod: aws.Int64(1), - CharacterSetName: aws.String("String"), - DBClusterParameterGroupName: aws.String("String"), - DBSubnetGroupName: aws.String("String"), - DatabaseName: aws.String("String"), - DestinationRegion: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - EngineVersion: aws.String("String"), - KmsKeyId: aws.String("String"), - MasterUserPassword: aws.String("String"), - MasterUsername: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PreSignedUrl: aws.String("String"), - PreferredBackupWindow: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - ReplicationSourceIdentifier: aws.String("String"), - SourceRegion: aws.String("String"), - StorageEncrypted: aws.Bool(true), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateDBCluster(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBClusterParameterGroupInput{ - DBClusterParameterGroupName: aws.String("String"), // Required - DBParameterGroupFamily: aws.String("String"), // Required - Description: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBClusterSnapshotInput{ - DBClusterIdentifier: aws.String("String"), // Required - DBClusterSnapshotIdentifier: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBInstance() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBInstanceInput{ - DBInstanceClass: aws.String("String"), // Required - DBInstanceIdentifier: aws.String("String"), // Required - Engine: aws.String("String"), // Required - AllocatedStorage: aws.Int64(1), - AutoMinorVersionUpgrade: aws.Bool(true), - AvailabilityZone: aws.String("String"), - BackupRetentionPeriod: aws.Int64(1), - CharacterSetName: aws.String("String"), - CopyTagsToSnapshot: aws.Bool(true), - DBClusterIdentifier: aws.String("String"), - DBName: aws.String("String"), - DBParameterGroupName: aws.String("String"), - DBSecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - DBSubnetGroupName: aws.String("String"), - Domain: aws.String("String"), - DomainIAMRoleName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - EngineVersion: aws.String("String"), - Iops: aws.Int64(1), - KmsKeyId: aws.String("String"), - LicenseModel: aws.String("String"), - MasterUserPassword: aws.String("String"), - MasterUsername: aws.String("String"), - MonitoringInterval: aws.Int64(1), - MonitoringRoleArn: aws.String("String"), - MultiAZ: aws.Bool(true), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PreferredBackupWindow: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - PromotionTier: aws.Int64(1), - PubliclyAccessible: aws.Bool(true), - StorageEncrypted: aws.Bool(true), - StorageType: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - TdeCredentialArn: aws.String("String"), - TdeCredentialPassword: aws.String("String"), - Timezone: aws.String("String"), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateDBInstance(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBInstanceReadReplica() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBInstanceReadReplicaInput{ - DBInstanceIdentifier: aws.String("String"), // Required - SourceDBInstanceIdentifier: aws.String("String"), // Required - AutoMinorVersionUpgrade: aws.Bool(true), - AvailabilityZone: aws.String("String"), - CopyTagsToSnapshot: aws.Bool(true), - DBInstanceClass: aws.String("String"), - DBSubnetGroupName: aws.String("String"), - DestinationRegion: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - Iops: aws.Int64(1), - KmsKeyId: aws.String("String"), - MonitoringInterval: aws.Int64(1), - MonitoringRoleArn: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PreSignedUrl: aws.String("String"), - PubliclyAccessible: aws.Bool(true), - SourceRegion: aws.String("String"), - StorageType: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBInstanceReadReplica(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBParameterGroupInput{ - DBParameterGroupFamily: aws.String("String"), // Required - DBParameterGroupName: aws.String("String"), // Required - Description: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBSecurityGroupInput{ - DBSecurityGroupDescription: aws.String("String"), // Required - DBSecurityGroupName: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBSecurityGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBSnapshotInput{ - DBInstanceIdentifier: aws.String("String"), // Required - DBSnapshotIdentifier: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateDBSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateDBSubnetGroupInput{ - DBSubnetGroupDescription: aws.String("String"), // Required - DBSubnetGroupName: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateDBSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateEventSubscriptionInput{ - SnsTopicArn: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceType: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRDS_CreateOptionGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.CreateOptionGroupInput{ - EngineName: aws.String("String"), // Required - MajorEngineVersion: aws.String("String"), // Required - OptionGroupDescription: aws.String("String"), // Required - OptionGroupName: aws.String("String"), // Required - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateOptionGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - FinalDBSnapshotIdentifier: aws.String("String"), - SkipFinalSnapshot: aws.Bool(true), - } - resp, err := svc.DeleteDBCluster(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBClusterParameterGroupInput{ - DBClusterParameterGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteDBClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBClusterSnapshotInput{ - DBClusterSnapshotIdentifier: aws.String("String"), // Required - } - resp, err := svc.DeleteDBClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBInstance() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBInstanceInput{ - DBInstanceIdentifier: aws.String("String"), // Required - FinalDBSnapshotIdentifier: aws.String("String"), - SkipFinalSnapshot: aws.Bool(true), - } - resp, err := svc.DeleteDBInstance(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBParameterGroupInput{ - DBParameterGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteDBParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSecurityGroupInput{ - DBSecurityGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteDBSecurityGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSnapshotInput{ - DBSnapshotIdentifier: aws.String("String"), // Required - } - resp, err := svc.DeleteDBSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteDBSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSubnetGroupInput{ - DBSubnetGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteDBSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - } - resp, err := svc.DeleteEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DeleteOptionGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteOptionGroupInput{ - OptionGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteOptionGroup(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeAccountAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - var params *rds.DescribeAccountAttributesInput - resp, err := svc.DescribeAccountAttributes(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeCertificates() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeCertificatesInput{ - CertificateIdentifier: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeCertificates(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBClusterParameterGroups() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClusterParameterGroupsInput{ - DBClusterParameterGroupName: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeDBClusterParameterGroups(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBClusterParameters() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClusterParametersInput{ - DBClusterParameterGroupName: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Source: aws.String("String"), - } - resp, err := svc.DescribeDBClusterParameters(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBClusterSnapshotAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClusterSnapshotAttributesInput{ - DBClusterSnapshotIdentifier: aws.String("String"), // Required - } - resp, err := svc.DescribeDBClusterSnapshotAttributes(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBClusterSnapshots() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClusterSnapshotsInput{ - DBClusterIdentifier: aws.String("String"), - DBClusterSnapshotIdentifier: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - IncludePublic: aws.Bool(true), - IncludeShared: aws.Bool(true), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SnapshotType: aws.String("String"), - } - resp, err := svc.DescribeDBClusterSnapshots(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBClusters() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClustersInput{ - DBClusterIdentifier: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeDBClusters(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBEngineVersions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBEngineVersionsInput{ - DBParameterGroupFamily: aws.String("String"), - DefaultOnly: aws.Bool(true), - Engine: aws.String("String"), - EngineVersion: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ListSupportedCharacterSets: aws.Bool(true), - ListSupportedTimezones: aws.Bool(true), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeDBEngineVersions(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBInstances() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBInstancesInput{ - DBInstanceIdentifier: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeDBInstances(params) - +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()) - return + panic(err) } - - // Pretty-print the response data. - fmt.Println(resp) + return &t } -func ExampleRDS_DescribeDBLogFiles() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBLogFilesInput{ - DBInstanceIdentifier: aws.String("String"), // Required - FileLastWritten: aws.Int64(1), - FileSize: aws.Int64(1), - FilenameContains: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// To add a source identifier to an event notification subscription +// +// This example add a source identifier to an event notification subscription. +func ExampleRDS_AddSourceIdentifierToSubscription_shared00() { + svc := rds.New(session.New()) + input := &rds.AddSourceIdentifierToSubscriptionInput{ + SourceIdentifier: aws.String("mymysqlinstance"), + SubscriptionName: aws.String("mymysqleventsubscription"), } - resp, err := svc.DescribeDBLogFiles(params) + result, err := svc.AddSourceIdentifierToSubscription(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 rds.ErrCodeSubscriptionNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error()) + case rds.ErrCodeSourceNotFoundFault: + fmt.Println(rds.ErrCodeSourceNotFoundFault, 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 ExampleRDS_DescribeDBParameterGroups() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBParameterGroupsInput{ - DBParameterGroupName: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, +// To add tags to a resource +// +// This example adds a tag to an option group. +func ExampleRDS_AddTagsToResource_shared00() { + svc := rds.New(session.New()) + input := &rds.AddTagsToResourceInput{ + ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mymysqloptiongroup"), + Tags: []*rds.TagList{ + { + Key: aws.String("Staging"), + Value: aws.String("LocationDB"), }, - // More values... }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), } - resp, err := svc.DescribeDBParameterGroups(params) + result, err := svc.AddTagsToResource(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()) - return - } + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, 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) +} - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleRDS_DescribeDBParameters() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBParametersInput{ - DBParameterGroupName: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, +// To apply a pending maintenance action +// +// This example immediately applies a pending system update to a DB instance. +func ExampleRDS_ApplyPendingMaintenanceAction_shared00() { + svc := rds.New(session.New()) + input := &rds.ApplyPendingMaintenanceActionInput{ + ApplyAction: aws.String("system-update"), + OptInType: aws.String("immediate"), + ResourceIdentifier: aws.String("arn:aws:rds:us-east-1:992648334831:db:mymysqlinstance"), + } + + result, err := svc.ApplyPendingMaintenanceAction(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeResourceNotFoundFault: + fmt.Println(rds.ErrCodeResourceNotFoundFault, 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) +} + +// To authorize DB security group integress +// +// This example authorizes access to the specified security group by the specified CIDR +// block. +func ExampleRDS_AuthorizeDBSecurityGroupIngress_shared00() { + svc := rds.New(session.New()) + input := &rds.AuthorizeDBSecurityGroupIngressInput{ + CIDRIP: aws.String("203.0.113.5/32"), + DBSecurityGroupName: aws.String("mydbsecuritygroup"), + } + + result, err := svc.AuthorizeDBSecurityGroupIngress(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBSecurityGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error()) + case rds.ErrCodeAuthorizationAlreadyExistsFault: + fmt.Println(rds.ErrCodeAuthorizationAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeAuthorizationQuotaExceededFault: + fmt.Println(rds.ErrCodeAuthorizationQuotaExceededFault, 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) +} + +// To copy a DB cluster parameter group +// +// This example copies a DB cluster parameter group. +func ExampleRDS_CopyDBClusterParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CopyDBClusterParameterGroupInput{ + SourceDBClusterParameterGroupIdentifier: aws.String("mydbclusterparametergroup"), + TargetDBClusterParameterGroupDescription: aws.String("My DB cluster parameter group copy"), + TargetDBClusterParameterGroupIdentifier: aws.String("mydbclusterparametergroup-copy"), + } + + result, err := svc.CopyDBClusterParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, 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) +} + +// To copy a DB cluster snapshot +// +// The following example copies an automated snapshot of a DB cluster to a new DB cluster +// snapshot. +func ExampleRDS_CopyDBClusterSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.CopyDBClusterSnapshotInput{ + SourceDBClusterSnapshotIdentifier: aws.String("rds:sample-cluster-2016-09-14-10-38"), + TargetDBClusterSnapshotIdentifier: aws.String("cluster-snapshot-copy-1"), + } + + result, err := svc.CopyDBClusterSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, 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) +} + +// To copy a DB parameter group +// +// This example copies a DB parameter group. +func ExampleRDS_CopyDBParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CopyDBParameterGroupInput{ + SourceDBParameterGroupIdentifier: aws.String("mymysqlparametergroup"), + TargetDBParameterGroupDescription: aws.String("My MySQL parameter group copy"), + TargetDBParameterGroupIdentifier: aws.String("mymysqlparametergroup-copy"), + } + + result, err := svc.CopyDBParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, 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) +} + +// To copy a DB snapshot +// +// This example copies a DB snapshot. +func ExampleRDS_CopyDBSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.CopyDBSnapshotInput{ + SourceDBSnapshotIdentifier: aws.String("mydbsnapshot"), + TargetDBSnapshotIdentifier: aws.String("mydbsnapshot-copy"), + } + + result, err := svc.CopyDBSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, 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) +} + +// To copy an option group +// +// This example copies an option group. +func ExampleRDS_CopyOptionGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CopyOptionGroupInput{ + SourceOptionGroupIdentifier: aws.String("mymysqloptiongroup"), + TargetOptionGroupDescription: aws.String("My MySQL option group copy"), + TargetOptionGroupIdentifier: aws.String("mymysqloptiongroup-copy"), + } + + result, err := svc.CopyOptionGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeOptionGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeOptionGroupAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeOptionGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeOptionGroupQuotaExceededFault, 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) +} + +// To create a DB cluster +// +// This example creates a DB cluster. +func ExampleRDS_CreateDBCluster_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBClusterInput{ + AvailabilityZones: []*string{ + aws.String("us-east-1a"), + }, + BackupRetentionPeriod: aws.Int64(1.000000), + DBClusterIdentifier: aws.String("mydbcluster"), + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + DatabaseName: aws.String("myauroradb"), + Engine: aws.String("aurora"), + EngineVersion: aws.String("5.6.10a"), + MasterUserPassword: aws.String("mypassword"), + MasterUsername: aws.String("myuser"), + Port: aws.Int64(3306.000000), + StorageEncrypted: aws.Bool(true), + } + + result, err := svc.CreateDBCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeInsufficientStorageClusterCapacityFault: + fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error()) + case rds.ErrCodeDBClusterQuotaExceededFault: + fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBSubnetGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBClusterParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, 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) +} + +// To create a DB cluster parameter group +// +// This example creates a DB cluster parameter group. +func ExampleRDS_CreateDBClusterParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBClusterParameterGroupInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + DBParameterGroupFamily: aws.String("aurora5.6"), + Description: aws.String("My DB cluster parameter group"), + } + + result, err := svc.CreateDBClusterParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBParameterGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, 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) +} + +// To create a DB cluster snapshot +// +// This example creates a DB cluster snapshot. +func ExampleRDS_CreateDBClusterSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBClusterSnapshotInput{ + DBClusterIdentifier: aws.String("mydbcluster"), + DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"), + } + + result, err := svc.CreateDBClusterSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, 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) +} + +// To create a DB instance. +// +// This example creates a DB instance. +func ExampleRDS_CreateDBInstance_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBInstanceInput{ + AllocatedStorage: aws.Int64(5.000000), + DBInstanceClass: aws.String("db.t2.micro"), + DBInstanceIdentifier: aws.String("mymysqlinstance"), + Engine: aws.String("MySQL"), + MasterUserPassword: aws.String("MyPassword"), + MasterUsername: aws.String("MyUser"), + } + + result, err := svc.CreateDBInstance(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeInsufficientDBInstanceCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInstanceQuotaExceededFault: + fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeProvisionedIopsNotAvailableInAZFault: + fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeStorageTypeNotSupportedFault: + fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error()) + case rds.ErrCodeAuthorizationNotFoundFault: + fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error()) + case rds.ErrCodeDomainNotFoundFault: + fmt.Println(rds.ErrCodeDomainNotFoundFault, 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) +} + +// To create a DB instance read replica. +// +// This example creates a DB instance read replica. +func ExampleRDS_CreateDBInstanceReadReplica_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBInstanceReadReplicaInput{ + AvailabilityZone: aws.String("us-east-1a"), + CopyTagsToSnapshot: aws.Bool(true), + DBInstanceClass: aws.String("db.t2.micro"), + DBInstanceIdentifier: aws.String("mydbreadreplica"), + PubliclyAccessible: aws.Bool(true), + SourceDBInstanceIdentifier: aws.String("mymysqlinstance"), + StorageType: aws.String("gp2"), + Tags: []*rds.TagList{ + { + Key: aws.String("mydbreadreplicakey"), + Value: aws.String("mydbreadreplicavalue"), }, - // More values... }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Source: aws.String("String"), - } - resp, err := svc.DescribeDBParameters(params) - - if err != nil { - // 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) -} - -func ExampleRDS_DescribeDBSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBSecurityGroupsInput{ - DBSecurityGroupName: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... + result, err := svc.CreateDBInstanceReadReplica(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeInsufficientDBInstanceCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInstanceQuotaExceededFault: + fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeProvisionedIopsNotAvailableInAZFault: + fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotAllowedFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotAllowedFault, aerr.Error()) + case rds.ErrCodeInvalidDBSubnetGroupFault: + fmt.Println(rds.ErrCodeInvalidDBSubnetGroupFault, aerr.Error()) + case rds.ErrCodeStorageTypeNotSupportedFault: + fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, 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) +} + +// To create a DB parameter group. +// +// This example creates a DB parameter group. +func ExampleRDS_CreateDBParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBParameterGroupInput{ + DBParameterGroupFamily: aws.String("mysql5.6"), + DBParameterGroupName: aws.String("mymysqlparametergroup"), + Description: aws.String("My MySQL parameter group"), + } + + result, err := svc.CreateDBParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBParameterGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBParameterGroupQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBParameterGroupAlreadyExistsFault, 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) +} + +// To create a DB security group. +// +// This example creates a DB security group. +func ExampleRDS_CreateDBSecurityGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBSecurityGroupInput{ + DBSecurityGroupDescription: aws.String("My DB security group"), + DBSecurityGroupName: aws.String("mydbsecuritygroup"), + } + + result, err := svc.CreateDBSecurityGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSecurityGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBSecurityGroupAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBSecurityGroupQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotSupportedFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotSupportedFault, 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) +} + +// To create a DB snapshot. +// +// This example creates a DB snapshot. +func ExampleRDS_CreateDBSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBSnapshotInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + DBSnapshotIdentifier: aws.String("mydbsnapshot"), + } + + result, err := svc.CreateDBSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, 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) +} + +// To create a DB subnet group. +// +// This example creates a DB subnet group. +func ExampleRDS_CreateDBSubnetGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateDBSubnetGroupInput{ + DBSubnetGroupDescription: aws.String("My DB subnet group"), + DBSubnetGroupName: aws.String("mydbsubnetgroup"), + SubnetIds: []*string{ + aws.String("subnet-1fab8a69"), + aws.String("subnet-d43a468c"), + }, + } + + result, err := svc.CreateDBSubnetGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSubnetGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBSubnetGroupAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeDBSubnetGroupQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetQuotaExceededFault: + fmt.Println(rds.ErrCodeDBSubnetQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, 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) +} + +// To create an event notification subscription +// +// This example creates an event notification subscription. +func ExampleRDS_CreateEventSubscription_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateEventSubscriptionInput{ + Enabled: aws.Bool(true), + EventCategories: []*string{ + aws.String("availability"), }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), + SnsTopicArn: aws.String("arn:aws:sns:us-east-1:992648334831:MyDemoSNSTopic"), + SourceIds: []*string{ + aws.String("mymysqlinstance"), + }, + SourceType: aws.String("db-instance"), + SubscriptionName: aws.String("mymysqleventsubscription"), + } + + result, err := svc.CreateEventSubscription(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeEventSubscriptionQuotaExceededFault: + fmt.Println(rds.ErrCodeEventSubscriptionQuotaExceededFault, aerr.Error()) + case rds.ErrCodeSubscriptionAlreadyExistFault: + fmt.Println(rds.ErrCodeSubscriptionAlreadyExistFault, aerr.Error()) + case rds.ErrCodeSNSInvalidTopicFault: + fmt.Println(rds.ErrCodeSNSInvalidTopicFault, aerr.Error()) + case rds.ErrCodeSNSNoAuthorizationFault: + fmt.Println(rds.ErrCodeSNSNoAuthorizationFault, aerr.Error()) + case rds.ErrCodeSNSTopicArnNotFoundFault: + fmt.Println(rds.ErrCodeSNSTopicArnNotFoundFault, aerr.Error()) + case rds.ErrCodeSubscriptionCategoryNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionCategoryNotFoundFault, aerr.Error()) + case rds.ErrCodeSourceNotFoundFault: + fmt.Println(rds.ErrCodeSourceNotFoundFault, 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) +} + +// To create an option group +// +// This example creates an option group. +func ExampleRDS_CreateOptionGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.CreateOptionGroupInput{ + EngineName: aws.String("MySQL"), + MajorEngineVersion: aws.String("5.6"), + OptionGroupDescription: aws.String("My MySQL 5.6 option group"), + OptionGroupName: aws.String("mymysqloptiongroup"), + } + + result, err := svc.CreateOptionGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeOptionGroupAlreadyExistsFault: + fmt.Println(rds.ErrCodeOptionGroupAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeOptionGroupQuotaExceededFault: + fmt.Println(rds.ErrCodeOptionGroupQuotaExceededFault, 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) +} + +// To delete a DB cluster. +// +// This example deletes the specified DB cluster. +func ExampleRDS_DeleteDBCluster_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBClusterInput{ + DBClusterIdentifier: aws.String("mydbcluster"), + SkipFinalSnapshot: aws.Bool(true), + } + + result, err := svc.DeleteDBCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeDBClusterSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, 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) +} + +// To delete a DB cluster parameter group. +// +// This example deletes the specified DB cluster parameter group. +func ExampleRDS_DeleteDBClusterParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBClusterParameterGroupInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + } + + result, err := svc.DeleteDBClusterParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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) +} + +// To delete a DB cluster snapshot. +// +// This example deletes the specified DB cluster snapshot. +func ExampleRDS_DeleteDBClusterSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBClusterSnapshotInput{ + DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"), + } + + result, err := svc.DeleteDBClusterSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error()) + case rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, 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) +} + +// To delete a DB instance. +// +// This example deletes the specified DB instance. +func ExampleRDS_DeleteDBInstance_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBInstanceInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + SkipFinalSnapshot: aws.Bool(true), } - resp, err := svc.DescribeDBSecurityGroups(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + + result, err := svc.DeleteDBInstance(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBSnapshotAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, 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 ExampleRDS_DescribeDBSnapshotAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBSnapshotAttributesInput{ - DBSnapshotIdentifier: aws.String("String"), // Required + +// To delete a DB parameter group +// +// The following example deletes a DB parameter group. +func ExampleRDS_DeleteDBParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBParameterGroupInput{ + DBParameterGroupName: aws.String("mydbparamgroup3"), } - resp, err := svc.DescribeDBSnapshotAttributes(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.DeleteDBParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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 ExampleRDS_DescribeDBSnapshots() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBSnapshotsInput{ - DBInstanceIdentifier: aws.String("String"), - DBSnapshotIdentifier: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - IncludePublic: aws.Bool(true), - IncludeShared: aws.Bool(true), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SnapshotType: aws.String("String"), + +// To delete a DB security group +// +// The following example deletes a DB security group. +func ExampleRDS_DeleteDBSecurityGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBSecurityGroupInput{ + DBSecurityGroupName: aws.String("mysecgroup"), } - resp, err := svc.DescribeDBSnapshots(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.DeleteDBSecurityGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBSecurityGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, 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 ExampleRDS_DescribeDBSubnetGroups() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBSubnetGroupsInput{ - DBSubnetGroupName: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), + +// To delete a DB cluster snapshot. +// +// This example deletes the specified DB snapshot. +func ExampleRDS_DeleteDBSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBSnapshotInput{ + DBSnapshotIdentifier: aws.String("mydbsnapshot"), } - resp, err := svc.DescribeDBSubnetGroups(params) - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) + result, err := svc.DeleteDBSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, 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 ExampleRDS_DescribeEngineDefaultClusterParameters() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeEngineDefaultClusterParametersInput{ - DBParameterGroupFamily: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// To delete a DB subnet group. +// +// This example deletes the specified DB subnetgroup. +func ExampleRDS_DeleteDBSubnetGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteDBSubnetGroupInput{ + DBSubnetGroupName: aws.String("mydbsubnetgroup"), } - resp, err := svc.DescribeEngineDefaultClusterParameters(params) + result, err := svc.DeleteDBSubnetGroup(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 rds.ErrCodeInvalidDBSubnetGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBSubnetStateFault: + fmt.Println(rds.ErrCodeInvalidDBSubnetStateFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, 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 ExampleRDS_DescribeEngineDefaultParameters() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeEngineDefaultParametersInput{ - DBParameterGroupFamily: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// To delete a DB event subscription. +// +// This example deletes the specified DB event subscription. +func ExampleRDS_DeleteEventSubscription_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteEventSubscriptionInput{ + SubscriptionName: aws.String("myeventsubscription"), } - resp, err := svc.DescribeEngineDefaultParameters(params) + result, err := svc.DeleteEventSubscription(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 rds.ErrCodeSubscriptionNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidEventSubscriptionStateFault: + fmt.Println(rds.ErrCodeInvalidEventSubscriptionStateFault, 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 ExampleRDS_DescribeEventCategories() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeEventCategoriesInput{ - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - SourceType: aws.String("String"), +// To delete an option group. +// +// This example deletes the specified option group. +func ExampleRDS_DeleteOptionGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.DeleteOptionGroupInput{ + OptionGroupName: aws.String("mydboptiongroup"), } - resp, err := svc.DescribeEventCategories(params) + result, err := svc.DeleteOptionGroup(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 rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidOptionGroupStateFault: + fmt.Println(rds.ErrCodeInvalidOptionGroupStateFault, 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 ExampleRDS_DescribeEventSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeEventSubscriptionsInput{ - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SubscriptionName: aws.String("String"), - } - resp, err := svc.DescribeEventSubscriptions(params) +// To list account attributes +// +// This example lists account attributes. +func ExampleRDS_DescribeAccountAttributes_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeAccountAttributesInput{} + result, err := svc.DescribeAccountAttributes(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() { + 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 ExampleRDS_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeEventsInput{ - Duration: aws.Int64(1), - EndTime: aws.Time(time.Now()), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SourceIdentifier: aws.String("String"), - SourceType: aws.String("SourceType"), - StartTime: aws.Time(time.Now()), +// To list certificates +// +// This example lists up to 20 certificates for the specified certificate identifier. +func ExampleRDS_DescribeCertificates_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeCertificatesInput{ + CertificateIdentifier: aws.String("rds-ca-2015"), + MaxRecords: aws.Int64(20.000000), } - resp, err := svc.DescribeEvents(params) + result, err := svc.DescribeCertificates(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 rds.ErrCodeCertificateNotFoundFault: + fmt.Println(rds.ErrCodeCertificateNotFoundFault, 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 ExampleRDS_DescribeOptionGroupOptions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeOptionGroupOptionsInput{ - EngineName: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MajorEngineVersion: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), +// To list DB cluster parameter group settings +// +// This example lists settings for the specified DB cluster parameter group. +func ExampleRDS_DescribeDBClusterParameterGroups_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBClusterParameterGroupsInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), } - resp, err := svc.DescribeOptionGroupOptions(params) + result, err := svc.DescribeDBClusterParameterGroups(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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 ExampleRDS_DescribeOptionGroups() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeOptionGroupsInput{ - EngineName: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MajorEngineVersion: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - OptionGroupName: aws.String("String"), +// To list DB cluster parameters +// +// This example lists system parameters for the specified DB cluster parameter group. +func ExampleRDS_DescribeDBClusterParameters_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBClusterParametersInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + Source: aws.String("system"), } - resp, err := svc.DescribeOptionGroups(params) + result, err := svc.DescribeDBClusterParameters(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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 ExampleRDS_DescribeOrderableDBInstanceOptions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeOrderableDBInstanceOptionsInput{ - Engine: aws.String("String"), // Required - DBInstanceClass: aws.String("String"), - EngineVersion: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - LicenseModel: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Vpc: aws.Bool(true), +// To list DB cluster snapshot attributes +// +// This example lists attributes for the specified DB cluster snapshot. +func ExampleRDS_DescribeDBClusterSnapshotAttributes_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBClusterSnapshotAttributesInput{ + DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"), } - resp, err := svc.DescribeOrderableDBInstanceOptions(params) + result, err := svc.DescribeDBClusterSnapshotAttributes(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 rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, 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 ExampleRDS_DescribePendingMaintenanceActions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribePendingMaintenanceActionsInput{ - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ResourceIdentifier: aws.String("String"), +// To list DB cluster snapshots +// +// This example lists settings for the specified, manually-created cluster snapshot. +func ExampleRDS_DescribeDBClusterSnapshots_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBClusterSnapshotsInput{ + DBClusterSnapshotIdentifier: aws.String("mydbclustersnapshot"), + SnapshotType: aws.String("manual"), } - resp, err := svc.DescribePendingMaintenanceActions(params) + result, err := svc.DescribeDBClusterSnapshots(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 rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, 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 ExampleRDS_DescribeReservedDBInstances() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeReservedDBInstancesInput{ - DBInstanceClass: aws.String("String"), - Duration: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - MultiAZ: aws.Bool(true), - OfferingType: aws.String("String"), - ProductDescription: aws.String("String"), - ReservedDBInstanceId: aws.String("String"), - ReservedDBInstancesOfferingId: aws.String("String"), +// To list DB clusters +// +// This example lists settings for the specified DB cluster. +func ExampleRDS_DescribeDBClusters_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBClustersInput{ + DBClusterIdentifier: aws.String("mynewdbcluster"), } - resp, err := svc.DescribeReservedDBInstances(params) + result, err := svc.DescribeDBClusters(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 rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, 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 ExampleRDS_DescribeReservedDBInstancesOfferings() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeReservedDBInstancesOfferingsInput{ - DBInstanceClass: aws.String("String"), - Duration: aws.String("String"), - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - MultiAZ: aws.Bool(true), - OfferingType: aws.String("String"), - ProductDescription: aws.String("String"), - ReservedDBInstancesOfferingId: aws.String("String"), +// To list DB engine version settings +// +// This example lists settings for the specified DB engine version. +func ExampleRDS_DescribeDBEngineVersions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBEngineVersionsInput{ + DBParameterGroupFamily: aws.String("mysql5.6"), + DefaultOnly: aws.Bool(true), + Engine: aws.String("mysql"), + EngineVersion: aws.String("5.6"), + ListSupportedCharacterSets: aws.Bool(true), } - resp, err := svc.DescribeReservedDBInstancesOfferings(params) + result, err := svc.DescribeDBEngineVersions(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() { + 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 ExampleRDS_DescribeSourceRegions() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeSourceRegionsInput{ - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - RegionName: aws.String("String"), +// To list DB instance settings +// +// This example lists settings for the specified DB instance. +func ExampleRDS_DescribeDBInstances_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBInstancesInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), } - resp, err := svc.DescribeSourceRegions(params) + result, err := svc.DescribeDBInstances(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 rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, 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 ExampleRDS_DownloadDBLogFilePortion() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DownloadDBLogFilePortionInput{ - DBInstanceIdentifier: aws.String("String"), // Required - LogFileName: aws.String("String"), // Required - Marker: aws.String("String"), - NumberOfLines: aws.Int64(1), +// To list DB log file names +// +// This example lists matching log file names for the specified DB instance, file name +// pattern, last write date in POSIX time with milleseconds, and minimum file size. +func ExampleRDS_DescribeDBLogFiles_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBLogFilesInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + FileLastWritten: aws.Int64(1470873600000.000000), + FileSize: aws.Int64(0.000000), + FilenameContains: aws.String("error"), } - resp, err := svc.DownloadDBLogFilePortion(params) + result, err := svc.DescribeDBLogFiles(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 rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, 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 ExampleRDS_FailoverDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.FailoverDBClusterInput{ - DBClusterIdentifier: aws.String("String"), - TargetDBInstanceIdentifier: aws.String("String"), +// To list information about DB parameter groups +// +// This example lists information about the specified DB parameter group. +func ExampleRDS_DescribeDBParameterGroups_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBParameterGroupsInput{ + DBParameterGroupName: aws.String("mymysqlparametergroup"), } - resp, err := svc.FailoverDBCluster(params) + result, err := svc.DescribeDBParameterGroups(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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 ExampleRDS_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ListTagsForResourceInput{ - ResourceName: aws.String("String"), // Required - Filters: []*rds.Filter{ - { // Required - Name: aws.String("String"), // Required - Values: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, +// To list information about DB parameters +// +// This example lists information for up to the first 20 system parameters for the specified +// DB parameter group. +func ExampleRDS_DescribeDBParameters_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBParametersInput{ + DBParameterGroupName: aws.String("mymysqlparametergroup"), + MaxRecords: aws.Int64(20.000000), + Source: aws.String("system"), } - resp, err := svc.ListTagsForResource(params) + result, err := svc.DescribeDBParameters(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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 ExampleRDS_ModifyDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - ApplyImmediately: aws.Bool(true), - BackupRetentionPeriod: aws.Int64(1), - DBClusterParameterGroupName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - MasterUserPassword: aws.String("String"), - NewDBClusterIdentifier: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PreferredBackupWindow: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, +// To list DB security group settings +// +// This example lists settings for the specified security group. +func ExampleRDS_DescribeDBSecurityGroups_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBSecurityGroupsInput{ + DBSecurityGroupName: aws.String("mydbsecuritygroup"), } - resp, err := svc.ModifyDBCluster(params) + result, err := svc.DescribeDBSecurityGroups(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 rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, 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 ExampleRDS_ModifyDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBClusterParameterGroupInput{ - DBClusterParameterGroupName: aws.String("String"), // Required - Parameters: []*rds.Parameter{ // Required - { // Required - AllowedValues: aws.String("String"), - ApplyMethod: aws.String("ApplyMethod"), - ApplyType: aws.String("String"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), - }, - // More values... - }, +// To list DB snapshot attributes +// +// This example lists attributes for the specified DB snapshot. +func ExampleRDS_DescribeDBSnapshotAttributes_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBSnapshotAttributesInput{ + DBSnapshotIdentifier: aws.String("mydbsnapshot"), } - resp, err := svc.ModifyDBClusterParameterGroup(params) + result, err := svc.DescribeDBSnapshotAttributes(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 rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, 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 ExampleRDS_ModifyDBClusterSnapshotAttribute() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBClusterSnapshotAttributeInput{ - AttributeName: aws.String("String"), // Required - DBClusterSnapshotIdentifier: aws.String("String"), // Required - ValuesToAdd: []*string{ - aws.String("String"), // Required - // More values... - }, - ValuesToRemove: []*string{ - aws.String("String"), // Required - // More values... - }, +// To list DB snapshot attributes +// +// This example lists all manually-created, shared snapshots for the specified DB instance. +func ExampleRDS_DescribeDBSnapshots_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBSnapshotsInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + IncludePublic: aws.Bool(false), + IncludeShared: aws.Bool(true), + SnapshotType: aws.String("manual"), } - resp, err := svc.ModifyDBClusterSnapshotAttribute(params) + result, err := svc.DescribeDBSnapshots(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 rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, 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 ExampleRDS_ModifyDBInstance() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBInstanceInput{ - DBInstanceIdentifier: aws.String("String"), // Required - AllocatedStorage: aws.Int64(1), - AllowMajorVersionUpgrade: aws.Bool(true), - ApplyImmediately: aws.Bool(true), - AutoMinorVersionUpgrade: aws.Bool(true), - BackupRetentionPeriod: aws.Int64(1), - CACertificateIdentifier: aws.String("String"), - CopyTagsToSnapshot: aws.Bool(true), - DBInstanceClass: aws.String("String"), - DBParameterGroupName: aws.String("String"), - DBPortNumber: aws.Int64(1), - DBSecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - DBSubnetGroupName: aws.String("String"), - Domain: aws.String("String"), - DomainIAMRoleName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - EngineVersion: aws.String("String"), - Iops: aws.Int64(1), - LicenseModel: aws.String("String"), - MasterUserPassword: aws.String("String"), - MonitoringInterval: aws.Int64(1), - MonitoringRoleArn: aws.String("String"), - MultiAZ: aws.Bool(true), - NewDBInstanceIdentifier: aws.String("String"), - OptionGroupName: aws.String("String"), - PreferredBackupWindow: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - PromotionTier: aws.Int64(1), - PubliclyAccessible: aws.Bool(true), - StorageType: aws.String("String"), - TdeCredentialArn: aws.String("String"), - TdeCredentialPassword: aws.String("String"), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, +// To list information about DB subnet groups +// +// This example lists information about the specified DB subnet group. +func ExampleRDS_DescribeDBSubnetGroups_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeDBSubnetGroupsInput{ + DBSubnetGroupName: aws.String("mydbsubnetgroup"), } - resp, err := svc.ModifyDBInstance(params) + result, err := svc.DescribeDBSubnetGroups(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 rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, 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 ExampleRDS_ModifyDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBParameterGroupInput{ - DBParameterGroupName: aws.String("String"), // Required - Parameters: []*rds.Parameter{ // Required - { // Required - AllowedValues: aws.String("String"), - ApplyMethod: aws.String("ApplyMethod"), - ApplyType: aws.String("String"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), - }, - // More values... - }, +// To list default parameters for a DB cluster engine +// +// This example lists default parameters for the specified DB cluster engine. +func ExampleRDS_DescribeEngineDefaultClusterParameters_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeEngineDefaultClusterParametersInput{ + DBParameterGroupFamily: aws.String("aurora5.6"), } - resp, err := svc.ModifyDBParameterGroup(params) + result, err := svc.DescribeEngineDefaultClusterParameters(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() { + 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 ExampleRDS_ModifyDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBSnapshotInput{ - DBSnapshotIdentifier: aws.String("String"), // Required - EngineVersion: aws.String("String"), +// To list default parameters for a DB engine +// +// This example lists default parameters for the specified DB engine. +func ExampleRDS_DescribeEngineDefaultParameters_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeEngineDefaultParametersInput{ + DBParameterGroupFamily: aws.String("mysql5.6"), } - resp, err := svc.ModifyDBSnapshot(params) + result, err := svc.DescribeEngineDefaultParameters(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() { + 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 ExampleRDS_ModifyDBSnapshotAttribute() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBSnapshotAttributeInput{ - AttributeName: aws.String("String"), // Required - DBSnapshotIdentifier: aws.String("String"), // Required - ValuesToAdd: []*string{ - aws.String("String"), // Required - // More values... - }, - ValuesToRemove: []*string{ - aws.String("String"), // Required - // More values... - }, +// To list event categories. +// +// This example lists all DB instance event categories. +func ExampleRDS_DescribeEventCategories_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeEventCategoriesInput{ + SourceType: aws.String("db-instance"), } - resp, err := svc.ModifyDBSnapshotAttribute(params) + result, err := svc.DescribeEventCategories(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() { + 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 ExampleRDS_ModifyDBSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBSubnetGroupInput{ - DBSubnetGroupName: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - DBSubnetGroupDescription: aws.String("String"), +// To list information about DB event notification subscriptions +// +// This example lists information for the specified DB event notification subscription. +func ExampleRDS_DescribeEventSubscriptions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeEventSubscriptionsInput{ + SubscriptionName: aws.String("mymysqleventsubscription"), } - resp, err := svc.ModifyDBSubnetGroup(params) + result, err := svc.DescribeEventSubscriptions(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 rds.ErrCodeSubscriptionNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, 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 ExampleRDS_ModifyEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), +// To list information about events +// +// This example lists information for all backup-related events for the specified DB +// instance for the past 7 days (7 days * 24 hours * 60 minutes = 10,080 minutes). +func ExampleRDS_DescribeEvents_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeEventsInput{ + Duration: aws.Int64(10080.000000), EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - SnsTopicArn: aws.String("String"), - SourceType: aws.String("String"), - } - resp, err := svc.ModifyEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRDS_ModifyOptionGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyOptionGroupInput{ - OptionGroupName: aws.String("String"), // Required - ApplyImmediately: aws.Bool(true), - OptionsToInclude: []*rds.OptionConfiguration{ - { // Required - OptionName: aws.String("String"), // Required - DBSecurityGroupMemberships: []*string{ - aws.String("String"), // Required - // More values... - }, - OptionSettings: []*rds.OptionSetting{ - { // Required - AllowedValues: aws.String("String"), - ApplyType: aws.String("String"), - DataType: aws.String("String"), - DefaultValue: aws.String("String"), - Description: aws.String("String"), - IsCollection: aws.Bool(true), - IsModifiable: aws.Bool(true), - Name: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - OptionVersion: aws.String("String"), - Port: aws.Int64(1), - VpcSecurityGroupMemberships: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - OptionsToRemove: []*string{ - aws.String("String"), // Required - // More values... + aws.String("backup"), }, - } - resp, err := svc.ModifyOptionGroup(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) - return + SourceIdentifier: aws.String("mymysqlinstance"), + SourceType: aws.String("db-instance"), } - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleRDS_PromoteReadReplica() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.PromoteReadReplicaInput{ - DBInstanceIdentifier: aws.String("String"), // Required - BackupRetentionPeriod: aws.Int64(1), - PreferredBackupWindow: aws.String("String"), - } - resp, err := svc.PromoteReadReplica(params) - + result, err := svc.DescribeEvents(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() { + 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 ExampleRDS_PromoteReadReplicaDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.PromoteReadReplicaDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required +// To list information about DB option group options +// +// This example lists information for all option group options for the specified DB +// engine. +func ExampleRDS_DescribeOptionGroupOptions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeOptionGroupOptionsInput{ + EngineName: aws.String("mysql"), + MajorEngineVersion: aws.String("5.6"), } - resp, err := svc.PromoteReadReplicaDBCluster(params) + result, err := svc.DescribeOptionGroupOptions(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() { + 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 ExampleRDS_PurchaseReservedDBInstancesOffering() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.PurchaseReservedDBInstancesOfferingInput{ - ReservedDBInstancesOfferingId: aws.String("String"), // Required - DBInstanceCount: aws.Int64(1), - ReservedDBInstanceId: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, +// To list information about DB option groups +// +// This example lists information for all option groups for the specified DB engine. +func ExampleRDS_DescribeOptionGroups_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeOptionGroupsInput{ + EngineName: aws.String("mysql"), + MajorEngineVersion: aws.String("5.6"), } - resp, err := svc.PurchaseReservedDBInstancesOffering(params) + result, err := svc.DescribeOptionGroups(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 rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, 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 ExampleRDS_RebootDBInstance() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RebootDBInstanceInput{ - DBInstanceIdentifier: aws.String("String"), // Required - ForceFailover: aws.Bool(true), +// To list information about orderable DB instance options +// +// This example lists information for all orderable DB instance options for the specified +// DB engine, engine version, DB instance class, license model, and VPC settings. +func ExampleRDS_DescribeOrderableDBInstanceOptions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeOrderableDBInstanceOptionsInput{ + DBInstanceClass: aws.String("db.t2.micro"), + Engine: aws.String("mysql"), + EngineVersion: aws.String("5.6.27"), + LicenseModel: aws.String("general-public-license"), + Vpc: aws.Bool(true), } - resp, err := svc.RebootDBInstance(params) + result, err := svc.DescribeOrderableDBInstanceOptions(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() { + 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 ExampleRDS_RemoveRoleFromDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RemoveRoleFromDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - RoleArn: aws.String("String"), // Required +// To list information about pending maintenance actions +// +// This example lists information for all pending maintenance actions for the specified +// DB instance. +func ExampleRDS_DescribePendingMaintenanceActions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribePendingMaintenanceActionsInput{ + ResourceIdentifier: aws.String("arn:aws:rds:us-east-1:992648334831:db:mymysqlinstance"), } - resp, err := svc.RemoveRoleFromDBCluster(params) + result, err := svc.DescribePendingMaintenanceActions(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 rds.ErrCodeResourceNotFoundFault: + fmt.Println(rds.ErrCodeResourceNotFoundFault, 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 ExampleRDS_RemoveSourceIdentifierFromSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RemoveSourceIdentifierFromSubscriptionInput{ - SourceIdentifier: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required +// To list information about reserved DB instances +// +// This example lists information for all reserved DB instances for the specified DB +// instance class, duration, product, offering type, and availability zone settings. +func ExampleRDS_DescribeReservedDBInstances_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeReservedDBInstancesInput{ + DBInstanceClass: aws.String("db.t2.micro"), + Duration: aws.String("1y"), + MultiAZ: aws.Bool(false), + OfferingType: aws.String("No Upfront"), + ProductDescription: aws.String("mysql"), } - resp, err := svc.RemoveSourceIdentifierFromSubscription(params) + result, err := svc.DescribeReservedDBInstances(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 rds.ErrCodeReservedDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeReservedDBInstanceNotFoundFault, 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 ExampleRDS_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RemoveTagsFromResourceInput{ - ResourceName: aws.String("String"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... - }, +// To list information about reserved DB instance offerings +// +// This example lists information for all reserved DB instance offerings for the specified +// DB instance class, duration, product, offering type, and availability zone settings. +func ExampleRDS_DescribeReservedDBInstancesOfferings_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeReservedDBInstancesOfferingsInput{ + DBInstanceClass: aws.String("db.t2.micro"), + Duration: aws.String("1y"), + MultiAZ: aws.Bool(false), + OfferingType: aws.String("No Upfront"), + ProductDescription: aws.String("mysql"), } - resp, err := svc.RemoveTagsFromResource(params) + result, err := svc.DescribeReservedDBInstancesOfferings(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 rds.ErrCodeReservedDBInstancesOfferingNotFoundFault: + fmt.Println(rds.ErrCodeReservedDBInstancesOfferingNotFoundFault, 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 ExampleRDS_ResetDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ResetDBClusterParameterGroupInput{ - DBClusterParameterGroupName: aws.String("String"), // Required - Parameters: []*rds.Parameter{ - { // Required - AllowedValues: aws.String("String"), - ApplyMethod: aws.String("ApplyMethod"), - ApplyType: aws.String("String"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), - }, - // More values... - }, - ResetAllParameters: aws.Bool(true), - } - resp, err := svc.ResetDBClusterParameterGroup(params) - +// To describe source regions +// +// To list the AWS regions where a Read Replica can be created. +func ExampleRDS_DescribeSourceRegions_shared00() { + svc := rds.New(session.New()) + input := &rds.DescribeSourceRegionsInput{} + + result, err := svc.DescribeSourceRegions(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()) - return - } - - // Pretty-print the response data. - fmt.Println(resp) + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) } -func ExampleRDS_ResetDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ResetDBParameterGroupInput{ - DBParameterGroupName: aws.String("String"), // Required - Parameters: []*rds.Parameter{ - { // Required - AllowedValues: aws.String("String"), - ApplyMethod: aws.String("ApplyMethod"), - ApplyType: aws.String("String"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), +// To list information about DB log files +// +// This example lists information for the specified log file for the specified DB instance. +func ExampleRDS_DownloadDBLogFilePortion_shared00() { + svc := rds.New(session.New()) + input := &rds.DownloadDBLogFilePortionInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + LogFileName: aws.String("mysqlUpgrade"), + } + + result, err := svc.DownloadDBLogFilePortion(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBLogFileNotFoundFault: + fmt.Println(rds.ErrCodeDBLogFileNotFoundFault, 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) +} + +// To perform a failover for a DB cluster +// +// This example performs a failover for the specified DB cluster to the specified DB +// instance. +func ExampleRDS_FailoverDBCluster_shared00() { + svc := rds.New(session.New()) + input := &rds.FailoverDBClusterInput{ + DBClusterIdentifier: aws.String("myaurorainstance-cluster"), + TargetDBInstanceIdentifier: aws.String("myaurorareplica"), + } + + result, err := svc.FailoverDBCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, 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) +} + +// To list information about tags associated with a resource +// +// This example lists information about all tags associated with the specified DB option +// group. +func ExampleRDS_ListTagsForResource_shared00() { + svc := rds.New(session.New()) + input := &rds.ListTagsForResourceInput{ + ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mymysqloptiongroup"), + } + + result, err := svc.ListTagsForResource(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, 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) +} + +// To change DB cluster settings +// +// This example changes the specified settings for the specified DB cluster. +func ExampleRDS_ModifyDBCluster_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBClusterInput{ + ApplyImmediately: aws.Bool(true), + DBClusterIdentifier: aws.String("mydbcluster"), + MasterUserPassword: aws.String("mynewpassword"), + NewDBClusterIdentifier: aws.String("mynewdbcluster"), + PreferredBackupWindow: aws.String("04:00-04:30"), + PreferredMaintenanceWindow: aws.String("Tue:05:00-Tue:05:30"), + } + + result, err := svc.ModifyDBCluster(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBSubnetGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSubnetGroupStateFault, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeDBClusterParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBSecurityGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBClusterAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, 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) +} + +// To change DB cluster parameter group settings +// +// This example immediately changes the specified setting for the specified DB cluster +// parameter group. +func ExampleRDS_ModifyDBClusterParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBClusterParameterGroupInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + Parameters: []*rds.ParametersList{ + { + ApplyMethod: aws.String("immediate"), + ParameterName: aws.String("time_zone"), + ParameterValue: aws.String("America/Phoenix"), }, - // More values... }, - ResetAllParameters: aws.Bool(true), } - resp, err := svc.ResetDBParameterGroup(params) + result, err := svc.ModifyDBClusterParameterGroup(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, 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 ExampleRDS_RestoreDBClusterFromS3() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RestoreDBClusterFromS3Input{ - DBClusterIdentifier: aws.String("String"), // Required - Engine: aws.String("String"), // Required - MasterUserPassword: aws.String("String"), // Required - MasterUsername: aws.String("String"), // Required - S3BucketName: aws.String("String"), // Required - S3IngestionRoleArn: aws.String("String"), // Required - SourceEngine: aws.String("String"), // Required - SourceEngineVersion: aws.String("String"), // Required - AvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... +// To add or remove access to a manual DB cluster snapshot +// +// The following example gives two AWS accounts access to a manual DB cluster snapshot +// and ensures that the DB cluster snapshot is private by removing the value "all". +func ExampleRDS_ModifyDBClusterSnapshotAttribute_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBClusterSnapshotAttributeInput{ + AttributeName: aws.String("restore"), + DBClusterSnapshotIdentifier: aws.String("manual-cluster-snapshot1"), + ValuesToAdd: []*string{ + aws.String("123451234512"), + aws.String("123456789012"), }, - BackupRetentionPeriod: aws.Int64(1), - CharacterSetName: aws.String("String"), - DBClusterParameterGroupName: aws.String("String"), - DBSubnetGroupName: aws.String("String"), - DatabaseName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - EngineVersion: aws.String("String"), - KmsKeyId: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PreferredBackupWindow: aws.String("String"), - PreferredMaintenanceWindow: aws.String("String"), - S3Prefix: aws.String("String"), - StorageEncrypted: aws.Bool(true), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), + ValuesToRemove: []*string{ + aws.String("all"), + }, + } + + result, err := svc.ModifyDBClusterSnapshotAttribute(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error()) + case rds.ErrCodeSharedSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSharedSnapshotQuotaExceededFault, 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) +} + +// To change DB instance settings +// +// This example immediately changes the specified settings for the specified DB instance. +func ExampleRDS_ModifyDBInstance_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBInstanceInput{ + AllocatedStorage: aws.Int64(10.000000), + ApplyImmediately: aws.Bool(true), + BackupRetentionPeriod: aws.Int64(1.000000), + DBInstanceClass: aws.String("db.t2.small"), + DBInstanceIdentifier: aws.String("mymysqlinstance"), + MasterUserPassword: aws.String("mynewpassword"), + PreferredBackupWindow: aws.String("04:00-04:30"), + PreferredMaintenanceWindow: aws.String("Tue:05:00-Tue:05:30"), + } + + result, err := svc.ModifyDBInstance(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBSecurityGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, aerr.Error()) + case rds.ErrCodeDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInsufficientDBInstanceCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeProvisionedIopsNotAvailableInAZFault: + fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBUpgradeDependencyFailureFault: + fmt.Println(rds.ErrCodeDBUpgradeDependencyFailureFault, aerr.Error()) + case rds.ErrCodeStorageTypeNotSupportedFault: + fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error()) + case rds.ErrCodeAuthorizationNotFoundFault: + fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case rds.ErrCodeCertificateNotFoundFault: + fmt.Println(rds.ErrCodeCertificateNotFoundFault, aerr.Error()) + case rds.ErrCodeDomainNotFoundFault: + fmt.Println(rds.ErrCodeDomainNotFoundFault, 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) +} + +// To change DB parameter group settings +// +// This example immediately changes the specified setting for the specified DB parameter +// group. +func ExampleRDS_ModifyDBParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBParameterGroupInput{ + DBParameterGroupName: aws.String("mymysqlparametergroup"), + Parameters: []*rds.ParametersList{ + { + ApplyMethod: aws.String("immediate"), + ParameterName: aws.String("time_zone"), + ParameterValue: aws.String("America/Phoenix"), }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.RestoreDBClusterFromS3(params) + result, err := svc.ModifyDBParameterGroup(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 rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, 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 ExampleRDS_RestoreDBClusterFromSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RestoreDBClusterFromSnapshotInput{ - DBClusterIdentifier: aws.String("String"), // Required - Engine: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - AvailabilityZones: []*string{ - aws.String("String"), // Required - // More values... - }, - DBSubnetGroupName: aws.String("String"), - DatabaseName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - EngineVersion: aws.String("String"), - KmsKeyId: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), +// To change DB snapshot attributes +// +// This example adds the specified attribute for the specified DB snapshot. +func ExampleRDS_ModifyDBSnapshotAttribute_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBSnapshotAttributeInput{ + AttributeName: aws.String("restore"), + DBSnapshotIdentifier: aws.String("mydbsnapshot"), + ValuesToAdd: []*string{ + aws.String("all"), + }, + } + + result, err := svc.ModifyDBSnapshotAttribute(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeSharedSnapshotQuotaExceededFault: + fmt.Println(rds.ErrCodeSharedSnapshotQuotaExceededFault, 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) +} + +// To change DB subnet group settings +// +// This example changes the specified setting for the specified DB subnet group. +func ExampleRDS_ModifyDBSubnetGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyDBSubnetGroupInput{ + DBSubnetGroupName: aws.String("mydbsubnetgroup"), + SubnetIds: []*string{ + aws.String("subnet-70e1975a"), + aws.String("subnet-747a5c49"), + }, + } + + result, err := svc.ModifyDBSubnetGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetQuotaExceededFault: + fmt.Println(rds.ErrCodeDBSubnetQuotaExceededFault, aerr.Error()) + case rds.ErrCodeSubnetAlreadyInUse: + fmt.Println(rds.ErrCodeSubnetAlreadyInUse, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, 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) +} + +// To change event notification subscription settings +// +// This example changes the specified setting for the specified event notification subscription. +func ExampleRDS_ModifyEventSubscription_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyEventSubscriptionInput{ + Enabled: aws.Bool(true), + EventCategories: []*string{ + aws.String("deletion"), + aws.String("low storage"), + }, + SourceType: aws.String("db-instance"), + SubscriptionName: aws.String("mymysqleventsubscription"), + } + + result, err := svc.ModifyEventSubscription(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeEventSubscriptionQuotaExceededFault: + fmt.Println(rds.ErrCodeEventSubscriptionQuotaExceededFault, aerr.Error()) + case rds.ErrCodeSubscriptionNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error()) + case rds.ErrCodeSNSInvalidTopicFault: + fmt.Println(rds.ErrCodeSNSInvalidTopicFault, aerr.Error()) + case rds.ErrCodeSNSNoAuthorizationFault: + fmt.Println(rds.ErrCodeSNSNoAuthorizationFault, aerr.Error()) + case rds.ErrCodeSNSTopicArnNotFoundFault: + fmt.Println(rds.ErrCodeSNSTopicArnNotFoundFault, aerr.Error()) + case rds.ErrCodeSubscriptionCategoryNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionCategoryNotFoundFault, 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) +} + +// To modify an option group +// +// The following example adds an option to an option group. +func ExampleRDS_ModifyOptionGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ModifyOptionGroupInput{ + ApplyImmediately: aws.Bool(true), + OptionGroupName: aws.String("myawsuser-og02"), + OptionsToInclude: []*rds.OptionConfigurationList{ + { + DBSecurityGroupMemberships: []*string{ + aws.String("default"), + }, + OptionName: aws.String("MEMCACHED"), }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.RestoreDBClusterFromSnapshot(params) + result, err := svc.ModifyOptionGroup(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()) - return - } + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidOptionGroupStateFault: + fmt.Println(rds.ErrCodeInvalidOptionGroupStateFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, 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 ExampleRDS_RestoreDBClusterToPointInTime() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RestoreDBClusterToPointInTimeInput{ - DBClusterIdentifier: aws.String("String"), // Required - SourceDBClusterIdentifier: aws.String("String"), // Required - DBSubnetGroupName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - KmsKeyId: aws.String("String"), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - RestoreToTime: aws.Time(time.Now()), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - UseLatestRestorableTime: aws.Bool(true), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, +// To promote a read replica +// +// This example promotes the specified read replica and sets its backup retention period +// and preferred backup window. +func ExampleRDS_PromoteReadReplica_shared00() { + svc := rds.New(session.New()) + input := &rds.PromoteReadReplicaInput{ + BackupRetentionPeriod: aws.Int64(1.000000), + DBInstanceIdentifier: aws.String("mydbreadreplica"), + PreferredBackupWindow: aws.String("03:30-04:00"), } - resp, err := svc.RestoreDBClusterToPointInTime(params) + result, err := svc.PromoteReadReplica(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()) - return + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, 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 ExampleRDS_RestoreDBInstanceFromDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RestoreDBInstanceFromDBSnapshotInput{ - DBInstanceIdentifier: aws.String("String"), // Required - DBSnapshotIdentifier: aws.String("String"), // Required - AutoMinorVersionUpgrade: aws.Bool(true), - AvailabilityZone: aws.String("String"), - CopyTagsToSnapshot: aws.Bool(true), - DBInstanceClass: aws.String("String"), - DBName: aws.String("String"), - DBSubnetGroupName: aws.String("String"), - Domain: aws.String("String"), - DomainIAMRoleName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - Engine: aws.String("String"), - Iops: aws.Int64(1), - LicenseModel: aws.String("String"), - MultiAZ: aws.Bool(true), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PubliclyAccessible: aws.Bool(true), - StorageType: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - TdeCredentialArn: aws.String("String"), - TdeCredentialPassword: aws.String("String"), - } - resp, err := svc.RestoreDBInstanceFromDBSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRDS_RestoreDBInstanceToPointInTime() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RestoreDBInstanceToPointInTimeInput{ - SourceDBInstanceIdentifier: aws.String("String"), // Required - TargetDBInstanceIdentifier: aws.String("String"), // Required - AutoMinorVersionUpgrade: aws.Bool(true), - AvailabilityZone: aws.String("String"), - CopyTagsToSnapshot: aws.Bool(true), - DBInstanceClass: aws.String("String"), - DBName: aws.String("String"), - DBSubnetGroupName: aws.String("String"), - Domain: aws.String("String"), - DomainIAMRoleName: aws.String("String"), - EnableIAMDatabaseAuthentication: aws.Bool(true), - Engine: aws.String("String"), - Iops: aws.Int64(1), - LicenseModel: aws.String("String"), - MultiAZ: aws.Bool(true), - OptionGroupName: aws.String("String"), - Port: aws.Int64(1), - PubliclyAccessible: aws.Bool(true), - RestoreTime: aws.Time(time.Now()), - StorageType: aws.String("String"), - Tags: []*rds.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - TdeCredentialArn: aws.String("String"), - TdeCredentialPassword: aws.String("String"), - UseLatestRestorableTime: aws.Bool(true), +// To purchase a reserved DB instance offering +// +// This example purchases a reserved DB instance offering that matches the specified +// settings. +func ExampleRDS_PurchaseReservedDBInstancesOffering_shared00() { + svc := rds.New(session.New()) + input := &rds.PurchaseReservedDBInstancesOfferingInput{ + ReservedDBInstanceId: aws.String("myreservationid"), + ReservedDBInstancesOfferingId: aws.String("fb29428a-646d-4390-850e-5fe89926e727"), } - resp, err := svc.RestoreDBInstanceToPointInTime(params) + result, err := svc.PurchaseReservedDBInstancesOffering(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()) - return - } + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeReservedDBInstancesOfferingNotFoundFault: + fmt.Println(rds.ErrCodeReservedDBInstancesOfferingNotFoundFault, aerr.Error()) + case rds.ErrCodeReservedDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeReservedDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeReservedDBInstanceQuotaExceededFault: + fmt.Println(rds.ErrCodeReservedDBInstanceQuotaExceededFault, 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 ExampleRDS_RevokeDBSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RevokeDBSecurityGroupIngressInput{ - DBSecurityGroupName: aws.String("String"), // Required - CIDRIP: aws.String("String"), - EC2SecurityGroupId: aws.String("String"), - EC2SecurityGroupName: aws.String("String"), - EC2SecurityGroupOwnerId: aws.String("String"), - } - resp, err := svc.RevokeDBSecurityGroupIngress(params) - - if err != nil { - // 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) +// To reboot a DB instance +// +// This example reboots the specified DB instance without forcing a failover. +func ExampleRDS_RebootDBInstance_shared00() { + svc := rds.New(session.New()) + input := &rds.RebootDBInstanceInput{ + DBInstanceIdentifier: aws.String("mymysqlinstance"), + ForceFailover: aws.Bool(false), + } + + result, err := svc.RebootDBInstance(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, 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) +} + +// To remove a source identifier from a DB event subscription +// +// This example removes the specified source identifier from the specified DB event +// subscription. +func ExampleRDS_RemoveSourceIdentifierFromSubscription_shared00() { + svc := rds.New(session.New()) + input := &rds.RemoveSourceIdentifierFromSubscriptionInput{ + SourceIdentifier: aws.String("mymysqlinstance"), + SubscriptionName: aws.String("myeventsubscription"), + } + + result, err := svc.RemoveSourceIdentifierFromSubscription(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeSubscriptionNotFoundFault: + fmt.Println(rds.ErrCodeSubscriptionNotFoundFault, aerr.Error()) + case rds.ErrCodeSourceNotFoundFault: + fmt.Println(rds.ErrCodeSourceNotFoundFault, 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) +} + +// To remove tags from a resource +// +// This example removes the specified tag associated with the specified DB option group. +func ExampleRDS_RemoveTagsFromResource_shared00() { + svc := rds.New(session.New()) + input := &rds.RemoveTagsFromResourceInput{ + ResourceName: aws.String("arn:aws:rds:us-east-1:992648334831:og:mydboptiongroup"), + TagKeys: []*string{ + aws.String("MyKey"), + }, + } + + result, err := svc.RemoveTagsFromResource(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, 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) +} + +// To reset the values of a DB cluster parameter group +// +// This example resets all parameters for the specified DB cluster parameter group to +// their default values. +func ExampleRDS_ResetDBClusterParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ResetDBClusterParameterGroupInput{ + DBClusterParameterGroupName: aws.String("mydbclusterparametergroup"), + ResetAllParameters: aws.Bool(true), + } + + result, err := svc.ResetDBClusterParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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) +} + +// To reset the values of a DB parameter group +// +// This example resets all parameters for the specified DB parameter group to their +// default values. +func ExampleRDS_ResetDBParameterGroup_shared00() { + svc := rds.New(session.New()) + input := &rds.ResetDBParameterGroupInput{ + DBParameterGroupName: aws.String("mydbparametergroup"), + ResetAllParameters: aws.Bool(true), + } + + result, err := svc.ResetDBParameterGroup(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeInvalidDBParameterGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBParameterGroupStateFault, aerr.Error()) + case rds.ErrCodeDBParameterGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBParameterGroupNotFoundFault, 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) +} + +// To restore an Amazon Aurora DB cluster from a DB cluster snapshot +// +// The following example restores an Amazon Aurora DB cluster from a DB cluster snapshot. +func ExampleRDS_RestoreDBClusterFromSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.RestoreDBClusterFromSnapshotInput{ + DBClusterIdentifier: aws.String("restored-cluster1"), + Engine: aws.String("aurora"), + SnapshotIdentifier: aws.String("sample-cluster-snapshot1"), + } + + result, err := svc.RestoreDBClusterFromSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBClusterQuotaExceededFault: + fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInsufficientDBClusterCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBClusterCapacityFault, aerr.Error()) + case rds.ErrCodeInsufficientStorageClusterCapacityFault: + fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error()) + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeInvalidRestoreFault: + fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, 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) +} + +// To restore a DB cluster to a point in time. +// +// The following example restores a DB cluster to a new DB cluster at a point in time +// from the source DB cluster. +func ExampleRDS_RestoreDBClusterToPointInTime_shared00() { + svc := rds.New(session.New()) + input := &rds.RestoreDBClusterToPointInTimeInput{ + DBClusterIdentifier: aws.String("sample-restored-cluster1"), + RestoreToTime: parseTime("2006-01-02T15:04:05Z", "2016-09-13T18:45:00Z"), + SourceDBClusterIdentifier: aws.String("sample-cluster1"), + } + + result, err := svc.RestoreDBClusterToPointInTime(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBClusterAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBClusterAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBClusterNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterNotFoundFault, aerr.Error()) + case rds.ErrCodeDBClusterQuotaExceededFault: + fmt.Println(rds.ErrCodeDBClusterQuotaExceededFault, aerr.Error()) + case rds.ErrCodeDBClusterSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBClusterSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeInsufficientDBClusterCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBClusterCapacityFault, aerr.Error()) + case rds.ErrCodeInsufficientStorageClusterCapacityFault: + fmt.Println(rds.ErrCodeInsufficientStorageClusterCapacityFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterSnapshotStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBClusterStateFault: + fmt.Println(rds.ErrCodeInvalidDBClusterStateFault, aerr.Error()) + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeInvalidRestoreFault: + fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, 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) +} + +// To restore a DB instance from a DB snapshot. +// +// The following example restores a DB instance from a DB snapshot. +func ExampleRDS_RestoreDBInstanceFromDBSnapshot_shared00() { + svc := rds.New(session.New()) + input := &rds.RestoreDBInstanceFromDBSnapshotInput{ + DBInstanceIdentifier: aws.String("mysqldb-restored"), + DBSnapshotIdentifier: aws.String("rds:mysqldb-2014-04-22-08-15"), + } + + result, err := svc.RestoreDBInstanceFromDBSnapshot(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBSnapshotNotFoundFault: + fmt.Println(rds.ErrCodeDBSnapshotNotFoundFault, aerr.Error()) + case rds.ErrCodeInstanceQuotaExceededFault: + fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInsufficientDBInstanceCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error()) + case rds.ErrCodeInvalidDBSnapshotStateFault: + fmt.Println(rds.ErrCodeInvalidDBSnapshotStateFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeInvalidRestoreFault: + fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeProvisionedIopsNotAvailableInAZFault: + fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeStorageTypeNotSupportedFault: + fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error()) + case rds.ErrCodeAuthorizationNotFoundFault: + fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDomainNotFoundFault: + fmt.Println(rds.ErrCodeDomainNotFoundFault, 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) +} + +// To restore a DB instance to a point in time. +// +// The following example restores a DB instance to a new DB instance at a point in time +// from the source DB instance. +func ExampleRDS_RestoreDBInstanceToPointInTime_shared00() { + svc := rds.New(session.New()) + input := &rds.RestoreDBInstanceToPointInTimeInput{ + RestoreTime: parseTime("2006-01-02T15:04:05Z", "2016-09-13T18:45:00Z"), + SourceDBInstanceIdentifier: aws.String("mysql-sample"), + TargetDBInstanceIdentifier: aws.String("mysql-sample-restored"), + } + + result, err := svc.RestoreDBInstanceToPointInTime(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBInstanceAlreadyExistsFault: + fmt.Println(rds.ErrCodeDBInstanceAlreadyExistsFault, aerr.Error()) + case rds.ErrCodeDBInstanceNotFoundFault: + fmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error()) + case rds.ErrCodeInstanceQuotaExceededFault: + fmt.Println(rds.ErrCodeInstanceQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInsufficientDBInstanceCapacityFault: + fmt.Println(rds.ErrCodeInsufficientDBInstanceCapacityFault, aerr.Error()) + case rds.ErrCodeInvalidDBInstanceStateFault: + fmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error()) + case rds.ErrCodePointInTimeRestoreNotEnabledFault: + fmt.Println(rds.ErrCodePointInTimeRestoreNotEnabledFault, aerr.Error()) + case rds.ErrCodeStorageQuotaExceededFault: + fmt.Println(rds.ErrCodeStorageQuotaExceededFault, aerr.Error()) + case rds.ErrCodeInvalidVPCNetworkStateFault: + fmt.Println(rds.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) + case rds.ErrCodeInvalidRestoreFault: + fmt.Println(rds.ErrCodeInvalidRestoreFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSubnetGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs: + fmt.Println(rds.ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs, aerr.Error()) + case rds.ErrCodeInvalidSubnet: + fmt.Println(rds.ErrCodeInvalidSubnet, aerr.Error()) + case rds.ErrCodeProvisionedIopsNotAvailableInAZFault: + fmt.Println(rds.ErrCodeProvisionedIopsNotAvailableInAZFault, aerr.Error()) + case rds.ErrCodeOptionGroupNotFoundFault: + fmt.Println(rds.ErrCodeOptionGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeStorageTypeNotSupportedFault: + fmt.Println(rds.ErrCodeStorageTypeNotSupportedFault, aerr.Error()) + case rds.ErrCodeAuthorizationNotFoundFault: + fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case rds.ErrCodeKMSKeyNotAccessibleFault: + fmt.Println(rds.ErrCodeKMSKeyNotAccessibleFault, aerr.Error()) + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeDomainNotFoundFault: + fmt.Println(rds.ErrCodeDomainNotFoundFault, 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) +} + +// To revoke ingress for a DB security group +// +// This example revokes ingress for the specified CIDR block associated with the specified +// DB security group. +func ExampleRDS_RevokeDBSecurityGroupIngress_shared00() { + svc := rds.New(session.New()) + input := &rds.RevokeDBSecurityGroupIngressInput{ + CIDRIP: aws.String("203.0.113.5/32"), + DBSecurityGroupName: aws.String("mydbsecuritygroup"), + } + + result, err := svc.RevokeDBSecurityGroupIngress(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case rds.ErrCodeDBSecurityGroupNotFoundFault: + fmt.Println(rds.ErrCodeDBSecurityGroupNotFoundFault, aerr.Error()) + case rds.ErrCodeAuthorizationNotFoundFault: + fmt.Println(rds.ErrCodeAuthorizationNotFoundFault, aerr.Error()) + case rds.ErrCodeInvalidDBSecurityGroupStateFault: + fmt.Println(rds.ErrCodeInvalidDBSecurityGroupStateFault, 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) } diff --git a/service/redshift/examples_test.go b/service/redshift/examples_test.go deleted file mode 100644 index e352a3dd0f8..00000000000 --- a/service/redshift/examples_test.go +++ /dev/null @@ -1,1740 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package redshift_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/redshift" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleRedshift_AuthorizeClusterSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.AuthorizeClusterSecurityGroupIngressInput{ - ClusterSecurityGroupName: aws.String("String"), // Required - CIDRIP: aws.String("String"), - EC2SecurityGroupName: aws.String("String"), - EC2SecurityGroupOwnerId: aws.String("String"), - } - resp, err := svc.AuthorizeClusterSecurityGroupIngress(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_AuthorizeSnapshotAccess() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.AuthorizeSnapshotAccessInput{ - AccountWithRestoreAccess: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - SnapshotClusterIdentifier: aws.String("String"), - } - resp, err := svc.AuthorizeSnapshotAccess(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CopyClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CopyClusterSnapshotInput{ - SourceSnapshotIdentifier: aws.String("String"), // Required - TargetSnapshotIdentifier: aws.String("String"), // Required - SourceSnapshotClusterIdentifier: aws.String("String"), - } - resp, err := svc.CopyClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateCluster() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateClusterInput{ - ClusterIdentifier: aws.String("String"), // Required - MasterUserPassword: aws.String("String"), // Required - MasterUsername: aws.String("String"), // Required - NodeType: aws.String("String"), // Required - AdditionalInfo: aws.String("String"), - AllowVersionUpgrade: aws.Bool(true), - AutomatedSnapshotRetentionPeriod: aws.Int64(1), - AvailabilityZone: aws.String("String"), - ClusterParameterGroupName: aws.String("String"), - ClusterSecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - ClusterSubnetGroupName: aws.String("String"), - ClusterType: aws.String("String"), - ClusterVersion: aws.String("String"), - DBName: aws.String("String"), - ElasticIp: aws.String("String"), - Encrypted: aws.Bool(true), - EnhancedVpcRouting: aws.Bool(true), - HsmClientCertificateIdentifier: aws.String("String"), - HsmConfigurationIdentifier: aws.String("String"), - IamRoles: []*string{ - aws.String("String"), // Required - // More values... - }, - KmsKeyId: aws.String("String"), - NumberOfNodes: aws.Int64(1), - Port: aws.Int64(1), - PreferredMaintenanceWindow: aws.String("String"), - PubliclyAccessible: aws.Bool(true), - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateCluster(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateClusterParameterGroupInput{ - Description: aws.String("String"), // Required - ParameterGroupFamily: aws.String("String"), // Required - ParameterGroupName: aws.String("String"), // Required - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateClusterSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateClusterSecurityGroupInput{ - ClusterSecurityGroupName: aws.String("String"), // Required - Description: aws.String("String"), // Required - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateClusterSecurityGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateClusterSnapshotInput{ - ClusterIdentifier: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateClusterSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateClusterSubnetGroupInput{ - ClusterSubnetGroupName: aws.String("String"), // Required - Description: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateClusterSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateEventSubscriptionInput{ - SnsTopicArn: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - Severity: aws.String("String"), - SourceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceType: aws.String("String"), - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateHsmClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateHsmClientCertificateInput{ - HsmClientCertificateIdentifier: aws.String("String"), // Required - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateHsmClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateHsmConfiguration() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateHsmConfigurationInput{ - Description: aws.String("String"), // Required - HsmConfigurationIdentifier: aws.String("String"), // Required - HsmIpAddress: aws.String("String"), // Required - HsmPartitionName: aws.String("String"), // Required - HsmPartitionPassword: aws.String("String"), // Required - HsmServerPublicCertificate: aws.String("String"), // Required - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateHsmConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateSnapshotCopyGrant() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateSnapshotCopyGrantInput{ - SnapshotCopyGrantName: aws.String("String"), // Required - KmsKeyId: aws.String("String"), - Tags: []*redshift.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateSnapshotCopyGrant(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_CreateTags() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.CreateTagsInput{ - ResourceName: aws.String("String"), // Required - Tags: []*redshift.Tag{ // Required - { // Required - Key: aws.String("String"), - Value: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.CreateTags(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteCluster() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteClusterInput{ - ClusterIdentifier: aws.String("String"), // Required - FinalClusterSnapshotIdentifier: aws.String("String"), - SkipFinalClusterSnapshot: aws.Bool(true), - } - resp, err := svc.DeleteCluster(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteClusterParameterGroupInput{ - ParameterGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteClusterSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteClusterSecurityGroupInput{ - ClusterSecurityGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteClusterSecurityGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteClusterSnapshotInput{ - SnapshotIdentifier: aws.String("String"), // Required - SnapshotClusterIdentifier: aws.String("String"), - } - resp, err := svc.DeleteClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteClusterSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteClusterSubnetGroupInput{ - ClusterSubnetGroupName: aws.String("String"), // Required - } - resp, err := svc.DeleteClusterSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - } - resp, err := svc.DeleteEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteHsmClientCertificate() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteHsmClientCertificateInput{ - HsmClientCertificateIdentifier: aws.String("String"), // Required - } - resp, err := svc.DeleteHsmClientCertificate(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteHsmConfiguration() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteHsmConfigurationInput{ - HsmConfigurationIdentifier: aws.String("String"), // Required - } - resp, err := svc.DeleteHsmConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteSnapshotCopyGrant() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteSnapshotCopyGrantInput{ - SnapshotCopyGrantName: aws.String("String"), // Required - } - resp, err := svc.DeleteSnapshotCopyGrant(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DeleteTagsInput{ - ResourceName: aws.String("String"), // Required - TagKeys: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DeleteTags(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterParameterGroups() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterParameterGroupsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ParameterGroupName: aws.String("String"), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeClusterParameterGroups(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterParameters() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterParametersInput{ - ParameterGroupName: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Source: aws.String("String"), - } - resp, err := svc.DescribeClusterParameters(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterSecurityGroups() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterSecurityGroupsInput{ - ClusterSecurityGroupName: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeClusterSecurityGroups(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterSnapshots() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterSnapshotsInput{ - ClusterIdentifier: aws.String("String"), - EndTime: aws.Time(time.Now()), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - OwnerAccount: aws.String("String"), - SnapshotIdentifier: aws.String("String"), - SnapshotType: aws.String("String"), - StartTime: aws.Time(time.Now()), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeClusterSnapshots(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterSubnetGroups() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterSubnetGroupsInput{ - ClusterSubnetGroupName: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeClusterSubnetGroups(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusterVersions() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClusterVersionsInput{ - ClusterParameterGroupFamily: aws.String("String"), - ClusterVersion: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeClusterVersions(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeClusters() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeClustersInput{ - ClusterIdentifier: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeClusters(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeDefaultClusterParameters() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeDefaultClusterParametersInput{ - ParameterGroupFamily: aws.String("String"), // Required - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - resp, err := svc.DescribeDefaultClusterParameters(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeEventCategories() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeEventCategoriesInput{ - SourceType: aws.String("String"), - } - resp, err := svc.DescribeEventCategories(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeEventSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeEventSubscriptionsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SubscriptionName: aws.String("String"), - } - resp, err := svc.DescribeEventSubscriptions(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeEvents() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeEventsInput{ - Duration: aws.Int64(1), - EndTime: aws.Time(time.Now()), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SourceIdentifier: aws.String("String"), - SourceType: aws.String("SourceType"), - StartTime: aws.Time(time.Now()), - } - resp, err := svc.DescribeEvents(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeHsmClientCertificates() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeHsmClientCertificatesInput{ - HsmClientCertificateIdentifier: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeHsmClientCertificates(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeHsmConfigurations() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeHsmConfigurationsInput{ - HsmConfigurationIdentifier: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeHsmConfigurations(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeLoggingStatus() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeLoggingStatusInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.DescribeLoggingStatus(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeOrderableClusterOptions() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeOrderableClusterOptionsInput{ - ClusterVersion: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - NodeType: aws.String("String"), - } - resp, err := svc.DescribeOrderableClusterOptions(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeReservedNodeOfferings() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeReservedNodeOfferingsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ReservedNodeOfferingId: aws.String("String"), - } - resp, err := svc.DescribeReservedNodeOfferings(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeReservedNodes() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeReservedNodesInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ReservedNodeId: aws.String("String"), - } - resp, err := svc.DescribeReservedNodes(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeResize() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeResizeInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.DescribeResize(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeSnapshotCopyGrants() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeSnapshotCopyGrantsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - SnapshotCopyGrantName: aws.String("String"), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeSnapshotCopyGrants(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeTableRestoreStatus() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeTableRestoreStatusInput{ - ClusterIdentifier: aws.String("String"), - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - TableRestoreRequestId: aws.String("String"), - } - resp, err := svc.DescribeTableRestoreStatus(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DescribeTagsInput{ - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - ResourceName: aws.String("String"), - ResourceType: aws.String("String"), - TagKeys: []*string{ - aws.String("String"), // Required - // More values... - }, - TagValues: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DisableLogging() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DisableLoggingInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.DisableLogging(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_DisableSnapshotCopy() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.DisableSnapshotCopyInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.DisableSnapshotCopy(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_EnableLogging() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.EnableLoggingInput{ - BucketName: aws.String("String"), // Required - ClusterIdentifier: aws.String("String"), // Required - S3KeyPrefix: aws.String("String"), - } - resp, err := svc.EnableLogging(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_EnableSnapshotCopy() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.EnableSnapshotCopyInput{ - ClusterIdentifier: aws.String("String"), // Required - DestinationRegion: aws.String("String"), // Required - RetentionPeriod: aws.Int64(1), - SnapshotCopyGrantName: aws.String("String"), - } - resp, err := svc.EnableSnapshotCopy(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_GetClusterCredentials() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.GetClusterCredentialsInput{ - ClusterIdentifier: aws.String("String"), // Required - DbUser: aws.String("String"), // Required - AutoCreate: aws.Bool(true), - DbGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - DbName: aws.String("String"), - DurationSeconds: aws.Int64(1), - } - resp, err := svc.GetClusterCredentials(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifyCluster() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifyClusterInput{ - ClusterIdentifier: aws.String("String"), // Required - AllowVersionUpgrade: aws.Bool(true), - AutomatedSnapshotRetentionPeriod: aws.Int64(1), - ClusterParameterGroupName: aws.String("String"), - ClusterSecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - ClusterType: aws.String("String"), - ClusterVersion: aws.String("String"), - ElasticIp: aws.String("String"), - EnhancedVpcRouting: aws.Bool(true), - HsmClientCertificateIdentifier: aws.String("String"), - HsmConfigurationIdentifier: aws.String("String"), - MasterUserPassword: aws.String("String"), - NewClusterIdentifier: aws.String("String"), - NodeType: aws.String("String"), - NumberOfNodes: aws.Int64(1), - PreferredMaintenanceWindow: aws.String("String"), - PubliclyAccessible: aws.Bool(true), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ModifyCluster(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifyClusterIamRoles() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifyClusterIamRolesInput{ - ClusterIdentifier: aws.String("String"), // Required - AddIamRoles: []*string{ - aws.String("String"), // Required - // More values... - }, - RemoveIamRoles: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.ModifyClusterIamRoles(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifyClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifyClusterParameterGroupInput{ - ParameterGroupName: aws.String("String"), // Required - Parameters: []*redshift.Parameter{ // Required - { // Required - AllowedValues: aws.String("String"), - ApplyType: aws.String("ParameterApplyType"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), - }, - // More values... - }, - } - resp, err := svc.ModifyClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifyClusterSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifyClusterSubnetGroupInput{ - ClusterSubnetGroupName: aws.String("String"), // Required - SubnetIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Description: aws.String("String"), - } - resp, err := svc.ModifyClusterSubnetGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifyEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifyEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required - Enabled: aws.Bool(true), - EventCategories: []*string{ - aws.String("String"), // Required - // More values... - }, - Severity: aws.String("String"), - SnsTopicArn: aws.String("String"), - SourceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - SourceType: aws.String("String"), - } - resp, err := svc.ModifyEventSubscription(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ModifySnapshotCopyRetentionPeriod() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ModifySnapshotCopyRetentionPeriodInput{ - ClusterIdentifier: aws.String("String"), // Required - RetentionPeriod: aws.Int64(1), // Required - } - resp, err := svc.ModifySnapshotCopyRetentionPeriod(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_PurchaseReservedNodeOffering() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.PurchaseReservedNodeOfferingInput{ - ReservedNodeOfferingId: aws.String("String"), // Required - NodeCount: aws.Int64(1), - } - resp, err := svc.PurchaseReservedNodeOffering(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RebootCluster() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RebootClusterInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.RebootCluster(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_ResetClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.ResetClusterParameterGroupInput{ - ParameterGroupName: aws.String("String"), // Required - Parameters: []*redshift.Parameter{ - { // Required - AllowedValues: aws.String("String"), - ApplyType: aws.String("ParameterApplyType"), - DataType: aws.String("String"), - Description: aws.String("String"), - IsModifiable: aws.Bool(true), - MinimumEngineVersion: aws.String("String"), - ParameterName: aws.String("String"), - ParameterValue: aws.String("String"), - Source: aws.String("String"), - }, - // More values... - }, - ResetAllParameters: aws.Bool(true), - } - resp, err := svc.ResetClusterParameterGroup(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RestoreFromClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RestoreFromClusterSnapshotInput{ - ClusterIdentifier: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - AdditionalInfo: aws.String("String"), - AllowVersionUpgrade: aws.Bool(true), - AutomatedSnapshotRetentionPeriod: aws.Int64(1), - AvailabilityZone: aws.String("String"), - ClusterParameterGroupName: aws.String("String"), - ClusterSecurityGroups: []*string{ - aws.String("String"), // Required - // More values... - }, - ClusterSubnetGroupName: aws.String("String"), - ElasticIp: aws.String("String"), - EnhancedVpcRouting: aws.Bool(true), - HsmClientCertificateIdentifier: aws.String("String"), - HsmConfigurationIdentifier: aws.String("String"), - IamRoles: []*string{ - aws.String("String"), // Required - // More values... - }, - KmsKeyId: aws.String("String"), - NodeType: aws.String("String"), - OwnerAccount: aws.String("String"), - Port: aws.Int64(1), - PreferredMaintenanceWindow: aws.String("String"), - PubliclyAccessible: aws.Bool(true), - SnapshotClusterIdentifier: aws.String("String"), - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RestoreFromClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RestoreTableFromClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RestoreTableFromClusterSnapshotInput{ - ClusterIdentifier: aws.String("String"), // Required - NewTableName: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - SourceDatabaseName: aws.String("String"), // Required - SourceTableName: aws.String("String"), // Required - SourceSchemaName: aws.String("String"), - TargetDatabaseName: aws.String("String"), - TargetSchemaName: aws.String("String"), - } - resp, err := svc.RestoreTableFromClusterSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RevokeClusterSecurityGroupIngress() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RevokeClusterSecurityGroupIngressInput{ - ClusterSecurityGroupName: aws.String("String"), // Required - CIDRIP: aws.String("String"), - EC2SecurityGroupName: aws.String("String"), - EC2SecurityGroupOwnerId: aws.String("String"), - } - resp, err := svc.RevokeClusterSecurityGroupIngress(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RevokeSnapshotAccess() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RevokeSnapshotAccessInput{ - AccountWithRestoreAccess: aws.String("String"), // Required - SnapshotIdentifier: aws.String("String"), // Required - SnapshotClusterIdentifier: aws.String("String"), - } - resp, err := svc.RevokeSnapshotAccess(params) - - if err != nil { - // 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) -} - -func ExampleRedshift_RotateEncryptionKey() { - sess := session.Must(session.NewSession()) - - svc := redshift.New(sess) - - params := &redshift.RotateEncryptionKeyInput{ - ClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.RotateEncryptionKey(params) - - if err != nil { - // 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) -} diff --git a/service/rekognition/examples_test.go b/service/rekognition/examples_test.go deleted file mode 100644 index 445d47e6513..00000000000 --- a/service/rekognition/examples_test.go +++ /dev/null @@ -1,345 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package rekognition_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/rekognition" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleRekognition_CompareFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.CompareFacesInput{ - SourceImage: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - TargetImage: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - SimilarityThreshold: aws.Float64(1.0), - } - resp, err := svc.CompareFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_CreateCollection() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.CreateCollectionInput{ - CollectionId: aws.String("CollectionId"), // Required - } - resp, err := svc.CreateCollection(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_DeleteCollection() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.DeleteCollectionInput{ - CollectionId: aws.String("CollectionId"), // Required - } - resp, err := svc.DeleteCollection(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_DeleteFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.DeleteFacesInput{ - CollectionId: aws.String("CollectionId"), // Required - FaceIds: []*string{ // Required - aws.String("FaceId"), // Required - // More values... - }, - } - resp, err := svc.DeleteFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_DetectFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.DetectFacesInput{ - Image: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - Attributes: []*string{ - aws.String("Attribute"), // Required - // More values... - }, - } - resp, err := svc.DetectFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_DetectLabels() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.DetectLabelsInput{ - Image: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - MaxLabels: aws.Int64(1), - MinConfidence: aws.Float64(1.0), - } - resp, err := svc.DetectLabels(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_DetectModerationLabels() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.DetectModerationLabelsInput{ - Image: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - MinConfidence: aws.Float64(1.0), - } - resp, err := svc.DetectModerationLabels(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_IndexFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.IndexFacesInput{ - CollectionId: aws.String("CollectionId"), // Required - Image: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - DetectionAttributes: []*string{ - aws.String("Attribute"), // Required - // More values... - }, - ExternalImageId: aws.String("ExternalImageId"), - } - resp, err := svc.IndexFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_ListCollections() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.ListCollectionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListCollections(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_ListFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.ListFacesInput{ - CollectionId: aws.String("CollectionId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_SearchFaces() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.SearchFacesInput{ - CollectionId: aws.String("CollectionId"), // Required - FaceId: aws.String("FaceId"), // Required - FaceMatchThreshold: aws.Float64(1.0), - MaxFaces: aws.Int64(1), - } - resp, err := svc.SearchFaces(params) - - if err != nil { - // 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) -} - -func ExampleRekognition_SearchFacesByImage() { - sess := session.Must(session.NewSession()) - - svc := rekognition.New(sess) - - params := &rekognition.SearchFacesByImageInput{ - CollectionId: aws.String("CollectionId"), // Required - Image: &rekognition.Image{ // Required - Bytes: []byte("PAYLOAD"), - S3Object: &rekognition.S3Object{ - Bucket: aws.String("S3Bucket"), - Name: aws.String("S3ObjectName"), - Version: aws.String("S3ObjectVersion"), - }, - }, - FaceMatchThreshold: aws.Float64(1.0), - MaxFaces: aws.Int64(1), - } - resp, err := svc.SearchFacesByImage(params) - - if err != nil { - // 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) -} diff --git a/service/resourcegroupstaggingapi/examples_test.go b/service/resourcegroupstaggingapi/examples_test.go deleted file mode 100644 index f3a618d87eb..00000000000 --- a/service/resourcegroupstaggingapi/examples_test.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package resourcegroupstaggingapi_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleResourceGroupsTaggingAPI_GetResources() { - sess := session.Must(session.NewSession()) - - svc := resourcegroupstaggingapi.New(sess) - - params := &resourcegroupstaggingapi.GetResourcesInput{ - PaginationToken: aws.String("PaginationToken"), - ResourceTypeFilters: []*string{ - aws.String("AmazonResourceType"), // Required - // More values... - }, - ResourcesPerPage: aws.Int64(1), - TagFilters: []*resourcegroupstaggingapi.TagFilter{ - { // Required - Key: aws.String("TagKey"), - Values: []*string{ - aws.String("TagValue"), // Required - // More values... - }, - }, - // More values... - }, - TagsPerPage: aws.Int64(1), - } - resp, err := svc.GetResources(params) - - if err != nil { - // 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) -} - -func ExampleResourceGroupsTaggingAPI_GetTagKeys() { - sess := session.Must(session.NewSession()) - - svc := resourcegroupstaggingapi.New(sess) - - params := &resourcegroupstaggingapi.GetTagKeysInput{ - PaginationToken: aws.String("PaginationToken"), - } - resp, err := svc.GetTagKeys(params) - - if err != nil { - // 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) -} - -func ExampleResourceGroupsTaggingAPI_GetTagValues() { - sess := session.Must(session.NewSession()) - - svc := resourcegroupstaggingapi.New(sess) - - params := &resourcegroupstaggingapi.GetTagValuesInput{ - Key: aws.String("TagKey"), // Required - PaginationToken: aws.String("PaginationToken"), - } - resp, err := svc.GetTagValues(params) - - if err != nil { - // 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) -} - -func ExampleResourceGroupsTaggingAPI_TagResources() { - sess := session.Must(session.NewSession()) - - svc := resourcegroupstaggingapi.New(sess) - - params := &resourcegroupstaggingapi.TagResourcesInput{ - ResourceARNList: []*string{ // Required - aws.String("ResourceARN"), // Required - // More values... - }, - Tags: map[string]*string{ // Required - "Key": aws.String("TagValue"), // Required - // More values... - }, - } - resp, err := svc.TagResources(params) - - if err != nil { - // 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) -} - -func ExampleResourceGroupsTaggingAPI_UntagResources() { - sess := session.Must(session.NewSession()) - - svc := resourcegroupstaggingapi.New(sess) - - params := &resourcegroupstaggingapi.UntagResourcesInput{ - ResourceARNList: []*string{ // Required - aws.String("ResourceARN"), // Required - // More values... - }, - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UntagResources(params) - - if err != nil { - // 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) -} diff --git a/service/route53/examples_test.go b/service/route53/examples_test.go index a2b7aa75aa7..86263339d44 100644 --- a/service/route53/examples_test.go +++ b/service/route53/examples_test.go @@ -8,1214 +8,658 @@ import ( "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/route53" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleRoute53_AssociateVPCWithHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.AssociateVPCWithHostedZoneInput{ - HostedZoneId: aws.String("ResourceId"), // Required - VPC: &route53.VPC{ // Required - VPCId: aws.String("VPCId"), - VPCRegion: aws.String("VPCRegion"), - }, - Comment: aws.String("AssociateVPCComment"), - } - resp, err := svc.AssociateVPCWithHostedZone(params) - +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()) - return + panic(err) } - - // Pretty-print the response data. - fmt.Println(resp) + return &t } -func ExampleRoute53_ChangeResourceRecordSets() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) +// To associate a VPC with a hosted zone +// +// The following example associates the VPC with ID vpc-1a2b3c4d with the hosted zone +// with ID Z3M3LMPEXAMPLE. +func ExampleRoute53_AssociateVPCWithHostedZone_shared00() { + svc := route53.New(session.New()) + input := &route53.AssociateVPCWithHostedZoneInput{ + Comment: aws.String(""), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + VPC: &route53.VPC{ + VPCId: aws.String("vpc-1a2b3c4d"), + VPCRegion: aws.String("us-east-2"), + }, + } - params := &route53.ChangeResourceRecordSetsInput{ - ChangeBatch: &route53.ChangeBatch{ // Required - Changes: []*route53.Change{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - ResourceRecordSet: &route53.ResourceRecordSet{ // Required - Name: aws.String("DNSName"), // Required - Type: aws.String("RRType"), // Required - AliasTarget: &route53.AliasTarget{ - DNSName: aws.String("DNSName"), // Required - EvaluateTargetHealth: aws.Bool(true), // Required - HostedZoneId: aws.String("ResourceId"), // Required - }, - Failover: aws.String("ResourceRecordSetFailover"), - GeoLocation: &route53.GeoLocation{ - ContinentCode: aws.String("GeoLocationContinentCode"), - CountryCode: aws.String("GeoLocationCountryCode"), - SubdivisionCode: aws.String("GeoLocationSubdivisionCode"), - }, - HealthCheckId: aws.String("HealthCheckId"), - Region: aws.String("ResourceRecordSetRegion"), - ResourceRecords: []*route53.ResourceRecord{ - { // Required - Value: aws.String("RData"), // Required - }, - // More values... - }, - SetIdentifier: aws.String("ResourceRecordSetIdentifier"), - TTL: aws.Int64(1), - TrafficPolicyInstanceId: aws.String("TrafficPolicyInstanceId"), - Weight: aws.Int64(1), - }, + result, err := svc.AssociateVPCWithHostedZone(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNotAuthorizedException: + fmt.Println(route53.ErrCodeNotAuthorizedException, aerr.Error()) + case route53.ErrCodeInvalidVPCId: + fmt.Println(route53.ErrCodeInvalidVPCId, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePublicZoneVPCAssociation: + fmt.Println(route53.ErrCodePublicZoneVPCAssociation, aerr.Error()) + case route53.ErrCodeConflictingDomainExists: + fmt.Println(route53.ErrCodeConflictingDomainExists, aerr.Error()) + case route53.ErrCodeLimitsExceeded: + fmt.Println(route53.ErrCodeLimitsExceeded, 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) +} + +// To create a basic resource record set +// +// The following example creates a resource record set that routes Internet traffic +// to a resource with an IP address of 192.0.2.44. +func ExampleRoute53_ChangeResourceRecordSets_shared00() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), }, - // More values... }, - Comment: aws.String("ResourceDescription"), + Comment: aws.String("Web server for example.com"), }, - HostedZoneId: aws.String("ResourceId"), // Required - } - resp, err := svc.ChangeResourceRecordSets(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ChangeTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ChangeTagsForResourceInput{ - ResourceId: aws.String("TagResourceId"), // Required - ResourceType: aws.String("TagResourceType"), // Required - AddTags: []*route53.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create weighted resource record sets +// +// The following example creates two weighted resource record sets. The resource with +// a Weight of 100 will get 1/3rd of traffic (100/100+200), and the other resource will +// get the rest of the traffic for example.com. +func ExampleRoute53_ChangeResourceRecordSets_shared01() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, }, - // More values... + Comment: aws.String("Web servers for example.com"), }, - RemoveTagKeys: []*string{ - aws.String("TagKey"), // Required - // More values... + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create an alias resource record set +// +// The following example creates an alias resource record set that routes traffic to +// a CloudFront distribution. +func ExampleRoute53_ChangeResourceRecordSets_shared02() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + }, + Comment: aws.String("CloudFront distribution for example.com"), }, - } - resp, err := svc.ChangeTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateHealthCheck() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateHealthCheckInput{ - CallerReference: aws.String("HealthCheckNonce"), // Required - HealthCheckConfig: &route53.HealthCheckConfig{ // Required - Type: aws.String("HealthCheckType"), // Required - AlarmIdentifier: &route53.AlarmIdentifier{ - Name: aws.String("AlarmName"), // Required - Region: aws.String("CloudWatchRegion"), // Required + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create weighted alias resource record sets +// +// The following example creates two weighted alias resource record sets that route +// traffic to ELB load balancers. The resource with a Weight of 100 will get 1/3rd of +// traffic (100/100+200), and the other resource will get the rest of the traffic for +// example.com. +func ExampleRoute53_ChangeResourceRecordSets_shared03() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, }, - ChildHealthChecks: []*string{ - aws.String("HealthCheckId"), // Required - // More values... + Comment: aws.String("ELB load balancers for example.com"), + }, + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create latency resource record sets +// +// The following example creates two latency resource record sets that route traffic +// to EC2 instances. Traffic for example.com is routed either to the Ohio region or +// the Oregon region, depending on the latency between the user and those regions. +func ExampleRoute53_ChangeResourceRecordSets_shared04() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, }, - EnableSNI: aws.Bool(true), - FailureThreshold: aws.Int64(1), - FullyQualifiedDomainName: aws.String("FullyQualifiedDomainName"), - HealthThreshold: aws.Int64(1), - IPAddress: aws.String("IPAddress"), - InsufficientDataHealthStatus: aws.String("InsufficientDataHealthStatus"), - Inverted: aws.Bool(true), - MeasureLatency: aws.Bool(true), - Port: aws.Int64(1), - Regions: []*string{ - aws.String("HealthCheckRegion"), // Required - // More values... + Comment: aws.String("EC2 instances for example.com"), + }, + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create latency alias resource record sets +// +// The following example creates two latency alias resource record sets that route traffic +// for example.com to ELB load balancers. Requests are routed either to the Ohio region +// or the Oregon region, depending on the latency between the user and those regions. +func ExampleRoute53_ChangeResourceRecordSets_shared05() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, }, - RequestInterval: aws.Int64(1), - ResourcePath: aws.String("ResourcePath"), - SearchString: aws.String("SearchString"), + Comment: aws.String("ELB load balancers for example.com"), }, - } - resp, err := svc.CreateHealthCheck(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateHostedZoneInput{ - CallerReference: aws.String("Nonce"), // Required - Name: aws.String("DNSName"), // Required - DelegationSetId: aws.String("ResourceId"), - HostedZoneConfig: &route53.HostedZoneConfig{ - Comment: aws.String("ResourceDescription"), - PrivateZone: aws.Bool(true), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create failover resource record sets +// +// The following example creates primary and secondary failover resource record sets +// that route traffic to EC2 instances. Traffic is generally routed to the primary resource, +// in the Ohio region. If that resource is unavailable, traffic is routed to the secondary +// resource, in the Oregon region. +func ExampleRoute53_ChangeResourceRecordSets_shared06() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + }, + Comment: aws.String("Failover configuration for example.com"), }, - VPC: &route53.VPC{ - VPCId: aws.String("VPCId"), - VPCRegion: aws.String("VPCRegion"), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create failover alias resource record sets +// +// The following example creates primary and secondary failover alias resource record +// sets that route traffic to ELB load balancers. Traffic is generally routed to the +// primary resource, in the Ohio region. If that resource is unavailable, traffic is +// routed to the secondary resource, in the Oregon region. +func ExampleRoute53_ChangeResourceRecordSets_shared07() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + }, + Comment: aws.String("Failover alias configuration for example.com"), }, - } - resp, err := svc.CreateHostedZone(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateReusableDelegationSet() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateReusableDelegationSetInput{ - CallerReference: aws.String("Nonce"), // Required - HostedZoneId: aws.String("ResourceId"), - } - resp, err := svc.CreateReusableDelegationSet(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateTrafficPolicy() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateTrafficPolicyInput{ - Document: aws.String("TrafficPolicyDocument"), // Required - Name: aws.String("TrafficPolicyName"), // Required - Comment: aws.String("TrafficPolicyComment"), - } - resp, err := svc.CreateTrafficPolicy(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateTrafficPolicyInstance() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateTrafficPolicyInstanceInput{ - HostedZoneId: aws.String("ResourceId"), // Required - Name: aws.String("DNSName"), // Required - TTL: aws.Int64(1), // Required - TrafficPolicyId: aws.String("TrafficPolicyId"), // Required - TrafficPolicyVersion: aws.Int64(1), // Required - } - resp, err := svc.CreateTrafficPolicyInstance(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateTrafficPolicyVersion() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateTrafficPolicyVersionInput{ - Document: aws.String("TrafficPolicyDocument"), // Required - Id: aws.String("TrafficPolicyId"), // Required - Comment: aws.String("TrafficPolicyComment"), - } - resp, err := svc.CreateTrafficPolicyVersion(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_CreateVPCAssociationAuthorization() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.CreateVPCAssociationAuthorizationInput{ - HostedZoneId: aws.String("ResourceId"), // Required - VPC: &route53.VPC{ // Required - VPCId: aws.String("VPCId"), - VPCRegion: aws.String("VPCRegion"), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create geolocation resource record sets +// +// The following example creates four geolocation resource record sets that use IPv4 +// addresses to route traffic to resources such as web servers running on EC2 instances. +// Traffic is routed to one of four IP addresses, for North America (NA), for South +// America (SA), for Europe (EU), and for all other locations (*). +func ExampleRoute53_ChangeResourceRecordSets_shared08() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + }, + Comment: aws.String("Geolocation configuration for example.com"), }, - } - resp, err := svc.CreateVPCAssociationAuthorization(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteHealthCheck() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteHealthCheckInput{ - HealthCheckId: aws.String("HealthCheckId"), // Required - } - resp, err := svc.DeleteHealthCheck(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteHostedZoneInput{ - Id: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteHostedZone(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteReusableDelegationSet() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteReusableDelegationSetInput{ - Id: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteReusableDelegationSet(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteTrafficPolicy() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteTrafficPolicyInput{ - Id: aws.String("TrafficPolicyId"), // Required - Version: aws.Int64(1), // Required - } - resp, err := svc.DeleteTrafficPolicy(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteTrafficPolicyInstance() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteTrafficPolicyInstanceInput{ - Id: aws.String("TrafficPolicyInstanceId"), // Required - } - resp, err := svc.DeleteTrafficPolicyInstance(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DeleteVPCAssociationAuthorization() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DeleteVPCAssociationAuthorizationInput{ - HostedZoneId: aws.String("ResourceId"), // Required - VPC: &route53.VPC{ // Required - VPCId: aws.String("VPCId"), - VPCRegion: aws.String("VPCRegion"), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To create geolocation alias resource record sets +// +// The following example creates four geolocation alias resource record sets that route +// traffic to ELB load balancers. Traffic is routed to one of four IP addresses, for +// North America (NA), for South America (SA), for Europe (EU), and for all other locations +// (*). +func ExampleRoute53_ChangeResourceRecordSets_shared09() { + svc := route53.New(session.New()) + input := &route53.ChangeResourceRecordSetsInput{ + ChangeBatch: &route53.ChangeBatch{ + Changes: []*route53.Changes{ + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + { + Action: aws.String("CREATE"), + }, + }, + Comment: aws.String("Geolocation alias configuration for example.com"), }, - } - resp, err := svc.DeleteVPCAssociationAuthorization(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_DisassociateVPCFromHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.DisassociateVPCFromHostedZoneInput{ - HostedZoneId: aws.String("ResourceId"), // Required - VPC: &route53.VPC{ // Required - VPCId: aws.String("VPCId"), - VPCRegion: aws.String("VPCRegion"), + HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.ChangeResourceRecordSets(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeInvalidChangeBatch: + fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, 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) +} + +// To add or remove tags from a hosted zone or health check +// +// The following example adds two tags and removes one tag from the hosted zone with +// ID Z3M3LMPEXAMPLE. +func ExampleRoute53_ChangeTagsForResource_shared00() { + svc := route53.New(session.New()) + input := &route53.ChangeTagsForResourceInput{ + AddTags: []*route53.TagList{ + { + Key: aws.String("apex"), + Value: aws.String("3874"), + }, + { + Key: aws.String("acme"), + Value: aws.String("4938"), + }, }, - Comment: aws.String("DisassociateVPCComment"), - } - resp, err := svc.DisassociateVPCFromHostedZone(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetChange() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetChangeInput{ - Id: aws.String("ResourceId"), // Required - } - resp, err := svc.GetChange(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetCheckerIpRanges() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - var params *route53.GetCheckerIpRangesInput - resp, err := svc.GetCheckerIpRanges(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetGeoLocation() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetGeoLocationInput{ - ContinentCode: aws.String("GeoLocationContinentCode"), - CountryCode: aws.String("GeoLocationCountryCode"), - SubdivisionCode: aws.String("GeoLocationSubdivisionCode"), - } - resp, err := svc.GetGeoLocation(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHealthCheck() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetHealthCheckInput{ - HealthCheckId: aws.String("HealthCheckId"), // Required - } - resp, err := svc.GetHealthCheck(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHealthCheckCount() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - var params *route53.GetHealthCheckCountInput - resp, err := svc.GetHealthCheckCount(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHealthCheckLastFailureReason() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetHealthCheckLastFailureReasonInput{ - HealthCheckId: aws.String("HealthCheckId"), // Required - } - resp, err := svc.GetHealthCheckLastFailureReason(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHealthCheckStatus() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetHealthCheckStatusInput{ - HealthCheckId: aws.String("HealthCheckId"), // Required - } - resp, err := svc.GetHealthCheckStatus(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetHostedZoneInput{ - Id: aws.String("ResourceId"), // Required - } - resp, err := svc.GetHostedZone(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetHostedZoneCount() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - var params *route53.GetHostedZoneCountInput - resp, err := svc.GetHostedZoneCount(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetReusableDelegationSet() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetReusableDelegationSetInput{ - Id: aws.String("ResourceId"), // Required - } - resp, err := svc.GetReusableDelegationSet(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetTrafficPolicy() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetTrafficPolicyInput{ - Id: aws.String("TrafficPolicyId"), // Required - Version: aws.Int64(1), // Required - } - resp, err := svc.GetTrafficPolicy(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetTrafficPolicyInstance() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.GetTrafficPolicyInstanceInput{ - Id: aws.String("TrafficPolicyInstanceId"), // Required - } - resp, err := svc.GetTrafficPolicyInstance(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_GetTrafficPolicyInstanceCount() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - var params *route53.GetTrafficPolicyInstanceCountInput - resp, err := svc.GetTrafficPolicyInstanceCount(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListGeoLocations() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListGeoLocationsInput{ - MaxItems: aws.String("PageMaxItems"), - StartContinentCode: aws.String("GeoLocationContinentCode"), - StartCountryCode: aws.String("GeoLocationCountryCode"), - StartSubdivisionCode: aws.String("GeoLocationSubdivisionCode"), - } - resp, err := svc.ListGeoLocations(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListHealthChecks() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListHealthChecksInput{ - Marker: aws.String("PageMarker"), - MaxItems: aws.String("PageMaxItems"), - } - resp, err := svc.ListHealthChecks(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListHostedZones() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListHostedZonesInput{ - DelegationSetId: aws.String("ResourceId"), - Marker: aws.String("PageMarker"), - MaxItems: aws.String("PageMaxItems"), - } - resp, err := svc.ListHostedZones(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListHostedZonesByName() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListHostedZonesByNameInput{ - DNSName: aws.String("DNSName"), - HostedZoneId: aws.String("ResourceId"), - MaxItems: aws.String("PageMaxItems"), - } - resp, err := svc.ListHostedZonesByName(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListResourceRecordSets() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListResourceRecordSetsInput{ - HostedZoneId: aws.String("ResourceId"), // Required - MaxItems: aws.String("PageMaxItems"), - StartRecordIdentifier: aws.String("ResourceRecordSetIdentifier"), - StartRecordName: aws.String("DNSName"), - StartRecordType: aws.String("RRType"), - } - resp, err := svc.ListResourceRecordSets(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListReusableDelegationSets() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListReusableDelegationSetsInput{ - Marker: aws.String("PageMarker"), - MaxItems: aws.String("PageMaxItems"), - } - resp, err := svc.ListReusableDelegationSets(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTagsForResourceInput{ - ResourceId: aws.String("TagResourceId"), // Required - ResourceType: aws.String("TagResourceType"), // Required - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTagsForResources() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTagsForResourcesInput{ - ResourceIds: []*string{ // Required - aws.String("TagResourceId"), // Required - // More values... - }, - ResourceType: aws.String("TagResourceType"), // Required - } - resp, err := svc.ListTagsForResources(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTrafficPolicies() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTrafficPoliciesInput{ - MaxItems: aws.String("PageMaxItems"), - TrafficPolicyIdMarker: aws.String("TrafficPolicyId"), - } - resp, err := svc.ListTrafficPolicies(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTrafficPolicyInstances() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTrafficPolicyInstancesInput{ - HostedZoneIdMarker: aws.String("ResourceId"), - MaxItems: aws.String("PageMaxItems"), - TrafficPolicyInstanceNameMarker: aws.String("DNSName"), - TrafficPolicyInstanceTypeMarker: aws.String("RRType"), - } - resp, err := svc.ListTrafficPolicyInstances(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTrafficPolicyInstancesByHostedZone() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTrafficPolicyInstancesByHostedZoneInput{ - HostedZoneId: aws.String("ResourceId"), // Required - MaxItems: aws.String("PageMaxItems"), - TrafficPolicyInstanceNameMarker: aws.String("DNSName"), - TrafficPolicyInstanceTypeMarker: aws.String("RRType"), - } - resp, err := svc.ListTrafficPolicyInstancesByHostedZone(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTrafficPolicyInstancesByPolicy() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTrafficPolicyInstancesByPolicyInput{ - TrafficPolicyId: aws.String("TrafficPolicyId"), // Required - TrafficPolicyVersion: aws.Int64(1), // Required - HostedZoneIdMarker: aws.String("ResourceId"), - MaxItems: aws.String("PageMaxItems"), - TrafficPolicyInstanceNameMarker: aws.String("DNSName"), - TrafficPolicyInstanceTypeMarker: aws.String("RRType"), - } - resp, err := svc.ListTrafficPolicyInstancesByPolicy(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListTrafficPolicyVersions() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListTrafficPolicyVersionsInput{ - Id: aws.String("TrafficPolicyId"), // Required - MaxItems: aws.String("PageMaxItems"), - TrafficPolicyVersionMarker: aws.String("TrafficPolicyVersionMarker"), - } - resp, err := svc.ListTrafficPolicyVersions(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_ListVPCAssociationAuthorizations() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.ListVPCAssociationAuthorizationsInput{ - HostedZoneId: aws.String("ResourceId"), // Required - MaxResults: aws.String("MaxResults"), - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.ListVPCAssociationAuthorizations(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_TestDNSAnswer() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.TestDNSAnswerInput{ - HostedZoneId: aws.String("ResourceId"), // Required - RecordName: aws.String("DNSName"), // Required - RecordType: aws.String("RRType"), // Required - EDNS0ClientSubnetIP: aws.String("IPAddress"), - EDNS0ClientSubnetMask: aws.String("SubnetMask"), - ResolverIP: aws.String("IPAddress"), - } - resp, err := svc.TestDNSAnswer(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_UpdateHealthCheck() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.UpdateHealthCheckInput{ - HealthCheckId: aws.String("HealthCheckId"), // Required - AlarmIdentifier: &route53.AlarmIdentifier{ - Name: aws.String("AlarmName"), // Required - Region: aws.String("CloudWatchRegion"), // Required - }, - ChildHealthChecks: []*string{ - aws.String("HealthCheckId"), // Required - // More values... - }, - EnableSNI: aws.Bool(true), - FailureThreshold: aws.Int64(1), - FullyQualifiedDomainName: aws.String("FullyQualifiedDomainName"), - HealthCheckVersion: aws.Int64(1), - HealthThreshold: aws.Int64(1), - IPAddress: aws.String("IPAddress"), - InsufficientDataHealthStatus: aws.String("InsufficientDataHealthStatus"), - Inverted: aws.Bool(true), - Port: aws.Int64(1), - Regions: []*string{ - aws.String("HealthCheckRegion"), // Required - // More values... + RemoveTagKeys: []*string{ + aws.String("Nadir"), }, - ResourcePath: aws.String("ResourcePath"), - SearchString: aws.String("SearchString"), - } - resp, err := svc.UpdateHealthCheck(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_UpdateHostedZoneComment() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.UpdateHostedZoneCommentInput{ - Id: aws.String("ResourceId"), // Required - Comment: aws.String("ResourceDescription"), - } - resp, err := svc.UpdateHostedZoneComment(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_UpdateTrafficPolicyComment() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.UpdateTrafficPolicyCommentInput{ - Comment: aws.String("TrafficPolicyComment"), // Required - Id: aws.String("TrafficPolicyId"), // Required - Version: aws.Int64(1), // Required - } - resp, err := svc.UpdateTrafficPolicyComment(params) - - if err != nil { - // 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) -} - -func ExampleRoute53_UpdateTrafficPolicyInstance() { - sess := session.Must(session.NewSession()) - - svc := route53.New(sess) - - params := &route53.UpdateTrafficPolicyInstanceInput{ - Id: aws.String("TrafficPolicyInstanceId"), // Required - TTL: aws.Int64(1), // Required - TrafficPolicyId: aws.String("TrafficPolicyId"), // Required - TrafficPolicyVersion: aws.Int64(1), // Required - } - resp, err := svc.UpdateTrafficPolicyInstance(params) - - if err != nil { - // 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) + ResourceId: aws.String("Z3M3LMPEXAMPLE"), + ResourceType: aws.String("hostedzone"), + } + + result, err := svc.ChangeTagsForResource(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) + case route53.ErrCodeNoSuchHealthCheck: + fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodePriorRequestNotComplete: + fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) + case route53.ErrCodeThrottlingException: + fmt.Println(route53.ErrCodeThrottlingException, 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) +} + +// To get information about a hosted zone +// +// The following example gets information about the Z3M3LMPEXAMPLE hosted zone. +func ExampleRoute53_GetHostedZone_shared00() { + svc := route53.New(session.New()) + input := &route53.GetHostedZoneInput{ + Id: aws.String("Z3M3LMPEXAMPLE"), + } + + result, err := svc.GetHostedZone(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case route53.ErrCodeNoSuchHostedZone: + fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) + case route53.ErrCodeInvalidInput: + fmt.Println(route53.ErrCodeInvalidInput, 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) } diff --git a/service/route53domains/examples_test.go b/service/route53domains/examples_test.go deleted file mode 100644 index 519969b2a23..00000000000 --- a/service/route53domains/examples_test.go +++ /dev/null @@ -1,755 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package route53domains_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/route53domains" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleRoute53Domains_CheckDomainAvailability() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.CheckDomainAvailabilityInput{ - DomainName: aws.String("DomainName"), // Required - IdnLangCode: aws.String("LangCode"), - } - resp, err := svc.CheckDomainAvailability(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_DeleteTagsForDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.DeleteTagsForDomainInput{ - DomainName: aws.String("DomainName"), // Required - TagsToDelete: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.DeleteTagsForDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_DisableDomainAutoRenew() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.DisableDomainAutoRenewInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DisableDomainAutoRenew(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_DisableDomainTransferLock() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.DisableDomainTransferLockInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.DisableDomainTransferLock(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_EnableDomainAutoRenew() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.EnableDomainAutoRenewInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.EnableDomainAutoRenew(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_EnableDomainTransferLock() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.EnableDomainTransferLockInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.EnableDomainTransferLock(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_GetContactReachabilityStatus() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.GetContactReachabilityStatusInput{ - DomainName: aws.String("DomainName"), - } - resp, err := svc.GetContactReachabilityStatus(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_GetDomainDetail() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.GetDomainDetailInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.GetDomainDetail(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_GetDomainSuggestions() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.GetDomainSuggestionsInput{ - DomainName: aws.String("DomainName"), // Required - OnlyAvailable: aws.Bool(true), // Required - SuggestionCount: aws.Int64(1), // Required - } - resp, err := svc.GetDomainSuggestions(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_GetOperationDetail() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.GetOperationDetailInput{ - OperationId: aws.String("OperationId"), // Required - } - resp, err := svc.GetOperationDetail(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_ListDomains() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.ListDomainsInput{ - Marker: aws.String("PageMarker"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListDomains(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_ListOperations() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.ListOperationsInput{ - Marker: aws.String("PageMarker"), - MaxItems: aws.Int64(1), - } - resp, err := svc.ListOperations(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_ListTagsForDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.ListTagsForDomainInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.ListTagsForDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_RegisterDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.RegisterDomainInput{ - AdminContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - DomainName: aws.String("DomainName"), // Required - DurationInYears: aws.Int64(1), // Required - RegistrantContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - TechContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - AutoRenew: aws.Bool(true), - IdnLangCode: aws.String("LangCode"), - PrivacyProtectAdminContact: aws.Bool(true), - PrivacyProtectRegistrantContact: aws.Bool(true), - PrivacyProtectTechContact: aws.Bool(true), - } - resp, err := svc.RegisterDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_RenewDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.RenewDomainInput{ - CurrentExpiryYear: aws.Int64(1), // Required - DomainName: aws.String("DomainName"), // Required - DurationInYears: aws.Int64(1), - } - resp, err := svc.RenewDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_ResendContactReachabilityEmail() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.ResendContactReachabilityEmailInput{ - DomainName: aws.String("DomainName"), - } - resp, err := svc.ResendContactReachabilityEmail(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_RetrieveDomainAuthCode() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.RetrieveDomainAuthCodeInput{ - DomainName: aws.String("DomainName"), // Required - } - resp, err := svc.RetrieveDomainAuthCode(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_TransferDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.TransferDomainInput{ - AdminContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - DomainName: aws.String("DomainName"), // Required - DurationInYears: aws.Int64(1), // Required - RegistrantContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - TechContact: &route53domains.ContactDetail{ // Required - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - AuthCode: aws.String("DomainAuthCode"), - AutoRenew: aws.Bool(true), - IdnLangCode: aws.String("LangCode"), - Nameservers: []*route53domains.Nameserver{ - { // Required - Name: aws.String("HostName"), // Required - GlueIps: []*string{ - aws.String("GlueIp"), // Required - // More values... - }, - }, - // More values... - }, - PrivacyProtectAdminContact: aws.Bool(true), - PrivacyProtectRegistrantContact: aws.Bool(true), - PrivacyProtectTechContact: aws.Bool(true), - } - resp, err := svc.TransferDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_UpdateDomainContact() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.UpdateDomainContactInput{ - DomainName: aws.String("DomainName"), // Required - AdminContact: &route53domains.ContactDetail{ - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - RegistrantContact: &route53domains.ContactDetail{ - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - TechContact: &route53domains.ContactDetail{ - AddressLine1: aws.String("AddressLine"), - AddressLine2: aws.String("AddressLine"), - City: aws.String("City"), - ContactType: aws.String("ContactType"), - CountryCode: aws.String("CountryCode"), - Email: aws.String("Email"), - ExtraParams: []*route53domains.ExtraParam{ - { // Required - Name: aws.String("ExtraParamName"), // Required - Value: aws.String("ExtraParamValue"), // Required - }, - // More values... - }, - Fax: aws.String("ContactNumber"), - FirstName: aws.String("ContactName"), - LastName: aws.String("ContactName"), - OrganizationName: aws.String("ContactName"), - PhoneNumber: aws.String("ContactNumber"), - State: aws.String("State"), - ZipCode: aws.String("ZipCode"), - }, - } - resp, err := svc.UpdateDomainContact(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_UpdateDomainContactPrivacy() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.UpdateDomainContactPrivacyInput{ - DomainName: aws.String("DomainName"), // Required - AdminPrivacy: aws.Bool(true), - RegistrantPrivacy: aws.Bool(true), - TechPrivacy: aws.Bool(true), - } - resp, err := svc.UpdateDomainContactPrivacy(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_UpdateDomainNameservers() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.UpdateDomainNameserversInput{ - DomainName: aws.String("DomainName"), // Required - Nameservers: []*route53domains.Nameserver{ // Required - { // Required - Name: aws.String("HostName"), // Required - GlueIps: []*string{ - aws.String("GlueIp"), // Required - // More values... - }, - }, - // More values... - }, - FIAuthKey: aws.String("FIAuthKey"), - } - resp, err := svc.UpdateDomainNameservers(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_UpdateTagsForDomain() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.UpdateTagsForDomainInput{ - DomainName: aws.String("DomainName"), // Required - TagsToUpdate: []*route53domains.Tag{ - { // Required - Key: aws.String("TagKey"), - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.UpdateTagsForDomain(params) - - if err != nil { - // 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) -} - -func ExampleRoute53Domains_ViewBilling() { - sess := session.Must(session.NewSession()) - - svc := route53domains.New(sess) - - params := &route53domains.ViewBillingInput{ - End: aws.Time(time.Now()), - Marker: aws.String("PageMarker"), - MaxItems: aws.Int64(1), - Start: aws.Time(time.Now()), - } - resp, err := svc.ViewBilling(params) - - if err != nil { - // 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) -} diff --git a/service/s3/api.go b/service/s3/api.go index 52ac02ca96e..754377de244 100644 --- a/service/s3/api.go +++ b/service/s3/api.go @@ -3225,6 +3225,12 @@ func (c *S3) HeadObjectRequest(input *HeadObjectInput) (req *request.Request, ou // See http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#RESTErrorResponses // for more information on returned errors. // +// See http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#RESTErrorResponses +// for more information on returned errors. +// +// See http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#RESTErrorResponses +// for more information on returned errors. +// // Returns awserr.Error for service API and SDK errors. Use runtime type assertions // with awserr.Error's Code and Message methods to get detailed information about // the error. diff --git a/service/s3/bucket_location_test.go b/service/s3/bucket_location_test.go index 5dcc07b7003..cd052b7ed00 100644 --- a/service/s3/bucket_location_test.go +++ b/service/s3/bucket_location_test.go @@ -119,8 +119,8 @@ func TestNoPopulateLocationConstraintIfProvided(t *testing.T) { t.Fatalf("expect no error, got %v", err) } v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") - if v := len(v); v != 0 { - t.Errorf("expect no values, got %d", v) + if l := len(v); l != 0 { + t.Errorf("expect no values, got %d", l) } } @@ -133,7 +133,7 @@ func TestNoPopulateLocationConstraintIfClassic(t *testing.T) { t.Fatalf("expect no error, got %v", err) } v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") - if v := len(v); v != 0 { - t.Errorf("expect no values, got %d", v) + if l := len(v); l != 0 { + t.Errorf("expect no values, got %d", l) } } diff --git a/service/s3/examples_test.go b/service/s3/examples_test.go index 4472990c234..e4818e1567c 100644 --- a/service/s3/examples_test.go +++ b/service/s3/examples_test.go @@ -8,2231 +8,2218 @@ import ( "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/s3" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleS3_AbortMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) +func parseTime(layout, value string) *time.Time { + t, err := time.Parse(layout, value) + if err != nil { + panic(err) + } + return &t +} - params := &s3.AbortMultipartUploadInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - UploadId: aws.String("MultipartUploadId"), // Required - RequestPayer: aws.String("RequestPayer"), +// To abort a multipart upload +// +// The following example aborts a multipart upload. +func ExampleS3_AbortMultipartUpload_shared00() { + svc := s3.New(session.New()) + input := &s3.AbortMultipartUploadInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("bigobject"), + UploadId: aws.String("xadcOB_7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--"), } - resp, err := svc.AbortMultipartUpload(params) + result, err := svc.AbortMultipartUpload(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 s3.ErrCodeNoSuchUpload: + fmt.Println(s3.ErrCodeNoSuchUpload, 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 ExampleS3_CompleteMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.CompleteMultipartUploadInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - UploadId: aws.String("MultipartUploadId"), // Required +// To complete multipart upload +// +// The following example completes a multipart upload. +func ExampleS3_CompleteMultipartUpload_shared00() { + svc := s3.New(session.New()) + input := &s3.CompleteMultipartUploadInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("bigobject"), MultipartUpload: &s3.CompletedMultipartUpload{ - Parts: []*s3.CompletedPart{ - { // Required - ETag: aws.String("ETag"), - PartNumber: aws.Int64(1), + Parts: []*s3.CompletedPartList{ + { + ETag: aws.String("\"d8c2eafd90c266e19ab9dcacc479f8af\""), + PartNumber: aws.String("1"), + }, + { + ETag: aws.String("\"d8c2eafd90c266e19ab9dcacc479f8af\""), + PartNumber: aws.String("2"), }, - // More values... }, }, - RequestPayer: aws.String("RequestPayer"), + UploadId: aws.String("7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--"), } - resp, err := svc.CompleteMultipartUpload(params) + result, err := svc.CompleteMultipartUpload(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() { + 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 ExampleS3_CopyObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.CopyObjectInput{ - Bucket: aws.String("BucketName"), // Required - CopySource: aws.String("CopySource"), // Required - Key: aws.String("ObjectKey"), // Required - ACL: aws.String("ObjectCannedACL"), - CacheControl: aws.String("CacheControl"), - ContentDisposition: aws.String("ContentDisposition"), - ContentEncoding: aws.String("ContentEncoding"), - ContentLanguage: aws.String("ContentLanguage"), - ContentType: aws.String("ContentType"), - CopySourceIfMatch: aws.String("CopySourceIfMatch"), - CopySourceIfModifiedSince: aws.Time(time.Now()), - CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"), - CopySourceIfUnmodifiedSince: aws.Time(time.Now()), - CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"), - CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"), - CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"), - Expires: aws.Time(time.Now()), - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWriteACP: aws.String("GrantWriteACP"), - Metadata: map[string]*string{ - "Key": aws.String("MetadataValue"), // Required - // More values... - }, - MetadataDirective: aws.String("MetadataDirective"), - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), - SSEKMSKeyId: aws.String("SSEKMSKeyId"), - ServerSideEncryption: aws.String("ServerSideEncryption"), - StorageClass: aws.String("StorageClass"), - Tagging: aws.String("TaggingHeader"), - TaggingDirective: aws.String("TaggingDirective"), - WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"), +// To copy an object +// +// The following example copies an object from one bucket to another. +func ExampleS3_CopyObject_shared00() { + svc := s3.New(session.New()) + input := &s3.CopyObjectInput{ + Bucket: aws.String("destinationbucket"), + CopySource: aws.String("/sourcebucket/HappyFacejpg"), + Key: aws.String("HappyFaceCopyjpg"), } - resp, err := svc.CopyObject(params) + result, err := svc.CopyObject(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 s3.ErrCodeObjectNotInActiveTierError: + fmt.Println(s3.ErrCodeObjectNotInActiveTierError, 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 ExampleS3_CreateBucket() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.CreateBucketInput{ - Bucket: aws.String("BucketName"), // Required - ACL: aws.String("BucketCannedACL"), +// To create a bucket in a specific region +// +// The following example creates a bucket. The request specifies an AWS region where +// to create the bucket. +func ExampleS3_CreateBucket_shared00() { + svc := s3.New(session.New()) + input := &s3.CreateBucketInput{ + Bucket: aws.String("examplebucket"), CreateBucketConfiguration: &s3.CreateBucketConfiguration{ - LocationConstraint: aws.String("BucketLocationConstraint"), + LocationConstraint: aws.String("eu-west-1"), }, - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWrite: aws.String("GrantWrite"), - GrantWriteACP: aws.String("GrantWriteACP"), } - resp, err := svc.CreateBucket(params) + result, err := svc.CreateBucket(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 s3.ErrCodeBucketAlreadyExists: + fmt.Println(s3.ErrCodeBucketAlreadyExists, aerr.Error()) + case s3.ErrCodeBucketAlreadyOwnedByYou: + fmt.Println(s3.ErrCodeBucketAlreadyOwnedByYou, 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 ExampleS3_CreateMultipartUpload() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.CreateMultipartUploadInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - ACL: aws.String("ObjectCannedACL"), - CacheControl: aws.String("CacheControl"), - ContentDisposition: aws.String("ContentDisposition"), - ContentEncoding: aws.String("ContentEncoding"), - ContentLanguage: aws.String("ContentLanguage"), - ContentType: aws.String("ContentType"), - Expires: aws.Time(time.Now()), - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWriteACP: aws.String("GrantWriteACP"), - Metadata: map[string]*string{ - "Key": aws.String("MetadataValue"), // Required - // More values... - }, - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), - SSEKMSKeyId: aws.String("SSEKMSKeyId"), - ServerSideEncryption: aws.String("ServerSideEncryption"), - StorageClass: aws.String("StorageClass"), - WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"), +// To create a bucket +// +// The following example creates a bucket. +func ExampleS3_CreateBucket_shared01() { + svc := s3.New(session.New()) + input := &s3.CreateBucketInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.CreateMultipartUpload(params) + result, err := svc.CreateBucket(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 s3.ErrCodeBucketAlreadyExists: + fmt.Println(s3.ErrCodeBucketAlreadyExists, aerr.Error()) + case s3.ErrCodeBucketAlreadyOwnedByYou: + fmt.Println(s3.ErrCodeBucketAlreadyOwnedByYou, 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 ExampleS3_DeleteBucket() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketInput{ - Bucket: aws.String("BucketName"), // Required +// To initiate a multipart upload +// +// The following example initiates a multipart upload. +func ExampleS3_CreateMultipartUpload_shared00() { + svc := s3.New(session.New()) + input := &s3.CreateMultipartUploadInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("largeobject"), } - resp, err := svc.DeleteBucket(params) + result, err := svc.CreateMultipartUpload(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() { + 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 ExampleS3_DeleteBucketAnalyticsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketAnalyticsConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("AnalyticsId"), // Required +// To delete a bucket +// +// The following example deletes the specified bucket. +func ExampleS3_DeleteBucket_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketInput{ + Bucket: aws.String("forrandall2"), } - resp, err := svc.DeleteBucketAnalyticsConfiguration(params) + result, err := svc.DeleteBucket(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() { + 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 ExampleS3_DeleteBucketCors() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketCorsInput{ - Bucket: aws.String("BucketName"), // Required +// To delete cors configuration on a bucket. +// +// The following example deletes CORS configuration on a bucket. +func ExampleS3_DeleteBucketCors_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketCorsInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.DeleteBucketCors(params) + result, err := svc.DeleteBucketCors(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() { + 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 ExampleS3_DeleteBucketInventoryConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketInventoryConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("InventoryId"), // Required +// To delete lifecycle configuration on a bucket. +// +// The following example deletes lifecycle configuration on a bucket. +func ExampleS3_DeleteBucketLifecycle_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketLifecycleInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.DeleteBucketInventoryConfiguration(params) + result, err := svc.DeleteBucketLifecycle(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() { + 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 ExampleS3_DeleteBucketLifecycle() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketLifecycleInput{ - Bucket: aws.String("BucketName"), // Required +// To delete bucket policy +// +// The following example deletes bucket policy on the specified bucket. +func ExampleS3_DeleteBucketPolicy_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketPolicyInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.DeleteBucketLifecycle(params) + result, err := svc.DeleteBucketPolicy(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() { + 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 ExampleS3_DeleteBucketMetricsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketMetricsConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("MetricsId"), // Required +// To delete bucket replication configuration +// +// The following example deletes replication configuration set on bucket. +func ExampleS3_DeleteBucketReplication_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketReplicationInput{ + Bucket: aws.String("example"), } - resp, err := svc.DeleteBucketMetricsConfiguration(params) + result, err := svc.DeleteBucketReplication(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() { + 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 ExampleS3_DeleteBucketPolicy() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketPolicyInput{ - Bucket: aws.String("BucketName"), // Required +// To delete bucket tags +// +// The following example deletes bucket tags. +func ExampleS3_DeleteBucketTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketTaggingInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.DeleteBucketPolicy(params) + result, err := svc.DeleteBucketTagging(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() { + 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 ExampleS3_DeleteBucketReplication() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketReplicationInput{ - Bucket: aws.String("BucketName"), // Required +// To delete bucket website configuration +// +// The following example deletes bucket website configuration. +func ExampleS3_DeleteBucketWebsite_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteBucketWebsiteInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.DeleteBucketReplication(params) + result, err := svc.DeleteBucketWebsite(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() { + 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 ExampleS3_DeleteBucketTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketTaggingInput{ - Bucket: aws.String("BucketName"), // Required +// To delete an object (from a non-versioned bucket) +// +// The following example deletes an object from a non-versioned bucket. +func ExampleS3_DeleteObject_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectInput{ + Bucket: aws.String("ExampleBucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.DeleteBucketTagging(params) + result, err := svc.DeleteObject(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() { + 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 ExampleS3_DeleteBucketWebsite() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteBucketWebsiteInput{ - Bucket: aws.String("BucketName"), // Required +// To delete an object +// +// The following example deletes an object from an S3 bucket. +func ExampleS3_DeleteObject_shared01() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("objectkey.jpg"), } - resp, err := svc.DeleteBucketWebsite(params) + result, err := svc.DeleteObject(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() { + 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 ExampleS3_DeleteObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteObjectInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - MFA: aws.String("MFA"), - RequestPayer: aws.String("RequestPayer"), - VersionId: aws.String("ObjectVersionId"), +// To remove tag set from an object version +// +// The following example removes tag set associated with the specified object version. +// The request specifies both the object key and object version. +func ExampleS3_DeleteObjectTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectTaggingInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), + VersionId: aws.String("ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI"), } - resp, err := svc.DeleteObject(params) + result, err := svc.DeleteObjectTagging(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() { + 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 ExampleS3_DeleteObjectTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteObjectTaggingInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - VersionId: aws.String("ObjectVersionId"), +// To remove tag set from an object +// +// The following example removes tag set associated with the specified object. If the +// bucket is versioning enabled, the operation removes tag set from the latest object +// version. +func ExampleS3_DeleteObjectTagging_shared01() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectTaggingInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.DeleteObjectTagging(params) + result, err := svc.DeleteObjectTagging(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() { + 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 ExampleS3_DeleteObjects() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.DeleteObjectsInput{ - Bucket: aws.String("BucketName"), // Required - Delete: &s3.Delete{ // Required - Objects: []*s3.ObjectIdentifier{ // Required - { // Required - Key: aws.String("ObjectKey"), // Required - VersionId: aws.String("ObjectVersionId"), +// To delete multiple object versions from a versioned bucket +// +// The following example deletes objects from a bucket. The request specifies object +// versions. S3 deletes specific object versions and returns the key and versions of +// deleted objects in the response. +func ExampleS3_DeleteObjects_shared00() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectsInput{ + Bucket: aws.String("examplebucket"), + Delete: &s3.Delete{ + Objects: []*s3.ObjectIdentifierList{ + { + Key: aws.String("HappyFace.jpg"), + VersionId: aws.String("2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b"), + }, + { + Key: aws.String("HappyFace.jpg"), + VersionId: aws.String("yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd"), }, - // More values... }, - Quiet: aws.Bool(true), + Quiet: aws.Bool(false), }, - MFA: aws.String("MFA"), - RequestPayer: aws.String("RequestPayer"), - } - resp, err := svc.DeleteObjects(params) - - if err != nil { - // 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) -} - -func ExampleS3_GetBucketAccelerateConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketAccelerateConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - } - resp, err := svc.GetBucketAccelerateConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleS3_GetBucketAcl() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketAclInput{ - Bucket: aws.String("BucketName"), // Required - } - resp, err := svc.GetBucketAcl(params) - + result, err := svc.DeleteObjects(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() { + 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 ExampleS3_GetBucketAnalyticsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketAnalyticsConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("AnalyticsId"), // Required - } - resp, err := svc.GetBucketAnalyticsConfiguration(params) - - if err != nil { - // 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) -} - -func ExampleS3_GetBucketCors() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketCorsInput{ - Bucket: aws.String("BucketName"), // Required - } - resp, err := svc.GetBucketCors(params) - - if err != nil { - // 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) -} - -func ExampleS3_GetBucketInventoryConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketInventoryConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("InventoryId"), // Required +// To delete multiple objects from a versioned bucket +// +// The following example deletes objects from a bucket. The bucket is versioned, and +// the request does not specify the object version to delete. In this case, all versions +// remain in the bucket and S3 adds a delete marker. +func ExampleS3_DeleteObjects_shared01() { + svc := s3.New(session.New()) + input := &s3.DeleteObjectsInput{ + Bucket: aws.String("examplebucket"), + Delete: &s3.Delete{ + Objects: []*s3.ObjectIdentifierList{ + { + Key: aws.String("objectkey1"), + }, + { + Key: aws.String("objectkey2"), + }, + }, + Quiet: aws.Bool(false), + }, } - resp, err := svc.GetBucketInventoryConfiguration(params) + result, err := svc.DeleteObjects(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() { + 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 ExampleS3_GetBucketLifecycle() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketLifecycleInput{ - Bucket: aws.String("BucketName"), // Required +// To get cors configuration set on a bucket +// +// The following example returns cross-origin resource sharing (CORS) configuration +// set on a bucket. +func ExampleS3_GetBucketCors_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketCorsInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketLifecycle(params) + result, err := svc.GetBucketCors(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() { + 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 ExampleS3_GetBucketLifecycleConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketLifecycleConfigurationInput{ - Bucket: aws.String("BucketName"), // Required +// To get a bucket acl +// +// The following example gets ACL on the specified bucket. +func ExampleS3_GetBucketLifecycle_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketLifecycleInput{ + Bucket: aws.String("acl1"), } - resp, err := svc.GetBucketLifecycleConfiguration(params) + result, err := svc.GetBucketLifecycle(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() { + 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 ExampleS3_GetBucketLocation() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketLocationInput{ - Bucket: aws.String("BucketName"), // Required +// To get lifecycle configuration on a bucket +// +// The following example retrieves lifecycle configuration on set on a bucket. +func ExampleS3_GetBucketLifecycleConfiguration_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketLifecycleConfigurationInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketLocation(params) + result, err := svc.GetBucketLifecycleConfiguration(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() { + 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 ExampleS3_GetBucketLogging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketLoggingInput{ - Bucket: aws.String("BucketName"), // Required +// To get bucket location +// +// The following example returns bucket location. +func ExampleS3_GetBucketLocation_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketLocationInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketLogging(params) + result, err := svc.GetBucketLocation(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() { + 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 ExampleS3_GetBucketMetricsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketMetricsConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("MetricsId"), // Required +// To get notification configuration set on a bucket +// +// The following example returns notification configuration set on a bucket. +func ExampleS3_GetBucketNotification_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketNotificationConfigurationRequest{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketMetricsConfiguration(params) + result, err := svc.GetBucketNotification(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() { + 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 ExampleS3_GetBucketNotification() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketNotificationConfigurationRequest{ - Bucket: aws.String("BucketName"), // Required +// To get notification configuration set on a bucket +// +// The following example returns notification configuration set on a bucket. +func ExampleS3_GetBucketNotification_shared01() { + svc := s3.New(session.New()) + input := &s3.GetBucketNotificationConfigurationRequest{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketNotification(params) + result, err := svc.GetBucketNotification(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() { + 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 ExampleS3_GetBucketNotificationConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketNotificationConfigurationRequest{ - Bucket: aws.String("BucketName"), // Required +// To get bucket policy +// +// The following example returns bucket policy associated with a bucket. +func ExampleS3_GetBucketPolicy_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketPolicyInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketNotificationConfiguration(params) + result, err := svc.GetBucketPolicy(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() { + 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 ExampleS3_GetBucketPolicy() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketPolicyInput{ - Bucket: aws.String("BucketName"), // Required +// To get replication configuration set on a bucket +// +// The following example returns replication configuration set on a bucket. +func ExampleS3_GetBucketReplication_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketReplicationInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketPolicy(params) + result, err := svc.GetBucketReplication(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() { + 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 ExampleS3_GetBucketReplication() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketReplicationInput{ - Bucket: aws.String("BucketName"), // Required +// To get bucket versioning configuration +// +// The following example retrieves bucket versioning configuration. +func ExampleS3_GetBucketRequestPayment_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketRequestPaymentInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketReplication(params) + result, err := svc.GetBucketRequestPayment(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() { + 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 ExampleS3_GetBucketRequestPayment() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketRequestPaymentInput{ - Bucket: aws.String("BucketName"), // Required +// To get tag set associated with a bucket +// +// The following example returns tag set associated with a bucket +func ExampleS3_GetBucketTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketTaggingInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketRequestPayment(params) + result, err := svc.GetBucketTagging(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() { + 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 ExampleS3_GetBucketTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketTaggingInput{ - Bucket: aws.String("BucketName"), // Required +// To get bucket versioning configuration +// +// The following example retrieves bucket versioning configuration. +func ExampleS3_GetBucketVersioning_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketVersioningInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketTagging(params) + result, err := svc.GetBucketVersioning(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() { + 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 ExampleS3_GetBucketVersioning() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketVersioningInput{ - Bucket: aws.String("BucketName"), // Required +// To get bucket website configuration +// +// The following example retrieves website configuration of a bucket. +func ExampleS3_GetBucketWebsite_shared00() { + svc := s3.New(session.New()) + input := &s3.GetBucketWebsiteInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.GetBucketVersioning(params) + result, err := svc.GetBucketWebsite(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() { + 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 ExampleS3_GetBucketWebsite() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetBucketWebsiteInput{ - Bucket: aws.String("BucketName"), // Required +// To retrieve an object +// +// The following example retrieves an object for an S3 bucket. +func ExampleS3_GetObject_shared00() { + svc := s3.New(session.New()) + input := &s3.GetObjectInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.GetBucketWebsite(params) + result, err := svc.GetObject(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 s3.ErrCodeNoSuchKey: + fmt.Println(s3.ErrCodeNoSuchKey, 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 ExampleS3_GetObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetObjectInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - IfMatch: aws.String("IfMatch"), - IfModifiedSince: aws.Time(time.Now()), - IfNoneMatch: aws.String("IfNoneMatch"), - IfUnmodifiedSince: aws.Time(time.Now()), - PartNumber: aws.Int64(1), - Range: aws.String("Range"), - RequestPayer: aws.String("RequestPayer"), - ResponseCacheControl: aws.String("ResponseCacheControl"), - ResponseContentDisposition: aws.String("ResponseContentDisposition"), - ResponseContentEncoding: aws.String("ResponseContentEncoding"), - ResponseContentLanguage: aws.String("ResponseContentLanguage"), - ResponseContentType: aws.String("ResponseContentType"), - ResponseExpires: aws.Time(time.Now()), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), - VersionId: aws.String("ObjectVersionId"), +// To retrieve a byte range of an object +// +// The following example retrieves an object for an S3 bucket. The request specifies +// the range header to retrieve a specific byte range. +func ExampleS3_GetObject_shared01() { + svc := s3.New(session.New()) + input := &s3.GetObjectInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("SampleFile.txt"), + Range: aws.String("bytes=0-9"), } - resp, err := svc.GetObject(params) + result, err := svc.GetObject(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 s3.ErrCodeNoSuchKey: + fmt.Println(s3.ErrCodeNoSuchKey, 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 ExampleS3_GetObjectAcl() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetObjectAclInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - RequestPayer: aws.String("RequestPayer"), - VersionId: aws.String("ObjectVersionId"), +// To retrieve object ACL +// +// The following example retrieves access control list (ACL) of an object. +func ExampleS3_GetObjectAcl_shared00() { + svc := s3.New(session.New()) + input := &s3.GetObjectAclInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.GetObjectAcl(params) + result, err := svc.GetObjectAcl(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 s3.ErrCodeNoSuchKey: + fmt.Println(s3.ErrCodeNoSuchKey, 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 ExampleS3_GetObjectTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetObjectTaggingInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - VersionId: aws.String("ObjectVersionId"), +// To retrieve tag set of an object +// +// The following example retrieves tag set of an object. +func ExampleS3_GetObjectTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.GetObjectTaggingInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.GetObjectTagging(params) + result, err := svc.GetObjectTagging(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() { + 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 ExampleS3_GetObjectTorrent() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.GetObjectTorrentInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - RequestPayer: aws.String("RequestPayer"), +// To retrieve tag set of a specific object version +// +// The following example retrieves tag set of an object. The request specifies object +// version. +func ExampleS3_GetObjectTagging_shared01() { + svc := s3.New(session.New()) + input := &s3.GetObjectTaggingInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("exampleobject"), + VersionId: aws.String("ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI"), } - resp, err := svc.GetObjectTorrent(params) + result, err := svc.GetObjectTagging(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() { + 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 ExampleS3_HeadBucket() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.HeadBucketInput{ - Bucket: aws.String("BucketName"), // Required +// To retrieve torrent files for an object +// +// The following example retrieves torrent files of an object. +func ExampleS3_GetObjectTorrent_shared00() { + svc := s3.New(session.New()) + input := &s3.GetObjectTorrentInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.HeadBucket(params) + result, err := svc.GetObjectTorrent(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() { + 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 ExampleS3_HeadObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.HeadObjectInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - IfMatch: aws.String("IfMatch"), - IfModifiedSince: aws.Time(time.Now()), - IfNoneMatch: aws.String("IfNoneMatch"), - IfUnmodifiedSince: aws.Time(time.Now()), - PartNumber: aws.Int64(1), - Range: aws.String("Range"), - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), - VersionId: aws.String("ObjectVersionId"), +// To determine if bucket exists +// +// This operation checks to see if a bucket exists. +func ExampleS3_HeadBucket_shared00() { + svc := s3.New(session.New()) + input := &s3.HeadBucketInput{ + Bucket: aws.String("acl1"), } - resp, err := svc.HeadObject(params) + result, err := svc.HeadBucket(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 s3.ErrCodeNoSuchBucket: + fmt.Println(s3.ErrCodeNoSuchBucket, 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 ExampleS3_ListBucketAnalyticsConfigurations() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListBucketAnalyticsConfigurationsInput{ - Bucket: aws.String("BucketName"), // Required - ContinuationToken: aws.String("Token"), +// To retrieve metadata of an object without returning the object itself +// +// The following example retrieves an object metadata. +func ExampleS3_HeadObject_shared00() { + svc := s3.New(session.New()) + input := &s3.HeadObjectInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.ListBucketAnalyticsConfigurations(params) + result, err := svc.HeadObject(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() { + 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 ExampleS3_ListBucketInventoryConfigurations() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListBucketInventoryConfigurationsInput{ - Bucket: aws.String("BucketName"), // Required - ContinuationToken: aws.String("Token"), - } - resp, err := svc.ListBucketInventoryConfigurations(params) +// To list object versions +// +// The following example return versions of an object with specific key name prefix. +// The request limits the number of items returned to two. If there are are more than +// two object version, S3 returns NextToken in the response. You can specify this token +// value in your next request to fetch next set of object versions. +func ExampleS3_ListBuckets_shared00() { + svc := s3.New(session.New()) + input := &s3.ListBucketsInput{} + result, err := svc.ListBuckets(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() { + 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 ExampleS3_ListBucketMetricsConfigurations() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListBucketMetricsConfigurationsInput{ - Bucket: aws.String("BucketName"), // Required - ContinuationToken: aws.String("Token"), +// To list in-progress multipart uploads on a bucket +// +// The following example lists in-progress multipart uploads on a specific bucket. +func ExampleS3_ListMultipartUploads_shared00() { + svc := s3.New(session.New()) + input := &s3.ListMultipartUploadsInput{ + Bucket: aws.String("examplebucket"), } - resp, err := svc.ListBucketMetricsConfigurations(params) + result, err := svc.ListMultipartUploads(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() { + 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 ExampleS3_ListBuckets() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - var params *s3.ListBucketsInput - resp, err := svc.ListBuckets(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) - return +// List next set of multipart uploads when previous result is truncated +// +// The following example specifies the upload-id-marker and key-marker from previous +// truncated response to retrieve next setup of multipart uploads. +func ExampleS3_ListMultipartUploads_shared01() { + svc := s3.New(session.New()) + input := &s3.ListMultipartUploadsInput{ + Bucket: aws.String("examplebucket"), + KeyMarker: aws.String("nextkeyfrompreviousresponse"), + MaxUploads: aws.Int64(2), + UploadIdMarker: aws.String("valuefrompreviousresponse"), } - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleS3_ListMultipartUploads() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListMultipartUploadsInput{ - Bucket: aws.String("BucketName"), // Required - Delimiter: aws.String("Delimiter"), - EncodingType: aws.String("EncodingType"), - KeyMarker: aws.String("KeyMarker"), - MaxUploads: aws.Int64(1), - Prefix: aws.String("Prefix"), - UploadIdMarker: aws.String("UploadIdMarker"), - } - resp, err := svc.ListMultipartUploads(params) - + result, err := svc.ListMultipartUploads(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() { + 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 ExampleS3_ListObjectVersions() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListObjectVersionsInput{ - Bucket: aws.String("BucketName"), // Required - Delimiter: aws.String("Delimiter"), - EncodingType: aws.String("EncodingType"), - KeyMarker: aws.String("KeyMarker"), - MaxKeys: aws.Int64(1), - Prefix: aws.String("Prefix"), - VersionIdMarker: aws.String("VersionIdMarker"), +// To list object versions +// +// The following example return versions of an object with specific key name prefix. +// The request limits the number of items returned to two. If there are are more than +// two object version, S3 returns NextToken in the response. You can specify this token +// value in your next request to fetch next set of object versions. +func ExampleS3_ListObjectVersions_shared00() { + svc := s3.New(session.New()) + input := &s3.ListObjectVersionsInput{ + Bucket: aws.String("examplebucket"), + Prefix: aws.String("HappyFace.jpg"), } - resp, err := svc.ListObjectVersions(params) + result, err := svc.ListObjectVersions(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() { + 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 ExampleS3_ListObjects() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListObjectsInput{ - Bucket: aws.String("BucketName"), // Required - Delimiter: aws.String("Delimiter"), - EncodingType: aws.String("EncodingType"), - Marker: aws.String("Marker"), - MaxKeys: aws.Int64(1), - Prefix: aws.String("Prefix"), - RequestPayer: aws.String("RequestPayer"), +// To list objects in a bucket +// +// The following example list two objects in a bucket. +func ExampleS3_ListObjects_shared00() { + svc := s3.New(session.New()) + input := &s3.ListObjectsInput{ + Bucket: aws.String("examplebucket"), + MaxKeys: aws.Int64(2), } - resp, err := svc.ListObjects(params) + result, err := svc.ListObjects(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 s3.ErrCodeNoSuchBucket: + fmt.Println(s3.ErrCodeNoSuchBucket, 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 ExampleS3_ListObjectsV2() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListObjectsV2Input{ - Bucket: aws.String("BucketName"), // Required - ContinuationToken: aws.String("Token"), - Delimiter: aws.String("Delimiter"), - EncodingType: aws.String("EncodingType"), - FetchOwner: aws.Bool(true), - MaxKeys: aws.Int64(1), - Prefix: aws.String("Prefix"), - RequestPayer: aws.String("RequestPayer"), - StartAfter: aws.String("StartAfter"), +// To get object list +// +// The following example retrieves object list. The request specifies max keys to limit +// response to include only 2 object keys. +func ExampleS3_ListObjectsV2_shared00() { + svc := s3.New(session.New()) + input := &s3.ListObjectsV2Input{ + Bucket: aws.String("examplebucket"), + MaxKeys: aws.Int64(2), } - resp, err := svc.ListObjectsV2(params) + result, err := svc.ListObjectsV2(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 s3.ErrCodeNoSuchBucket: + fmt.Println(s3.ErrCodeNoSuchBucket, 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 ExampleS3_ListParts() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.ListPartsInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - UploadId: aws.String("MultipartUploadId"), // Required - MaxParts: aws.Int64(1), - PartNumberMarker: aws.Int64(1), - RequestPayer: aws.String("RequestPayer"), +// To list parts of a multipart upload. +// +// The following example lists parts uploaded for a specific multipart upload. +func ExampleS3_ListParts_shared00() { + svc := s3.New(session.New()) + input := &s3.ListPartsInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("bigobject"), + UploadId: aws.String("example7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--"), } - resp, err := svc.ListParts(params) + result, err := svc.ListParts(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() { + 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 ExampleS3_PutBucketAccelerateConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketAccelerateConfigurationInput{ - AccelerateConfiguration: &s3.AccelerateConfiguration{ // Required - Status: aws.String("BucketAccelerateStatus"), - }, - Bucket: aws.String("BucketName"), // Required +// Put bucket acl +// +// The following example replaces existing ACL on a bucket. The ACL grants the bucket +// owner (specified using the owner ID) and write permission to the LogDelivery group. +// Because this is a replace operation, you must specify all the grants in your request. +// To incrementally add or remove ACL grants, you might use the console. +func ExampleS3_PutBucketAcl_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketAclInput{ + Bucket: aws.String("examplebucket"), + GrantFullControl: aws.String("id=examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484"), + GrantWrite: aws.String("uri=http://acs.amazonaws.com/groups/s3/LogDelivery"), } - resp, err := svc.PutBucketAccelerateConfiguration(params) + result, err := svc.PutBucketAcl(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() { + 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 ExampleS3_PutBucketAcl() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketAclInput{ - Bucket: aws.String("BucketName"), // Required - ACL: aws.String("BucketCannedACL"), - AccessControlPolicy: &s3.AccessControlPolicy{ - Grants: []*s3.Grant{ - { // Required - Grantee: &s3.Grantee{ - Type: aws.String("Type"), // Required - DisplayName: aws.String("DisplayName"), - EmailAddress: aws.String("EmailAddress"), - ID: aws.String("ID"), - URI: aws.String("URI"), +// To set cors configuration on a bucket. +// +// The following example enables PUT, POST, and DELETE requests from www.example.com, +// and enables GET requests from any domain. +func ExampleS3_PutBucketCors_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketCorsInput{ + Bucket: aws.String(""), + CORSConfiguration: &s3.CORSConfiguration{ + CORSRules: []*s3.CORSRules{ + { + AllowedHeaders: []*string{ + aws.String("*"), + }, + AllowedMethods: []*string{ + aws.String("PUT"), + aws.String("POST"), + aws.String("DELETE"), + }, + AllowedOrigins: []*string{ + aws.String("http://www.example.com"), + }, + ExposeHeaders: []*string{ + aws.String("x-amz-server-side-encryption"), }, - Permission: aws.String("Permission"), + MaxAgeSeconds: aws.Float64(3000.000000), + }, + { + AllowedHeaders: []*string{ + aws.String("Authorization"), + }, + AllowedMethods: []*string{ + aws.String("GET"), + }, + AllowedOrigins: []*string{ + aws.String("*"), + }, + MaxAgeSeconds: aws.Float64(3000.000000), }, - // More values... - }, - Owner: &s3.Owner{ - DisplayName: aws.String("DisplayName"), - ID: aws.String("ID"), }, }, - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWrite: aws.String("GrantWrite"), - GrantWriteACP: aws.String("GrantWriteACP"), + ContentMD5: aws.String(""), } - resp, err := svc.PutBucketAcl(params) + result, err := svc.PutBucketCors(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() { + 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 ExampleS3_PutBucketAnalyticsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketAnalyticsConfigurationInput{ - AnalyticsConfiguration: &s3.AnalyticsConfiguration{ // Required - Id: aws.String("AnalyticsId"), // Required - StorageClassAnalysis: &s3.StorageClassAnalysis{ // Required - DataExport: &s3.StorageClassAnalysisDataExport{ - Destination: &s3.AnalyticsExportDestination{ // Required - S3BucketDestination: &s3.AnalyticsS3BucketDestination{ // Required - Bucket: aws.String("BucketName"), // Required - Format: aws.String("AnalyticsS3ExportFileFormat"), // Required - BucketAccountId: aws.String("AccountId"), - Prefix: aws.String("Prefix"), - }, - }, - OutputSchemaVersion: aws.String("StorageClassAnalysisSchemaVersion"), // Required - }, - }, - Filter: &s3.AnalyticsFilter{ - And: &s3.AnalyticsAndOperator{ - Prefix: aws.String("Prefix"), - Tags: []*s3.Tag{ - { // Required - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required +// Put bucket lifecycle +// +// The following example replaces existing lifecycle configuration, if any, on the specified +// bucket. +func ExampleS3_PutBucketLifecycleConfiguration_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketLifecycleConfigurationInput{ + Bucket: aws.String("examplebucket"), + LifecycleConfiguration: &s3.BucketLifecycleConfiguration{ + Rules: []*s3.LifecycleRules{ + { + ID: aws.String("TestOnly"), + Status: aws.String("Enabled"), + Transitions: []*s3.LifecycleRule{ + { + Days: aws.Float64(365.000000), + StorageClass: aws.String("GLACIER"), }, - // More values... }, }, - Prefix: aws.String("Prefix"), - Tag: &s3.Tag{ - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required - }, }, }, - Bucket: aws.String("BucketName"), // Required - Id: aws.String("AnalyticsId"), // Required } - resp, err := svc.PutBucketAnalyticsConfiguration(params) + result, err := svc.PutBucketLifecycleConfiguration(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() { + 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 ExampleS3_PutBucketCors() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketCorsInput{ - Bucket: aws.String("BucketName"), // Required - CORSConfiguration: &s3.CORSConfiguration{ // Required - CORSRules: []*s3.CORSRule{ // Required - { // Required - AllowedMethods: []*string{ // Required - aws.String("AllowedMethod"), // Required - // More values... - }, - AllowedOrigins: []*string{ // Required - aws.String("AllowedOrigin"), // Required - // More values... - }, - AllowedHeaders: []*string{ - aws.String("AllowedHeader"), // Required - // More values... - }, - ExposeHeaders: []*string{ - aws.String("ExposeHeader"), // Required - // More values... +// Set logging configuration for a bucket +// +// The following example sets logging policy on a bucket. For the Log Delivery group +// to deliver logs to the destination bucket, it needs permission for the READ_ACP action +// which the policy grants. +func ExampleS3_PutBucketLogging_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketLoggingInput{ + Bucket: aws.String("sourcebucket"), + BucketLoggingStatus: &s3.BucketLoggingStatus{ + LoggingEnabled: &s3.LoggingEnabled{ + TargetBucket: aws.String("targetbucket"), + TargetGrants: []*s3.TargetGrants{ + { + Permission: aws.String("READ"), }, - MaxAgeSeconds: aws.Int64(1), }, - // More values... + TargetPrefix: aws.String("MyBucketLogs/"), }, }, } - resp, err := svc.PutBucketCors(params) + result, err := svc.PutBucketLogging(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() { + 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 ExampleS3_PutBucketInventoryConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketInventoryConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("InventoryId"), // Required - InventoryConfiguration: &s3.InventoryConfiguration{ // Required - Destination: &s3.InventoryDestination{ // Required - S3BucketDestination: &s3.InventoryS3BucketDestination{ // Required - Bucket: aws.String("BucketName"), // Required - Format: aws.String("InventoryFormat"), // Required - AccountId: aws.String("AccountId"), - Prefix: aws.String("Prefix"), +// Set notification configuration for a bucket +// +// The following example sets notification configuration on a bucket to publish the +// object created events to an SNS topic. +func ExampleS3_PutBucketNotificationConfiguration_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketNotificationConfigurationInput{ + Bucket: aws.String("examplebucket"), + NotificationConfiguration: &s3.NotificationConfiguration{ + TopicConfigurations: []*s3.TopicConfigurationList{ + { + Events: []*string{ + aws.String("s3:ObjectCreated:*"), + }, + TopicArn: aws.String("arn:aws:sns:us-west-2:123456789012:s3-notification-topic"), }, }, - Id: aws.String("InventoryId"), // Required - IncludedObjectVersions: aws.String("InventoryIncludedObjectVersions"), // Required - IsEnabled: aws.Bool(true), // Required - Schedule: &s3.InventorySchedule{ // Required - Frequency: aws.String("InventoryFrequency"), // Required - }, - Filter: &s3.InventoryFilter{ - Prefix: aws.String("Prefix"), // Required - }, - OptionalFields: []*string{ - aws.String("InventoryOptionalField"), // Required - // More values... - }, }, } - resp, err := svc.PutBucketInventoryConfiguration(params) + result, err := svc.PutBucketNotificationConfiguration(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() { + 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 ExampleS3_PutBucketLifecycle() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketLifecycleInput{ - Bucket: aws.String("BucketName"), // Required - LifecycleConfiguration: &s3.LifecycleConfiguration{ - Rules: []*s3.Rule{ // Required - { // Required - Prefix: aws.String("Prefix"), // Required - Status: aws.String("ExpirationStatus"), // Required - AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{ - DaysAfterInitiation: aws.Int64(1), - }, - Expiration: &s3.LifecycleExpiration{ - Date: aws.Time(time.Now()), - Days: aws.Int64(1), - ExpiredObjectDeleteMarker: aws.Bool(true), - }, - ID: aws.String("ID"), - NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{ - NoncurrentDays: aws.Int64(1), - }, - NoncurrentVersionTransition: &s3.NoncurrentVersionTransition{ - NoncurrentDays: aws.Int64(1), - StorageClass: aws.String("TransitionStorageClass"), - }, - Transition: &s3.Transition{ - Date: aws.Time(time.Now()), - Days: aws.Int64(1), - StorageClass: aws.String("TransitionStorageClass"), - }, - }, - // More values... - }, - }, +// Set bucket policy +// +// The following example sets a permission policy on a bucket. +func ExampleS3_PutBucketPolicy_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketPolicyInput{ + Bucket: aws.String("examplebucket"), + Policy: aws.String("{\"Version\": \"2012-10-17\", \"Statement\": [{ \"Sid\": \"id-1\",\"Effect\": \"Allow\",\"Principal\": {\"AWS\": \"arn:aws:iam::123456789012:root\"}, \"Action\": [ \"s3:PutObject\",\"s3:PutObjectAcl\"], \"Resource\": [\"arn:aws:s3:::acl3/*\" ] } ]}"), } - resp, err := svc.PutBucketLifecycle(params) + result, err := svc.PutBucketPolicy(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() { + 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 ExampleS3_PutBucketLifecycleConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketLifecycleConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - LifecycleConfiguration: &s3.BucketLifecycleConfiguration{ - Rules: []*s3.LifecycleRule{ // Required - { // Required - Status: aws.String("ExpirationStatus"), // Required - AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{ - DaysAfterInitiation: aws.Int64(1), - }, - Expiration: &s3.LifecycleExpiration{ - Date: aws.Time(time.Now()), - Days: aws.Int64(1), - ExpiredObjectDeleteMarker: aws.Bool(true), - }, - Filter: &s3.LifecycleRuleFilter{ - And: &s3.LifecycleRuleAndOperator{ - Prefix: aws.String("Prefix"), - Tags: []*s3.Tag{ - { // Required - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required - }, - // More values... - }, - }, - Prefix: aws.String("Prefix"), - Tag: &s3.Tag{ - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required - }, - }, - ID: aws.String("ID"), - NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{ - NoncurrentDays: aws.Int64(1), - }, - NoncurrentVersionTransitions: []*s3.NoncurrentVersionTransition{ - { // Required - NoncurrentDays: aws.Int64(1), - StorageClass: aws.String("TransitionStorageClass"), - }, - // More values... - }, - Prefix: aws.String("Prefix"), - Transitions: []*s3.Transition{ - { // Required - Date: aws.Time(time.Now()), - Days: aws.Int64(1), - StorageClass: aws.String("TransitionStorageClass"), - }, - // More values... - }, +// Set replication configuration on a bucket +// +// The following example sets replication configuration on a bucket. +func ExampleS3_PutBucketReplication_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketReplicationInput{ + Bucket: aws.String("examplebucket"), + ReplicationConfiguration: &s3.ReplicationConfiguration{ + Role: aws.String("arn:aws:iam::123456789012:role/examplerole"), + Rules: []*s3.ReplicationRules{ + { + Prefix: aws.String(""), + Status: aws.String("Enabled"), }, - // More values... }, }, } - resp, err := svc.PutBucketLifecycleConfiguration(params) + result, err := svc.PutBucketReplication(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() { + 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 ExampleS3_PutBucketLogging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketLoggingInput{ - Bucket: aws.String("BucketName"), // Required - BucketLoggingStatus: &s3.BucketLoggingStatus{ // Required - LoggingEnabled: &s3.LoggingEnabled{ - TargetBucket: aws.String("TargetBucket"), - TargetGrants: []*s3.TargetGrant{ - { // Required - Grantee: &s3.Grantee{ - Type: aws.String("Type"), // Required - DisplayName: aws.String("DisplayName"), - EmailAddress: aws.String("EmailAddress"), - ID: aws.String("ID"), - URI: aws.String("URI"), - }, - Permission: aws.String("BucketLogsPermission"), - }, - // More values... - }, - TargetPrefix: aws.String("TargetPrefix"), - }, +// Set request payment configuration on a bucket. +// +// The following example sets request payment configuration on a bucket so that person +// requesting the download is charged. +func ExampleS3_PutBucketRequestPayment_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketRequestPaymentInput{ + Bucket: aws.String("examplebucket"), + RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ + Payer: aws.String("Requester"), }, } - resp, err := svc.PutBucketLogging(params) + result, err := svc.PutBucketRequestPayment(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() { + 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 ExampleS3_PutBucketMetricsConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketMetricsConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - Id: aws.String("MetricsId"), // Required - MetricsConfiguration: &s3.MetricsConfiguration{ // Required - Id: aws.String("MetricsId"), // Required - Filter: &s3.MetricsFilter{ - And: &s3.MetricsAndOperator{ - Prefix: aws.String("Prefix"), - Tags: []*s3.Tag{ - { // Required - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required - }, - // More values... - }, +// Set tags on a bucket +// +// The following example sets tags on a bucket. Any existing tags are replaced. +func ExampleS3_PutBucketTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketTaggingInput{ + Bucket: aws.String("examplebucket"), + Tagging: &s3.Tagging{ + TagSet: []*s3.TagSet{ + { + Key: aws.String("Key1"), + Value: aws.String("Value1"), }, - Prefix: aws.String("Prefix"), - Tag: &s3.Tag{ - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required + { + Key: aws.String("Key2"), + Value: aws.String("Value2"), }, }, }, } - resp, err := svc.PutBucketMetricsConfiguration(params) + result, err := svc.PutBucketTagging(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() { + 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 ExampleS3_PutBucketNotification() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketNotificationInput{ - Bucket: aws.String("BucketName"), // Required - NotificationConfiguration: &s3.NotificationConfigurationDeprecated{ // Required - CloudFunctionConfiguration: &s3.CloudFunctionConfiguration{ - CloudFunction: aws.String("CloudFunction"), - Event: aws.String("Event"), - Events: []*string{ - aws.String("Event"), // Required - // More values... - }, - Id: aws.String("NotificationId"), - InvocationRole: aws.String("CloudFunctionInvocationRole"), - }, - QueueConfiguration: &s3.QueueConfigurationDeprecated{ - Event: aws.String("Event"), - Events: []*string{ - aws.String("Event"), // Required - // More values... - }, - Id: aws.String("NotificationId"), - Queue: aws.String("QueueArn"), - }, - TopicConfiguration: &s3.TopicConfigurationDeprecated{ - Event: aws.String("Event"), - Events: []*string{ - aws.String("Event"), // Required - // More values... - }, - Id: aws.String("NotificationId"), - Topic: aws.String("TopicArn"), - }, +// Set versioning configuration on a bucket +// +// The following example sets versioning configuration on bucket. The configuration +// enables versioning on the bucket. +func ExampleS3_PutBucketVersioning_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketVersioningInput{ + Bucket: aws.String("examplebucket"), + VersioningConfiguration: &s3.VersioningConfiguration{ + MFADelete: aws.String("Disabled"), + Status: aws.String("Enabled"), }, } - resp, err := svc.PutBucketNotification(params) + result, err := svc.PutBucketVersioning(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() { + 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 ExampleS3_PutBucketNotificationConfiguration() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketNotificationConfigurationInput{ - Bucket: aws.String("BucketName"), // Required - NotificationConfiguration: &s3.NotificationConfiguration{ // Required - LambdaFunctionConfigurations: []*s3.LambdaFunctionConfiguration{ - { // Required - Events: []*string{ // Required - aws.String("Event"), // Required - // More values... - }, - LambdaFunctionArn: aws.String("LambdaFunctionArn"), // Required - Filter: &s3.NotificationConfigurationFilter{ - Key: &s3.KeyFilter{ - FilterRules: []*s3.FilterRule{ - { // Required - Name: aws.String("FilterRuleName"), - Value: aws.String("FilterRuleValue"), - }, - // More values... - }, - }, - }, - Id: aws.String("NotificationId"), - }, - // More values... - }, - QueueConfigurations: []*s3.QueueConfiguration{ - { // Required - Events: []*string{ // Required - aws.String("Event"), // Required - // More values... - }, - QueueArn: aws.String("QueueArn"), // Required - Filter: &s3.NotificationConfigurationFilter{ - Key: &s3.KeyFilter{ - FilterRules: []*s3.FilterRule{ - { // Required - Name: aws.String("FilterRuleName"), - Value: aws.String("FilterRuleValue"), - }, - // More values... - }, - }, - }, - Id: aws.String("NotificationId"), - }, - // More values... +// Set website configuration on a bucket +// +// The following example adds website configuration to a bucket. +func ExampleS3_PutBucketWebsite_shared00() { + svc := s3.New(session.New()) + input := &s3.PutBucketWebsiteInput{ + Bucket: aws.String("examplebucket"), + ContentMD5: aws.String(""), + WebsiteConfiguration: &s3.WebsiteConfiguration{ + ErrorDocument: &s3.ErrorDocument{ + Key: aws.String("error.html"), }, - TopicConfigurations: []*s3.TopicConfiguration{ - { // Required - Events: []*string{ // Required - aws.String("Event"), // Required - // More values... - }, - TopicArn: aws.String("TopicArn"), // Required - Filter: &s3.NotificationConfigurationFilter{ - Key: &s3.KeyFilter{ - FilterRules: []*s3.FilterRule{ - { // Required - Name: aws.String("FilterRuleName"), - Value: aws.String("FilterRuleValue"), - }, - // More values... - }, - }, - }, - Id: aws.String("NotificationId"), - }, - // More values... + IndexDocument: &s3.IndexDocument{ + Suffix: aws.String("index.html"), }, }, } - resp, err := svc.PutBucketNotificationConfiguration(params) + result, err := svc.PutBucketWebsite(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() { + 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 ExampleS3_PutBucketPolicy() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketPolicyInput{ - Bucket: aws.String("BucketName"), // Required - Policy: aws.String("Policy"), // Required +// To upload an object and specify server-side encryption and object tags +// +// The following example uploads and object. The request specifies the optional server-side +// encryption option. The request also specifies optional object tags. If the bucket +// is versioning enabled, S3 returns version ID in response. +func ExampleS3_PutObject_shared00() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("filetoupload"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("exampleobject"), + ServerSideEncryption: aws.String("AES256"), + Tagging: aws.String("key1=value1&key2=value2"), } - resp, err := svc.PutBucketPolicy(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutBucketReplication() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketReplicationInput{ - Bucket: aws.String("BucketName"), // Required - ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required - Role: aws.String("Role"), // Required - Rules: []*s3.ReplicationRule{ // Required - { // Required - Destination: &s3.Destination{ // Required - Bucket: aws.String("BucketName"), // Required - StorageClass: aws.String("StorageClass"), - }, - Prefix: aws.String("Prefix"), // Required - Status: aws.String("ReplicationRuleStatus"), // Required - ID: aws.String("ID"), - }, - // More values... - }, - }, +// To upload an object and specify canned ACL. +// +// The following example uploads and object. The request specifies optional canned ACL +// (access control list) to all READ access to authenticated users. If the bucket is +// versioning enabled, S3 returns version ID in response. +func ExampleS3_PutObject_shared01() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + ACL: aws.String("authenticated-read"), + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("filetoupload"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("exampleobject"), } - resp, err := svc.PutBucketReplication(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutBucketRequestPayment() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketRequestPaymentInput{ - Bucket: aws.String("BucketName"), // Required - RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ // Required - Payer: aws.String("Payer"), // Required - }, +// To upload an object +// +// The following example uploads an object to a versioning-enabled bucket. The source +// file is specified using Windows file syntax. S3 returns VersionId of the newly created +// object. +func ExampleS3_PutObject_shared02() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("HappyFace.jpg"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.PutBucketRequestPayment(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutBucketTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketTaggingInput{ - Bucket: aws.String("BucketName"), // Required - Tagging: &s3.Tagging{ // Required - TagSet: []*s3.Tag{ // Required - { // Required - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required - }, - // More values... - }, - }, +// To create an object. +// +// The following example creates an object. If the bucket is versioning enabled, S3 +// returns version ID in response. +func ExampleS3_PutObject_shared03() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("filetoupload"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("objectkey"), } - resp, err := svc.PutBucketTagging(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutBucketVersioning() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketVersioningInput{ - Bucket: aws.String("BucketName"), // Required - VersioningConfiguration: &s3.VersioningConfiguration{ // Required - MFADelete: aws.String("MFADelete"), - Status: aws.String("BucketVersioningStatus"), - }, - MFA: aws.String("MFA"), +// To upload an object and specify optional tags +// +// The following example uploads an object. The request specifies optional object tags. +// The bucket is versioned, therefore S3 returns version ID of the newly created object. +func ExampleS3_PutObject_shared04() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("c:\\HappyFace.jpg"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), + Tagging: aws.String("key1=value1&key2=value2"), } - resp, err := svc.PutBucketVersioning(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutBucketWebsite() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutBucketWebsiteInput{ - Bucket: aws.String("BucketName"), // Required - WebsiteConfiguration: &s3.WebsiteConfiguration{ // Required - ErrorDocument: &s3.ErrorDocument{ - Key: aws.String("ObjectKey"), // Required - }, - IndexDocument: &s3.IndexDocument{ - Suffix: aws.String("Suffix"), // Required - }, - RedirectAllRequestsTo: &s3.RedirectAllRequestsTo{ - HostName: aws.String("HostName"), // Required - Protocol: aws.String("Protocol"), - }, - RoutingRules: []*s3.RoutingRule{ - { // Required - Redirect: &s3.Redirect{ // Required - HostName: aws.String("HostName"), - HttpRedirectCode: aws.String("HttpRedirectCode"), - Protocol: aws.String("Protocol"), - ReplaceKeyPrefixWith: aws.String("ReplaceKeyPrefixWith"), - ReplaceKeyWith: aws.String("ReplaceKeyWith"), - }, - Condition: &s3.Condition{ - HttpErrorCodeReturnedEquals: aws.String("HttpErrorCodeReturnedEquals"), - KeyPrefixEquals: aws.String("KeyPrefixEquals"), - }, - }, - // More values... - }, +// To upload object and specify user-defined metadata +// +// The following example creates an object. The request also specifies optional metadata. +// If the bucket is versioning enabled, S3 returns version ID in response. +func ExampleS3_PutObject_shared05() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("filetoupload"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("exampleobject"), + Metadata: map[string]*string{ + "metadata1": aws.String("value1"), + "metadata2": aws.String("value2"), }, } - resp, err := svc.PutBucketWebsite(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutObjectInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - ACL: aws.String("ObjectCannedACL"), - Body: bytes.NewReader([]byte("PAYLOAD")), - CacheControl: aws.String("CacheControl"), - ContentDisposition: aws.String("ContentDisposition"), - ContentEncoding: aws.String("ContentEncoding"), - ContentLanguage: aws.String("ContentLanguage"), - ContentLength: aws.Int64(1), - ContentType: aws.String("ContentType"), - Expires: aws.Time(time.Now()), - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWriteACP: aws.String("GrantWriteACP"), - Metadata: map[string]*string{ - "Key": aws.String("MetadataValue"), // Required - // More values... - }, - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), - SSEKMSKeyId: aws.String("SSEKMSKeyId"), - ServerSideEncryption: aws.String("ServerSideEncryption"), - StorageClass: aws.String("StorageClass"), - Tagging: aws.String("TaggingHeader"), - WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"), +// To upload an object (specify optional headers) +// +// The following example uploads an object. The request specifies optional request headers +// to directs S3 to use specific storage class and use server-side encryption. +func ExampleS3_PutObject_shared06() { + svc := s3.New(session.New()) + input := &s3.PutObjectInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("HappyFace.jpg"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), + ServerSideEncryption: aws.String("AES256"), + StorageClass: aws.String("STANDARD_IA"), } - resp, err := svc.PutObject(params) + result, err := svc.PutObject(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() { + 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 ExampleS3_PutObjectAcl() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutObjectAclInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - ACL: aws.String("ObjectCannedACL"), - AccessControlPolicy: &s3.AccessControlPolicy{ - Grants: []*s3.Grant{ - { // Required - Grantee: &s3.Grantee{ - Type: aws.String("Type"), // Required - DisplayName: aws.String("DisplayName"), - EmailAddress: aws.String("EmailAddress"), - ID: aws.String("ID"), - URI: aws.String("URI"), - }, - Permission: aws.String("Permission"), - }, - // More values... - }, - Owner: &s3.Owner{ - DisplayName: aws.String("DisplayName"), - ID: aws.String("ID"), - }, - }, - GrantFullControl: aws.String("GrantFullControl"), - GrantRead: aws.String("GrantRead"), - GrantReadACP: aws.String("GrantReadACP"), - GrantWrite: aws.String("GrantWrite"), - GrantWriteACP: aws.String("GrantWriteACP"), - RequestPayer: aws.String("RequestPayer"), - VersionId: aws.String("ObjectVersionId"), +// To grant permissions using object ACL +// +// The following example adds grants to an object ACL. The first permission grants user1 +// and user2 FULL_CONTROL and the AllUsers group READ permission. +func ExampleS3_PutObjectAcl_shared00() { + svc := s3.New(session.New()) + input := &s3.PutObjectAclInput{ + AccessControlPolicy: &s3.AccessControlPolicy{}, + Bucket: aws.String("examplebucket"), + GrantFullControl: aws.String("emailaddress=user1@example.com,emailaddress=user2@example.com"), + GrantRead: aws.String("uri=http://acs.amazonaws.com/groups/global/AllUsers"), + Key: aws.String("HappyFace.jpg"), } - resp, err := svc.PutObjectAcl(params) + result, err := svc.PutObjectAcl(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 s3.ErrCodeNoSuchKey: + fmt.Println(s3.ErrCodeNoSuchKey, 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 ExampleS3_PutObjectTagging() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.PutObjectTaggingInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - Tagging: &s3.Tagging{ // Required - TagSet: []*s3.Tag{ // Required - { // Required - Key: aws.String("ObjectKey"), // Required - Value: aws.String("Value"), // Required +// To add tags to an existing object +// +// The following example adds tags to an existing object. +func ExampleS3_PutObjectTagging_shared00() { + svc := s3.New(session.New()) + input := &s3.PutObjectTaggingInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("HappyFace.jpg"), + Tagging: &s3.Tagging{ + TagSet: []*s3.TagSet{ + { + Key: aws.String("Key3"), + Value: aws.String("Value3"), + }, + { + Key: aws.String("Key4"), + Value: aws.String("Value4"), }, - // More values... }, }, - VersionId: aws.String("ObjectVersionId"), } - resp, err := svc.PutObjectTagging(params) + result, err := svc.PutObjectTagging(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() { + 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 ExampleS3_RestoreObject() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.RestoreObjectInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - RequestPayer: aws.String("RequestPayer"), +// To restore an archived object +// +// The following example restores for one day an archived copy of an object back into +// Amazon S3 bucket. +func ExampleS3_RestoreObject_shared00() { + svc := s3.New(session.New()) + input := &s3.RestoreObjectInput{ + Bucket: aws.String("examplebucket"), + Key: aws.String("archivedobjectkey"), RestoreRequest: &s3.RestoreRequest{ - Days: aws.Int64(1), // Required + Days: aws.Int64(1.000000), GlacierJobParameters: &s3.GlacierJobParameters{ - Tier: aws.String("Tier"), // Required + Tier: aws.String("Expedited"), }, }, - VersionId: aws.String("ObjectVersionId"), } - resp, err := svc.RestoreObject(params) + result, err := svc.RestoreObject(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 s3.ErrCodeObjectAlreadyInActiveTierError: + fmt.Println(s3.ErrCodeObjectAlreadyInActiveTierError, 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 ExampleS3_UploadPart() { - sess := session.Must(session.NewSession()) - - svc := s3.New(sess) - - params := &s3.UploadPartInput{ - Bucket: aws.String("BucketName"), // Required - Key: aws.String("ObjectKey"), // Required - PartNumber: aws.Int64(1), // Required - UploadId: aws.String("MultipartUploadId"), // Required - Body: bytes.NewReader([]byte("PAYLOAD")), - ContentLength: aws.Int64(1), - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), +// To upload a part +// +// The following example uploads part 1 of a multipart upload. The example specifies +// a file name for the part data. The Upload ID is same that is returned by the initiate +// multipart upload. +func ExampleS3_UploadPart_shared00() { + svc := s3.New(session.New()) + input := &s3.UploadPartInput{ + Body: aws.ReadSeekCloser(bytes.NewBuffer([]byte("fileToUpload"))), + Bucket: aws.String("examplebucket"), + Key: aws.String("examplelargeobject"), + PartNumber: aws.Int64(1), + UploadId: aws.String("xadcOB_7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--"), } - resp, err := svc.UploadPart(params) + result, err := svc.UploadPart(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() { + 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 ExampleS3_UploadPartCopy() { - sess := session.Must(session.NewSession()) +// To upload a part by copying byte range from an existing object as data source +// +// The following example uploads a part of a multipart upload by copying a specified +// byte range from an existing object as data source. +func ExampleS3_UploadPartCopy_shared00() { + svc := s3.New(session.New()) + input := &s3.UploadPartCopyInput{ + Bucket: aws.String("examplebucket"), + CopySource: aws.String("/bucketname/sourceobjectkey"), + CopySourceRange: aws.String("bytes=1-100000"), + Key: aws.String("examplelargeobject"), + PartNumber: aws.Int64(2), + UploadId: aws.String("exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--"), + } - svc := s3.New(sess) + result, err := svc.UploadPartCopy(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + 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) +} - params := &s3.UploadPartCopyInput{ - Bucket: aws.String("BucketName"), // Required - CopySource: aws.String("CopySource"), // Required - Key: aws.String("ObjectKey"), // Required - PartNumber: aws.Int64(1), // Required - UploadId: aws.String("MultipartUploadId"), // Required - CopySourceIfMatch: aws.String("CopySourceIfMatch"), - CopySourceIfModifiedSince: aws.Time(time.Now()), - CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"), - CopySourceIfUnmodifiedSince: aws.Time(time.Now()), - CopySourceRange: aws.String("CopySourceRange"), - CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"), - CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"), - CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"), - RequestPayer: aws.String("RequestPayer"), - SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"), - SSECustomerKey: aws.String("SSECustomerKey"), - SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"), +// To upload a part by copying data from an existing object as data source +// +// The following example uploads a part of a multipart upload by copying data from an +// existing object as data source. +func ExampleS3_UploadPartCopy_shared01() { + svc := s3.New(session.New()) + input := &s3.UploadPartCopyInput{ + Bucket: aws.String("examplebucket"), + CopySource: aws.String("bucketname/sourceobjectkey"), + Key: aws.String("examplelargeobject"), + PartNumber: aws.Int64(1), + UploadId: aws.String("exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--"), } - resp, err := svc.UploadPartCopy(params) + result, err := svc.UploadPartCopy(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() { + 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) } diff --git a/service/servicecatalog/examples_test.go b/service/servicecatalog/examples_test.go deleted file mode 100644 index 21ce6de68e4..00000000000 --- a/service/servicecatalog/examples_test.go +++ /dev/null @@ -1,1146 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package servicecatalog_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/servicecatalog" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleServiceCatalog_AcceptPortfolioShare() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.AcceptPortfolioShareInput{ - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.AcceptPortfolioShare(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_AssociatePrincipalWithPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.AssociatePrincipalWithPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - PrincipalARN: aws.String("PrincipalARN"), // Required - PrincipalType: aws.String("PrincipalType"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.AssociatePrincipalWithPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_AssociateProductWithPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.AssociateProductWithPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - SourcePortfolioId: aws.String("Id"), - } - resp, err := svc.AssociateProductWithPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_CreateConstraint() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.CreateConstraintInput{ - IdempotencyToken: aws.String("IdempotencyToken"), // Required - Parameters: aws.String("ConstraintParameters"), // Required - PortfolioId: aws.String("Id"), // Required - ProductId: aws.String("Id"), // Required - Type: aws.String("ConstraintType"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - Description: aws.String("ConstraintDescription"), - } - resp, err := svc.CreateConstraint(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_CreatePortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.CreatePortfolioInput{ - DisplayName: aws.String("PortfolioDisplayName"), // Required - IdempotencyToken: aws.String("IdempotencyToken"), // Required - ProviderName: aws.String("ProviderName"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - Description: aws.String("PortfolioDescription"), - Tags: []*servicecatalog.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.CreatePortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_CreatePortfolioShare() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.CreatePortfolioShareInput{ - AccountId: aws.String("AccountId"), // Required - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.CreatePortfolioShare(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_CreateProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.CreateProductInput{ - IdempotencyToken: aws.String("IdempotencyToken"), // Required - Name: aws.String("ProductViewName"), // Required - Owner: aws.String("ProductViewOwner"), // Required - ProductType: aws.String("ProductType"), // Required - ProvisioningArtifactParameters: &servicecatalog.ProvisioningArtifactProperties{ // Required - Info: map[string]*string{ // Required - "Key": aws.String("ProvisioningArtifactInfoValue"), // Required - // More values... - }, - Description: aws.String("ProvisioningArtifactDescription"), - Name: aws.String("ProvisioningArtifactName"), - Type: aws.String("ProvisioningArtifactType"), - }, - AcceptLanguage: aws.String("AcceptLanguage"), - Description: aws.String("ProductViewShortDescription"), - Distributor: aws.String("ProductViewOwner"), - SupportDescription: aws.String("SupportDescription"), - SupportEmail: aws.String("SupportEmail"), - SupportUrl: aws.String("SupportUrl"), - Tags: []*servicecatalog.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.CreateProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_CreateProvisioningArtifact() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.CreateProvisioningArtifactInput{ - IdempotencyToken: aws.String("IdempotencyToken"), // Required - Parameters: &servicecatalog.ProvisioningArtifactProperties{ // Required - Info: map[string]*string{ // Required - "Key": aws.String("ProvisioningArtifactInfoValue"), // Required - // More values... - }, - Description: aws.String("ProvisioningArtifactDescription"), - Name: aws.String("ProvisioningArtifactName"), - Type: aws.String("ProvisioningArtifactType"), - }, - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.CreateProvisioningArtifact(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DeleteConstraint() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DeleteConstraintInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DeleteConstraint(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DeletePortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DeletePortfolioInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DeletePortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DeletePortfolioShare() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DeletePortfolioShareInput{ - AccountId: aws.String("AccountId"), // Required - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DeletePortfolioShare(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DeleteProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DeleteProductInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DeleteProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DeleteProvisioningArtifact() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DeleteProvisioningArtifactInput{ - ProductId: aws.String("Id"), // Required - ProvisioningArtifactId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DeleteProvisioningArtifact(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeConstraint() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeConstraintInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribeConstraint(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribePortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribePortfolioInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribePortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeProductInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribeProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeProductAsAdmin() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeProductAsAdminInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribeProductAsAdmin(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeProductView() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeProductViewInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribeProductView(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeProvisioningArtifact() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeProvisioningArtifactInput{ - ProductId: aws.String("Id"), // Required - ProvisioningArtifactId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DescribeProvisioningArtifact(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeProvisioningParameters() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeProvisioningParametersInput{ - ProductId: aws.String("Id"), // Required - ProvisioningArtifactId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PathId: aws.String("Id"), - } - resp, err := svc.DescribeProvisioningParameters(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DescribeRecord() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DescribeRecordInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.DescribeRecord(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DisassociatePrincipalFromPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DisassociatePrincipalFromPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - PrincipalARN: aws.String("PrincipalARN"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DisassociatePrincipalFromPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_DisassociateProductFromPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.DisassociateProductFromPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.DisassociateProductFromPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListAcceptedPortfolioShares() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListAcceptedPortfolioSharesInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ListAcceptedPortfolioShares(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListConstraintsForPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListConstraintsForPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - ProductId: aws.String("Id"), - } - resp, err := svc.ListConstraintsForPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListLaunchPaths() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListLaunchPathsInput{ - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ListLaunchPaths(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListPortfolioAccess() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListPortfolioAccessInput{ - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.ListPortfolioAccess(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListPortfolios() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListPortfoliosInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ListPortfolios(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListPortfoliosForProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListPortfoliosForProductInput{ - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ListPortfoliosForProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListPrincipalsForPortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListPrincipalsForPortfolioInput{ - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ListPrincipalsForPortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListProvisioningArtifacts() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListProvisioningArtifactsInput{ - ProductId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.ListProvisioningArtifacts(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ListRecordHistory() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ListRecordHistoryInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - AccessLevelFilter: &servicecatalog.AccessLevelFilter{ - Key: aws.String("AccessLevelFilterKey"), - Value: aws.String("AccessLevelFilterValue"), - }, - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - SearchFilter: &servicecatalog.ListRecordHistorySearchFilter{ - Key: aws.String("SearchFilterKey"), - Value: aws.String("SearchFilterValue"), - }, - } - resp, err := svc.ListRecordHistory(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ProvisionProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ProvisionProductInput{ - ProductId: aws.String("Id"), // Required - ProvisionToken: aws.String("IdempotencyToken"), // Required - ProvisionedProductName: aws.String("ProvisionedProductName"), // Required - ProvisioningArtifactId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - NotificationArns: []*string{ - aws.String("NotificationArn"), // Required - // More values... - }, - PathId: aws.String("Id"), - ProvisioningParameters: []*servicecatalog.ProvisioningParameter{ - { // Required - Key: aws.String("ParameterKey"), - Value: aws.String("ParameterValue"), - }, - // More values... - }, - Tags: []*servicecatalog.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.ProvisionProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_RejectPortfolioShare() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.RejectPortfolioShareInput{ - PortfolioId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - } - resp, err := svc.RejectPortfolioShare(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_ScanProvisionedProducts() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.ScanProvisionedProductsInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - AccessLevelFilter: &servicecatalog.AccessLevelFilter{ - Key: aws.String("AccessLevelFilterKey"), - Value: aws.String("AccessLevelFilterValue"), - }, - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - } - resp, err := svc.ScanProvisionedProducts(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_SearchProducts() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.SearchProductsInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - Filters: map[string][]*string{ - "Key": { // Required - aws.String("ProductViewFilterValue"), // Required - // More values... - }, - // More values... - }, - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - SortBy: aws.String("ProductViewSortBy"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.SearchProducts(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_SearchProductsAsAdmin() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.SearchProductsAsAdminInput{ - AcceptLanguage: aws.String("AcceptLanguage"), - Filters: map[string][]*string{ - "Key": { // Required - aws.String("ProductViewFilterValue"), // Required - // More values... - }, - // More values... - }, - PageSize: aws.Int64(1), - PageToken: aws.String("PageToken"), - PortfolioId: aws.String("Id"), - ProductSource: aws.String("ProductSource"), - SortBy: aws.String("ProductViewSortBy"), - SortOrder: aws.String("SortOrder"), - } - resp, err := svc.SearchProductsAsAdmin(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_TerminateProvisionedProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.TerminateProvisionedProductInput{ - TerminateToken: aws.String("IdempotencyToken"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - IgnoreErrors: aws.Bool(true), - ProvisionedProductId: aws.String("Id"), - ProvisionedProductName: aws.String("ProvisionedProductNameOrArn"), - } - resp, err := svc.TerminateProvisionedProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_UpdateConstraint() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.UpdateConstraintInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - Description: aws.String("ConstraintDescription"), - } - resp, err := svc.UpdateConstraint(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_UpdatePortfolio() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.UpdatePortfolioInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - AddTags: []*servicecatalog.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - Description: aws.String("PortfolioDescription"), - DisplayName: aws.String("PortfolioDisplayName"), - ProviderName: aws.String("ProviderName"), - RemoveTags: []*string{ - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.UpdatePortfolio(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_UpdateProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.UpdateProductInput{ - Id: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - AddTags: []*servicecatalog.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - Description: aws.String("ProductViewShortDescription"), - Distributor: aws.String("ProductViewOwner"), - Name: aws.String("ProductViewName"), - Owner: aws.String("ProductViewOwner"), - RemoveTags: []*string{ - aws.String("TagKey"), // Required - // More values... - }, - SupportDescription: aws.String("SupportDescription"), - SupportEmail: aws.String("SupportEmail"), - SupportUrl: aws.String("SupportUrl"), - } - resp, err := svc.UpdateProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_UpdateProvisionedProduct() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.UpdateProvisionedProductInput{ - UpdateToken: aws.String("IdempotencyToken"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - PathId: aws.String("Id"), - ProductId: aws.String("Id"), - ProvisionedProductId: aws.String("Id"), - ProvisionedProductName: aws.String("ProvisionedProductNameOrArn"), - ProvisioningArtifactId: aws.String("Id"), - ProvisioningParameters: []*servicecatalog.UpdateProvisioningParameter{ - { // Required - Key: aws.String("ParameterKey"), - UsePreviousValue: aws.Bool(true), - Value: aws.String("ParameterValue"), - }, - // More values... - }, - } - resp, err := svc.UpdateProvisionedProduct(params) - - if err != nil { - // 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) -} - -func ExampleServiceCatalog_UpdateProvisioningArtifact() { - sess := session.Must(session.NewSession()) - - svc := servicecatalog.New(sess) - - params := &servicecatalog.UpdateProvisioningArtifactInput{ - ProductId: aws.String("Id"), // Required - ProvisioningArtifactId: aws.String("Id"), // Required - AcceptLanguage: aws.String("AcceptLanguage"), - Description: aws.String("ProvisioningArtifactDescription"), - Name: aws.String("ProvisioningArtifactName"), - } - resp, err := svc.UpdateProvisioningArtifact(params) - - if err != nil { - // 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) -} diff --git a/service/ses/examples_test.go b/service/ses/examples_test.go index 6210585f747..d47addd74ff 100644 --- a/service/ses/examples_test.go +++ b/service/ses/examples_test.go @@ -8,1323 +8,1299 @@ import ( "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/ses" ) var _ time.Duration var _ bytes.Buffer +var _ aws.Config -func ExampleSES_CloneReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CloneReceiptRuleSetInput{ - OriginalRuleSetName: aws.String("ReceiptRuleSetName"), // Required - RuleSetName: aws.String("ReceiptRuleSetName"), // Required - } - resp, err := svc.CloneReceiptRuleSet(params) - +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()) - return + panic(err) } - - // Pretty-print the response data. - fmt.Println(resp) + return &t } -func ExampleSES_CreateConfigurationSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateConfigurationSetInput{ - ConfigurationSet: &ses.ConfigurationSet{ // Required - Name: aws.String("ConfigurationSetName"), // Required - }, - } - resp, err := svc.CreateConfigurationSet(params) - - if err != nil { - // 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) -} - -func ExampleSES_CreateConfigurationSetEventDestination() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateConfigurationSetEventDestinationInput{ - ConfigurationSetName: aws.String("ConfigurationSetName"), // Required - EventDestination: &ses.EventDestination{ // Required - MatchingEventTypes: []*string{ // Required - aws.String("EventType"), // Required - // More values... - }, - Name: aws.String("EventDestinationName"), // Required - CloudWatchDestination: &ses.CloudWatchDestination{ - DimensionConfigurations: []*ses.CloudWatchDimensionConfiguration{ // Required - { // Required - DefaultDimensionValue: aws.String("DefaultDimensionValue"), // Required - DimensionName: aws.String("DimensionName"), // Required - DimensionValueSource: aws.String("DimensionValueSource"), // Required - }, - // More values... - }, - }, - Enabled: aws.Bool(true), - KinesisFirehoseDestination: &ses.KinesisFirehoseDestination{ - DeliveryStreamARN: aws.String("AmazonResourceName"), // Required - IAMRoleARN: aws.String("AmazonResourceName"), // Required - }, - }, +// CloneReceiptRuleSet +// +// The following example creates a receipt rule set by cloning an existing one: +func ExampleSES_CloneReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.CloneReceiptRuleSetInput{ + OriginalRuleSetName: aws.String("RuleSetToClone"), + RuleSetName: aws.String("RuleSetToCreate"), } - resp, err := svc.CreateConfigurationSetEventDestination(params) + result, err := svc.CloneReceiptRuleSet(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error()) + case ses.ErrCodeAlreadyExistsException: + fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error()) + case ses.ErrCodeLimitExceededException: + fmt.Println(ses.ErrCodeLimitExceededException, 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 ExampleSES_CreateReceiptFilter() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateReceiptFilterInput{ - Filter: &ses.ReceiptFilter{ // Required - IpFilter: &ses.ReceiptIpFilter{ // Required - Cidr: aws.String("Cidr"), // Required - Policy: aws.String("ReceiptFilterPolicy"), // Required +// CreateReceiptFilter +// +// The following example creates a new IP address filter: +func ExampleSES_CreateReceiptFilter_shared00() { + svc := ses.New(session.New()) + input := &ses.CreateReceiptFilterInput{ + Filter: &ses.ReceiptFilter{ + IpFilter: &ses.ReceiptIpFilter{ + Cidr: aws.String("1.2.3.4/24"), + Policy: aws.String("Allow"), }, - Name: aws.String("ReceiptFilterName"), // Required + Name: aws.String("MyFilter"), }, } - resp, err := svc.CreateReceiptFilter(params) + result, err := svc.CreateReceiptFilter(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 ses.ErrCodeLimitExceededException: + fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error()) + case ses.ErrCodeAlreadyExistsException: + fmt.Println(ses.ErrCodeAlreadyExistsException, 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 ExampleSES_CreateReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateReceiptRuleInput{ - Rule: &ses.ReceiptRule{ // Required - Name: aws.String("ReceiptRuleName"), // Required - Actions: []*ses.ReceiptAction{ - { // Required - AddHeaderAction: &ses.AddHeaderAction{ - HeaderName: aws.String("HeaderName"), // Required - HeaderValue: aws.String("HeaderValue"), // Required - }, - BounceAction: &ses.BounceAction{ - Message: aws.String("BounceMessage"), // Required - Sender: aws.String("Address"), // Required - SmtpReplyCode: aws.String("BounceSmtpReplyCode"), // Required - StatusCode: aws.String("BounceStatusCode"), - TopicArn: aws.String("AmazonResourceName"), - }, - LambdaAction: &ses.LambdaAction{ - FunctionArn: aws.String("AmazonResourceName"), // Required - InvocationType: aws.String("InvocationType"), - TopicArn: aws.String("AmazonResourceName"), - }, - S3Action: &ses.S3Action{ - BucketName: aws.String("S3BucketName"), // Required - KmsKeyArn: aws.String("AmazonResourceName"), - ObjectKeyPrefix: aws.String("S3KeyPrefix"), - TopicArn: aws.String("AmazonResourceName"), - }, - SNSAction: &ses.SNSAction{ - TopicArn: aws.String("AmazonResourceName"), // Required - Encoding: aws.String("SNSActionEncoding"), - }, - StopAction: &ses.StopAction{ - Scope: aws.String("StopScope"), // Required - TopicArn: aws.String("AmazonResourceName"), - }, - WorkmailAction: &ses.WorkmailAction{ - OrganizationArn: aws.String("AmazonResourceName"), // Required - TopicArn: aws.String("AmazonResourceName"), - }, - }, - // More values... - }, - Enabled: aws.Bool(true), - Recipients: []*string{ - aws.String("Recipient"), // Required - // More values... +// CreateReceiptRule +// +// The following example creates a new receipt rule: +func ExampleSES_CreateReceiptRule_shared00() { + svc := ses.New(session.New()) + input := &ses.CreateReceiptRuleInput{ + After: aws.String(""), + Rule: &ses.ReceiptRule{ + Actions: []*ses.ReceiptActionsList{ + {}, }, + Enabled: aws.Bool(true), + Name: aws.String("MyRule"), ScanEnabled: aws.Bool(true), - TlsPolicy: aws.String("TlsPolicy"), + TlsPolicy: aws.String("Optional"), }, - RuleSetName: aws.String("ReceiptRuleSetName"), // Required - After: aws.String("ReceiptRuleName"), + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.CreateReceiptRule(params) + result, err := svc.CreateReceiptRule(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 ses.ErrCodeInvalidSnsTopicException: + fmt.Println(ses.ErrCodeInvalidSnsTopicException, aerr.Error()) + case ses.ErrCodeInvalidS3ConfigurationException: + fmt.Println(ses.ErrCodeInvalidS3ConfigurationException, aerr.Error()) + case ses.ErrCodeInvalidLambdaFunctionException: + fmt.Println(ses.ErrCodeInvalidLambdaFunctionException, aerr.Error()) + case ses.ErrCodeAlreadyExistsException: + fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error()) + case ses.ErrCodeRuleDoesNotExistException: + fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error()) + case ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error()) + case ses.ErrCodeLimitExceededException: + fmt.Println(ses.ErrCodeLimitExceededException, 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 ExampleSES_CreateReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateReceiptRuleSetInput{ - RuleSetName: aws.String("ReceiptRuleSetName"), // Required +// CreateReceiptRuleSet +// +// The following example creates an empty receipt rule set: +func ExampleSES_CreateReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.CreateReceiptRuleSetInput{ + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.CreateReceiptRuleSet(params) + result, err := svc.CreateReceiptRuleSet(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 ses.ErrCodeAlreadyExistsException: + fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error()) + case ses.ErrCodeLimitExceededException: + fmt.Println(ses.ErrCodeLimitExceededException, 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 ExampleSES_DeleteConfigurationSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteConfigurationSetInput{ - ConfigurationSetName: aws.String("ConfigurationSetName"), // Required +// DeleteIdentity +// +// The following example deletes an identity from the list of identities that have been +// submitted for verification with Amazon SES: +func ExampleSES_DeleteIdentity_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteIdentityInput{ + Identity: aws.String("user@example.com"), } - resp, err := svc.DeleteConfigurationSet(params) + result, err := svc.DeleteIdentity(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() { + 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 ExampleSES_DeleteConfigurationSetEventDestination() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteConfigurationSetEventDestinationInput{ - ConfigurationSetName: aws.String("ConfigurationSetName"), // Required - EventDestinationName: aws.String("EventDestinationName"), // Required +// DeleteIdentityPolicy +// +// The following example deletes a sending authorization policy for an identity: +func ExampleSES_DeleteIdentityPolicy_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteIdentityPolicyInput{ + Identity: aws.String("user@example.com"), + PolicyName: aws.String("MyPolicy"), } - resp, err := svc.DeleteConfigurationSetEventDestination(params) + result, err := svc.DeleteIdentityPolicy(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() { + 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 ExampleSES_DeleteIdentity() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteIdentityInput{ - Identity: aws.String("Identity"), // Required +// DeleteReceiptFilter +// +// The following example deletes an IP address filter: +func ExampleSES_DeleteReceiptFilter_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteReceiptFilterInput{ + FilterName: aws.String("MyFilter"), } - resp, err := svc.DeleteIdentity(params) + result, err := svc.DeleteReceiptFilter(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() { + 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 ExampleSES_DeleteIdentityPolicy() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteIdentityPolicyInput{ - Identity: aws.String("Identity"), // Required - PolicyName: aws.String("PolicyName"), // Required +// DeleteReceiptRule +// +// The following example deletes a receipt rule: +func ExampleSES_DeleteReceiptRule_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteReceiptRuleInput{ + RuleName: aws.String("MyRule"), + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.DeleteIdentityPolicy(params) + result, err := svc.DeleteReceiptRule(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, 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 ExampleSES_DeleteReceiptFilter() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteReceiptFilterInput{ - FilterName: aws.String("ReceiptFilterName"), // Required +// DeleteReceiptRuleSet +// +// The following example deletes a receipt rule set: +func ExampleSES_DeleteReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteReceiptRuleSetInput{ + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.DeleteReceiptFilter(params) + result, err := svc.DeleteReceiptRuleSet(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 ses.ErrCodeCannotDeleteException: + fmt.Println(ses.ErrCodeCannotDeleteException, 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 ExampleSES_DeleteReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteReceiptRuleInput{ - RuleName: aws.String("ReceiptRuleName"), // Required - RuleSetName: aws.String("ReceiptRuleSetName"), // Required +// DeleteVerifiedEmailAddress +// +// The following example deletes an email address from the list of identities that have +// been submitted for verification with Amazon SES: +func ExampleSES_DeleteVerifiedEmailAddress_shared00() { + svc := ses.New(session.New()) + input := &ses.DeleteVerifiedEmailAddressInput{ + EmailAddress: aws.String("user@example.com"), } - resp, err := svc.DeleteReceiptRule(params) + result, err := svc.DeleteVerifiedEmailAddress(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() { + 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 ExampleSES_DeleteReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteReceiptRuleSetInput{ - RuleSetName: aws.String("ReceiptRuleSetName"), // Required - } - resp, err := svc.DeleteReceiptRuleSet(params) +// DescribeActiveReceiptRuleSet +// +// The following example returns the metadata and receipt rules for the receipt rule +// set that is currently active: +func ExampleSES_DescribeActiveReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.DescribeActiveReceiptRuleSetInput{} + result, err := svc.DescribeActiveReceiptRuleSet(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() { + 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 ExampleSES_DeleteVerifiedEmailAddress() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DeleteVerifiedEmailAddressInput{ - EmailAddress: aws.String("Address"), // Required - } - resp, err := svc.DeleteVerifiedEmailAddress(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) - return +// DescribeReceiptRule +// +// The following example returns the details of a receipt rule: +func ExampleSES_DescribeReceiptRule_shared00() { + svc := ses.New(session.New()) + input := &ses.DescribeReceiptRuleInput{ + RuleName: aws.String("MyRule"), + RuleSetName: aws.String("MyRuleSet"), } - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleSES_DescribeActiveReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.DescribeActiveReceiptRuleSetInput - resp, err := svc.DescribeActiveReceiptRuleSet(params) - + result, err := svc.DescribeReceiptRule(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 ses.ErrCodeRuleDoesNotExistException: + fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error()) + case ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, 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 ExampleSES_DescribeConfigurationSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DescribeConfigurationSetInput{ - ConfigurationSetName: aws.String("ConfigurationSetName"), // Required - ConfigurationSetAttributeNames: []*string{ - aws.String("ConfigurationSetAttribute"), // Required - // More values... - }, - } - resp, err := svc.DescribeConfigurationSet(params) - - if err != nil { - // 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) -} - -func ExampleSES_DescribeReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DescribeReceiptRuleInput{ - RuleName: aws.String("ReceiptRuleName"), // Required - RuleSetName: aws.String("ReceiptRuleSetName"), // Required +// DescribeReceiptRuleSet +// +// The following example returns the metadata and receipt rules of a receipt rule set: +func ExampleSES_DescribeReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.DescribeReceiptRuleSetInput{ + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.DescribeReceiptRule(params) + result, err := svc.DescribeReceiptRuleSet(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, 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 ExampleSES_DescribeReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DescribeReceiptRuleSetInput{ - RuleSetName: aws.String("ReceiptRuleSetName"), // Required - } - resp, err := svc.DescribeReceiptRuleSet(params) - - if err != nil { - // 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) -} - -func ExampleSES_GetIdentityDkimAttributes() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.GetIdentityDkimAttributesInput{ - Identities: []*string{ // Required - aws.String("Identity"), // Required - // More values... +// GetIdentityDkimAttributes +// +// The following example retrieves the Amazon SES Easy DKIM attributes for a list of +// identities: +func ExampleSES_GetIdentityDkimAttributes_shared00() { + svc := ses.New(session.New()) + input := &ses.GetIdentityDkimAttributesInput{ + Identities: []*string{ + aws.String("example.com"), + aws.String("user@example.com"), }, } - resp, err := svc.GetIdentityDkimAttributes(params) + result, err := svc.GetIdentityDkimAttributes(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() { + 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 ExampleSES_GetIdentityMailFromDomainAttributes() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.GetIdentityMailFromDomainAttributesInput{ - Identities: []*string{ // Required - aws.String("Identity"), // Required - // More values... +// GetIdentityMailFromDomainAttributes +// +// The following example returns the custom MAIL FROM attributes for an identity: +func ExampleSES_GetIdentityMailFromDomainAttributes_shared00() { + svc := ses.New(session.New()) + input := &ses.GetIdentityMailFromDomainAttributesInput{ + Identities: []*string{ + aws.String("example.com"), }, } - resp, err := svc.GetIdentityMailFromDomainAttributes(params) + result, err := svc.GetIdentityMailFromDomainAttributes(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() { + 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 ExampleSES_GetIdentityNotificationAttributes() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.GetIdentityNotificationAttributesInput{ - Identities: []*string{ // Required - aws.String("Identity"), // Required - // More values... +// GetIdentityNotificationAttributes +// +// The following example returns the notification attributes for an identity: +func ExampleSES_GetIdentityNotificationAttributes_shared00() { + svc := ses.New(session.New()) + input := &ses.GetIdentityNotificationAttributesInput{ + Identities: []*string{ + aws.String("example.com"), }, } - resp, err := svc.GetIdentityNotificationAttributes(params) + result, err := svc.GetIdentityNotificationAttributes(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() { + 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 ExampleSES_GetIdentityPolicies() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.GetIdentityPoliciesInput{ - Identity: aws.String("Identity"), // Required - PolicyNames: []*string{ // Required - aws.String("PolicyName"), // Required - // More values... +// GetIdentityPolicies +// +// The following example returns a sending authorization policy for an identity: +func ExampleSES_GetIdentityPolicies_shared00() { + svc := ses.New(session.New()) + input := &ses.GetIdentityPoliciesInput{ + Identity: aws.String("example.com"), + PolicyNames: []*string{ + aws.String("MyPolicy"), }, } - resp, err := svc.GetIdentityPolicies(params) + result, err := svc.GetIdentityPolicies(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() { + 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 ExampleSES_GetIdentityVerificationAttributes() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.GetIdentityVerificationAttributesInput{ - Identities: []*string{ // Required - aws.String("Identity"), // Required - // More values... +// GetIdentityVerificationAttributes +// +// The following example returns the verification status and the verification token +// for a domain identity: +func ExampleSES_GetIdentityVerificationAttributes_shared00() { + svc := ses.New(session.New()) + input := &ses.GetIdentityVerificationAttributesInput{ + Identities: []*string{ + aws.String("example.com"), }, } - resp, err := svc.GetIdentityVerificationAttributes(params) + result, err := svc.GetIdentityVerificationAttributes(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() { + 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 ExampleSES_GetSendQuota() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.GetSendQuotaInput - resp, err := svc.GetSendQuota(params) +// GetSendQuota +// +// The following example returns the Amazon SES sending limits for an AWS account: +func ExampleSES_GetSendQuota_shared00() { + svc := ses.New(session.New()) + input := &ses.GetSendQuotaInput{} + result, err := svc.GetSendQuota(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() { + 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 ExampleSES_GetSendStatistics() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.GetSendStatisticsInput - resp, err := svc.GetSendStatistics(params) +// GetSendStatistics +// +// The following example returns Amazon SES sending statistics: +func ExampleSES_GetSendStatistics_shared00() { + svc := ses.New(session.New()) + input := &ses.GetSendStatisticsInput{} + result, err := svc.GetSendStatistics(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() { + 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 ExampleSES_ListConfigurationSets() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.ListConfigurationSetsInput{ - MaxItems: aws.Int64(1), - NextToken: aws.String("NextToken"), +// ListIdentities +// +// The following example lists the email address identities that have been submitted +// for verification with Amazon SES: +func ExampleSES_ListIdentities_shared00() { + svc := ses.New(session.New()) + input := &ses.ListIdentitiesInput{ + IdentityType: aws.String("EmailAddress"), + MaxItems: aws.Int64(123.000000), + NextToken: aws.String(""), } - resp, err := svc.ListConfigurationSets(params) + result, err := svc.ListIdentities(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() { + 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 ExampleSES_ListIdentities() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.ListIdentitiesInput{ - IdentityType: aws.String("IdentityType"), - MaxItems: aws.Int64(1), - NextToken: aws.String("NextToken"), +// ListIdentityPolicies +// +// The following example returns a list of sending authorization policies that are attached +// to an identity: +func ExampleSES_ListIdentityPolicies_shared00() { + svc := ses.New(session.New()) + input := &ses.ListIdentityPoliciesInput{ + Identity: aws.String("example.com"), } - resp, err := svc.ListIdentities(params) + result, err := svc.ListIdentityPolicies(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() { + 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 ExampleSES_ListIdentityPolicies() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.ListIdentityPoliciesInput{ - Identity: aws.String("Identity"), // Required - } - resp, err := svc.ListIdentityPolicies(params) +// ListReceiptFilters +// +// The following example lists the IP address filters that are associated with an AWS +// account: +func ExampleSES_ListReceiptFilters_shared00() { + svc := ses.New(session.New()) + input := &ses.ListReceiptFiltersInput{} + result, err := svc.ListReceiptFilters(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() { + 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 ExampleSES_ListReceiptFilters() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.ListReceiptFiltersInput - resp, err := svc.ListReceiptFilters(params) - - if err != nil { - // Print the error, cast err to awserr.Error to get the Code and - // Message from an error. - fmt.Println(err.Error()) - return +// ListReceiptRuleSets +// +// The following example lists the receipt rule sets that exist under an AWS account: +func ExampleSES_ListReceiptRuleSets_shared00() { + svc := ses.New(session.New()) + input := &ses.ListReceiptRuleSetsInput{ + NextToken: aws.String(""), } - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleSES_ListReceiptRuleSets() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.ListReceiptRuleSetsInput{ - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListReceiptRuleSets(params) - + result, err := svc.ListReceiptRuleSets(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() { + 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 ExampleSES_ListVerifiedEmailAddresses() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.ListVerifiedEmailAddressesInput - resp, err := svc.ListVerifiedEmailAddresses(params) +// ListVerifiedEmailAddresses +// +// The following example lists all email addresses that have been submitted for verification +// with Amazon SES: +func ExampleSES_ListVerifiedEmailAddresses_shared00() { + svc := ses.New(session.New()) + input := &ses.ListVerifiedEmailAddressesInput{} + result, err := svc.ListVerifiedEmailAddresses(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() { + 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 ExampleSES_PutIdentityPolicy() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.PutIdentityPolicyInput{ - Identity: aws.String("Identity"), // Required - Policy: aws.String("Policy"), // Required - PolicyName: aws.String("PolicyName"), // Required - } - resp, err := svc.PutIdentityPolicy(params) - - if err != nil { - // 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) -} - -func ExampleSES_ReorderReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.ReorderReceiptRuleSetInput{ - RuleNames: []*string{ // Required - aws.String("ReceiptRuleName"), // Required - // More values... - }, - RuleSetName: aws.String("ReceiptRuleSetName"), // Required +// PutIdentityPolicy +// +// The following example adds a sending authorization policy to an identity: +func ExampleSES_PutIdentityPolicy_shared00() { + svc := ses.New(session.New()) + input := &ses.PutIdentityPolicyInput{ + Identity: aws.String("example.com"), + Policy: aws.String("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"stmt1469123904194\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:root\"},\"Action\":[\"ses:SendEmail\",\"ses:SendRawEmail\"],\"Resource\":\"arn:aws:ses:us-east-1:EXAMPLE65304:identity/example.com\"}]}"), + PolicyName: aws.String("MyPolicy"), } - resp, err := svc.ReorderReceiptRuleSet(params) + result, err := svc.PutIdentityPolicy(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 ses.ErrCodeInvalidPolicyException: + fmt.Println(ses.ErrCodeInvalidPolicyException, 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 ExampleSES_SendBounce() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SendBounceInput{ - BounceSender: aws.String("Address"), // Required - BouncedRecipientInfoList: []*ses.BouncedRecipientInfo{ // Required - { // Required - Recipient: aws.String("Address"), // Required - BounceType: aws.String("BounceType"), - RecipientArn: aws.String("AmazonResourceName"), - RecipientDsnFields: &ses.RecipientDsnFields{ - Action: aws.String("DsnAction"), // Required - Status: aws.String("DsnStatus"), // Required - DiagnosticCode: aws.String("DiagnosticCode"), - ExtensionFields: []*ses.ExtensionField{ - { // Required - Name: aws.String("ExtensionFieldName"), // Required - Value: aws.String("ExtensionFieldValue"), // Required - }, - // More values... - }, - FinalRecipient: aws.String("Address"), - LastAttemptDate: aws.Time(time.Now()), - RemoteMta: aws.String("RemoteMta"), - }, - }, - // More values... - }, - OriginalMessageId: aws.String("MessageId"), // Required - BounceSenderArn: aws.String("AmazonResourceName"), - Explanation: aws.String("Explanation"), - MessageDsn: &ses.MessageDsn{ - ReportingMta: aws.String("ReportingMta"), // Required - ArrivalDate: aws.Time(time.Now()), - ExtensionFields: []*ses.ExtensionField{ - { // Required - Name: aws.String("ExtensionFieldName"), // Required - Value: aws.String("ExtensionFieldValue"), // Required - }, - // More values... - }, +// ReorderReceiptRuleSet +// +// The following example reorders the receipt rules within a receipt rule set: +func ExampleSES_ReorderReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.ReorderReceiptRuleSetInput{ + RuleNames: []*string{ + aws.String("MyRule"), + aws.String("MyOtherRule"), }, + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.SendBounce(params) + result, err := svc.ReorderReceiptRuleSet(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error()) + case ses.ErrCodeRuleDoesNotExistException: + fmt.Println(ses.ErrCodeRuleDoesNotExistException, 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 ExampleSES_SendEmail() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SendEmailInput{ - Destination: &ses.Destination{ // Required - BccAddresses: []*string{ - aws.String("Address"), // Required - // More values... - }, +// SendEmail +// +// The following example sends a formatted email: +func ExampleSES_SendEmail_shared00() { + svc := ses.New(session.New()) + input := &ses.SendEmailInput{ + Destination: &ses.Destination{ CcAddresses: []*string{ - aws.String("Address"), // Required - // More values... + aws.String("recipient3@example.com"), }, ToAddresses: []*string{ - aws.String("Address"), // Required - // More values... + aws.String("recipient1@example.com"), + aws.String("recipient2@example.com"), }, }, - Message: &ses.Message{ // Required - Body: &ses.Body{ // Required + Message: &ses.Message{ + Body: &ses.Body{ Html: &ses.Content{ - Data: aws.String("MessageData"), // Required - Charset: aws.String("Charset"), + Charset: aws.String("UTF-8"), + Data: aws.String("This message body contains HTML formatting. It can, for example, contain links like this one: Amazon SES Developer Guide."), }, Text: &ses.Content{ - Data: aws.String("MessageData"), // Required - Charset: aws.String("Charset"), + Charset: aws.String("UTF-8"), + Data: aws.String("This is the message body in text format."), }, }, - Subject: &ses.Content{ // Required - Data: aws.String("MessageData"), // Required - Charset: aws.String("Charset"), - }, - }, - Source: aws.String("Address"), // Required - ConfigurationSetName: aws.String("ConfigurationSetName"), - ReplyToAddresses: []*string{ - aws.String("Address"), // Required - // More values... - }, - ReturnPath: aws.String("Address"), - ReturnPathArn: aws.String("AmazonResourceName"), - SourceArn: aws.String("AmazonResourceName"), - Tags: []*ses.MessageTag{ - { // Required - Name: aws.String("MessageTagName"), // Required - Value: aws.String("MessageTagValue"), // Required + Subject: &ses.Content{ + Charset: aws.String("UTF-8"), + Data: aws.String("Test email"), }, - // More values... }, + ReturnPath: aws.String(""), + ReturnPathArn: aws.String(""), + Source: aws.String("sender@example.com"), + SourceArn: aws.String(""), } - resp, err := svc.SendEmail(params) + result, err := svc.SendEmail(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 ses.ErrCodeMessageRejected: + fmt.Println(ses.ErrCodeMessageRejected, aerr.Error()) + case ses.ErrCodeMailFromDomainNotVerifiedException: + fmt.Println(ses.ErrCodeMailFromDomainNotVerifiedException, aerr.Error()) + case ses.ErrCodeConfigurationSetDoesNotExistException: + fmt.Println(ses.ErrCodeConfigurationSetDoesNotExistException, 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 ExampleSES_SendRawEmail() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SendRawEmailInput{ - RawMessage: &ses.RawMessage{ // Required - Data: []byte("PAYLOAD"), // Required - }, - ConfigurationSetName: aws.String("ConfigurationSetName"), - Destinations: []*string{ - aws.String("Address"), // Required - // More values... - }, - FromArn: aws.String("AmazonResourceName"), - ReturnPathArn: aws.String("AmazonResourceName"), - Source: aws.String("Address"), - SourceArn: aws.String("AmazonResourceName"), - Tags: []*ses.MessageTag{ - { // Required - Name: aws.String("MessageTagName"), // Required - Value: aws.String("MessageTagValue"), // Required - }, - // More values... +// SendRawEmail +// +// The following example sends an email with an attachment: +func ExampleSES_SendRawEmail_shared00() { + svc := ses.New(session.New()) + input := &ses.SendRawEmailInput{ + FromArn: aws.String(""), + RawMessage: &ses.RawMessage{ + Data: []byte("From: sender@example.com\\nTo: recipient@example.com\\nSubject: Test email (contains an attachment)\\nMIME-Version: 1.0\\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\\n\\n--NextPart\\nContent-Type: text/plain\\n\\nThis is the message body.\\n\\n--NextPart\\nContent-Type: text/plain;\\nContent-Disposition: attachment; filename=\"attachment.txt\"\\n\\nThis is the text in the attachment.\\n\\n--NextPart--"), }, + ReturnPathArn: aws.String(""), + Source: aws.String(""), + SourceArn: aws.String(""), } - resp, err := svc.SendRawEmail(params) + result, err := svc.SendRawEmail(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 ses.ErrCodeMessageRejected: + fmt.Println(ses.ErrCodeMessageRejected, aerr.Error()) + case ses.ErrCodeMailFromDomainNotVerifiedException: + fmt.Println(ses.ErrCodeMailFromDomainNotVerifiedException, aerr.Error()) + case ses.ErrCodeConfigurationSetDoesNotExistException: + fmt.Println(ses.ErrCodeConfigurationSetDoesNotExistException, 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 ExampleSES_SetActiveReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetActiveReceiptRuleSetInput{ - RuleSetName: aws.String("ReceiptRuleSetName"), +// SetActiveReceiptRuleSet +// +// The following example sets the active receipt rule set: +func ExampleSES_SetActiveReceiptRuleSet_shared00() { + svc := ses.New(session.New()) + input := &ses.SetActiveReceiptRuleSetInput{ + RuleSetName: aws.String("RuleSetToActivate"), } - resp, err := svc.SetActiveReceiptRuleSet(params) + result, err := svc.SetActiveReceiptRuleSet(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, 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 ExampleSES_SetIdentityDkimEnabled() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetIdentityDkimEnabledInput{ - DkimEnabled: aws.Bool(true), // Required - Identity: aws.String("Identity"), // Required +// SetIdentityDkimEnabled +// +// The following example configures Amazon SES to Easy DKIM-sign the email sent from +// an identity: +func ExampleSES_SetIdentityDkimEnabled_shared00() { + svc := ses.New(session.New()) + input := &ses.SetIdentityDkimEnabledInput{ + DkimEnabled: aws.Bool(true), + Identity: aws.String("user@example.com"), } - resp, err := svc.SetIdentityDkimEnabled(params) + result, err := svc.SetIdentityDkimEnabled(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() { + 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 ExampleSES_SetIdentityFeedbackForwardingEnabled() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetIdentityFeedbackForwardingEnabledInput{ - ForwardingEnabled: aws.Bool(true), // Required - Identity: aws.String("Identity"), // Required +// SetIdentityFeedbackForwardingEnabled +// +// The following example configures Amazon SES to forward an identity's bounces and +// complaints via email: +func ExampleSES_SetIdentityFeedbackForwardingEnabled_shared00() { + svc := ses.New(session.New()) + input := &ses.SetIdentityFeedbackForwardingEnabledInput{ + ForwardingEnabled: aws.Bool(true), + Identity: aws.String("user@example.com"), } - resp, err := svc.SetIdentityFeedbackForwardingEnabled(params) + result, err := svc.SetIdentityFeedbackForwardingEnabled(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() { + 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 ExampleSES_SetIdentityHeadersInNotificationsEnabled() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetIdentityHeadersInNotificationsEnabledInput{ - Enabled: aws.Bool(true), // Required - Identity: aws.String("Identity"), // Required - NotificationType: aws.String("NotificationType"), // Required +// SetIdentityHeadersInNotificationsEnabled +// +// The following example configures Amazon SES to include the original email headers +// in the Amazon SNS bounce notifications for an identity: +func ExampleSES_SetIdentityHeadersInNotificationsEnabled_shared00() { + svc := ses.New(session.New()) + input := &ses.SetIdentityHeadersInNotificationsEnabledInput{ + Enabled: aws.Bool(true), + Identity: aws.String("user@example.com"), + NotificationType: aws.String("Bounce"), } - resp, err := svc.SetIdentityHeadersInNotificationsEnabled(params) + result, err := svc.SetIdentityHeadersInNotificationsEnabled(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() { + 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 ExampleSES_SetIdentityMailFromDomain() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetIdentityMailFromDomainInput{ - Identity: aws.String("Identity"), // Required - BehaviorOnMXFailure: aws.String("BehaviorOnMXFailure"), - MailFromDomain: aws.String("MailFromDomainName"), +// SetIdentityMailFromDomain +// +// The following example configures Amazon SES to use a custom MAIL FROM domain for +// an identity: +func ExampleSES_SetIdentityMailFromDomain_shared00() { + svc := ses.New(session.New()) + input := &ses.SetIdentityMailFromDomainInput{ + BehaviorOnMXFailure: aws.String("UseDefaultValue"), + Identity: aws.String("user@example.com"), + MailFromDomain: aws.String("bounces.example.com"), } - resp, err := svc.SetIdentityMailFromDomain(params) + result, err := svc.SetIdentityMailFromDomain(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() { + 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 ExampleSES_SetIdentityNotificationTopic() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetIdentityNotificationTopicInput{ - Identity: aws.String("Identity"), // Required - NotificationType: aws.String("NotificationType"), // Required - SnsTopic: aws.String("NotificationTopic"), +// SetIdentityNotificationTopic +// +// The following example sets the Amazon SNS topic to which Amazon SES will publish +// bounce, complaint, and/or delivery notifications for emails sent with the specified +// identity as the Source: +func ExampleSES_SetIdentityNotificationTopic_shared00() { + svc := ses.New(session.New()) + input := &ses.SetIdentityNotificationTopicInput{ + Identity: aws.String("user@example.com"), + NotificationType: aws.String("Bounce"), + SnsTopic: aws.String("arn:aws:sns:us-west-2:111122223333:MyTopic"), } - resp, err := svc.SetIdentityNotificationTopic(params) + result, err := svc.SetIdentityNotificationTopic(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() { + 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 ExampleSES_SetReceiptRulePosition() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.SetReceiptRulePositionInput{ - RuleName: aws.String("ReceiptRuleName"), // Required - RuleSetName: aws.String("ReceiptRuleSetName"), // Required - After: aws.String("ReceiptRuleName"), +// SetReceiptRulePosition +// +// The following example sets the position of a receipt rule in a receipt rule set: +func ExampleSES_SetReceiptRulePosition_shared00() { + svc := ses.New(session.New()) + input := &ses.SetReceiptRulePositionInput{ + After: aws.String("PutRuleAfterThisRule"), + RuleName: aws.String("RuleToReposition"), + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.SetReceiptRulePosition(params) + result, err := svc.SetReceiptRulePosition(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 ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error()) + case ses.ErrCodeRuleDoesNotExistException: + fmt.Println(ses.ErrCodeRuleDoesNotExistException, 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 ExampleSES_UpdateConfigurationSetEventDestination() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.UpdateConfigurationSetEventDestinationInput{ - ConfigurationSetName: aws.String("ConfigurationSetName"), // Required - EventDestination: &ses.EventDestination{ // Required - MatchingEventTypes: []*string{ // Required - aws.String("EventType"), // Required - // More values... - }, - Name: aws.String("EventDestinationName"), // Required - CloudWatchDestination: &ses.CloudWatchDestination{ - DimensionConfigurations: []*ses.CloudWatchDimensionConfiguration{ // Required - { // Required - DefaultDimensionValue: aws.String("DefaultDimensionValue"), // Required - DimensionName: aws.String("DimensionName"), // Required - DimensionValueSource: aws.String("DimensionValueSource"), // Required - }, - // More values... - }, - }, - Enabled: aws.Bool(true), - KinesisFirehoseDestination: &ses.KinesisFirehoseDestination{ - DeliveryStreamARN: aws.String("AmazonResourceName"), // Required - IAMRoleARN: aws.String("AmazonResourceName"), // Required - }, - }, - } - resp, err := svc.UpdateConfigurationSetEventDestination(params) - - if err != nil { - // 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) -} - -func ExampleSES_UpdateReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.UpdateReceiptRuleInput{ - Rule: &ses.ReceiptRule{ // Required - Name: aws.String("ReceiptRuleName"), // Required - Actions: []*ses.ReceiptAction{ - { // Required - AddHeaderAction: &ses.AddHeaderAction{ - HeaderName: aws.String("HeaderName"), // Required - HeaderValue: aws.String("HeaderValue"), // Required - }, - BounceAction: &ses.BounceAction{ - Message: aws.String("BounceMessage"), // Required - Sender: aws.String("Address"), // Required - SmtpReplyCode: aws.String("BounceSmtpReplyCode"), // Required - StatusCode: aws.String("BounceStatusCode"), - TopicArn: aws.String("AmazonResourceName"), - }, - LambdaAction: &ses.LambdaAction{ - FunctionArn: aws.String("AmazonResourceName"), // Required - InvocationType: aws.String("InvocationType"), - TopicArn: aws.String("AmazonResourceName"), - }, - S3Action: &ses.S3Action{ - BucketName: aws.String("S3BucketName"), // Required - KmsKeyArn: aws.String("AmazonResourceName"), - ObjectKeyPrefix: aws.String("S3KeyPrefix"), - TopicArn: aws.String("AmazonResourceName"), - }, - SNSAction: &ses.SNSAction{ - TopicArn: aws.String("AmazonResourceName"), // Required - Encoding: aws.String("SNSActionEncoding"), - }, - StopAction: &ses.StopAction{ - Scope: aws.String("StopScope"), // Required - TopicArn: aws.String("AmazonResourceName"), - }, - WorkmailAction: &ses.WorkmailAction{ - OrganizationArn: aws.String("AmazonResourceName"), // Required - TopicArn: aws.String("AmazonResourceName"), - }, - }, - // More values... - }, - Enabled: aws.Bool(true), - Recipients: []*string{ - aws.String("Recipient"), // Required - // More values... +// UpdateReceiptRule +// +// The following example updates a receipt rule to use an Amazon S3 action: +func ExampleSES_UpdateReceiptRule_shared00() { + svc := ses.New(session.New()) + input := &ses.UpdateReceiptRuleInput{ + Rule: &ses.ReceiptRule{ + Actions: []*ses.ReceiptActionsList{ + {}, }, + Enabled: aws.Bool(true), + Name: aws.String("MyRule"), ScanEnabled: aws.Bool(true), - TlsPolicy: aws.String("TlsPolicy"), + TlsPolicy: aws.String("Optional"), }, - RuleSetName: aws.String("ReceiptRuleSetName"), // Required + RuleSetName: aws.String("MyRuleSet"), } - resp, err := svc.UpdateReceiptRule(params) + result, err := svc.UpdateReceiptRule(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 ses.ErrCodeInvalidSnsTopicException: + fmt.Println(ses.ErrCodeInvalidSnsTopicException, aerr.Error()) + case ses.ErrCodeInvalidS3ConfigurationException: + fmt.Println(ses.ErrCodeInvalidS3ConfigurationException, aerr.Error()) + case ses.ErrCodeInvalidLambdaFunctionException: + fmt.Println(ses.ErrCodeInvalidLambdaFunctionException, aerr.Error()) + case ses.ErrCodeRuleSetDoesNotExistException: + fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error()) + case ses.ErrCodeRuleDoesNotExistException: + fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error()) + case ses.ErrCodeLimitExceededException: + fmt.Println(ses.ErrCodeLimitExceededException, 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 ExampleSES_VerifyDomainDkim() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.VerifyDomainDkimInput{ - Domain: aws.String("Domain"), // Required +// VerifyDomainDkim +// +// The following example generates DKIM tokens for a domain that has been verified with +// Amazon SES: +func ExampleSES_VerifyDomainDkim_shared00() { + svc := ses.New(session.New()) + input := &ses.VerifyDomainDkimInput{ + Domain: aws.String("example.com"), } - resp, err := svc.VerifyDomainDkim(params) + result, err := svc.VerifyDomainDkim(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() { + 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 ExampleSES_VerifyDomainIdentity() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.VerifyDomainIdentityInput{ - Domain: aws.String("Domain"), // Required +// VerifyDomainIdentity +// +// The following example starts the domain verification process with Amazon SES: +func ExampleSES_VerifyDomainIdentity_shared00() { + svc := ses.New(session.New()) + input := &ses.VerifyDomainIdentityInput{ + Domain: aws.String("example.com"), } - resp, err := svc.VerifyDomainIdentity(params) + result, err := svc.VerifyDomainIdentity(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() { + 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 ExampleSES_VerifyEmailAddress() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.VerifyEmailAddressInput{ - EmailAddress: aws.String("Address"), // Required +// VerifyEmailAddress +// +// The following example starts the email address verification process with Amazon SES: +func ExampleSES_VerifyEmailAddress_shared00() { + svc := ses.New(session.New()) + input := &ses.VerifyEmailAddressInput{ + EmailAddress: aws.String("user@example.com"), } - resp, err := svc.VerifyEmailAddress(params) + result, err := svc.VerifyEmailAddress(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() { + 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 ExampleSES_VerifyEmailIdentity() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.VerifyEmailIdentityInput{ - EmailAddress: aws.String("Address"), // Required +// VerifyEmailIdentity +// +// The following example starts the email address verification process with Amazon SES: +func ExampleSES_VerifyEmailIdentity_shared00() { + svc := ses.New(session.New()) + input := &ses.VerifyEmailIdentityInput{ + EmailAddress: aws.String("user@example.com"), } - resp, err := svc.VerifyEmailIdentity(params) + result, err := svc.VerifyEmailIdentity(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() { + 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) } diff --git a/service/sfn/examples_test.go b/service/sfn/examples_test.go deleted file mode 100644 index 359be32158c..00000000000 --- a/service/sfn/examples_test.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package sfn_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sfn" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSFN_CreateActivity() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.CreateActivityInput{ - Name: aws.String("Name"), // Required - } - resp, err := svc.CreateActivity(params) - - if err != nil { - // 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) -} - -func ExampleSFN_CreateStateMachine() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.CreateStateMachineInput{ - Definition: aws.String("Definition"), // Required - Name: aws.String("Name"), // Required - RoleArn: aws.String("Arn"), // Required - } - resp, err := svc.CreateStateMachine(params) - - if err != nil { - // 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) -} - -func ExampleSFN_DeleteActivity() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.DeleteActivityInput{ - ActivityArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteActivity(params) - - if err != nil { - // 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) -} - -func ExampleSFN_DeleteStateMachine() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.DeleteStateMachineInput{ - StateMachineArn: aws.String("Arn"), // Required - } - resp, err := svc.DeleteStateMachine(params) - - if err != nil { - // 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) -} - -func ExampleSFN_DescribeActivity() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.DescribeActivityInput{ - ActivityArn: aws.String("Arn"), // Required - } - resp, err := svc.DescribeActivity(params) - - if err != nil { - // 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) -} - -func ExampleSFN_DescribeExecution() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.DescribeExecutionInput{ - ExecutionArn: aws.String("Arn"), // Required - } - resp, err := svc.DescribeExecution(params) - - if err != nil { - // 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) -} - -func ExampleSFN_DescribeStateMachine() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.DescribeStateMachineInput{ - StateMachineArn: aws.String("Arn"), // Required - } - resp, err := svc.DescribeStateMachine(params) - - if err != nil { - // 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) -} - -func ExampleSFN_GetActivityTask() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.GetActivityTaskInput{ - ActivityArn: aws.String("Arn"), // Required - WorkerName: aws.String("Name"), - } - resp, err := svc.GetActivityTask(params) - - if err != nil { - // 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) -} - -func ExampleSFN_GetExecutionHistory() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.GetExecutionHistoryInput{ - ExecutionArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.GetExecutionHistory(params) - - if err != nil { - // 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) -} - -func ExampleSFN_ListActivities() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.ListActivitiesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PageToken"), - } - resp, err := svc.ListActivities(params) - - if err != nil { - // 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) -} - -func ExampleSFN_ListExecutions() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.ListExecutionsInput{ - StateMachineArn: aws.String("Arn"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("PageToken"), - StatusFilter: aws.String("ExecutionStatus"), - } - resp, err := svc.ListExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSFN_ListStateMachines() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.ListStateMachinesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("PageToken"), - } - resp, err := svc.ListStateMachines(params) - - if err != nil { - // 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) -} - -func ExampleSFN_SendTaskFailure() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.SendTaskFailureInput{ - TaskToken: aws.String("TaskToken"), // Required - Cause: aws.String("Cause"), - Error: aws.String("Error"), - } - resp, err := svc.SendTaskFailure(params) - - if err != nil { - // 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) -} - -func ExampleSFN_SendTaskHeartbeat() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.SendTaskHeartbeatInput{ - TaskToken: aws.String("TaskToken"), // Required - } - resp, err := svc.SendTaskHeartbeat(params) - - if err != nil { - // 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) -} - -func ExampleSFN_SendTaskSuccess() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.SendTaskSuccessInput{ - Output: aws.String("Data"), // Required - TaskToken: aws.String("TaskToken"), // Required - } - resp, err := svc.SendTaskSuccess(params) - - if err != nil { - // 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) -} - -func ExampleSFN_StartExecution() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.StartExecutionInput{ - StateMachineArn: aws.String("Arn"), // Required - Input: aws.String("Data"), - Name: aws.String("Name"), - } - resp, err := svc.StartExecution(params) - - if err != nil { - // 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) -} - -func ExampleSFN_StopExecution() { - sess := session.Must(session.NewSession()) - - svc := sfn.New(sess) - - params := &sfn.StopExecutionInput{ - ExecutionArn: aws.String("Arn"), // Required - Cause: aws.String("Cause"), - Error: aws.String("Error"), - } - resp, err := svc.StopExecution(params) - - if err != nil { - // 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) -} diff --git a/service/shield/examples_test.go b/service/shield/examples_test.go deleted file mode 100644 index 0c897a50b10..00000000000 --- a/service/shield/examples_test.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package shield_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/shield" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleShield_CreateProtection() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.CreateProtectionInput{ - Name: aws.String("ProtectionName"), // Required - ResourceArn: aws.String("ResourceArn"), // Required - } - resp, err := svc.CreateProtection(params) - - if err != nil { - // 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) -} - -func ExampleShield_CreateSubscription() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - var params *shield.CreateSubscriptionInput - resp, err := svc.CreateSubscription(params) - - if err != nil { - // 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) -} - -func ExampleShield_DeleteProtection() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.DeleteProtectionInput{ - ProtectionId: aws.String("ProtectionId"), // Required - } - resp, err := svc.DeleteProtection(params) - - if err != nil { - // 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) -} - -func ExampleShield_DeleteSubscription() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - var params *shield.DeleteSubscriptionInput - resp, err := svc.DeleteSubscription(params) - - if err != nil { - // 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) -} - -func ExampleShield_DescribeAttack() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.DescribeAttackInput{ - AttackId: aws.String("AttackId"), // Required - } - resp, err := svc.DescribeAttack(params) - - if err != nil { - // 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) -} - -func ExampleShield_DescribeProtection() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.DescribeProtectionInput{ - ProtectionId: aws.String("ProtectionId"), // Required - } - resp, err := svc.DescribeProtection(params) - - if err != nil { - // 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) -} - -func ExampleShield_DescribeSubscription() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - var params *shield.DescribeSubscriptionInput - resp, err := svc.DescribeSubscription(params) - - if err != nil { - // 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) -} - -func ExampleShield_ListAttacks() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.ListAttacksInput{ - EndTime: &shield.TimeRange{ - FromInclusive: aws.Time(time.Now()), - ToExclusive: aws.Time(time.Now()), - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("Token"), - ResourceArns: []*string{ - aws.String("ResourceArn"), // Required - // More values... - }, - StartTime: &shield.TimeRange{ - FromInclusive: aws.Time(time.Now()), - ToExclusive: aws.Time(time.Now()), - }, - } - resp, err := svc.ListAttacks(params) - - if err != nil { - // 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) -} - -func ExampleShield_ListProtections() { - sess := session.Must(session.NewSession()) - - svc := shield.New(sess) - - params := &shield.ListProtectionsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("Token"), - } - resp, err := svc.ListProtections(params) - - if err != nil { - // 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) -} diff --git a/service/simpledb/examples_test.go b/service/simpledb/examples_test.go deleted file mode 100644 index 909da254b5a..00000000000 --- a/service/simpledb/examples_test.go +++ /dev/null @@ -1,289 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package simpledb_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/simpledb" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSimpleDB_BatchDeleteAttributes() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.BatchDeleteAttributesInput{ - DomainName: aws.String("String"), // Required - Items: []*simpledb.DeletableItem{ // Required - { // Required - Name: aws.String("String"), // Required - Attributes: []*simpledb.DeletableAttribute{ - { // Required - Name: aws.String("String"), // Required - Value: aws.String("String"), - }, - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.BatchDeleteAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_BatchPutAttributes() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.BatchPutAttributesInput{ - DomainName: aws.String("String"), // Required - Items: []*simpledb.ReplaceableItem{ // Required - { // Required - Attributes: []*simpledb.ReplaceableAttribute{ // Required - { // Required - Name: aws.String("String"), // Required - Value: aws.String("String"), // Required - Replace: aws.Bool(true), - }, - // More values... - }, - Name: aws.String("String"), // Required - }, - // More values... - }, - } - resp, err := svc.BatchPutAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_CreateDomain() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.CreateDomainInput{ - DomainName: aws.String("String"), // Required - } - resp, err := svc.CreateDomain(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_DeleteAttributes() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.DeleteAttributesInput{ - DomainName: aws.String("String"), // Required - ItemName: aws.String("String"), // Required - Attributes: []*simpledb.DeletableAttribute{ - { // Required - Name: aws.String("String"), // Required - Value: aws.String("String"), - }, - // More values... - }, - Expected: &simpledb.UpdateCondition{ - Exists: aws.Bool(true), - Name: aws.String("String"), - Value: aws.String("String"), - }, - } - resp, err := svc.DeleteAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_DeleteDomain() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.DeleteDomainInput{ - DomainName: aws.String("String"), // Required - } - resp, err := svc.DeleteDomain(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_DomainMetadata() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.DomainMetadataInput{ - DomainName: aws.String("String"), // Required - } - resp, err := svc.DomainMetadata(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_GetAttributes() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.GetAttributesInput{ - DomainName: aws.String("String"), // Required - ItemName: aws.String("String"), // Required - AttributeNames: []*string{ - aws.String("String"), // Required - // More values... - }, - ConsistentRead: aws.Bool(true), - } - resp, err := svc.GetAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_ListDomains() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.ListDomainsInput{ - MaxNumberOfDomains: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListDomains(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_PutAttributes() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.PutAttributesInput{ - Attributes: []*simpledb.ReplaceableAttribute{ // Required - { // Required - Name: aws.String("String"), // Required - Value: aws.String("String"), // Required - Replace: aws.Bool(true), - }, - // More values... - }, - DomainName: aws.String("String"), // Required - ItemName: aws.String("String"), // Required - Expected: &simpledb.UpdateCondition{ - Exists: aws.Bool(true), - Name: aws.String("String"), - Value: aws.String("String"), - }, - } - resp, err := svc.PutAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSimpleDB_Select() { - sess := session.Must(session.NewSession()) - - svc := simpledb.New(sess) - - params := &simpledb.SelectInput{ - SelectExpression: aws.String("String"), // Required - ConsistentRead: aws.Bool(true), - NextToken: aws.String("String"), - } - resp, err := svc.Select(params) - - if err != nil { - // 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) -} diff --git a/service/sms/examples_test.go b/service/sms/examples_test.go deleted file mode 100644 index c9e6a179240..00000000000 --- a/service/sms/examples_test.go +++ /dev/null @@ -1,260 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package sms_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sms" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSMS_CreateReplicationJob() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.CreateReplicationJobInput{ - Frequency: aws.Int64(1), // Required - SeedReplicationTime: aws.Time(time.Now()), // Required - ServerId: aws.String("ServerId"), // Required - Description: aws.String("Description"), - LicenseType: aws.String("LicenseType"), - RoleName: aws.String("RoleName"), - } - resp, err := svc.CreateReplicationJob(params) - - if err != nil { - // 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) -} - -func ExampleSMS_DeleteReplicationJob() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.DeleteReplicationJobInput{ - ReplicationJobId: aws.String("ReplicationJobId"), // Required - } - resp, err := svc.DeleteReplicationJob(params) - - if err != nil { - // 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) -} - -func ExampleSMS_DeleteServerCatalog() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - var params *sms.DeleteServerCatalogInput - resp, err := svc.DeleteServerCatalog(params) - - if err != nil { - // 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) -} - -func ExampleSMS_DisassociateConnector() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.DisassociateConnectorInput{ - ConnectorId: aws.String("ConnectorId"), // Required - } - resp, err := svc.DisassociateConnector(params) - - if err != nil { - // 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) -} - -func ExampleSMS_GetConnectors() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.GetConnectorsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetConnectors(params) - - if err != nil { - // 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) -} - -func ExampleSMS_GetReplicationJobs() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.GetReplicationJobsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ReplicationJobId: aws.String("ReplicationJobId"), - } - resp, err := svc.GetReplicationJobs(params) - - if err != nil { - // 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) -} - -func ExampleSMS_GetReplicationRuns() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.GetReplicationRunsInput{ - ReplicationJobId: aws.String("ReplicationJobId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetReplicationRuns(params) - - if err != nil { - // 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) -} - -func ExampleSMS_GetServers() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.GetServersInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.GetServers(params) - - if err != nil { - // 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) -} - -func ExampleSMS_ImportServerCatalog() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - var params *sms.ImportServerCatalogInput - resp, err := svc.ImportServerCatalog(params) - - if err != nil { - // 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) -} - -func ExampleSMS_StartOnDemandReplicationRun() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.StartOnDemandReplicationRunInput{ - ReplicationJobId: aws.String("ReplicationJobId"), // Required - Description: aws.String("Description"), - } - resp, err := svc.StartOnDemandReplicationRun(params) - - if err != nil { - // 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) -} - -func ExampleSMS_UpdateReplicationJob() { - sess := session.Must(session.NewSession()) - - svc := sms.New(sess) - - params := &sms.UpdateReplicationJobInput{ - ReplicationJobId: aws.String("ReplicationJobId"), // Required - Description: aws.String("Description"), - Frequency: aws.Int64(1), - LicenseType: aws.String("LicenseType"), - NextReplicationRunStartTime: aws.Time(time.Now()), - RoleName: aws.String("RoleName"), - } - resp, err := svc.UpdateReplicationJob(params) - - if err != nil { - // 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) -} diff --git a/service/snowball/examples_test.go b/service/snowball/examples_test.go deleted file mode 100644 index a2e7c3a5dd0..00000000000 --- a/service/snowball/examples_test.go +++ /dev/null @@ -1,546 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package snowball_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/snowball" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSnowball_CancelCluster() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.CancelClusterInput{ - ClusterId: aws.String("ClusterId"), // Required - } - resp, err := svc.CancelCluster(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_CancelJob() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.CancelJobInput{ - JobId: aws.String("JobId"), // Required - } - resp, err := svc.CancelJob(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_CreateAddress() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.CreateAddressInput{ - Address: &snowball.Address{ // Required - AddressId: aws.String("AddressId"), - City: aws.String("String"), - Company: aws.String("String"), - Country: aws.String("String"), - IsRestricted: aws.Bool(true), - Landmark: aws.String("String"), - Name: aws.String("String"), - PhoneNumber: aws.String("String"), - PostalCode: aws.String("String"), - PrefectureOrDistrict: aws.String("String"), - StateOrProvince: aws.String("String"), - Street1: aws.String("String"), - Street2: aws.String("String"), - Street3: aws.String("String"), - }, - } - resp, err := svc.CreateAddress(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_CreateCluster() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.CreateClusterInput{ - AddressId: aws.String("AddressId"), // Required - JobType: aws.String("JobType"), // Required - Resources: &snowball.JobResource{ // Required - LambdaResources: []*snowball.LambdaResource{ - { // Required - EventTriggers: []*snowball.EventTriggerDefinition{ - { // Required - EventResourceARN: aws.String("ResourceARN"), - }, - // More values... - }, - LambdaArn: aws.String("ResourceARN"), - }, - // More values... - }, - S3Resources: []*snowball.S3Resource{ - { // Required - BucketArn: aws.String("ResourceARN"), - KeyRange: &snowball.KeyRange{ - BeginMarker: aws.String("String"), - EndMarker: aws.String("String"), - }, - }, - // More values... - }, - }, - RoleARN: aws.String("RoleARN"), // Required - ShippingOption: aws.String("ShippingOption"), // Required - Description: aws.String("String"), - ForwardingAddressId: aws.String("AddressId"), - KmsKeyARN: aws.String("KmsKeyARN"), - Notification: &snowball.Notification{ - JobStatesToNotify: []*string{ - aws.String("JobState"), // Required - // More values... - }, - NotifyAll: aws.Bool(true), - SnsTopicARN: aws.String("SnsTopicARN"), - }, - SnowballType: aws.String("Type"), - } - resp, err := svc.CreateCluster(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_CreateJob() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.CreateJobInput{ - AddressId: aws.String("AddressId"), - ClusterId: aws.String("ClusterId"), - Description: aws.String("String"), - ForwardingAddressId: aws.String("AddressId"), - JobType: aws.String("JobType"), - KmsKeyARN: aws.String("KmsKeyARN"), - Notification: &snowball.Notification{ - JobStatesToNotify: []*string{ - aws.String("JobState"), // Required - // More values... - }, - NotifyAll: aws.Bool(true), - SnsTopicARN: aws.String("SnsTopicARN"), - }, - Resources: &snowball.JobResource{ - LambdaResources: []*snowball.LambdaResource{ - { // Required - EventTriggers: []*snowball.EventTriggerDefinition{ - { // Required - EventResourceARN: aws.String("ResourceARN"), - }, - // More values... - }, - LambdaArn: aws.String("ResourceARN"), - }, - // More values... - }, - S3Resources: []*snowball.S3Resource{ - { // Required - BucketArn: aws.String("ResourceARN"), - KeyRange: &snowball.KeyRange{ - BeginMarker: aws.String("String"), - EndMarker: aws.String("String"), - }, - }, - // More values... - }, - }, - RoleARN: aws.String("RoleARN"), - ShippingOption: aws.String("ShippingOption"), - SnowballCapacityPreference: aws.String("Capacity"), - SnowballType: aws.String("Type"), - } - resp, err := svc.CreateJob(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_DescribeAddress() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.DescribeAddressInput{ - AddressId: aws.String("AddressId"), // Required - } - resp, err := svc.DescribeAddress(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_DescribeAddresses() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.DescribeAddressesInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.DescribeAddresses(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_DescribeCluster() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.DescribeClusterInput{ - ClusterId: aws.String("ClusterId"), // Required - } - resp, err := svc.DescribeCluster(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_DescribeJob() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.DescribeJobInput{ - JobId: aws.String("JobId"), // Required - } - resp, err := svc.DescribeJob(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_GetJobManifest() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.GetJobManifestInput{ - JobId: aws.String("JobId"), // Required - } - resp, err := svc.GetJobManifest(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_GetJobUnlockCode() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.GetJobUnlockCodeInput{ - JobId: aws.String("JobId"), // Required - } - resp, err := svc.GetJobUnlockCode(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_GetSnowballUsage() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - var params *snowball.GetSnowballUsageInput - resp, err := svc.GetSnowballUsage(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_ListClusterJobs() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.ListClusterJobsInput{ - ClusterId: aws.String("ClusterId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListClusterJobs(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_ListClusters() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.ListClustersInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListClusters(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_ListJobs() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.ListJobsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListJobs(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_UpdateCluster() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.UpdateClusterInput{ - ClusterId: aws.String("ClusterId"), // Required - AddressId: aws.String("AddressId"), - Description: aws.String("String"), - ForwardingAddressId: aws.String("AddressId"), - Notification: &snowball.Notification{ - JobStatesToNotify: []*string{ - aws.String("JobState"), // Required - // More values... - }, - NotifyAll: aws.Bool(true), - SnsTopicARN: aws.String("SnsTopicARN"), - }, - Resources: &snowball.JobResource{ - LambdaResources: []*snowball.LambdaResource{ - { // Required - EventTriggers: []*snowball.EventTriggerDefinition{ - { // Required - EventResourceARN: aws.String("ResourceARN"), - }, - // More values... - }, - LambdaArn: aws.String("ResourceARN"), - }, - // More values... - }, - S3Resources: []*snowball.S3Resource{ - { // Required - BucketArn: aws.String("ResourceARN"), - KeyRange: &snowball.KeyRange{ - BeginMarker: aws.String("String"), - EndMarker: aws.String("String"), - }, - }, - // More values... - }, - }, - RoleARN: aws.String("RoleARN"), - ShippingOption: aws.String("ShippingOption"), - } - resp, err := svc.UpdateCluster(params) - - if err != nil { - // 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) -} - -func ExampleSnowball_UpdateJob() { - sess := session.Must(session.NewSession()) - - svc := snowball.New(sess) - - params := &snowball.UpdateJobInput{ - JobId: aws.String("JobId"), // Required - AddressId: aws.String("AddressId"), - Description: aws.String("String"), - ForwardingAddressId: aws.String("AddressId"), - Notification: &snowball.Notification{ - JobStatesToNotify: []*string{ - aws.String("JobState"), // Required - // More values... - }, - NotifyAll: aws.Bool(true), - SnsTopicARN: aws.String("SnsTopicARN"), - }, - Resources: &snowball.JobResource{ - LambdaResources: []*snowball.LambdaResource{ - { // Required - EventTriggers: []*snowball.EventTriggerDefinition{ - { // Required - EventResourceARN: aws.String("ResourceARN"), - }, - // More values... - }, - LambdaArn: aws.String("ResourceARN"), - }, - // More values... - }, - S3Resources: []*snowball.S3Resource{ - { // Required - BucketArn: aws.String("ResourceARN"), - KeyRange: &snowball.KeyRange{ - BeginMarker: aws.String("String"), - EndMarker: aws.String("String"), - }, - }, - // More values... - }, - }, - RoleARN: aws.String("RoleARN"), - ShippingOption: aws.String("ShippingOption"), - SnowballCapacityPreference: aws.String("Capacity"), - } - resp, err := svc.UpdateJob(params) - - if err != nil { - // 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) -} diff --git a/service/sns/examples_test.go b/service/sns/examples_test.go deleted file mode 100644 index 2c77790ebb9..00000000000 --- a/service/sns/examples_test.go +++ /dev/null @@ -1,704 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package sns_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sns" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSNS_AddPermission() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.AddPermissionInput{ - AWSAccountId: []*string{ // Required - aws.String("delegate"), // Required - // More values... - }, - ActionName: []*string{ // Required - aws.String("action"), // Required - // More values... - }, - Label: aws.String("label"), // Required - TopicArn: aws.String("topicARN"), // Required - } - resp, err := svc.AddPermission(params) - - if err != nil { - // 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) -} - -func ExampleSNS_CheckIfPhoneNumberIsOptedOut() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.CheckIfPhoneNumberIsOptedOutInput{ - PhoneNumber: aws.String("PhoneNumber"), // Required - } - resp, err := svc.CheckIfPhoneNumberIsOptedOut(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ConfirmSubscription() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ConfirmSubscriptionInput{ - Token: aws.String("token"), // Required - TopicArn: aws.String("topicARN"), // Required - AuthenticateOnUnsubscribe: aws.String("authenticateOnUnsubscribe"), - } - resp, err := svc.ConfirmSubscription(params) - - if err != nil { - // 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) -} - -func ExampleSNS_CreatePlatformApplication() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.CreatePlatformApplicationInput{ - Attributes: map[string]*string{ // Required - "Key": aws.String("String"), // Required - // More values... - }, - Name: aws.String("String"), // Required - Platform: aws.String("String"), // Required - } - resp, err := svc.CreatePlatformApplication(params) - - if err != nil { - // 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) -} - -func ExampleSNS_CreatePlatformEndpoint() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.CreatePlatformEndpointInput{ - PlatformApplicationArn: aws.String("String"), // Required - Token: aws.String("String"), // Required - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - CustomUserData: aws.String("String"), - } - resp, err := svc.CreatePlatformEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleSNS_CreateTopic() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.CreateTopicInput{ - Name: aws.String("topicName"), // Required - } - resp, err := svc.CreateTopic(params) - - if err != nil { - // 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) -} - -func ExampleSNS_DeleteEndpoint() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.DeleteEndpointInput{ - EndpointArn: aws.String("String"), // Required - } - resp, err := svc.DeleteEndpoint(params) - - if err != nil { - // 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) -} - -func ExampleSNS_DeletePlatformApplication() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.DeletePlatformApplicationInput{ - PlatformApplicationArn: aws.String("String"), // Required - } - resp, err := svc.DeletePlatformApplication(params) - - if err != nil { - // 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) -} - -func ExampleSNS_DeleteTopic() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.DeleteTopicInput{ - TopicArn: aws.String("topicARN"), // Required - } - resp, err := svc.DeleteTopic(params) - - if err != nil { - // 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) -} - -func ExampleSNS_GetEndpointAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.GetEndpointAttributesInput{ - EndpointArn: aws.String("String"), // Required - } - resp, err := svc.GetEndpointAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_GetPlatformApplicationAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.GetPlatformApplicationAttributesInput{ - PlatformApplicationArn: aws.String("String"), // Required - } - resp, err := svc.GetPlatformApplicationAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_GetSMSAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.GetSMSAttributesInput{ - Attributes: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.GetSMSAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_GetSubscriptionAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.GetSubscriptionAttributesInput{ - SubscriptionArn: aws.String("subscriptionARN"), // Required - } - resp, err := svc.GetSubscriptionAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_GetTopicAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.GetTopicAttributesInput{ - TopicArn: aws.String("topicARN"), // Required - } - resp, err := svc.GetTopicAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListEndpointsByPlatformApplication() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListEndpointsByPlatformApplicationInput{ - PlatformApplicationArn: aws.String("String"), // Required - NextToken: aws.String("String"), - } - resp, err := svc.ListEndpointsByPlatformApplication(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListPhoneNumbersOptedOut() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListPhoneNumbersOptedOutInput{ - NextToken: aws.String("string"), - } - resp, err := svc.ListPhoneNumbersOptedOut(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListPlatformApplications() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListPlatformApplicationsInput{ - NextToken: aws.String("String"), - } - resp, err := svc.ListPlatformApplications(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListSubscriptionsInput{ - NextToken: aws.String("nextToken"), - } - resp, err := svc.ListSubscriptions(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListSubscriptionsByTopic() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListSubscriptionsByTopicInput{ - TopicArn: aws.String("topicARN"), // Required - NextToken: aws.String("nextToken"), - } - resp, err := svc.ListSubscriptionsByTopic(params) - - if err != nil { - // 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) -} - -func ExampleSNS_ListTopics() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.ListTopicsInput{ - NextToken: aws.String("nextToken"), - } - resp, err := svc.ListTopics(params) - - if err != nil { - // 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) -} - -func ExampleSNS_OptInPhoneNumber() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.OptInPhoneNumberInput{ - PhoneNumber: aws.String("PhoneNumber"), // Required - } - resp, err := svc.OptInPhoneNumber(params) - - if err != nil { - // 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) -} - -func ExampleSNS_Publish() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.PublishInput{ - Message: aws.String("message"), // Required - MessageAttributes: map[string]*sns.MessageAttributeValue{ - "Key": { // Required - DataType: aws.String("String"), // Required - BinaryValue: []byte("PAYLOAD"), - StringValue: aws.String("String"), - }, - // More values... - }, - MessageStructure: aws.String("messageStructure"), - PhoneNumber: aws.String("String"), - Subject: aws.String("subject"), - TargetArn: aws.String("String"), - TopicArn: aws.String("topicARN"), - } - resp, err := svc.Publish(params) - - if err != nil { - // 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) -} - -func ExampleSNS_RemovePermission() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.RemovePermissionInput{ - Label: aws.String("label"), // Required - TopicArn: aws.String("topicARN"), // Required - } - resp, err := svc.RemovePermission(params) - - if err != nil { - // 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) -} - -func ExampleSNS_SetEndpointAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SetEndpointAttributesInput{ - Attributes: map[string]*string{ // Required - "Key": aws.String("String"), // Required - // More values... - }, - EndpointArn: aws.String("String"), // Required - } - resp, err := svc.SetEndpointAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_SetPlatformApplicationAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SetPlatformApplicationAttributesInput{ - Attributes: map[string]*string{ // Required - "Key": aws.String("String"), // Required - // More values... - }, - PlatformApplicationArn: aws.String("String"), // Required - } - resp, err := svc.SetPlatformApplicationAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_SetSMSAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SetSMSAttributesInput{ - Attributes: map[string]*string{ // Required - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.SetSMSAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_SetSubscriptionAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SetSubscriptionAttributesInput{ - AttributeName: aws.String("attributeName"), // Required - SubscriptionArn: aws.String("subscriptionARN"), // Required - AttributeValue: aws.String("attributeValue"), - } - resp, err := svc.SetSubscriptionAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_SetTopicAttributes() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SetTopicAttributesInput{ - AttributeName: aws.String("attributeName"), // Required - TopicArn: aws.String("topicARN"), // Required - AttributeValue: aws.String("attributeValue"), - } - resp, err := svc.SetTopicAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSNS_Subscribe() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.SubscribeInput{ - Protocol: aws.String("protocol"), // Required - TopicArn: aws.String("topicARN"), // Required - Endpoint: aws.String("endpoint"), - } - resp, err := svc.Subscribe(params) - - if err != nil { - // 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) -} - -func ExampleSNS_Unsubscribe() { - sess := session.Must(session.NewSession()) - - svc := sns.New(sess) - - params := &sns.UnsubscribeInput{ - SubscriptionArn: aws.String("subscriptionARN"), // Required - } - resp, err := svc.Unsubscribe(params) - - if err != nil { - // 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) -} diff --git a/service/sqs/examples_test.go b/service/sqs/examples_test.go deleted file mode 100644 index d39e328e3e4..00000000000 --- a/service/sqs/examples_test.go +++ /dev/null @@ -1,472 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package sqs_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sqs" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSQS_AddPermission() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.AddPermissionInput{ - AWSAccountIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Actions: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - Label: aws.String("String"), // Required - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.AddPermission(params) - - if err != nil { - // 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) -} - -func ExampleSQS_ChangeMessageVisibility() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.ChangeMessageVisibilityInput{ - QueueUrl: aws.String("String"), // Required - ReceiptHandle: aws.String("String"), // Required - VisibilityTimeout: aws.Int64(1), // Required - } - resp, err := svc.ChangeMessageVisibility(params) - - if err != nil { - // 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) -} - -func ExampleSQS_ChangeMessageVisibilityBatch() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.ChangeMessageVisibilityBatchInput{ - Entries: []*sqs.ChangeMessageVisibilityBatchRequestEntry{ // Required - { // Required - Id: aws.String("String"), // Required - ReceiptHandle: aws.String("String"), // Required - VisibilityTimeout: aws.Int64(1), - }, - // More values... - }, - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.ChangeMessageVisibilityBatch(params) - - if err != nil { - // 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) -} - -func ExampleSQS_CreateQueue() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.CreateQueueInput{ - QueueName: aws.String("String"), // Required - Attributes: map[string]*string{ - "Key": aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.CreateQueue(params) - - if err != nil { - // 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) -} - -func ExampleSQS_DeleteMessage() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.DeleteMessageInput{ - QueueUrl: aws.String("String"), // Required - ReceiptHandle: aws.String("String"), // Required - } - resp, err := svc.DeleteMessage(params) - - if err != nil { - // 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) -} - -func ExampleSQS_DeleteMessageBatch() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.DeleteMessageBatchInput{ - Entries: []*sqs.DeleteMessageBatchRequestEntry{ // Required - { // Required - Id: aws.String("String"), // Required - ReceiptHandle: aws.String("String"), // Required - }, - // More values... - }, - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.DeleteMessageBatch(params) - - if err != nil { - // 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) -} - -func ExampleSQS_DeleteQueue() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.DeleteQueueInput{ - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.DeleteQueue(params) - - if err != nil { - // 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) -} - -func ExampleSQS_GetQueueAttributes() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.GetQueueAttributesInput{ - QueueUrl: aws.String("String"), // Required - AttributeNames: []*string{ - aws.String("QueueAttributeName"), // Required - // More values... - }, - } - resp, err := svc.GetQueueAttributes(params) - - if err != nil { - // 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) -} - -func ExampleSQS_GetQueueUrl() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.GetQueueUrlInput{ - QueueName: aws.String("String"), // Required - QueueOwnerAWSAccountId: aws.String("String"), - } - resp, err := svc.GetQueueUrl(params) - - if err != nil { - // 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) -} - -func ExampleSQS_ListDeadLetterSourceQueues() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.ListDeadLetterSourceQueuesInput{ - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.ListDeadLetterSourceQueues(params) - - if err != nil { - // 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) -} - -func ExampleSQS_ListQueues() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.ListQueuesInput{ - QueueNamePrefix: aws.String("String"), - } - resp, err := svc.ListQueues(params) - - if err != nil { - // 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) -} - -func ExampleSQS_PurgeQueue() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.PurgeQueueInput{ - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.PurgeQueue(params) - - if err != nil { - // 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) -} - -func ExampleSQS_ReceiveMessage() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.ReceiveMessageInput{ - QueueUrl: aws.String("String"), // Required - AttributeNames: []*string{ - aws.String("QueueAttributeName"), // Required - // More values... - }, - MaxNumberOfMessages: aws.Int64(1), - MessageAttributeNames: []*string{ - aws.String("MessageAttributeName"), // Required - // More values... - }, - ReceiveRequestAttemptId: aws.String("String"), - VisibilityTimeout: aws.Int64(1), - WaitTimeSeconds: aws.Int64(1), - } - resp, err := svc.ReceiveMessage(params) - - if err != nil { - // 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) -} - -func ExampleSQS_RemovePermission() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.RemovePermissionInput{ - Label: aws.String("String"), // Required - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.RemovePermission(params) - - if err != nil { - // 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) -} - -func ExampleSQS_SendMessage() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.SendMessageInput{ - MessageBody: aws.String("String"), // Required - QueueUrl: aws.String("String"), // Required - DelaySeconds: aws.Int64(1), - MessageAttributes: map[string]*sqs.MessageAttributeValue{ - "Key": { // Required - DataType: aws.String("String"), // Required - BinaryListValues: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - BinaryValue: []byte("PAYLOAD"), - StringListValues: []*string{ - aws.String("String"), // Required - // More values... - }, - StringValue: aws.String("String"), - }, - // More values... - }, - MessageDeduplicationId: aws.String("String"), - MessageGroupId: aws.String("String"), - } - resp, err := svc.SendMessage(params) - - if err != nil { - // 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) -} - -func ExampleSQS_SendMessageBatch() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.SendMessageBatchInput{ - Entries: []*sqs.SendMessageBatchRequestEntry{ // Required - { // Required - Id: aws.String("String"), // Required - MessageBody: aws.String("String"), // Required - DelaySeconds: aws.Int64(1), - MessageAttributes: map[string]*sqs.MessageAttributeValue{ - "Key": { // Required - DataType: aws.String("String"), // Required - BinaryListValues: [][]byte{ - []byte("PAYLOAD"), // Required - // More values... - }, - BinaryValue: []byte("PAYLOAD"), - StringListValues: []*string{ - aws.String("String"), // Required - // More values... - }, - StringValue: aws.String("String"), - }, - // More values... - }, - MessageDeduplicationId: aws.String("String"), - MessageGroupId: aws.String("String"), - }, - // More values... - }, - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.SendMessageBatch(params) - - if err != nil { - // 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) -} - -func ExampleSQS_SetQueueAttributes() { - sess := session.Must(session.NewSession()) - - svc := sqs.New(sess) - - params := &sqs.SetQueueAttributesInput{ - Attributes: map[string]*string{ // Required - "Key": aws.String("String"), // Required - // More values... - }, - QueueUrl: aws.String("String"), // Required - } - resp, err := svc.SetQueueAttributes(params) - - if err != nil { - // 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) -} diff --git a/service/ssm/examples_test.go b/service/ssm/examples_test.go deleted file mode 100644 index ef01280c829..00000000000 --- a/service/ssm/examples_test.go +++ /dev/null @@ -1,2311 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package ssm_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/ssm" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSSM_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.AddTagsToResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - ResourceType: aws.String("ResourceTypeForTagging"), // Required - Tags: []*ssm.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CancelCommand() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CancelCommandInput{ - CommandId: aws.String("CommandId"), // Required - InstanceIds: []*string{ - aws.String("InstanceId"), // Required - // More values... - }, - } - resp, err := svc.CancelCommand(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreateActivation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreateActivationInput{ - IamRole: aws.String("IamRole"), // Required - DefaultInstanceName: aws.String("DefaultInstanceName"), - Description: aws.String("ActivationDescription"), - ExpirationDate: aws.Time(time.Now()), - RegistrationLimit: aws.Int64(1), - } - resp, err := svc.CreateActivation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreateAssociation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreateAssociationInput{ - Name: aws.String("DocumentName"), // Required - DocumentVersion: aws.String("DocumentVersion"), - InstanceId: aws.String("InstanceId"), - OutputLocation: &ssm.InstanceAssociationOutputLocation{ - S3Location: &ssm.S3OutputLocation{ - OutputS3BucketName: aws.String("S3BucketName"), - OutputS3KeyPrefix: aws.String("S3KeyPrefix"), - OutputS3Region: aws.String("S3Region"), - }, - }, - Parameters: map[string][]*string{ - "Key": { // Required - aws.String("ParameterValue"), // Required - // More values... - }, - // More values... - }, - ScheduleExpression: aws.String("ScheduleExpression"), - Targets: []*ssm.Target{ - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.CreateAssociation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreateAssociationBatch() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreateAssociationBatchInput{ - Entries: []*ssm.CreateAssociationBatchRequestEntry{ // Required - { // Required - Name: aws.String("DocumentName"), // Required - DocumentVersion: aws.String("DocumentVersion"), - InstanceId: aws.String("InstanceId"), - OutputLocation: &ssm.InstanceAssociationOutputLocation{ - S3Location: &ssm.S3OutputLocation{ - OutputS3BucketName: aws.String("S3BucketName"), - OutputS3KeyPrefix: aws.String("S3KeyPrefix"), - OutputS3Region: aws.String("S3Region"), - }, - }, - Parameters: map[string][]*string{ - "Key": { // Required - aws.String("ParameterValue"), // Required - // More values... - }, - // More values... - }, - ScheduleExpression: aws.String("ScheduleExpression"), - Targets: []*ssm.Target{ - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.CreateAssociationBatch(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreateDocument() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreateDocumentInput{ - Content: aws.String("DocumentContent"), // Required - Name: aws.String("DocumentName"), // Required - DocumentType: aws.String("DocumentType"), - } - resp, err := svc.CreateDocument(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreateMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreateMaintenanceWindowInput{ - AllowUnassociatedTargets: aws.Bool(true), // Required - Cutoff: aws.Int64(1), // Required - Duration: aws.Int64(1), // Required - Name: aws.String("MaintenanceWindowName"), // Required - Schedule: aws.String("MaintenanceWindowSchedule"), // Required - ClientToken: aws.String("ClientToken"), - } - resp, err := svc.CreateMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_CreatePatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.CreatePatchBaselineInput{ - Name: aws.String("BaselineName"), // Required - ApprovalRules: &ssm.PatchRuleGroup{ - PatchRules: []*ssm.PatchRule{ // Required - { // Required - ApproveAfterDays: aws.Int64(1), // Required - PatchFilterGroup: &ssm.PatchFilterGroup{ // Required - PatchFilters: []*ssm.PatchFilter{ // Required - { // Required - Key: aws.String("PatchFilterKey"), // Required - Values: []*string{ // Required - aws.String("PatchFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - }, - // More values... - }, - }, - ApprovedPatches: []*string{ - aws.String("PatchId"), // Required - // More values... - }, - ClientToken: aws.String("ClientToken"), - Description: aws.String("BaselineDescription"), - GlobalFilters: &ssm.PatchFilterGroup{ - PatchFilters: []*ssm.PatchFilter{ // Required - { // Required - Key: aws.String("PatchFilterKey"), // Required - Values: []*string{ // Required - aws.String("PatchFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - RejectedPatches: []*string{ - aws.String("PatchId"), // Required - // More values... - }, - } - resp, err := svc.CreatePatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeleteActivation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeleteActivationInput{ - ActivationId: aws.String("ActivationId"), // Required - } - resp, err := svc.DeleteActivation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeleteAssociation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeleteAssociationInput{ - AssociationId: aws.String("AssociationId"), - InstanceId: aws.String("InstanceId"), - Name: aws.String("DocumentName"), - } - resp, err := svc.DeleteAssociation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeleteDocument() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeleteDocumentInput{ - Name: aws.String("DocumentName"), // Required - } - resp, err := svc.DeleteDocument(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeleteMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeleteMaintenanceWindowInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - } - resp, err := svc.DeleteMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeleteParameter() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeleteParameterInput{ - Name: aws.String("PSParameterName"), // Required - } - resp, err := svc.DeleteParameter(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeletePatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeletePatchBaselineInput{ - BaselineId: aws.String("BaselineId"), // Required - } - resp, err := svc.DeletePatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeregisterManagedInstance() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeregisterManagedInstanceInput{ - InstanceId: aws.String("ManagedInstanceId"), // Required - } - resp, err := svc.DeregisterManagedInstance(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeregisterPatchBaselineForPatchGroup() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeregisterPatchBaselineForPatchGroupInput{ - BaselineId: aws.String("BaselineId"), // Required - PatchGroup: aws.String("PatchGroup"), // Required - } - resp, err := svc.DeregisterPatchBaselineForPatchGroup(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeregisterTargetFromMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeregisterTargetFromMaintenanceWindowInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - WindowTargetId: aws.String("MaintenanceWindowTargetId"), // Required - } - resp, err := svc.DeregisterTargetFromMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DeregisterTaskFromMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DeregisterTaskFromMaintenanceWindowInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - WindowTaskId: aws.String("MaintenanceWindowTaskId"), // Required - } - resp, err := svc.DeregisterTaskFromMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeActivations() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeActivationsInput{ - Filters: []*ssm.DescribeActivationsFilter{ - { // Required - FilterKey: aws.String("DescribeActivationsFilterKeys"), - FilterValues: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeActivations(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeAssociation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeAssociationInput{ - AssociationId: aws.String("AssociationId"), - InstanceId: aws.String("InstanceId"), - Name: aws.String("DocumentName"), - } - resp, err := svc.DescribeAssociation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeAutomationExecutions() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeAutomationExecutionsInput{ - Filters: []*ssm.AutomationExecutionFilter{ - { // Required - Key: aws.String("AutomationExecutionFilterKey"), // Required - Values: []*string{ // Required - aws.String("AutomationExecutionFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeAutomationExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeAvailablePatches() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeAvailablePatchesInput{ - Filters: []*ssm.PatchOrchestratorFilter{ - { // Required - Key: aws.String("PatchOrchestratorFilterKey"), - Values: []*string{ - aws.String("PatchOrchestratorFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeAvailablePatches(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeDocument() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeDocumentInput{ - Name: aws.String("DocumentARN"), // Required - DocumentVersion: aws.String("DocumentVersion"), - } - resp, err := svc.DescribeDocument(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeDocumentPermission() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeDocumentPermissionInput{ - Name: aws.String("DocumentName"), // Required - PermissionType: aws.String("DocumentPermissionType"), // Required - } - resp, err := svc.DescribeDocumentPermission(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeEffectiveInstanceAssociations() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeEffectiveInstanceAssociationsInput{ - InstanceId: aws.String("InstanceId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeEffectiveInstanceAssociations(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeEffectivePatchesForPatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeEffectivePatchesForPatchBaselineInput{ - BaselineId: aws.String("BaselineId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeEffectivePatchesForPatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeInstanceAssociationsStatus() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeInstanceAssociationsStatusInput{ - InstanceId: aws.String("InstanceId"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstanceAssociationsStatus(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeInstanceInformation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeInstanceInformationInput{ - Filters: []*ssm.InstanceInformationStringFilter{ - { // Required - Key: aws.String("InstanceInformationStringFilterKey"), // Required - Values: []*string{ // Required - aws.String("InstanceInformationFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - InstanceInformationFilterList: []*ssm.InstanceInformationFilter{ - { // Required - Key: aws.String("InstanceInformationFilterKey"), // Required - ValueSet: []*string{ // Required - aws.String("InstanceInformationFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstanceInformation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeInstancePatchStates() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeInstancePatchStatesInput{ - InstanceIds: []*string{ // Required - aws.String("InstanceId"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstancePatchStates(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeInstancePatchStatesForPatchGroup() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeInstancePatchStatesForPatchGroupInput{ - PatchGroup: aws.String("PatchGroup"), // Required - Filters: []*ssm.InstancePatchStateFilter{ - { // Required - Key: aws.String("InstancePatchStateFilterKey"), // Required - Type: aws.String("InstancePatchStateOperatorType"), // Required - Values: []*string{ // Required - aws.String("InstancePatchStateFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstancePatchStatesForPatchGroup(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeInstancePatches() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeInstancePatchesInput{ - InstanceId: aws.String("InstanceId"), // Required - Filters: []*ssm.PatchOrchestratorFilter{ - { // Required - Key: aws.String("PatchOrchestratorFilterKey"), - Values: []*string{ - aws.String("PatchOrchestratorFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeInstancePatches(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindowExecutionTaskInvocations() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowExecutionTaskInvocationsInput{ - TaskId: aws.String("MaintenanceWindowExecutionTaskId"), // Required - WindowExecutionId: aws.String("MaintenanceWindowExecutionId"), // Required - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindowExecutionTaskInvocations(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindowExecutionTasks() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowExecutionTasksInput{ - WindowExecutionId: aws.String("MaintenanceWindowExecutionId"), // Required - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindowExecutionTasks(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindowExecutions() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowExecutionsInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindowExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindowTargets() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowTargetsInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindowTargets(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindowTasks() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowTasksInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindowTasks(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeMaintenanceWindows() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeMaintenanceWindowsInput{ - Filters: []*ssm.MaintenanceWindowFilter{ - { // Required - Key: aws.String("MaintenanceWindowFilterKey"), - Values: []*string{ - aws.String("MaintenanceWindowFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeMaintenanceWindows(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribeParameters() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribeParametersInput{ - Filters: []*ssm.ParametersFilter{ - { // Required - Values: []*string{ // Required - aws.String("ParametersFilterValue"), // Required - // More values... - }, - Key: aws.String("ParametersFilterKey"), - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeParameters(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribePatchBaselines() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribePatchBaselinesInput{ - Filters: []*ssm.PatchOrchestratorFilter{ - { // Required - Key: aws.String("PatchOrchestratorFilterKey"), - Values: []*string{ - aws.String("PatchOrchestratorFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribePatchBaselines(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribePatchGroupState() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribePatchGroupStateInput{ - PatchGroup: aws.String("PatchGroup"), // Required - } - resp, err := svc.DescribePatchGroupState(params) - - if err != nil { - // 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) -} - -func ExampleSSM_DescribePatchGroups() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.DescribePatchGroupsInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribePatchGroups(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetAutomationExecution() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetAutomationExecutionInput{ - AutomationExecutionId: aws.String("AutomationExecutionId"), // Required - } - resp, err := svc.GetAutomationExecution(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetCommandInvocation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetCommandInvocationInput{ - CommandId: aws.String("CommandId"), // Required - InstanceId: aws.String("InstanceId"), // Required - PluginName: aws.String("CommandPluginName"), - } - resp, err := svc.GetCommandInvocation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetDefaultPatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - var params *ssm.GetDefaultPatchBaselineInput - resp, err := svc.GetDefaultPatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetDeployablePatchSnapshotForInstance() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetDeployablePatchSnapshotForInstanceInput{ - InstanceId: aws.String("InstanceId"), // Required - SnapshotId: aws.String("SnapshotId"), // Required - } - resp, err := svc.GetDeployablePatchSnapshotForInstance(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetDocument() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetDocumentInput{ - Name: aws.String("DocumentARN"), // Required - DocumentVersion: aws.String("DocumentVersion"), - } - resp, err := svc.GetDocument(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetInventory() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetInventoryInput{ - Filters: []*ssm.InventoryFilter{ - { // Required - Key: aws.String("InventoryFilterKey"), // Required - Values: []*string{ // Required - aws.String("InventoryFilterValue"), // Required - // More values... - }, - Type: aws.String("InventoryQueryOperatorType"), - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - ResultAttributes: []*ssm.ResultAttribute{ - { // Required - TypeName: aws.String("InventoryItemTypeName"), // Required - }, - // More values... - }, - } - resp, err := svc.GetInventory(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetInventorySchema() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetInventorySchemaInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - TypeName: aws.String("InventoryItemTypeNameFilter"), - } - resp, err := svc.GetInventorySchema(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetMaintenanceWindowInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - } - resp, err := svc.GetMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetMaintenanceWindowExecution() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetMaintenanceWindowExecutionInput{ - WindowExecutionId: aws.String("MaintenanceWindowExecutionId"), // Required - } - resp, err := svc.GetMaintenanceWindowExecution(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetMaintenanceWindowExecutionTask() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetMaintenanceWindowExecutionTaskInput{ - TaskId: aws.String("MaintenanceWindowExecutionTaskId"), // Required - WindowExecutionId: aws.String("MaintenanceWindowExecutionId"), // Required - } - resp, err := svc.GetMaintenanceWindowExecutionTask(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetParameterHistory() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetParameterHistoryInput{ - Name: aws.String("PSParameterName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - WithDecryption: aws.Bool(true), - } - resp, err := svc.GetParameterHistory(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetParameters() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetParametersInput{ - Names: []*string{ // Required - aws.String("PSParameterName"), // Required - // More values... - }, - WithDecryption: aws.Bool(true), - } - resp, err := svc.GetParameters(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetPatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetPatchBaselineInput{ - BaselineId: aws.String("BaselineId"), // Required - } - resp, err := svc.GetPatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_GetPatchBaselineForPatchGroup() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.GetPatchBaselineForPatchGroupInput{ - PatchGroup: aws.String("PatchGroup"), // Required - } - resp, err := svc.GetPatchBaselineForPatchGroup(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListAssociations() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListAssociationsInput{ - AssociationFilterList: []*ssm.AssociationFilter{ - { // Required - Key: aws.String("AssociationFilterKey"), // Required - Value: aws.String("AssociationFilterValue"), // Required - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListAssociations(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListCommandInvocations() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListCommandInvocationsInput{ - CommandId: aws.String("CommandId"), - Details: aws.Bool(true), - Filters: []*ssm.CommandFilter{ - { // Required - Key: aws.String("CommandFilterKey"), // Required - Value: aws.String("CommandFilterValue"), // Required - }, - // More values... - }, - InstanceId: aws.String("InstanceId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListCommandInvocations(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListCommands() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListCommandsInput{ - CommandId: aws.String("CommandId"), - Filters: []*ssm.CommandFilter{ - { // Required - Key: aws.String("CommandFilterKey"), // Required - Value: aws.String("CommandFilterValue"), // Required - }, - // More values... - }, - InstanceId: aws.String("InstanceId"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListCommands(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListDocumentVersions() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListDocumentVersionsInput{ - Name: aws.String("DocumentName"), // Required - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDocumentVersions(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListDocuments() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListDocumentsInput{ - DocumentFilterList: []*ssm.DocumentFilter{ - { // Required - Key: aws.String("DocumentFilterKey"), // Required - Value: aws.String("DocumentFilterValue"), // Required - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListDocuments(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListInventoryEntries() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListInventoryEntriesInput{ - InstanceId: aws.String("InstanceId"), // Required - TypeName: aws.String("InventoryItemTypeName"), // Required - Filters: []*ssm.InventoryFilter{ - { // Required - Key: aws.String("InventoryFilterKey"), // Required - Values: []*string{ // Required - aws.String("InventoryFilterValue"), // Required - // More values... - }, - Type: aws.String("InventoryQueryOperatorType"), - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.ListInventoryEntries(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ListTagsForResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - ResourceType: aws.String("ResourceTypeForTagging"), // Required - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleSSM_ModifyDocumentPermission() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.ModifyDocumentPermissionInput{ - Name: aws.String("DocumentName"), // Required - PermissionType: aws.String("DocumentPermissionType"), // Required - AccountIdsToAdd: []*string{ - aws.String("AccountId"), // Required - // More values... - }, - AccountIdsToRemove: []*string{ - aws.String("AccountId"), // Required - // More values... - }, - } - resp, err := svc.ModifyDocumentPermission(params) - - if err != nil { - // 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) -} - -func ExampleSSM_PutInventory() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.PutInventoryInput{ - InstanceId: aws.String("InstanceId"), // Required - Items: []*ssm.InventoryItem{ // Required - { // Required - CaptureTime: aws.String("InventoryItemCaptureTime"), // Required - SchemaVersion: aws.String("InventoryItemSchemaVersion"), // Required - TypeName: aws.String("InventoryItemTypeName"), // Required - Content: []map[string]*string{ - { // Required - "Key": aws.String("AttributeValue"), // Required - // More values... - }, - // More values... - }, - ContentHash: aws.String("InventoryItemContentHash"), - }, - // More values... - }, - } - resp, err := svc.PutInventory(params) - - if err != nil { - // 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) -} - -func ExampleSSM_PutParameter() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.PutParameterInput{ - Name: aws.String("PSParameterName"), // Required - Type: aws.String("ParameterType"), // Required - Value: aws.String("PSParameterValue"), // Required - Description: aws.String("ParameterDescription"), - KeyId: aws.String("ParameterKeyId"), - Overwrite: aws.Bool(true), - } - resp, err := svc.PutParameter(params) - - if err != nil { - // 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) -} - -func ExampleSSM_RegisterDefaultPatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.RegisterDefaultPatchBaselineInput{ - BaselineId: aws.String("BaselineId"), // Required - } - resp, err := svc.RegisterDefaultPatchBaseline(params) - - if err != nil { - // 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) -} - -func ExampleSSM_RegisterPatchBaselineForPatchGroup() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.RegisterPatchBaselineForPatchGroupInput{ - BaselineId: aws.String("BaselineId"), // Required - PatchGroup: aws.String("PatchGroup"), // Required - } - resp, err := svc.RegisterPatchBaselineForPatchGroup(params) - - if err != nil { - // 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) -} - -func ExampleSSM_RegisterTargetWithMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.RegisterTargetWithMaintenanceWindowInput{ - ResourceType: aws.String("MaintenanceWindowResourceType"), // Required - Targets: []*ssm.Target{ // Required - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - WindowId: aws.String("MaintenanceWindowId"), // Required - ClientToken: aws.String("ClientToken"), - OwnerInformation: aws.String("OwnerInformation"), - } - resp, err := svc.RegisterTargetWithMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_RegisterTaskWithMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.RegisterTaskWithMaintenanceWindowInput{ - MaxConcurrency: aws.String("MaxConcurrency"), // Required - MaxErrors: aws.String("MaxErrors"), // Required - ServiceRoleArn: aws.String("ServiceRole"), // Required - Targets: []*ssm.Target{ // Required - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - TaskArn: aws.String("MaintenanceWindowTaskArn"), // Required - TaskType: aws.String("MaintenanceWindowTaskType"), // Required - WindowId: aws.String("MaintenanceWindowId"), // Required - ClientToken: aws.String("ClientToken"), - LoggingInfo: &ssm.LoggingInfo{ - S3BucketName: aws.String("S3BucketName"), // Required - S3Region: aws.String("S3Region"), // Required - S3KeyPrefix: aws.String("S3KeyPrefix"), - }, - Priority: aws.Int64(1), - TaskParameters: map[string]*ssm.MaintenanceWindowTaskParameterValueExpression{ - "Key": { // Required - Values: []*string{ - aws.String("MaintenanceWindowTaskParameterValue"), // Required - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.RegisterTaskWithMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.RemoveTagsFromResourceInput{ - ResourceId: aws.String("ResourceId"), // Required - ResourceType: aws.String("ResourceTypeForTagging"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromResource(params) - - if err != nil { - // 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) -} - -func ExampleSSM_SendCommand() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.SendCommandInput{ - DocumentName: aws.String("DocumentARN"), // Required - Comment: aws.String("Comment"), - DocumentHash: aws.String("DocumentHash"), - DocumentHashType: aws.String("DocumentHashType"), - InstanceIds: []*string{ - aws.String("InstanceId"), // Required - // More values... - }, - MaxConcurrency: aws.String("MaxConcurrency"), - MaxErrors: aws.String("MaxErrors"), - NotificationConfig: &ssm.NotificationConfig{ - NotificationArn: aws.String("NotificationArn"), - NotificationEvents: []*string{ - aws.String("NotificationEvent"), // Required - // More values... - }, - NotificationType: aws.String("NotificationType"), - }, - OutputS3BucketName: aws.String("S3BucketName"), - OutputS3KeyPrefix: aws.String("S3KeyPrefix"), - OutputS3Region: aws.String("S3Region"), - Parameters: map[string][]*string{ - "Key": { // Required - aws.String("ParameterValue"), // Required - // More values... - }, - // More values... - }, - ServiceRoleArn: aws.String("ServiceRole"), - Targets: []*ssm.Target{ - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - TimeoutSeconds: aws.Int64(1), - } - resp, err := svc.SendCommand(params) - - if err != nil { - // 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) -} - -func ExampleSSM_StartAutomationExecution() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.StartAutomationExecutionInput{ - DocumentName: aws.String("DocumentARN"), // Required - DocumentVersion: aws.String("DocumentVersion"), - Parameters: map[string][]*string{ - "Key": { // Required - aws.String("AutomationParameterValue"), // Required - // More values... - }, - // More values... - }, - } - resp, err := svc.StartAutomationExecution(params) - - if err != nil { - // 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) -} - -func ExampleSSM_StopAutomationExecution() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.StopAutomationExecutionInput{ - AutomationExecutionId: aws.String("AutomationExecutionId"), // Required - } - resp, err := svc.StopAutomationExecution(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateAssociation() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateAssociationInput{ - AssociationId: aws.String("AssociationId"), // Required - DocumentVersion: aws.String("DocumentVersion"), - Name: aws.String("DocumentName"), - OutputLocation: &ssm.InstanceAssociationOutputLocation{ - S3Location: &ssm.S3OutputLocation{ - OutputS3BucketName: aws.String("S3BucketName"), - OutputS3KeyPrefix: aws.String("S3KeyPrefix"), - OutputS3Region: aws.String("S3Region"), - }, - }, - Parameters: map[string][]*string{ - "Key": { // Required - aws.String("ParameterValue"), // Required - // More values... - }, - // More values... - }, - ScheduleExpression: aws.String("ScheduleExpression"), - Targets: []*ssm.Target{ - { // Required - Key: aws.String("TargetKey"), - Values: []*string{ - aws.String("TargetValue"), // Required - // More values... - }, - }, - // More values... - }, - } - resp, err := svc.UpdateAssociation(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateAssociationStatus() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateAssociationStatusInput{ - AssociationStatus: &ssm.AssociationStatus{ // Required - Date: aws.Time(time.Now()), // Required - Message: aws.String("StatusMessage"), // Required - Name: aws.String("AssociationStatusName"), // Required - AdditionalInfo: aws.String("StatusAdditionalInfo"), - }, - InstanceId: aws.String("InstanceId"), // Required - Name: aws.String("DocumentName"), // Required - } - resp, err := svc.UpdateAssociationStatus(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateDocument() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateDocumentInput{ - Content: aws.String("DocumentContent"), // Required - Name: aws.String("DocumentName"), // Required - DocumentVersion: aws.String("DocumentVersion"), - } - resp, err := svc.UpdateDocument(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateDocumentDefaultVersion() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateDocumentDefaultVersionInput{ - DocumentVersion: aws.String("DocumentVersionNumber"), // Required - Name: aws.String("DocumentName"), // Required - } - resp, err := svc.UpdateDocumentDefaultVersion(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateMaintenanceWindow() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateMaintenanceWindowInput{ - WindowId: aws.String("MaintenanceWindowId"), // Required - AllowUnassociatedTargets: aws.Bool(true), - Cutoff: aws.Int64(1), - Duration: aws.Int64(1), - Enabled: aws.Bool(true), - Name: aws.String("MaintenanceWindowName"), - Schedule: aws.String("MaintenanceWindowSchedule"), - } - resp, err := svc.UpdateMaintenanceWindow(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdateManagedInstanceRole() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdateManagedInstanceRoleInput{ - IamRole: aws.String("IamRole"), // Required - InstanceId: aws.String("ManagedInstanceId"), // Required - } - resp, err := svc.UpdateManagedInstanceRole(params) - - if err != nil { - // 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) -} - -func ExampleSSM_UpdatePatchBaseline() { - sess := session.Must(session.NewSession()) - - svc := ssm.New(sess) - - params := &ssm.UpdatePatchBaselineInput{ - BaselineId: aws.String("BaselineId"), // Required - ApprovalRules: &ssm.PatchRuleGroup{ - PatchRules: []*ssm.PatchRule{ // Required - { // Required - ApproveAfterDays: aws.Int64(1), // Required - PatchFilterGroup: &ssm.PatchFilterGroup{ // Required - PatchFilters: []*ssm.PatchFilter{ // Required - { // Required - Key: aws.String("PatchFilterKey"), // Required - Values: []*string{ // Required - aws.String("PatchFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - }, - // More values... - }, - }, - ApprovedPatches: []*string{ - aws.String("PatchId"), // Required - // More values... - }, - Description: aws.String("BaselineDescription"), - GlobalFilters: &ssm.PatchFilterGroup{ - PatchFilters: []*ssm.PatchFilter{ // Required - { // Required - Key: aws.String("PatchFilterKey"), // Required - Values: []*string{ // Required - aws.String("PatchFilterValue"), // Required - // More values... - }, - }, - // More values... - }, - }, - Name: aws.String("BaselineName"), - RejectedPatches: []*string{ - aws.String("PatchId"), // Required - // More values... - }, - } - resp, err := svc.UpdatePatchBaseline(params) - - if err != nil { - // 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) -} diff --git a/service/storagegateway/examples_test.go b/service/storagegateway/examples_test.go deleted file mode 100644 index af692d64c9e..00000000000 --- a/service/storagegateway/examples_test.go +++ /dev/null @@ -1,1461 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package storagegateway_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/storagegateway" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleStorageGateway_ActivateGateway() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ActivateGatewayInput{ - ActivationKey: aws.String("ActivationKey"), // Required - GatewayName: aws.String("GatewayName"), // Required - GatewayRegion: aws.String("RegionId"), // Required - GatewayTimezone: aws.String("GatewayTimezone"), // Required - GatewayType: aws.String("GatewayType"), - MediumChangerType: aws.String("MediumChangerType"), - TapeDriveType: aws.String("TapeDriveType"), - } - resp, err := svc.ActivateGateway(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_AddCache() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.AddCacheInput{ - DiskIds: []*string{ // Required - aws.String("DiskId"), // Required - // More values... - }, - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.AddCache(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_AddTagsToResource() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.AddTagsToResourceInput{ - ResourceARN: aws.String("ResourceARN"), // Required - Tags: []*storagegateway.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), // Required - }, - // More values... - }, - } - resp, err := svc.AddTagsToResource(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_AddUploadBuffer() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.AddUploadBufferInput{ - DiskIds: []*string{ // Required - aws.String("DiskId"), // Required - // More values... - }, - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.AddUploadBuffer(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_AddWorkingStorage() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.AddWorkingStorageInput{ - DiskIds: []*string{ // Required - aws.String("DiskId"), // Required - // More values... - }, - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.AddWorkingStorage(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CancelArchival() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CancelArchivalInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.CancelArchival(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CancelRetrieval() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CancelRetrievalInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.CancelRetrieval(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateCachediSCSIVolume() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateCachediSCSIVolumeInput{ - ClientToken: aws.String("ClientToken"), // Required - GatewayARN: aws.String("GatewayARN"), // Required - NetworkInterfaceId: aws.String("NetworkInterfaceId"), // Required - TargetName: aws.String("TargetName"), // Required - VolumeSizeInBytes: aws.Int64(1), // Required - SnapshotId: aws.String("SnapshotId"), - SourceVolumeARN: aws.String("VolumeARN"), - } - resp, err := svc.CreateCachediSCSIVolume(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateNFSFileShare() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateNFSFileShareInput{ - ClientToken: aws.String("ClientToken"), // Required - GatewayARN: aws.String("GatewayARN"), // Required - LocationARN: aws.String("LocationARN"), // Required - Role: aws.String("Role"), // Required - ClientList: []*string{ - aws.String("IPV4AddressCIDR"), // Required - // More values... - }, - DefaultStorageClass: aws.String("StorageClass"), - KMSEncrypted: aws.Bool(true), - KMSKey: aws.String("KMSKey"), - NFSFileShareDefaults: &storagegateway.NFSFileShareDefaults{ - DirectoryMode: aws.String("PermissionMode"), - FileMode: aws.String("PermissionMode"), - GroupId: aws.Int64(1), - OwnerId: aws.Int64(1), - }, - ReadOnly: aws.Bool(true), - Squash: aws.String("Squash"), - } - resp, err := svc.CreateNFSFileShare(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateSnapshot() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateSnapshotInput{ - SnapshotDescription: aws.String("SnapshotDescription"), // Required - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.CreateSnapshot(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateSnapshotFromVolumeRecoveryPoint() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateSnapshotFromVolumeRecoveryPointInput{ - SnapshotDescription: aws.String("SnapshotDescription"), // Required - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.CreateSnapshotFromVolumeRecoveryPoint(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateStorediSCSIVolume() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateStorediSCSIVolumeInput{ - DiskId: aws.String("DiskId"), // Required - GatewayARN: aws.String("GatewayARN"), // Required - NetworkInterfaceId: aws.String("NetworkInterfaceId"), // Required - PreserveExistingData: aws.Bool(true), // Required - TargetName: aws.String("TargetName"), // Required - SnapshotId: aws.String("SnapshotId"), - } - resp, err := svc.CreateStorediSCSIVolume(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateTapeWithBarcode() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateTapeWithBarcodeInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeBarcode: aws.String("TapeBarcode"), // Required - TapeSizeInBytes: aws.Int64(1), // Required - } - resp, err := svc.CreateTapeWithBarcode(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_CreateTapes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.CreateTapesInput{ - ClientToken: aws.String("ClientToken"), // Required - GatewayARN: aws.String("GatewayARN"), // Required - NumTapesToCreate: aws.Int64(1), // Required - TapeBarcodePrefix: aws.String("TapeBarcodePrefix"), // Required - TapeSizeInBytes: aws.Int64(1), // Required - } - resp, err := svc.CreateTapes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteBandwidthRateLimit() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteBandwidthRateLimitInput{ - BandwidthType: aws.String("BandwidthType"), // Required - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DeleteBandwidthRateLimit(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteChapCredentials() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteChapCredentialsInput{ - InitiatorName: aws.String("IqnName"), // Required - TargetARN: aws.String("TargetARN"), // Required - } - resp, err := svc.DeleteChapCredentials(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteFileShare() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteFileShareInput{ - FileShareARN: aws.String("FileShareARN"), // Required - } - resp, err := svc.DeleteFileShare(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteGateway() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteGatewayInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DeleteGateway(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteSnapshotSchedule() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteSnapshotScheduleInput{ - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.DeleteSnapshotSchedule(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteTape() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteTapeInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.DeleteTape(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteTapeArchive() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteTapeArchiveInput{ - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.DeleteTapeArchive(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DeleteVolume() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DeleteVolumeInput{ - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.DeleteVolume(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeBandwidthRateLimit() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeBandwidthRateLimitInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeBandwidthRateLimit(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeCache() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeCacheInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeCache(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeCachediSCSIVolumes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeCachediSCSIVolumesInput{ - VolumeARNs: []*string{ // Required - aws.String("VolumeARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeCachediSCSIVolumes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeChapCredentials() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeChapCredentialsInput{ - TargetARN: aws.String("TargetARN"), // Required - } - resp, err := svc.DescribeChapCredentials(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeGatewayInformation() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeGatewayInformationInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeGatewayInformation(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeMaintenanceStartTime() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeMaintenanceStartTimeInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeMaintenanceStartTime(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeNFSFileShares() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeNFSFileSharesInput{ - FileShareARNList: []*string{ // Required - aws.String("FileShareARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeNFSFileShares(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeSnapshotSchedule() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeSnapshotScheduleInput{ - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.DescribeSnapshotSchedule(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeStorediSCSIVolumes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeStorediSCSIVolumesInput{ - VolumeARNs: []*string{ // Required - aws.String("VolumeARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeStorediSCSIVolumes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeTapeArchives() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeTapeArchivesInput{ - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - TapeARNs: []*string{ - aws.String("TapeARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeTapeArchives(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeTapeRecoveryPoints() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeTapeRecoveryPointsInput{ - GatewayARN: aws.String("GatewayARN"), // Required - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - } - resp, err := svc.DescribeTapeRecoveryPoints(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeTapes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeTapesInput{ - GatewayARN: aws.String("GatewayARN"), // Required - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - TapeARNs: []*string{ - aws.String("TapeARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeTapes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeUploadBuffer() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeUploadBufferInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeUploadBuffer(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeVTLDevices() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeVTLDevicesInput{ - GatewayARN: aws.String("GatewayARN"), // Required - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - VTLDeviceARNs: []*string{ - aws.String("VTLDeviceARN"), // Required - // More values... - }, - } - resp, err := svc.DescribeVTLDevices(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DescribeWorkingStorage() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DescribeWorkingStorageInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DescribeWorkingStorage(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_DisableGateway() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.DisableGatewayInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.DisableGateway(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListFileShares() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListFileSharesInput{ - GatewayARN: aws.String("GatewayARN"), - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - } - resp, err := svc.ListFileShares(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListGateways() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListGatewaysInput{ - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - } - resp, err := svc.ListGateways(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListLocalDisks() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListLocalDisksInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.ListLocalDisks(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListTagsForResource() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListTagsForResourceInput{ - ResourceARN: aws.String("ResourceARN"), // Required - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - } - resp, err := svc.ListTagsForResource(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListTapes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListTapesInput{ - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - TapeARNs: []*string{ - aws.String("TapeARN"), // Required - // More values... - }, - } - resp, err := svc.ListTapes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListVolumeInitiators() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListVolumeInitiatorsInput{ - VolumeARN: aws.String("VolumeARN"), // Required - } - resp, err := svc.ListVolumeInitiators(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListVolumeRecoveryPoints() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListVolumeRecoveryPointsInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.ListVolumeRecoveryPoints(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ListVolumes() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ListVolumesInput{ - GatewayARN: aws.String("GatewayARN"), - Limit: aws.Int64(1), - Marker: aws.String("Marker"), - } - resp, err := svc.ListVolumes(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_RefreshCache() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.RefreshCacheInput{ - FileShareARN: aws.String("FileShareARN"), // Required - } - resp, err := svc.RefreshCache(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_RemoveTagsFromResource() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.RemoveTagsFromResourceInput{ - ResourceARN: aws.String("ResourceARN"), // Required - TagKeys: []*string{ // Required - aws.String("TagKey"), // Required - // More values... - }, - } - resp, err := svc.RemoveTagsFromResource(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ResetCache() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ResetCacheInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.ResetCache(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_RetrieveTapeArchive() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.RetrieveTapeArchiveInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.RetrieveTapeArchive(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_RetrieveTapeRecoveryPoint() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.RetrieveTapeRecoveryPointInput{ - GatewayARN: aws.String("GatewayARN"), // Required - TapeARN: aws.String("TapeARN"), // Required - } - resp, err := svc.RetrieveTapeRecoveryPoint(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_SetLocalConsolePassword() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.SetLocalConsolePasswordInput{ - GatewayARN: aws.String("GatewayARN"), // Required - LocalConsolePassword: aws.String("LocalConsolePassword"), // Required - } - resp, err := svc.SetLocalConsolePassword(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_ShutdownGateway() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.ShutdownGatewayInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.ShutdownGateway(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_StartGateway() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.StartGatewayInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.StartGateway(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateBandwidthRateLimit() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateBandwidthRateLimitInput{ - GatewayARN: aws.String("GatewayARN"), // Required - AverageDownloadRateLimitInBitsPerSec: aws.Int64(1), - AverageUploadRateLimitInBitsPerSec: aws.Int64(1), - } - resp, err := svc.UpdateBandwidthRateLimit(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateChapCredentials() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateChapCredentialsInput{ - InitiatorName: aws.String("IqnName"), // Required - SecretToAuthenticateInitiator: aws.String("ChapSecret"), // Required - TargetARN: aws.String("TargetARN"), // Required - SecretToAuthenticateTarget: aws.String("ChapSecret"), - } - resp, err := svc.UpdateChapCredentials(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateGatewayInformation() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateGatewayInformationInput{ - GatewayARN: aws.String("GatewayARN"), // Required - GatewayName: aws.String("GatewayName"), - GatewayTimezone: aws.String("GatewayTimezone"), - } - resp, err := svc.UpdateGatewayInformation(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateGatewaySoftwareNow() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateGatewaySoftwareNowInput{ - GatewayARN: aws.String("GatewayARN"), // Required - } - resp, err := svc.UpdateGatewaySoftwareNow(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateMaintenanceStartTime() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateMaintenanceStartTimeInput{ - DayOfWeek: aws.Int64(1), // Required - GatewayARN: aws.String("GatewayARN"), // Required - HourOfDay: aws.Int64(1), // Required - MinuteOfHour: aws.Int64(1), // Required - } - resp, err := svc.UpdateMaintenanceStartTime(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateNFSFileShare() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateNFSFileShareInput{ - FileShareARN: aws.String("FileShareARN"), // Required - ClientList: []*string{ - aws.String("IPV4AddressCIDR"), // Required - // More values... - }, - DefaultStorageClass: aws.String("StorageClass"), - KMSEncrypted: aws.Bool(true), - KMSKey: aws.String("KMSKey"), - NFSFileShareDefaults: &storagegateway.NFSFileShareDefaults{ - DirectoryMode: aws.String("PermissionMode"), - FileMode: aws.String("PermissionMode"), - GroupId: aws.Int64(1), - OwnerId: aws.Int64(1), - }, - ReadOnly: aws.Bool(true), - Squash: aws.String("Squash"), - } - resp, err := svc.UpdateNFSFileShare(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateSnapshotSchedule() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateSnapshotScheduleInput{ - RecurrenceInHours: aws.Int64(1), // Required - StartAt: aws.Int64(1), // Required - VolumeARN: aws.String("VolumeARN"), // Required - Description: aws.String("Description"), - } - resp, err := svc.UpdateSnapshotSchedule(params) - - if err != nil { - // 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) -} - -func ExampleStorageGateway_UpdateVTLDeviceType() { - sess := session.Must(session.NewSession()) - - svc := storagegateway.New(sess) - - params := &storagegateway.UpdateVTLDeviceTypeInput{ - DeviceType: aws.String("DeviceType"), // Required - VTLDeviceARN: aws.String("VTLDeviceARN"), // Required - } - resp, err := svc.UpdateVTLDeviceType(params) - - if err != nil { - // 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) -} diff --git a/service/sts/examples_test.go b/service/sts/examples_test.go deleted file mode 100644 index 05df494a7fe..00000000000 --- a/service/sts/examples_test.go +++ /dev/null @@ -1,180 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package sts_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/sts" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSTS_AssumeRole() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.AssumeRoleInput{ - RoleArn: aws.String("arnType"), // Required - RoleSessionName: aws.String("roleSessionNameType"), // Required - DurationSeconds: aws.Int64(1), - ExternalId: aws.String("externalIdType"), - Policy: aws.String("sessionPolicyDocumentType"), - SerialNumber: aws.String("serialNumberType"), - TokenCode: aws.String("tokenCodeType"), - } - resp, err := svc.AssumeRole(params) - - if err != nil { - // 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) -} - -func ExampleSTS_AssumeRoleWithSAML() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.AssumeRoleWithSAMLInput{ - PrincipalArn: aws.String("arnType"), // Required - RoleArn: aws.String("arnType"), // Required - SAMLAssertion: aws.String("SAMLAssertionType"), // Required - DurationSeconds: aws.Int64(1), - Policy: aws.String("sessionPolicyDocumentType"), - } - resp, err := svc.AssumeRoleWithSAML(params) - - if err != nil { - // 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) -} - -func ExampleSTS_AssumeRoleWithWebIdentity() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.AssumeRoleWithWebIdentityInput{ - RoleArn: aws.String("arnType"), // Required - RoleSessionName: aws.String("roleSessionNameType"), // Required - WebIdentityToken: aws.String("clientTokenType"), // Required - DurationSeconds: aws.Int64(1), - Policy: aws.String("sessionPolicyDocumentType"), - ProviderId: aws.String("urlType"), - } - resp, err := svc.AssumeRoleWithWebIdentity(params) - - if err != nil { - // 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) -} - -func ExampleSTS_DecodeAuthorizationMessage() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.DecodeAuthorizationMessageInput{ - EncodedMessage: aws.String("encodedMessageType"), // Required - } - resp, err := svc.DecodeAuthorizationMessage(params) - - if err != nil { - // 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) -} - -func ExampleSTS_GetCallerIdentity() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - var params *sts.GetCallerIdentityInput - resp, err := svc.GetCallerIdentity(params) - - if err != nil { - // 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) -} - -func ExampleSTS_GetFederationToken() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.GetFederationTokenInput{ - Name: aws.String("userNameType"), // Required - DurationSeconds: aws.Int64(1), - Policy: aws.String("sessionPolicyDocumentType"), - } - resp, err := svc.GetFederationToken(params) - - if err != nil { - // 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) -} - -func ExampleSTS_GetSessionToken() { - sess := session.Must(session.NewSession()) - - svc := sts.New(sess) - - params := &sts.GetSessionTokenInput{ - DurationSeconds: aws.Int64(1), - SerialNumber: aws.String("serialNumberType"), - TokenCode: aws.String("tokenCodeType"), - } - resp, err := svc.GetSessionToken(params) - - if err != nil { - // 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) -} diff --git a/service/support/examples_test.go b/service/support/examples_test.go deleted file mode 100644 index 967f54f6adf..00000000000 --- a/service/support/examples_test.go +++ /dev/null @@ -1,360 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package support_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/support" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSupport_AddAttachmentsToSet() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.AddAttachmentsToSetInput{ - Attachments: []*support.Attachment{ // Required - { // Required - Data: []byte("PAYLOAD"), - FileName: aws.String("FileName"), - }, - // More values... - }, - AttachmentSetId: aws.String("AttachmentSetId"), - } - resp, err := svc.AddAttachmentsToSet(params) - - if err != nil { - // 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) -} - -func ExampleSupport_AddCommunicationToCase() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.AddCommunicationToCaseInput{ - CommunicationBody: aws.String("CommunicationBody"), // Required - AttachmentSetId: aws.String("AttachmentSetId"), - CaseId: aws.String("CaseId"), - CcEmailAddresses: []*string{ - aws.String("CcEmailAddress"), // Required - // More values... - }, - } - resp, err := svc.AddCommunicationToCase(params) - - if err != nil { - // 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) -} - -func ExampleSupport_CreateCase() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.CreateCaseInput{ - CommunicationBody: aws.String("CommunicationBody"), // Required - Subject: aws.String("Subject"), // Required - AttachmentSetId: aws.String("AttachmentSetId"), - CategoryCode: aws.String("CategoryCode"), - CcEmailAddresses: []*string{ - aws.String("CcEmailAddress"), // Required - // More values... - }, - IssueType: aws.String("IssueType"), - Language: aws.String("Language"), - ServiceCode: aws.String("ServiceCode"), - SeverityCode: aws.String("SeverityCode"), - } - resp, err := svc.CreateCase(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeAttachment() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeAttachmentInput{ - AttachmentId: aws.String("AttachmentId"), // Required - } - resp, err := svc.DescribeAttachment(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeCases() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeCasesInput{ - AfterTime: aws.String("AfterTime"), - BeforeTime: aws.String("BeforeTime"), - CaseIdList: []*string{ - aws.String("CaseId"), // Required - // More values... - }, - DisplayId: aws.String("DisplayId"), - IncludeCommunications: aws.Bool(true), - IncludeResolvedCases: aws.Bool(true), - Language: aws.String("Language"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeCases(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeCommunications() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeCommunicationsInput{ - CaseId: aws.String("CaseId"), // Required - AfterTime: aws.String("AfterTime"), - BeforeTime: aws.String("BeforeTime"), - MaxResults: aws.Int64(1), - NextToken: aws.String("NextToken"), - } - resp, err := svc.DescribeCommunications(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeServices() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeServicesInput{ - Language: aws.String("Language"), - ServiceCodeList: []*string{ - aws.String("ServiceCode"), // Required - // More values... - }, - } - resp, err := svc.DescribeServices(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeSeverityLevels() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeSeverityLevelsInput{ - Language: aws.String("Language"), - } - resp, err := svc.DescribeSeverityLevels(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeTrustedAdvisorCheckRefreshStatuses() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeTrustedAdvisorCheckRefreshStatusesInput{ - CheckIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeTrustedAdvisorCheckRefreshStatuses(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeTrustedAdvisorCheckResult() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeTrustedAdvisorCheckResultInput{ - CheckId: aws.String("String"), // Required - Language: aws.String("String"), - } - resp, err := svc.DescribeTrustedAdvisorCheckResult(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeTrustedAdvisorCheckSummaries() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeTrustedAdvisorCheckSummariesInput{ - CheckIds: []*string{ // Required - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeTrustedAdvisorCheckSummaries(params) - - if err != nil { - // 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) -} - -func ExampleSupport_DescribeTrustedAdvisorChecks() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.DescribeTrustedAdvisorChecksInput{ - Language: aws.String("String"), // Required - } - resp, err := svc.DescribeTrustedAdvisorChecks(params) - - if err != nil { - // 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) -} - -func ExampleSupport_RefreshTrustedAdvisorCheck() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.RefreshTrustedAdvisorCheckInput{ - CheckId: aws.String("String"), // Required - } - resp, err := svc.RefreshTrustedAdvisorCheck(params) - - if err != nil { - // 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) -} - -func ExampleSupport_ResolveCase() { - sess := session.Must(session.NewSession()) - - svc := support.New(sess) - - params := &support.ResolveCaseInput{ - CaseId: aws.String("CaseId"), - } - resp, err := svc.ResolveCase(params) - - if err != nil { - // 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) -} diff --git a/service/swf/examples_test.go b/service/swf/examples_test.go deleted file mode 100644 index d9d56ca4230..00000000000 --- a/service/swf/examples_test.go +++ /dev/null @@ -1,962 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package swf_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/swf" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleSWF_CountClosedWorkflowExecutions() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.CountClosedWorkflowExecutionsInput{ - Domain: aws.String("DomainName"), // Required - CloseStatusFilter: &swf.CloseStatusFilter{ - Status: aws.String("CloseStatus"), // Required - }, - CloseTimeFilter: &swf.ExecutionTimeFilter{ - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - ExecutionFilter: &swf.WorkflowExecutionFilter{ - WorkflowId: aws.String("WorkflowId"), // Required - }, - StartTimeFilter: &swf.ExecutionTimeFilter{ - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - TagFilter: &swf.TagFilter{ - Tag: aws.String("Tag"), // Required - }, - TypeFilter: &swf.WorkflowTypeFilter{ - Name: aws.String("Name"), // Required - Version: aws.String("VersionOptional"), - }, - } - resp, err := svc.CountClosedWorkflowExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSWF_CountOpenWorkflowExecutions() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.CountOpenWorkflowExecutionsInput{ - Domain: aws.String("DomainName"), // Required - StartTimeFilter: &swf.ExecutionTimeFilter{ // Required - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - ExecutionFilter: &swf.WorkflowExecutionFilter{ - WorkflowId: aws.String("WorkflowId"), // Required - }, - TagFilter: &swf.TagFilter{ - Tag: aws.String("Tag"), // Required - }, - TypeFilter: &swf.WorkflowTypeFilter{ - Name: aws.String("Name"), // Required - Version: aws.String("VersionOptional"), - }, - } - resp, err := svc.CountOpenWorkflowExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSWF_CountPendingActivityTasks() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.CountPendingActivityTasksInput{ - Domain: aws.String("DomainName"), // Required - TaskList: &swf.TaskList{ // Required - Name: aws.String("Name"), // Required - }, - } - resp, err := svc.CountPendingActivityTasks(params) - - if err != nil { - // 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) -} - -func ExampleSWF_CountPendingDecisionTasks() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.CountPendingDecisionTasksInput{ - Domain: aws.String("DomainName"), // Required - TaskList: &swf.TaskList{ // Required - Name: aws.String("Name"), // Required - }, - } - resp, err := svc.CountPendingDecisionTasks(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DeprecateActivityType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DeprecateActivityTypeInput{ - ActivityType: &swf.ActivityType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - Domain: aws.String("DomainName"), // Required - } - resp, err := svc.DeprecateActivityType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DeprecateDomain() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DeprecateDomainInput{ - Name: aws.String("DomainName"), // Required - } - resp, err := svc.DeprecateDomain(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DeprecateWorkflowType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DeprecateWorkflowTypeInput{ - Domain: aws.String("DomainName"), // Required - WorkflowType: &swf.WorkflowType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - } - resp, err := svc.DeprecateWorkflowType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DescribeActivityType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DescribeActivityTypeInput{ - ActivityType: &swf.ActivityType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - Domain: aws.String("DomainName"), // Required - } - resp, err := svc.DescribeActivityType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DescribeDomain() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DescribeDomainInput{ - Name: aws.String("DomainName"), // Required - } - resp, err := svc.DescribeDomain(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DescribeWorkflowExecution() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DescribeWorkflowExecutionInput{ - Domain: aws.String("DomainName"), // Required - Execution: &swf.WorkflowExecution{ // Required - RunId: aws.String("RunId"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - }, - } - resp, err := svc.DescribeWorkflowExecution(params) - - if err != nil { - // 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) -} - -func ExampleSWF_DescribeWorkflowType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.DescribeWorkflowTypeInput{ - Domain: aws.String("DomainName"), // Required - WorkflowType: &swf.WorkflowType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - } - resp, err := svc.DescribeWorkflowType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_GetWorkflowExecutionHistory() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.GetWorkflowExecutionHistoryInput{ - Domain: aws.String("DomainName"), // Required - Execution: &swf.WorkflowExecution{ // Required - RunId: aws.String("RunId"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - }, - MaximumPageSize: aws.Int64(1), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.GetWorkflowExecutionHistory(params) - - if err != nil { - // 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) -} - -func ExampleSWF_ListActivityTypes() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.ListActivityTypesInput{ - Domain: aws.String("DomainName"), // Required - RegistrationStatus: aws.String("RegistrationStatus"), // Required - MaximumPageSize: aws.Int64(1), - Name: aws.String("Name"), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.ListActivityTypes(params) - - if err != nil { - // 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) -} - -func ExampleSWF_ListClosedWorkflowExecutions() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.ListClosedWorkflowExecutionsInput{ - Domain: aws.String("DomainName"), // Required - CloseStatusFilter: &swf.CloseStatusFilter{ - Status: aws.String("CloseStatus"), // Required - }, - CloseTimeFilter: &swf.ExecutionTimeFilter{ - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - ExecutionFilter: &swf.WorkflowExecutionFilter{ - WorkflowId: aws.String("WorkflowId"), // Required - }, - MaximumPageSize: aws.Int64(1), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - StartTimeFilter: &swf.ExecutionTimeFilter{ - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - TagFilter: &swf.TagFilter{ - Tag: aws.String("Tag"), // Required - }, - TypeFilter: &swf.WorkflowTypeFilter{ - Name: aws.String("Name"), // Required - Version: aws.String("VersionOptional"), - }, - } - resp, err := svc.ListClosedWorkflowExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSWF_ListDomains() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.ListDomainsInput{ - RegistrationStatus: aws.String("RegistrationStatus"), // Required - MaximumPageSize: aws.Int64(1), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.ListDomains(params) - - if err != nil { - // 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) -} - -func ExampleSWF_ListOpenWorkflowExecutions() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.ListOpenWorkflowExecutionsInput{ - Domain: aws.String("DomainName"), // Required - StartTimeFilter: &swf.ExecutionTimeFilter{ // Required - OldestDate: aws.Time(time.Now()), // Required - LatestDate: aws.Time(time.Now()), - }, - ExecutionFilter: &swf.WorkflowExecutionFilter{ - WorkflowId: aws.String("WorkflowId"), // Required - }, - MaximumPageSize: aws.Int64(1), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - TagFilter: &swf.TagFilter{ - Tag: aws.String("Tag"), // Required - }, - TypeFilter: &swf.WorkflowTypeFilter{ - Name: aws.String("Name"), // Required - Version: aws.String("VersionOptional"), - }, - } - resp, err := svc.ListOpenWorkflowExecutions(params) - - if err != nil { - // 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) -} - -func ExampleSWF_ListWorkflowTypes() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.ListWorkflowTypesInput{ - Domain: aws.String("DomainName"), // Required - RegistrationStatus: aws.String("RegistrationStatus"), // Required - MaximumPageSize: aws.Int64(1), - Name: aws.String("Name"), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.ListWorkflowTypes(params) - - if err != nil { - // 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) -} - -func ExampleSWF_PollForActivityTask() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.PollForActivityTaskInput{ - Domain: aws.String("DomainName"), // Required - TaskList: &swf.TaskList{ // Required - Name: aws.String("Name"), // Required - }, - Identity: aws.String("Identity"), - } - resp, err := svc.PollForActivityTask(params) - - if err != nil { - // 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) -} - -func ExampleSWF_PollForDecisionTask() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.PollForDecisionTaskInput{ - Domain: aws.String("DomainName"), // Required - TaskList: &swf.TaskList{ // Required - Name: aws.String("Name"), // Required - }, - Identity: aws.String("Identity"), - MaximumPageSize: aws.Int64(1), - NextPageToken: aws.String("PageToken"), - ReverseOrder: aws.Bool(true), - } - resp, err := svc.PollForDecisionTask(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RecordActivityTaskHeartbeat() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RecordActivityTaskHeartbeatInput{ - TaskToken: aws.String("TaskToken"), // Required - Details: aws.String("LimitedData"), - } - resp, err := svc.RecordActivityTaskHeartbeat(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RegisterActivityType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RegisterActivityTypeInput{ - Domain: aws.String("DomainName"), // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - DefaultTaskHeartbeatTimeout: aws.String("DurationInSecondsOptional"), - DefaultTaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - DefaultTaskPriority: aws.String("TaskPriority"), - DefaultTaskScheduleToCloseTimeout: aws.String("DurationInSecondsOptional"), - DefaultTaskScheduleToStartTimeout: aws.String("DurationInSecondsOptional"), - DefaultTaskStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - Description: aws.String("Description"), - } - resp, err := svc.RegisterActivityType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RegisterDomain() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RegisterDomainInput{ - Name: aws.String("DomainName"), // Required - WorkflowExecutionRetentionPeriodInDays: aws.String("DurationInDays"), // Required - Description: aws.String("Description"), - } - resp, err := svc.RegisterDomain(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RegisterWorkflowType() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RegisterWorkflowTypeInput{ - Domain: aws.String("DomainName"), // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - DefaultChildPolicy: aws.String("ChildPolicy"), - DefaultExecutionStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - DefaultLambdaRole: aws.String("Arn"), - DefaultTaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - DefaultTaskPriority: aws.String("TaskPriority"), - DefaultTaskStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - Description: aws.String("Description"), - } - resp, err := svc.RegisterWorkflowType(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RequestCancelWorkflowExecution() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RequestCancelWorkflowExecutionInput{ - Domain: aws.String("DomainName"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - RunId: aws.String("RunIdOptional"), - } - resp, err := svc.RequestCancelWorkflowExecution(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RespondActivityTaskCanceled() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RespondActivityTaskCanceledInput{ - TaskToken: aws.String("TaskToken"), // Required - Details: aws.String("Data"), - } - resp, err := svc.RespondActivityTaskCanceled(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RespondActivityTaskCompleted() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RespondActivityTaskCompletedInput{ - TaskToken: aws.String("TaskToken"), // Required - Result: aws.String("Data"), - } - resp, err := svc.RespondActivityTaskCompleted(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RespondActivityTaskFailed() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RespondActivityTaskFailedInput{ - TaskToken: aws.String("TaskToken"), // Required - Details: aws.String("Data"), - Reason: aws.String("FailureReason"), - } - resp, err := svc.RespondActivityTaskFailed(params) - - if err != nil { - // 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) -} - -func ExampleSWF_RespondDecisionTaskCompleted() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.RespondDecisionTaskCompletedInput{ - TaskToken: aws.String("TaskToken"), // Required - Decisions: []*swf.Decision{ - { // Required - DecisionType: aws.String("DecisionType"), // Required - CancelTimerDecisionAttributes: &swf.CancelTimerDecisionAttributes{ - TimerId: aws.String("TimerId"), // Required - }, - CancelWorkflowExecutionDecisionAttributes: &swf.CancelWorkflowExecutionDecisionAttributes{ - Details: aws.String("Data"), - }, - CompleteWorkflowExecutionDecisionAttributes: &swf.CompleteWorkflowExecutionDecisionAttributes{ - Result: aws.String("Data"), - }, - ContinueAsNewWorkflowExecutionDecisionAttributes: &swf.ContinueAsNewWorkflowExecutionDecisionAttributes{ - ChildPolicy: aws.String("ChildPolicy"), - ExecutionStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - Input: aws.String("Data"), - LambdaRole: aws.String("Arn"), - TagList: []*string{ - aws.String("Tag"), // Required - // More values... - }, - TaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - TaskPriority: aws.String("TaskPriority"), - TaskStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - WorkflowTypeVersion: aws.String("Version"), - }, - FailWorkflowExecutionDecisionAttributes: &swf.FailWorkflowExecutionDecisionAttributes{ - Details: aws.String("Data"), - Reason: aws.String("FailureReason"), - }, - RecordMarkerDecisionAttributes: &swf.RecordMarkerDecisionAttributes{ - MarkerName: aws.String("MarkerName"), // Required - Details: aws.String("Data"), - }, - RequestCancelActivityTaskDecisionAttributes: &swf.RequestCancelActivityTaskDecisionAttributes{ - ActivityId: aws.String("ActivityId"), // Required - }, - RequestCancelExternalWorkflowExecutionDecisionAttributes: &swf.RequestCancelExternalWorkflowExecutionDecisionAttributes{ - WorkflowId: aws.String("WorkflowId"), // Required - Control: aws.String("Data"), - RunId: aws.String("RunIdOptional"), - }, - ScheduleActivityTaskDecisionAttributes: &swf.ScheduleActivityTaskDecisionAttributes{ - ActivityId: aws.String("ActivityId"), // Required - ActivityType: &swf.ActivityType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - Control: aws.String("Data"), - HeartbeatTimeout: aws.String("DurationInSecondsOptional"), - Input: aws.String("Data"), - ScheduleToCloseTimeout: aws.String("DurationInSecondsOptional"), - ScheduleToStartTimeout: aws.String("DurationInSecondsOptional"), - StartToCloseTimeout: aws.String("DurationInSecondsOptional"), - TaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - TaskPriority: aws.String("TaskPriority"), - }, - ScheduleLambdaFunctionDecisionAttributes: &swf.ScheduleLambdaFunctionDecisionAttributes{ - Id: aws.String("FunctionId"), // Required - Name: aws.String("FunctionName"), // Required - Input: aws.String("FunctionInput"), - StartToCloseTimeout: aws.String("DurationInSecondsOptional"), - }, - SignalExternalWorkflowExecutionDecisionAttributes: &swf.SignalExternalWorkflowExecutionDecisionAttributes{ - SignalName: aws.String("SignalName"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - Control: aws.String("Data"), - Input: aws.String("Data"), - RunId: aws.String("RunIdOptional"), - }, - StartChildWorkflowExecutionDecisionAttributes: &swf.StartChildWorkflowExecutionDecisionAttributes{ - WorkflowId: aws.String("WorkflowId"), // Required - WorkflowType: &swf.WorkflowType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - ChildPolicy: aws.String("ChildPolicy"), - Control: aws.String("Data"), - ExecutionStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - Input: aws.String("Data"), - LambdaRole: aws.String("Arn"), - TagList: []*string{ - aws.String("Tag"), // Required - // More values... - }, - TaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - TaskPriority: aws.String("TaskPriority"), - TaskStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - }, - StartTimerDecisionAttributes: &swf.StartTimerDecisionAttributes{ - StartToFireTimeout: aws.String("DurationInSeconds"), // Required - TimerId: aws.String("TimerId"), // Required - Control: aws.String("Data"), - }, - }, - // More values... - }, - ExecutionContext: aws.String("Data"), - } - resp, err := svc.RespondDecisionTaskCompleted(params) - - if err != nil { - // 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) -} - -func ExampleSWF_SignalWorkflowExecution() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.SignalWorkflowExecutionInput{ - Domain: aws.String("DomainName"), // Required - SignalName: aws.String("SignalName"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - Input: aws.String("Data"), - RunId: aws.String("RunIdOptional"), - } - resp, err := svc.SignalWorkflowExecution(params) - - if err != nil { - // 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) -} - -func ExampleSWF_StartWorkflowExecution() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.StartWorkflowExecutionInput{ - Domain: aws.String("DomainName"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - WorkflowType: &swf.WorkflowType{ // Required - Name: aws.String("Name"), // Required - Version: aws.String("Version"), // Required - }, - ChildPolicy: aws.String("ChildPolicy"), - ExecutionStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - Input: aws.String("Data"), - LambdaRole: aws.String("Arn"), - TagList: []*string{ - aws.String("Tag"), // Required - // More values... - }, - TaskList: &swf.TaskList{ - Name: aws.String("Name"), // Required - }, - TaskPriority: aws.String("TaskPriority"), - TaskStartToCloseTimeout: aws.String("DurationInSecondsOptional"), - } - resp, err := svc.StartWorkflowExecution(params) - - if err != nil { - // 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) -} - -func ExampleSWF_TerminateWorkflowExecution() { - sess := session.Must(session.NewSession()) - - svc := swf.New(sess) - - params := &swf.TerminateWorkflowExecutionInput{ - Domain: aws.String("DomainName"), // Required - WorkflowId: aws.String("WorkflowId"), // Required - ChildPolicy: aws.String("ChildPolicy"), - Details: aws.String("Data"), - Reason: aws.String("TerminateReason"), - RunId: aws.String("RunIdOptional"), - } - resp, err := svc.TerminateWorkflowExecution(params) - - if err != nil { - // 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) -} diff --git a/service/waf/examples_test.go b/service/waf/examples_test.go deleted file mode 100644 index d0ddd228d3f..00000000000 --- a/service/waf/examples_test.go +++ /dev/null @@ -1,944 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package waf_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/waf" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleWAF_CreateByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateByteMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateIPSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateRule() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - MetricName: aws.String("MetricName"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateRule(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateWebACL() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - DefaultAction: &waf.WafAction{ // Required - Type: aws.String("WafActionType"), // Required - }, - MetricName: aws.String("MetricName"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAF_CreateXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.CreateXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - ChangeToken: aws.String("ChangeToken"), // Required - } - resp, err := svc.DeleteByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteIPSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - IPSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteRule() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - RuleId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteRule(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SizeConstraintSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteWebACL() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAF_DeleteXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.DeleteXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetChangeToken() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - var params *waf.GetChangeTokenInput - resp, err := svc.GetChangeToken(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetChangeTokenStatus() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetChangeTokenStatusInput{ - ChangeToken: aws.String("ChangeToken"), // Required - } - resp, err := svc.GetChangeTokenStatus(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetIPSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetIPSetInput{ - IPSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetRule() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetRuleInput{ - RuleId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetRule(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetSampledRequests() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetSampledRequestsInput{ - MaxItems: aws.Int64(1), // Required - RuleId: aws.String("ResourceId"), // Required - TimeWindow: &waf.TimeWindow{ // Required - EndTime: aws.Time(time.Now()), // Required - StartTime: aws.Time(time.Now()), // Required - }, - WebAclId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSampledRequests(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetSizeConstraintSetInput{ - SizeConstraintSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetSqlInjectionMatchSetInput{ - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetWebACL() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetWebACLInput{ - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAF_GetXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.GetXssMatchSetInput{ - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListByteMatchSets() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListByteMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListByteMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListIPSets() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListIPSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListIPSets(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListRules() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListRulesInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListRules(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListSizeConstraintSets() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListSizeConstraintSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListSizeConstraintSets(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListSqlInjectionMatchSets() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListSqlInjectionMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListSqlInjectionMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListWebACLs() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListWebACLsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListWebACLs(params) - - if err != nil { - // 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) -} - -func ExampleWAF_ListXssMatchSets() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.ListXssMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListXssMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - ChangeToken: aws.String("ChangeToken"), // Required - Updates: []*waf.ByteMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - ByteMatchTuple: &waf.ByteMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - PositionalConstraint: aws.String("PositionalConstraint"), // Required - TargetString: []byte("PAYLOAD"), // Required - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateIPSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - IPSetId: aws.String("ResourceId"), // Required - Updates: []*waf.IPSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - IPSetDescriptor: &waf.IPSetDescriptor{ // Required - Type: aws.String("IPSetDescriptorType"), // Required - Value: aws.String("IPSetDescriptorValue"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateRule() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - RuleId: aws.String("ResourceId"), // Required - Updates: []*waf.RuleUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - Predicate: &waf.Predicate{ // Required - DataId: aws.String("ResourceId"), // Required - Negated: aws.Bool(true), // Required - Type: aws.String("PredicateType"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateRule(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SizeConstraintSetId: aws.String("ResourceId"), // Required - Updates: []*waf.SizeConstraintSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - SizeConstraint: &waf.SizeConstraint{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - Size: aws.Int64(1), // Required - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - Updates: []*waf.SqlInjectionMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - SqlInjectionMatchTuple: &waf.SqlInjectionMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateWebACL() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - WebACLId: aws.String("ResourceId"), // Required - DefaultAction: &waf.WafAction{ - Type: aws.String("WafActionType"), // Required - }, - Updates: []*waf.WebACLUpdate{ - { // Required - Action: aws.String("ChangeAction"), // Required - ActivatedRule: &waf.ActivatedRule{ // Required - Action: &waf.WafAction{ // Required - Type: aws.String("WafActionType"), // Required - }, - Priority: aws.Int64(1), // Required - RuleId: aws.String("ResourceId"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAF_UpdateXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := waf.New(sess) - - params := &waf.UpdateXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Updates: []*waf.XssMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - XssMatchTuple: &waf.XssMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.UpdateXssMatchSet(params) - - if err != nil { - // 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) -} diff --git a/service/wafregional/examples_test.go b/service/wafregional/examples_test.go deleted file mode 100644 index a79db9c7e12..00000000000 --- a/service/wafregional/examples_test.go +++ /dev/null @@ -1,1030 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package wafregional_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/waf" - "github.com/aws/aws-sdk-go/service/wafregional" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleWAFRegional_AssociateWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &wafregional.AssociateWebACLInput{ - ResourceArn: aws.String("ResourceArn"), // Required - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.AssociateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateByteMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateIPSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateRule() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - MetricName: aws.String("MetricName"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateRule(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - DefaultAction: &waf.WafAction{ // Required - Type: aws.String("WafActionType"), // Required - }, - MetricName: aws.String("MetricName"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_CreateXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.CreateXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Name: aws.String("ResourceName"), // Required - } - resp, err := svc.CreateXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - ChangeToken: aws.String("ChangeToken"), // Required - } - resp, err := svc.DeleteByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteIPSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - IPSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteRule() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - RuleId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteRule(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SizeConstraintSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DeleteXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.DeleteXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.DeleteXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_DisassociateWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &wafregional.DisassociateWebACLInput{ - ResourceArn: aws.String("ResourceArn"), // Required - } - resp, err := svc.DisassociateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetChangeToken() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - var params *waf.GetChangeTokenInput - resp, err := svc.GetChangeToken(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetChangeTokenStatus() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetChangeTokenStatusInput{ - ChangeToken: aws.String("ChangeToken"), // Required - } - resp, err := svc.GetChangeTokenStatus(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetIPSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetIPSetInput{ - IPSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetRule() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetRuleInput{ - RuleId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetRule(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetSampledRequests() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetSampledRequestsInput{ - MaxItems: aws.Int64(1), // Required - RuleId: aws.String("ResourceId"), // Required - TimeWindow: &waf.TimeWindow{ // Required - EndTime: aws.Time(time.Now()), // Required - StartTime: aws.Time(time.Now()), // Required - }, - WebAclId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSampledRequests(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetSizeConstraintSetInput{ - SizeConstraintSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetSqlInjectionMatchSetInput{ - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetWebACLInput{ - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetWebACLForResource() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &wafregional.GetWebACLForResourceInput{ - ResourceArn: aws.String("ResourceArn"), // Required - } - resp, err := svc.GetWebACLForResource(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_GetXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.GetXssMatchSetInput{ - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.GetXssMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListByteMatchSets() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListByteMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListByteMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListIPSets() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListIPSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListIPSets(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListResourcesForWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &wafregional.ListResourcesForWebACLInput{ - WebACLId: aws.String("ResourceId"), // Required - } - resp, err := svc.ListResourcesForWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListRules() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListRulesInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListRules(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListSizeConstraintSets() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListSizeConstraintSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListSizeConstraintSets(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListSqlInjectionMatchSets() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListSqlInjectionMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListSqlInjectionMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListWebACLs() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListWebACLsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListWebACLs(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_ListXssMatchSets() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.ListXssMatchSetsInput{ - Limit: aws.Int64(1), - NextMarker: aws.String("NextMarker"), - } - resp, err := svc.ListXssMatchSets(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateByteMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateByteMatchSetInput{ - ByteMatchSetId: aws.String("ResourceId"), // Required - ChangeToken: aws.String("ChangeToken"), // Required - Updates: []*waf.ByteMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - ByteMatchTuple: &waf.ByteMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - PositionalConstraint: aws.String("PositionalConstraint"), // Required - TargetString: []byte("PAYLOAD"), // Required - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateByteMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateIPSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateIPSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - IPSetId: aws.String("ResourceId"), // Required - Updates: []*waf.IPSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - IPSetDescriptor: &waf.IPSetDescriptor{ // Required - Type: aws.String("IPSetDescriptorType"), // Required - Value: aws.String("IPSetDescriptorValue"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateIPSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateRule() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateRuleInput{ - ChangeToken: aws.String("ChangeToken"), // Required - RuleId: aws.String("ResourceId"), // Required - Updates: []*waf.RuleUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - Predicate: &waf.Predicate{ // Required - DataId: aws.String("ResourceId"), // Required - Negated: aws.Bool(true), // Required - Type: aws.String("PredicateType"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateRule(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateSizeConstraintSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateSizeConstraintSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SizeConstraintSetId: aws.String("ResourceId"), // Required - Updates: []*waf.SizeConstraintSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - SizeConstraint: &waf.SizeConstraint{ // Required - ComparisonOperator: aws.String("ComparisonOperator"), // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - Size: aws.Int64(1), // Required - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateSizeConstraintSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateSqlInjectionMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateSqlInjectionMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - SqlInjectionMatchSetId: aws.String("ResourceId"), // Required - Updates: []*waf.SqlInjectionMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - SqlInjectionMatchTuple: &waf.SqlInjectionMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateSqlInjectionMatchSet(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateWebACL() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateWebACLInput{ - ChangeToken: aws.String("ChangeToken"), // Required - WebACLId: aws.String("ResourceId"), // Required - DefaultAction: &waf.WafAction{ - Type: aws.String("WafActionType"), // Required - }, - Updates: []*waf.WebACLUpdate{ - { // Required - Action: aws.String("ChangeAction"), // Required - ActivatedRule: &waf.ActivatedRule{ // Required - Action: &waf.WafAction{ // Required - Type: aws.String("WafActionType"), // Required - }, - Priority: aws.Int64(1), // Required - RuleId: aws.String("ResourceId"), // Required - }, - }, - // More values... - }, - } - resp, err := svc.UpdateWebACL(params) - - if err != nil { - // 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) -} - -func ExampleWAFRegional_UpdateXssMatchSet() { - sess := session.Must(session.NewSession()) - - svc := wafregional.New(sess) - - params := &waf.UpdateXssMatchSetInput{ - ChangeToken: aws.String("ChangeToken"), // Required - Updates: []*waf.XssMatchSetUpdate{ // Required - { // Required - Action: aws.String("ChangeAction"), // Required - XssMatchTuple: &waf.XssMatchTuple{ // Required - FieldToMatch: &waf.FieldToMatch{ // Required - Type: aws.String("MatchFieldType"), // Required - Data: aws.String("MatchFieldData"), - }, - TextTransformation: aws.String("TextTransformation"), // Required - }, - }, - // More values... - }, - XssMatchSetId: aws.String("ResourceId"), // Required - } - resp, err := svc.UpdateXssMatchSet(params) - - if err != nil { - // 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) -} diff --git a/service/workdocs/examples_test.go b/service/workdocs/examples_test.go deleted file mode 100644 index 7f3a4a9cd79..00000000000 --- a/service/workdocs/examples_test.go +++ /dev/null @@ -1,703 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package workdocs_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/workdocs" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleWorkDocs_AbortDocumentVersionUpload() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.AbortDocumentVersionUploadInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required - } - resp, err := svc.AbortDocumentVersionUpload(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_ActivateUser() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.ActivateUserInput{ - UserId: aws.String("IdType"), // Required - } - resp, err := svc.ActivateUser(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_AddResourcePermissions() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.AddResourcePermissionsInput{ - Principals: []*workdocs.SharePrincipal{ // Required - { // Required - Id: aws.String("IdType"), // Required - Role: aws.String("RoleType"), // Required - Type: aws.String("PrincipalType"), // Required - }, - // More values... - }, - ResourceId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.AddResourcePermissions(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_CreateFolder() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.CreateFolderInput{ - ParentFolderId: aws.String("ResourceIdType"), // Required - Name: aws.String("ResourceNameType"), - } - resp, err := svc.CreateFolder(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_CreateNotificationSubscription() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.CreateNotificationSubscriptionInput{ - Endpoint: aws.String("SubscriptionEndPointType"), // Required - OrganizationId: aws.String("IdType"), // Required - Protocol: aws.String("SubscriptionProtocolType"), // Required - SubscriptionType: aws.String("SubscriptionType"), // Required - } - resp, err := svc.CreateNotificationSubscription(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_CreateUser() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.CreateUserInput{ - GivenName: aws.String("UserAttributeValueType"), // Required - Password: aws.String("PasswordType"), // Required - Surname: aws.String("UserAttributeValueType"), // Required - Username: aws.String("UsernameType"), // Required - OrganizationId: aws.String("IdType"), - StorageRule: &workdocs.StorageRuleType{ - StorageAllocatedInBytes: aws.Int64(1), - StorageType: aws.String("StorageType"), - }, - TimeZoneId: aws.String("TimeZoneIdType"), - } - resp, err := svc.CreateUser(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeactivateUser() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeactivateUserInput{ - UserId: aws.String("IdType"), // Required - } - resp, err := svc.DeactivateUser(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeleteDocument() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeleteDocumentInput{ - DocumentId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.DeleteDocument(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeleteFolder() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeleteFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.DeleteFolder(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeleteFolderContents() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeleteFolderContentsInput{ - FolderId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.DeleteFolderContents(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeleteNotificationSubscription() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeleteNotificationSubscriptionInput{ - OrganizationId: aws.String("IdType"), // Required - SubscriptionId: aws.String("IdType"), // Required - } - resp, err := svc.DeleteNotificationSubscription(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DeleteUser() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DeleteUserInput{ - UserId: aws.String("IdType"), // Required - } - resp, err := svc.DeleteUser(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DescribeDocumentVersions() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DescribeDocumentVersionsInput{ - DocumentId: aws.String("ResourceIdType"), // Required - Fields: aws.String("FieldNamesType"), - Include: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - } - resp, err := svc.DescribeDocumentVersions(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DescribeFolderContents() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DescribeFolderContentsInput{ - FolderId: aws.String("ResourceIdType"), // Required - Include: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - Order: aws.String("OrderType"), - Sort: aws.String("ResourceSortType"), - Type: aws.String("FolderContentType"), - } - resp, err := svc.DescribeFolderContents(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DescribeNotificationSubscriptions() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DescribeNotificationSubscriptionsInput{ - OrganizationId: aws.String("IdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - } - resp, err := svc.DescribeNotificationSubscriptions(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DescribeResourcePermissions() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DescribeResourcePermissionsInput{ - ResourceId: aws.String("ResourceIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - } - resp, err := svc.DescribeResourcePermissions(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_DescribeUsers() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.DescribeUsersInput{ - Fields: aws.String("FieldNamesType"), - Include: aws.String("UserFilterType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - Order: aws.String("OrderType"), - OrganizationId: aws.String("IdType"), - Query: aws.String("SearchQueryType"), - Sort: aws.String("UserSortType"), - UserIds: aws.String("UserIdsType"), - } - resp, err := svc.DescribeUsers(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_GetDocument() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.GetDocumentInput{ - DocumentId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.GetDocument(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_GetDocumentPath() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.GetDocumentPathInput{ - DocumentId: aws.String("IdType"), // Required - Fields: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - } - resp, err := svc.GetDocumentPath(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_GetDocumentVersion() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.GetDocumentVersionInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required - Fields: aws.String("FieldNamesType"), - } - resp, err := svc.GetDocumentVersion(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_GetFolder() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.GetFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.GetFolder(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_GetFolderPath() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.GetFolderPathInput{ - FolderId: aws.String("IdType"), // Required - Fields: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), - } - resp, err := svc.GetFolderPath(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_InitiateDocumentVersionUpload() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.InitiateDocumentVersionUploadInput{ - ParentFolderId: aws.String("ResourceIdType"), // Required - ContentCreatedTimestamp: aws.Time(time.Now()), - ContentModifiedTimestamp: aws.Time(time.Now()), - ContentType: aws.String("DocumentContentType"), - DocumentSizeInBytes: aws.Int64(1), - Id: aws.String("ResourceIdType"), - Name: aws.String("ResourceNameType"), - } - resp, err := svc.InitiateDocumentVersionUpload(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_RemoveAllResourcePermissions() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.RemoveAllResourcePermissionsInput{ - ResourceId: aws.String("ResourceIdType"), // Required - } - resp, err := svc.RemoveAllResourcePermissions(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_RemoveResourcePermission() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.RemoveResourcePermissionInput{ - PrincipalId: aws.String("IdType"), // Required - ResourceId: aws.String("ResourceIdType"), // Required - PrincipalType: aws.String("PrincipalType"), - } - resp, err := svc.RemoveResourcePermission(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_UpdateDocument() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.UpdateDocumentInput{ - DocumentId: aws.String("ResourceIdType"), // Required - Name: aws.String("ResourceNameType"), - ParentFolderId: aws.String("ResourceIdType"), - ResourceState: aws.String("ResourceStateType"), - } - resp, err := svc.UpdateDocument(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_UpdateDocumentVersion() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.UpdateDocumentVersionInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required - VersionStatus: aws.String("DocumentVersionStatus"), - } - resp, err := svc.UpdateDocumentVersion(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_UpdateFolder() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.UpdateFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required - Name: aws.String("ResourceNameType"), - ParentFolderId: aws.String("ResourceIdType"), - ResourceState: aws.String("ResourceStateType"), - } - resp, err := svc.UpdateFolder(params) - - if err != nil { - // 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) -} - -func ExampleWorkDocs_UpdateUser() { - sess := session.Must(session.NewSession()) - - svc := workdocs.New(sess) - - params := &workdocs.UpdateUserInput{ - UserId: aws.String("IdType"), // Required - GivenName: aws.String("UserAttributeValueType"), - Locale: aws.String("LocaleType"), - StorageRule: &workdocs.StorageRuleType{ - StorageAllocatedInBytes: aws.Int64(1), - StorageType: aws.String("StorageType"), - }, - Surname: aws.String("UserAttributeValueType"), - TimeZoneId: aws.String("TimeZoneIdType"), - Type: aws.String("UserType"), - } - resp, err := svc.UpdateUser(params) - - if err != nil { - // 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) -} diff --git a/service/workspaces/examples_test.go b/service/workspaces/examples_test.go deleted file mode 100644 index dedb985a1e2..00000000000 --- a/service/workspaces/examples_test.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package workspaces_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/workspaces" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleWorkSpaces_CreateTags() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.CreateTagsInput{ - ResourceId: aws.String("NonEmptyString"), // Required - Tags: []*workspaces.Tag{ // Required - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - } - resp, err := svc.CreateTags(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_CreateWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.CreateWorkspacesInput{ - Workspaces: []*workspaces.WorkspaceRequest{ // Required - { // Required - BundleId: aws.String("BundleId"), // Required - DirectoryId: aws.String("DirectoryId"), // Required - UserName: aws.String("UserName"), // Required - RootVolumeEncryptionEnabled: aws.Bool(true), - Tags: []*workspaces.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), - }, - // More values... - }, - UserVolumeEncryptionEnabled: aws.Bool(true), - VolumeEncryptionKey: aws.String("VolumeEncryptionKey"), - WorkspaceProperties: &workspaces.WorkspaceProperties{ - RunningMode: aws.String("RunningMode"), - RunningModeAutoStopTimeoutInMinutes: aws.Int64(1), - }, - }, - // More values... - }, - } - resp, err := svc.CreateWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DeleteTags() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DeleteTagsInput{ - ResourceId: aws.String("NonEmptyString"), // Required - TagKeys: []*string{ // Required - aws.String("NonEmptyString"), // Required - // More values... - }, - } - resp, err := svc.DeleteTags(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DescribeTagsInput{ - ResourceId: aws.String("NonEmptyString"), // Required - } - resp, err := svc.DescribeTags(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DescribeWorkspaceBundles() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DescribeWorkspaceBundlesInput{ - BundleIds: []*string{ - aws.String("BundleId"), // Required - // More values... - }, - NextToken: aws.String("PaginationToken"), - Owner: aws.String("BundleOwner"), - } - resp, err := svc.DescribeWorkspaceBundles(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DescribeWorkspaceDirectories() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DescribeWorkspaceDirectoriesInput{ - DirectoryIds: []*string{ - aws.String("DirectoryId"), // Required - // More values... - }, - NextToken: aws.String("PaginationToken"), - } - resp, err := svc.DescribeWorkspaceDirectories(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DescribeWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DescribeWorkspacesInput{ - BundleId: aws.String("BundleId"), - DirectoryId: aws.String("DirectoryId"), - Limit: aws.Int64(1), - NextToken: aws.String("PaginationToken"), - UserName: aws.String("UserName"), - WorkspaceIds: []*string{ - aws.String("WorkspaceId"), // Required - // More values... - }, - } - resp, err := svc.DescribeWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_DescribeWorkspacesConnectionStatus() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.DescribeWorkspacesConnectionStatusInput{ - NextToken: aws.String("PaginationToken"), - WorkspaceIds: []*string{ - aws.String("WorkspaceId"), // Required - // More values... - }, - } - resp, err := svc.DescribeWorkspacesConnectionStatus(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_ModifyWorkspaceProperties() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.ModifyWorkspacePropertiesInput{ - WorkspaceId: aws.String("WorkspaceId"), // Required - WorkspaceProperties: &workspaces.WorkspaceProperties{ // Required - RunningMode: aws.String("RunningMode"), - RunningModeAutoStopTimeoutInMinutes: aws.Int64(1), - }, - } - resp, err := svc.ModifyWorkspaceProperties(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_RebootWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.RebootWorkspacesInput{ - RebootWorkspaceRequests: []*workspaces.RebootRequest{ // Required - { // Required - WorkspaceId: aws.String("WorkspaceId"), // Required - }, - // More values... - }, - } - resp, err := svc.RebootWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_RebuildWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.RebuildWorkspacesInput{ - RebuildWorkspaceRequests: []*workspaces.RebuildRequest{ // Required - { // Required - WorkspaceId: aws.String("WorkspaceId"), // Required - }, - // More values... - }, - } - resp, err := svc.RebuildWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_StartWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.StartWorkspacesInput{ - StartWorkspaceRequests: []*workspaces.StartRequest{ // Required - { // Required - WorkspaceId: aws.String("WorkspaceId"), - }, - // More values... - }, - } - resp, err := svc.StartWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_StopWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.StopWorkspacesInput{ - StopWorkspaceRequests: []*workspaces.StopRequest{ // Required - { // Required - WorkspaceId: aws.String("WorkspaceId"), - }, - // More values... - }, - } - resp, err := svc.StopWorkspaces(params) - - if err != nil { - // 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) -} - -func ExampleWorkSpaces_TerminateWorkspaces() { - sess := session.Must(session.NewSession()) - - svc := workspaces.New(sess) - - params := &workspaces.TerminateWorkspacesInput{ - TerminateWorkspaceRequests: []*workspaces.TerminateRequest{ // Required - { // Required - WorkspaceId: aws.String("WorkspaceId"), // Required - }, - // More values... - }, - } - resp, err := svc.TerminateWorkspaces(params) - - if err != nil { - // 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) -} diff --git a/service/xray/examples_test.go b/service/xray/examples_test.go deleted file mode 100644 index 53dbc4b368e..00000000000 --- a/service/xray/examples_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package xray_test - -import ( - "bytes" - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/xray" -) - -var _ time.Duration -var _ bytes.Buffer - -func ExampleXRay_BatchGetTraces() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.BatchGetTracesInput{ - TraceIds: []*string{ // Required - aws.String("TraceId"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.BatchGetTraces(params) - - if err != nil { - // 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) -} - -func ExampleXRay_GetServiceGraph() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.GetServiceGraphInput{ - EndTime: aws.Time(time.Now()), // Required - StartTime: aws.Time(time.Now()), // Required - NextToken: aws.String("String"), - } - resp, err := svc.GetServiceGraph(params) - - if err != nil { - // 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) -} - -func ExampleXRay_GetTraceGraph() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.GetTraceGraphInput{ - TraceIds: []*string{ // Required - aws.String("TraceId"), // Required - // More values... - }, - NextToken: aws.String("String"), - } - resp, err := svc.GetTraceGraph(params) - - if err != nil { - // 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) -} - -func ExampleXRay_GetTraceSummaries() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.GetTraceSummariesInput{ - EndTime: aws.Time(time.Now()), // Required - StartTime: aws.Time(time.Now()), // Required - FilterExpression: aws.String("FilterExpression"), - NextToken: aws.String("String"), - Sampling: aws.Bool(true), - } - resp, err := svc.GetTraceSummaries(params) - - if err != nil { - // 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) -} - -func ExampleXRay_PutTelemetryRecords() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.PutTelemetryRecordsInput{ - TelemetryRecords: []*xray.TelemetryRecord{ // Required - { // Required - BackendConnectionErrors: &xray.BackendConnectionErrors{ - ConnectionRefusedCount: aws.Int64(1), - HTTPCode4XXCount: aws.Int64(1), - HTTPCode5XXCount: aws.Int64(1), - OtherCount: aws.Int64(1), - TimeoutCount: aws.Int64(1), - UnknownHostCount: aws.Int64(1), - }, - SegmentsReceivedCount: aws.Int64(1), - SegmentsRejectedCount: aws.Int64(1), - SegmentsSentCount: aws.Int64(1), - SegmentsSpilloverCount: aws.Int64(1), - Timestamp: aws.Time(time.Now()), - }, - // More values... - }, - EC2InstanceId: aws.String("String"), - Hostname: aws.String("String"), - ResourceARN: aws.String("String"), - } - resp, err := svc.PutTelemetryRecords(params) - - if err != nil { - // 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) -} - -func ExampleXRay_PutTraceSegments() { - sess := session.Must(session.NewSession()) - - svc := xray.New(sess) - - params := &xray.PutTraceSegmentsInput{ - TraceSegmentDocuments: []*string{ // Required - aws.String("TraceSegmentDocument"), // Required - // More values... - }, - } - resp, err := svc.PutTraceSegments(params) - - if err != nil { - // 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) -}