diff --git a/aws/credentials/shared_credentials_provider.go b/aws/credentials/shared_credentials_provider.go index 7fb7cbf0db0..51e21e0f38f 100644 --- a/aws/credentials/shared_credentials_provider.go +++ b/aws/credentials/shared_credentials_provider.go @@ -3,11 +3,11 @@ package credentials import ( "fmt" "os" - "path/filepath" "github.com/go-ini/ini" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/internal/shareddefaults" ) // SharedCredsProviderName provides a name of SharedCreds provider @@ -15,8 +15,6 @@ const SharedCredsProviderName = "SharedCredentialsProvider" var ( // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found. - // - // @readonly ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil) ) @@ -117,22 +115,23 @@ func loadProfile(filename, profile string) (Value, error) { // // Will return an error if the user's home directory path cannot be found. func (p *SharedCredentialsProvider) filename() (string, error) { - if p.Filename == "" { - if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { - return p.Filename, nil - } - - homeDir := os.Getenv("HOME") // *nix - if homeDir == "" { // Windows - homeDir = os.Getenv("USERPROFILE") - } - if homeDir == "" { - return "", ErrSharedCredentialsHomeNotFound - } - - p.Filename = filepath.Join(homeDir, ".aws", "credentials") + if len(p.Filename) != 0 { + return p.Filename, nil + } + + if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); len(p.Filename) != 0 { + return p.Filename, nil } + if home := shareddefaults.UserHomeDir(); len(home) == 0 { + // Backwards compatibility of home directly not found error being returned. + // This error is too verbose, failure when opening the file would of been + // a better error to return. + return "", ErrSharedCredentialsHomeNotFound + } + + p.Filename = shareddefaults.SharedCredentialsFilename() + return p.Filename, nil } diff --git a/aws/credentials/shared_credentials_provider_test.go b/aws/credentials/shared_credentials_provider_test.go index 6b4093a1564..1eb45f263b2 100644 --- a/aws/credentials/shared_credentials_provider_test.go +++ b/aws/credentials/shared_credentials_provider_test.go @@ -5,6 +5,7 @@ import ( "path/filepath" "testing" + "github.com/aws/aws-sdk-go/internal/shareddefaults" "github.com/stretchr/testify/assert" ) @@ -97,6 +98,25 @@ func TestSharedCredentialsProviderColonInCredFile(t *testing.T) { assert.Empty(t, creds.SessionToken, "Expect no token") } +func TestSharedCredentialsProvider_DefaultFilename(t *testing.T) { + os.Clearenv() + os.Setenv("USERPROFILE", "profile_dir") + os.Setenv("HOME", "home_dir") + + // default filename and profile + p := SharedCredentialsProvider{} + + filename, err := p.filename() + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + if e, a := shareddefaults.SharedCredentialsFilename(), filename; e != a { + t.Errorf("expect %q filename, got %q", e, a) + } +} + func BenchmarkSharedCredentialsProvider(b *testing.B) { os.Clearenv() diff --git a/aws/defaults/shared_config.go b/aws/defaults/shared_config.go new file mode 100644 index 00000000000..ca0ee1dcc78 --- /dev/null +++ b/aws/defaults/shared_config.go @@ -0,0 +1,27 @@ +package defaults + +import ( + "github.com/aws/aws-sdk-go/internal/shareddefaults" +) + +// SharedCredentialsFilename returns the SDK's default file path +// for the shared credentials file. +// +// Builds the shared config file path based on the OS's platform. +// +// - Linux/Unix: $HOME/.aws/credentials +// - Windows: %USERPROFILE%\.aws\credentials +func SharedCredentialsFilename() string { + return shareddefaults.SharedCredentialsFilename() +} + +// SharedConfigFilename returns the SDK's default file path for +// the shared config file. +// +// Builds the shared config file path based on the OS's platform. +// +// - Linux/Unix: $HOME/.aws/config +// - Windows: %USERPROFILE%\.aws\config +func SharedConfigFilename() string { + return shareddefaults.SharedConfigFilename() +} diff --git a/aws/endpoints/defaults.go b/aws/endpoints/defaults.go index b1ae6794ef0..d6d87e446c8 100644 --- a/aws/endpoints/defaults.go +++ b/aws/endpoints/defaults.go @@ -47,6 +47,7 @@ const ( ApigatewayServiceID = "apigateway" // Apigateway. ApplicationAutoscalingServiceID = "application-autoscaling" // ApplicationAutoscaling. Appstream2ServiceID = "appstream2" // Appstream2. + AthenaServiceID = "athena" // Athena. AutoscalingServiceID = "autoscaling" // Autoscaling. BatchServiceID = "batch" // Batch. BudgetsServiceID = "budgets" // Budgets. @@ -307,6 +308,14 @@ var awsPartition = partition{ "us-west-2": endpoint{}, }, }, + "athena": service{ + + Endpoints: endpoints{ + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, + }, + }, "autoscaling": service{ Defaults: endpoint{ Protocols: []string{"http", "https"}, @@ -331,7 +340,9 @@ var awsPartition = partition{ "batch": service{ Endpoints: endpoints{ + "eu-west-1": endpoint{}, "us-east-1": endpoint{}, + "us-west-2": endpoint{}, }, }, "budgets": service{ @@ -457,10 +468,14 @@ var awsPartition = partition{ "codecommit": service{ Endpoints: endpoints{ - "eu-west-1": endpoint{}, - "us-east-1": endpoint{}, - "us-east-2": endpoint{}, - "us-west-2": endpoint{}, + "ap-northeast-1": endpoint{}, + "ap-southeast-1": endpoint{}, + "ap-southeast-2": endpoint{}, + "eu-central-1": endpoint{}, + "eu-west-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, }, }, "codedeploy": service{ @@ -1079,12 +1094,16 @@ var awsPartition = partition{ "lightsail": service{ Endpoints: endpoints{ - "eu-central-1": endpoint{}, - "eu-west-1": endpoint{}, - "eu-west-2": endpoint{}, - "us-east-1": endpoint{}, - "us-east-2": endpoint{}, - "us-west-2": endpoint{}, + "ap-northeast-1": endpoint{}, + "ap-south-1": endpoint{}, + "ap-southeast-1": endpoint{}, + "ap-southeast-2": endpoint{}, + "eu-central-1": endpoint{}, + "eu-west-1": endpoint{}, + "eu-west-2": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, }, }, "logs": service{ @@ -1497,10 +1516,13 @@ var awsPartition = partition{ Endpoints: endpoints{ "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, + "ap-south-1": endpoint{}, "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, + "ca-central-1": endpoint{}, "eu-central-1": endpoint{}, "eu-west-1": endpoint{}, + "eu-west-2": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, @@ -2029,6 +2051,12 @@ var awsusgovPartition = partition{ "us-gov-west-1": endpoint{}, }, }, + "codedeploy": service{ + + Endpoints: endpoints{ + "us-gov-west-1": endpoint{}, + }, + }, "config": service{ Endpoints: endpoints{ diff --git a/aws/session/custom_ca_bundle_test.go b/aws/session/custom_ca_bundle_test.go index 52e59d99c51..a89c0af5982 100644 --- a/aws/session/custom_ca_bundle_test.go +++ b/aws/session/custom_ca_bundle_test.go @@ -42,7 +42,7 @@ func TestMain(m *testing.M) { func TestNewSession_WithCustomCABundle_Env(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) endpoint, err := awstesting.CreateTLSServer(TLSBundleCertFile, TLSBundleKeyFile, nil) if err != nil { @@ -76,7 +76,7 @@ func TestNewSession_WithCustomCABundle_Env(t *testing.T) { func TestNewSession_WithCustomCABundle_EnvNotExists(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_CA_BUNDLE", "file-not-exists") @@ -94,7 +94,7 @@ func TestNewSession_WithCustomCABundle_EnvNotExists(t *testing.T) { func TestNewSession_WithCustomCABundle_Option(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) endpoint, err := awstesting.CreateTLSServer(TLSBundleCertFile, TLSBundleKeyFile, nil) if err != nil { @@ -129,7 +129,7 @@ func TestNewSession_WithCustomCABundle_Option(t *testing.T) { func TestNewSession_WithCustomCABundle_OptionPriority(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) endpoint, err := awstesting.CreateTLSServer(TLSBundleCertFile, TLSBundleKeyFile, nil) if err != nil { @@ -172,7 +172,7 @@ func (m *mockRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) { func TestNewSession_WithCustomCABundle_UnsupportedTransport(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) s, err := NewSessionWithOptions(Options{ Config: aws.Config{ @@ -199,7 +199,7 @@ func TestNewSession_WithCustomCABundle_UnsupportedTransport(t *testing.T) { func TestNewSession_WithCustomCABundle_TransportSet(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) endpoint, err := awstesting.CreateTLSServer(TLSBundleCertFile, TLSBundleKeyFile, nil) if err != nil { diff --git a/aws/session/env_config.go b/aws/session/env_config.go index e6278a782c7..7357e545acd 100644 --- a/aws/session/env_config.go +++ b/aws/session/env_config.go @@ -2,7 +2,6 @@ package session import ( "os" - "path/filepath" "strconv" "github.com/aws/aws-sdk-go/aws/credentials" @@ -116,6 +115,12 @@ var ( "AWS_PROFILE", "AWS_DEFAULT_PROFILE", // Only read if AWS_SDK_LOAD_CONFIG is also set } + sharedCredsFileEnvKey = []string{ + "AWS_SHARED_CREDENTIALS_FILE", + } + sharedConfigFileEnvKey = []string{ + "AWS_CONFIG_FILE", + } ) // loadEnvConfig retrieves the SDK's environment configuration. @@ -165,8 +170,8 @@ func envConfigLoad(enableSharedConfig bool) envConfig { setFromEnvVal(&cfg.Region, regionKeys) setFromEnvVal(&cfg.Profile, profileKeys) - cfg.SharedCredentialsFile = sharedCredentialsFilename() - cfg.SharedConfigFile = sharedConfigFilename() + setFromEnvVal(&cfg.SharedCredentialsFile, sharedCredsFileEnvKey) + setFromEnvVal(&cfg.SharedConfigFile, sharedConfigFileEnvKey) cfg.CustomCABundle = os.Getenv("AWS_CA_BUNDLE") @@ -181,28 +186,3 @@ func setFromEnvVal(dst *string, keys []string) { } } } - -func sharedCredentialsFilename() string { - if name := os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); len(name) > 0 { - return name - } - - return filepath.Join(userHomeDir(), ".aws", "credentials") -} - -func sharedConfigFilename() string { - if name := os.Getenv("AWS_CONFIG_FILE"); len(name) > 0 { - return name - } - - return filepath.Join(userHomeDir(), ".aws", "config") -} - -func userHomeDir() string { - homeDir := os.Getenv("HOME") // *nix - if len(homeDir) == 0 { // windows - homeDir = os.Getenv("USERPROFILE") - } - - return homeDir -} diff --git a/aws/session/env_config_test.go b/aws/session/env_config_test.go index 162a710546f..10e3662a282 100644 --- a/aws/session/env_config_test.go +++ b/aws/session/env_config_test.go @@ -2,17 +2,16 @@ package session import ( "os" - "path/filepath" - "strings" + "reflect" "testing" "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/stretchr/testify/assert" + "github.com/aws/aws-sdk-go/awstesting" ) func TestLoadEnvConfig_Creds(t *testing.T) { - env := stashEnv() - defer popEnv(env) + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) cases := []struct { Env map[string]string @@ -83,26 +82,30 @@ func TestLoadEnvConfig_Creds(t *testing.T) { } cfg := loadEnvConfig() - assert.Equal(t, c.Val, cfg.Creds) + if !reflect.DeepEqual(c.Val, cfg.Creds) { + t.Errorf("expect credentials to match.\n%s", + awstesting.SprintExpectActual(c.Val, cfg.Creds)) + } } } func TestLoadEnvConfig(t *testing.T) { - env := stashEnv() - defer popEnv(env) + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) cases := []struct { Env map[string]string - Region, Profile string - CustomCABundle string UseSharedConfigCall bool + Config envConfig }{ { Env: map[string]string{ "AWS_REGION": "region", "AWS_PROFILE": "profile", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + }, }, { Env: map[string]string{ @@ -111,7 +114,9 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_PROFILE": "profile", "AWS_DEFAULT_PROFILE": "default_profile", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + }, }, { Env: map[string]string{ @@ -121,7 +126,10 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_DEFAULT_PROFILE": "default_profile", "AWS_SDK_LOAD_CONFIG": "1", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + EnableSharedConfig: true, + }, }, { Env: map[string]string{ @@ -135,14 +143,20 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_DEFAULT_PROFILE": "default_profile", "AWS_SDK_LOAD_CONFIG": "1", }, - Region: "default_region", Profile: "default_profile", + Config: envConfig{ + Region: "default_region", Profile: "default_profile", + EnableSharedConfig: true, + }, }, { Env: map[string]string{ "AWS_REGION": "region", "AWS_PROFILE": "profile", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, { @@ -152,7 +166,10 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_PROFILE": "profile", "AWS_DEFAULT_PROFILE": "default_profile", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, { @@ -163,7 +180,10 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_DEFAULT_PROFILE": "default_profile", "AWS_SDK_LOAD_CONFIG": "1", }, - Region: "region", Profile: "profile", + Config: envConfig{ + Region: "region", Profile: "profile", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, { @@ -171,7 +191,10 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_DEFAULT_REGION": "default_region", "AWS_DEFAULT_PROFILE": "default_profile", }, - Region: "default_region", Profile: "default_profile", + Config: envConfig{ + Region: "default_region", Profile: "default_profile", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, { @@ -180,22 +203,40 @@ func TestLoadEnvConfig(t *testing.T) { "AWS_DEFAULT_PROFILE": "default_profile", "AWS_SDK_LOAD_CONFIG": "1", }, - Region: "default_region", Profile: "default_profile", + Config: envConfig{ + Region: "default_region", Profile: "default_profile", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, { Env: map[string]string{ "AWS_CA_BUNDLE": "custom_ca_bundle", }, - CustomCABundle: "custom_ca_bundle", + Config: envConfig{ + CustomCABundle: "custom_ca_bundle", + }, }, { Env: map[string]string{ "AWS_CA_BUNDLE": "custom_ca_bundle", }, - CustomCABundle: "custom_ca_bundle", + Config: envConfig{ + CustomCABundle: "custom_ca_bundle", + EnableSharedConfig: true, + }, UseSharedConfigCall: true, }, + { + Env: map[string]string{ + "AWS_SHARED_CREDENTIALS_FILE": "/path/to/credentials/file", + "AWS_CONFIG_FILE": "/path/to/config/file", + }, + Config: envConfig{ + SharedCredentialsFile: "/path/to/credentials/file", + SharedConfigFile: "/path/to/config/file", + }, + }, } for _, c := range cases { @@ -212,55 +253,16 @@ func TestLoadEnvConfig(t *testing.T) { cfg = loadEnvConfig() } - assert.Equal(t, c.Region, cfg.Region) - assert.Equal(t, c.Profile, cfg.Profile) - assert.Equal(t, c.CustomCABundle, cfg.CustomCABundle) + if !reflect.DeepEqual(c.Config, cfg) { + t.Errorf("expect config to match.\n%s", + awstesting.SprintExpectActual(c.Config, cfg)) + } } } -func TestSharedCredsFilename(t *testing.T) { - env := stashEnv() - defer popEnv(env) - - os.Setenv("USERPROFILE", "profile_dir") - expect := filepath.Join("profile_dir", ".aws", "credentials") - name := sharedCredentialsFilename() - assert.Equal(t, expect, name) - - os.Setenv("HOME", "home_dir") - expect = filepath.Join("home_dir", ".aws", "credentials") - name = sharedCredentialsFilename() - assert.Equal(t, expect, name) - - expect = filepath.Join("path/to/credentials/file") - os.Setenv("AWS_SHARED_CREDENTIALS_FILE", expect) - name = sharedCredentialsFilename() - assert.Equal(t, expect, name) -} - -func TestSharedConfigFilename(t *testing.T) { - env := stashEnv() - defer popEnv(env) - - os.Setenv("USERPROFILE", "profile_dir") - expect := filepath.Join("profile_dir", ".aws", "config") - name := sharedConfigFilename() - assert.Equal(t, expect, name) - - os.Setenv("HOME", "home_dir") - expect = filepath.Join("home_dir", ".aws", "config") - name = sharedConfigFilename() - assert.Equal(t, expect, name) - - expect = filepath.Join("path/to/config/file") - os.Setenv("AWS_CONFIG_FILE", expect) - name = sharedConfigFilename() - assert.Equal(t, expect, name) -} - func TestSetEnvValue(t *testing.T) { - env := stashEnv() - defer popEnv(env) + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) os.Setenv("empty_key", "") os.Setenv("second_key", "2") @@ -271,21 +273,7 @@ func TestSetEnvValue(t *testing.T) { "empty_key", "first_key", "second_key", "third_key", }) - assert.Equal(t, "2", dst) -} - -func stashEnv() []string { - env := os.Environ() - os.Clearenv() - - return env -} - -func popEnv(env []string) { - os.Clearenv() - - for _, e := range env { - p := strings.SplitN(e, "=", 2) - os.Setenv(p[0], p[1]) + if e, a := "2", dst; e != a { + t.Errorf("expect %s value from environment, got %s", e, a) } } diff --git a/aws/session/session.go b/aws/session/session.go index 34a292085c0..9f75d5ac588 100644 --- a/aws/session/session.go +++ b/aws/session/session.go @@ -243,6 +243,13 @@ func NewSessionWithOptions(opts Options) (*Session, error) { envCfg.EnableSharedConfig = true } + if len(envCfg.SharedCredentialsFile) == 0 { + envCfg.SharedCredentialsFile = defaults.SharedCredentialsFilename() + } + if len(envCfg.SharedConfigFile) == 0 { + envCfg.SharedConfigFile = defaults.SharedConfigFilename() + } + // Only use AWS_CA_BUNDLE if session option is not provided. if len(envCfg.CustomCABundle) != 0 && opts.CustomCABundle == nil { f, err := os.Open(envCfg.CustomCABundle) diff --git a/aws/session/session_test.go b/aws/session/session_test.go index 25aed6892a8..d0ab360e265 100644 --- a/aws/session/session_test.go +++ b/aws/session/session_test.go @@ -14,12 +14,13 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/defaults" + "github.com/aws/aws-sdk-go/awstesting" "github.com/aws/aws-sdk-go/service/s3" ) func TestNewDefaultSession(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) s := New(&aws.Config{Region: aws.String("region")}) @@ -31,7 +32,7 @@ func TestNewDefaultSession(t *testing.T) { func TestNew_WithCustomCreds(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) customCreds := credentials.NewStaticCredentials("AKID", "SECRET", "TOKEN") s := New(&aws.Config{Credentials: customCreds}) @@ -49,7 +50,7 @@ func (w mockLogger) Log(args ...interface{}) { func TestNew_WithSessionLoadError(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "1") os.Setenv("AWS_CONFIG_FILE", testConfigFilename) @@ -72,7 +73,7 @@ func TestNew_WithSessionLoadError(t *testing.T) { func TestSessionCopy(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_REGION", "orig_region") @@ -100,7 +101,7 @@ func TestSessionClientConfig(t *testing.T) { func TestNewSession_NoCredentials(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) s, err := NewSession() assert.NoError(t, err) @@ -111,7 +112,7 @@ func TestNewSession_NoCredentials(t *testing.T) { func TestNewSessionWithOptions_OverrideProfile(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "1") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -134,7 +135,7 @@ func TestNewSessionWithOptions_OverrideProfile(t *testing.T) { func TestNewSessionWithOptions_OverrideSharedConfigEnable(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "0") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -157,7 +158,7 @@ func TestNewSessionWithOptions_OverrideSharedConfigEnable(t *testing.T) { func TestNewSessionWithOptions_OverrideSharedConfigDisable(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "1") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -180,7 +181,7 @@ func TestNewSessionWithOptions_OverrideSharedConfigDisable(t *testing.T) { func TestNewSessionWithOptions_OverrideSharedConfigFiles(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "1") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -258,7 +259,7 @@ func TestNewSessionWithOptions_Overrides(t *testing.T) { for _, c := range cases { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) for k, v := range c.InEnvs { os.Setenv(k, v) @@ -302,7 +303,7 @@ const assumeRoleRespMsg = ` func TestSesisonAssumeRole(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_REGION", "us-east-1") os.Setenv("AWS_SDK_LOAD_CONFIG", "1") @@ -325,7 +326,7 @@ func TestSesisonAssumeRole(t *testing.T) { func TestSessionAssumeRole_WithMFA(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_REGION", "us-east-1") os.Setenv("AWS_SDK_LOAD_CONFIG", "1") @@ -368,7 +369,7 @@ func TestSessionAssumeRole_WithMFA(t *testing.T) { func TestSessionAssumeRole_WithMFA_NoTokenProvider(t *testing.T) { oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_REGION", "us-east-1") os.Setenv("AWS_SDK_LOAD_CONFIG", "1") @@ -386,7 +387,7 @@ func TestSessionAssumeRole_DisableSharedConfig(t *testing.T) { // Backwards compatibility with Shared config disabled // assume role should not be built into the config. oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "0") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -406,7 +407,7 @@ func TestSessionAssumeRole_InvalidSourceProfile(t *testing.T) { // Backwards compatibility with Shared config disabled // assume role should not be built into the config. oldEnv := initSessionTestEnv() - defer popEnv(oldEnv) + defer awstesting.PopEnv(oldEnv) os.Setenv("AWS_SDK_LOAD_CONFIG", "1") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", testConfigFilename) @@ -419,7 +420,7 @@ func TestSessionAssumeRole_InvalidSourceProfile(t *testing.T) { } func initSessionTestEnv() (oldEnv []string) { - oldEnv = stashEnv() + oldEnv = awstesting.StashEnv() os.Setenv("AWS_CONFIG_FILE", "file_not_exists") os.Setenv("AWS_SHARED_CREDENTIALS_FILE", "file_not_exists") diff --git a/aws/version.go b/aws/version.go index 794d5de6026..bbf4c2f1255 100644 --- a/aws/version.go +++ b/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.8.31" +const SDKVersion = "1.8.34" diff --git a/internal/shareddefaults/shared_config.go b/internal/shareddefaults/shared_config.go new file mode 100644 index 00000000000..ebcbc2b40a3 --- /dev/null +++ b/internal/shareddefaults/shared_config.go @@ -0,0 +1,40 @@ +package shareddefaults + +import ( + "os" + "path/filepath" + "runtime" +) + +// SharedCredentialsFilename returns the SDK's default file path +// for the shared credentials file. +// +// Builds the shared config file path based on the OS's platform. +// +// - Linux/Unix: $HOME/.aws/credentials +// - Windows: %USERPROFILE%\.aws\credentials +func SharedCredentialsFilename() string { + return filepath.Join(UserHomeDir(), ".aws", "credentials") +} + +// SharedConfigFilename returns the SDK's default file path for +// the shared config file. +// +// Builds the shared config file path based on the OS's platform. +// +// - Linux/Unix: $HOME/.aws/config +// - Windows: %USERPROFILE%\.aws\config +func SharedConfigFilename() string { + return filepath.Join(UserHomeDir(), ".aws", "config") +} + +// UserHomeDir returns the home directory for the user the process is +// running under. +func UserHomeDir() string { + if runtime.GOOS == "windows" { // Windows + return os.Getenv("USERPROFILE") + } + + // *nix + return os.Getenv("HOME") +} diff --git a/internal/shareddefaults/shared_config_other_test.go b/internal/shareddefaults/shared_config_other_test.go new file mode 100644 index 00000000000..a2fd4558b05 --- /dev/null +++ b/internal/shareddefaults/shared_config_other_test.go @@ -0,0 +1,40 @@ +package shareddefaults_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/aws/aws-sdk-go/awstesting" + "github.com/aws/aws-sdk-go/internal/shareddefaults" +) + +func TestSharedCredsFilename(t *testing.T) { + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) + + os.Setenv("HOME", "home_dir") + os.Setenv("USERPROFILE", "profile_dir") + + expect := filepath.Join("home_dir", ".aws", "credentials") + + name := shareddefaults.SharedCredentialsFilename() + if e, a := expect, name; e != a { + t.Errorf("expect %q shared creds filename, got %q", e, a) + } +} + +func TestSharedConfigFilename(t *testing.T) { + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) + + os.Setenv("HOME", "home_dir") + os.Setenv("USERPROFILE", "profile_dir") + + expect := filepath.Join("home_dir", ".aws", "config") + + name := shareddefaults.SharedConfigFilename() + if e, a := expect, name; e != a { + t.Errorf("expect %q shared config filename, got %q", e, a) + } +} diff --git a/internal/shareddefaults/shared_config_windows_test.go b/internal/shareddefaults/shared_config_windows_test.go new file mode 100644 index 00000000000..afe96b17deb --- /dev/null +++ b/internal/shareddefaults/shared_config_windows_test.go @@ -0,0 +1,40 @@ +package shareddefaults_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/aws/aws-sdk-go/awstesting" + "github.com/aws/aws-sdk-go/internal/shareddefaults" +) + +func TestSharedCredsFilename(t *testing.T) { + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) + + os.Setenv("HOME", "home_dir") + os.Setenv("USERPROFILE", "profile_dir") + + expect := filepath.Join("profile_dir", ".aws", "credentials") + + name := shareddefaults.SharedCredentialsFilename() + if e, a := expect, name; e != a { + t.Errorf("expect %q shared creds filename, got %q", e, a) + } +} + +func TestSharedConfigFilename(t *testing.T) { + env := awstesting.StashEnv() + defer awstesting.PopEnv(env) + + os.Setenv("HOME", "home_dir") + os.Setenv("USERPROFILE", "profile_dir") + + expect := filepath.Join("profile_dir", ".aws", "config") + + name := shareddefaults.SharedConfigFilename() + if e, a := expect, name; e != a { + t.Errorf("expect %q shared config filename, got %q", e, a) + } +} diff --git a/models/apis/codedeploy/2014-10-06/api-2.json b/models/apis/codedeploy/2014-10-06/api-2.json index 0812c796876..ae064d4ab15 100644 --- a/models/apis/codedeploy/2014-10-06/api-2.json +++ b/models/apis/codedeploy/2014-10-06/api-2.json @@ -492,6 +492,19 @@ {"shape":"InvalidNextTokenException"} ] }, + "ListGitHubAccountTokenNames":{ + "name":"ListGitHubAccountTokenNames", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"ListGitHubAccountTokenNamesInput"}, + "output":{"shape":"ListGitHubAccountTokenNamesOutput"}, + "errors":[ + {"shape":"InvalidNextTokenException"}, + {"shape":"ResourceValidationException"} + ] + }, "ListOnPremisesInstances":{ "name":"ListOnPremisesInstances", "http":{ @@ -694,7 +707,8 @@ "applicationId":{"shape":"ApplicationId"}, "applicationName":{"shape":"ApplicationName"}, "createTime":{"shape":"Timestamp"}, - "linkedToGitHub":{"shape":"Boolean"} + "linkedToGitHub":{"shape":"Boolean"}, + "gitHubAccountName":{"shape":"GitHubAccountTokenName"} } }, "ApplicationLimitExceededException":{ @@ -1108,7 +1122,9 @@ "autoRollbackConfiguration":{"shape":"AutoRollbackConfiguration"}, "deploymentStyle":{"shape":"DeploymentStyle"}, "blueGreenDeploymentConfiguration":{"shape":"BlueGreenDeploymentConfiguration"}, - "loadBalancerInfo":{"shape":"LoadBalancerInfo"} + "loadBalancerInfo":{"shape":"LoadBalancerInfo"}, + "lastSuccessfulDeployment":{"shape":"LastDeploymentInfo"}, + "lastAttemptedDeployment":{"shape":"LastDeploymentInfo"} } }, "DeploymentGroupInfoList":{ @@ -1471,6 +1487,17 @@ "instanceInfo":{"shape":"InstanceInfo"} } }, + "GitHubAccountTokenDoesNotExistException":{ + "type":"structure", + "members":{ + }, + "exception":true + }, + "GitHubAccountTokenName":{"type":"string"}, + "GitHubAccountTokenNameList":{ + "type":"list", + "member":{"shape":"GitHubAccountTokenName"} + }, "GitHubLocation":{ "type":"structure", "members":{ @@ -1841,6 +1868,15 @@ "exception":true }, "Key":{"type":"string"}, + "LastDeploymentInfo":{ + "type":"structure", + "members":{ + "deploymentId":{"shape":"DeploymentId"}, + "status":{"shape":"DeploymentStatus"}, + "endTime":{"shape":"Timestamp"}, + "createTime":{"shape":"Timestamp"} + } + }, "LifecycleErrorCode":{ "type":"string", "enum":[ @@ -1981,6 +2017,19 @@ "nextToken":{"shape":"NextToken"} } }, + "ListGitHubAccountTokenNamesInput":{ + "type":"structure", + "members":{ + "nextToken":{"shape":"NextToken"} + } + }, + "ListGitHubAccountTokenNamesOutput":{ + "type":"structure", + "members":{ + "tokenNameList":{"shape":"GitHubAccountTokenNameList"}, + "nextToken":{"shape":"NextToken"} + } + }, "ListOnPremisesInstancesInput":{ "type":"structure", "members":{ @@ -2075,6 +2124,12 @@ } }, "Repository":{"type":"string"}, + "ResourceValidationException":{ + "type":"structure", + "members":{ + }, + "exception":true + }, "RevisionDoesNotExistException":{ "type":"structure", "members":{ diff --git a/models/apis/codedeploy/2014-10-06/docs-2.json b/models/apis/codedeploy/2014-10-06/docs-2.json index e41e75152ad..1fa67463c0b 100644 --- a/models/apis/codedeploy/2014-10-06/docs-2.json +++ b/models/apis/codedeploy/2014-10-06/docs-2.json @@ -31,6 +31,7 @@ "ListDeploymentGroups": "

Lists the deployment groups for an application registered with the applicable IAM user or AWS account.

", "ListDeploymentInstances": "

Lists the instance for a deployment associated with the applicable IAM user or AWS account.

", "ListDeployments": "

Lists the deployments in a deployment group for an application registered with the applicable IAM user or AWS account.

", + "ListGitHubAccountTokenNames": "

Lists the names of stored connections to GitHub accounts.

", "ListOnPremisesInstances": "

Gets a list of names for one or more on-premises instances.

Unless otherwise specified, both registered and deregistered on-premises instance names will be listed. To list only registered or deregistered on-premises instance names, use the registration status parameter.

", "RegisterApplicationRevision": "

Registers with AWS CodeDeploy a revision for the specified application.

", "RegisterOnPremisesInstance": "

Registers an on-premises instance.

Only one IAM ARN (an IAM session ARN or IAM user ARN) is supported in the request. You cannot use both.

", @@ -223,62 +224,62 @@ } }, "BatchGetApplicationRevisionsInput": { - "base": "

Represents the input of a batch get application revisions operation.

", + "base": "

Represents the input of a BatchGetApplicationRevisions operation.

", "refs": { } }, "BatchGetApplicationRevisionsOutput": { - "base": "

Represents the output of a batch get application revisions operation.

", + "base": "

Represents the output of a BatchGetApplicationRevisions operation.

", "refs": { } }, "BatchGetApplicationsInput": { - "base": "

Represents the input of a batch get applications operation.

", + "base": "

Represents the input of a BatchGetApplications operation.

", "refs": { } }, "BatchGetApplicationsOutput": { - "base": "

Represents the output of a batch get applications operation.

", + "base": "

Represents the output of a BatchGetApplications operation.

", "refs": { } }, "BatchGetDeploymentGroupsInput": { - "base": "

Represents the input of a batch get deployment groups operation.

", + "base": "

Represents the input of a BatchGetDeploymentGroups operation.

", "refs": { } }, "BatchGetDeploymentGroupsOutput": { - "base": "

Represents the output of a batch get deployment groups operation.

", + "base": "

Represents the output of a BatchGetDeploymentGroups operation.

", "refs": { } }, "BatchGetDeploymentInstancesInput": { - "base": "

Represents the input of a batch get deployment instances operation.

", + "base": "

Represents the input of a BatchGetDeploymentInstances operation.

", "refs": { } }, "BatchGetDeploymentInstancesOutput": { - "base": "

Represents the output of a batch get deployment instance operation.

", + "base": "

Represents the output of a BatchGetDeploymentInstances operation.

", "refs": { } }, "BatchGetDeploymentsInput": { - "base": "

Represents the input of a batch get deployments operation.

", + "base": "

Represents the input of a BatchGetDeployments operation.

", "refs": { } }, "BatchGetDeploymentsOutput": { - "base": "

Represents the output of a batch get deployments operation.

", + "base": "

Represents the output of a BatchGetDeployments operation.

", "refs": { } }, "BatchGetOnPremisesInstancesInput": { - "base": "

Represents the input of a batch get on-premises instances operation.

", + "base": "

Represents the input of a BatchGetOnPremisesInstances operation.

", "refs": { } }, "BatchGetOnPremisesInstancesOutput": { - "base": "

Represents the output of a batch get on-premises instances operation.

", + "base": "

Represents the output of a BatchGetOnPremisesInstances operation.

", "refs": { } }, @@ -339,62 +340,62 @@ } }, "CreateApplicationInput": { - "base": "

Represents the input of a create application operation.

", + "base": "

Represents the input of a CreateApplication operation.

", "refs": { } }, "CreateApplicationOutput": { - "base": "

Represents the output of a create application operation.

", + "base": "

Represents the output of a CreateApplication operation.

", "refs": { } }, "CreateDeploymentConfigInput": { - "base": "

Represents the input of a create deployment configuration operation.

", + "base": "

Represents the input of a CreateDeploymentConfig operation.

", "refs": { } }, "CreateDeploymentConfigOutput": { - "base": "

Represents the output of a create deployment configuration operation.

", + "base": "

Represents the output of a CreateDeploymentConfig operation.

", "refs": { } }, "CreateDeploymentGroupInput": { - "base": "

Represents the input of a create deployment group operation.

", + "base": "

Represents the input of a CreateDeploymentGroup operation.

", "refs": { } }, "CreateDeploymentGroupOutput": { - "base": "

Represents the output of a create deployment group operation.

", + "base": "

Represents the output of a CreateDeploymentGroup operation.

", "refs": { } }, "CreateDeploymentInput": { - "base": "

Represents the input of a create deployment operation.

", + "base": "

Represents the input of a CreateDeployment operation.

", "refs": { } }, "CreateDeploymentOutput": { - "base": "

Represents the output of a create deployment operation.

", + "base": "

Represents the output of a CreateDeployment operation.

", "refs": { } }, "DeleteApplicationInput": { - "base": "

Represents the input of a delete application operation.

", + "base": "

Represents the input of a DeleteApplication operation.

", "refs": { } }, "DeleteDeploymentConfigInput": { - "base": "

Represents the input of a delete deployment configuration operation.

", + "base": "

Represents the input of a DeleteDeploymentConfig operation.

", "refs": { } }, "DeleteDeploymentGroupInput": { - "base": "

Represents the input of a delete deployment group operation.

", + "base": "

Represents the input of a DeleteDeploymentGroup operation.

", "refs": { } }, "DeleteDeploymentGroupOutput": { - "base": "

Represents the output of a delete deployment group operation.

", + "base": "

Represents the output of a DeleteDeploymentGroup operation.

", "refs": { } }, @@ -547,6 +548,7 @@ "GetDeploymentInput$deploymentId": "

A deployment ID associated with the applicable IAM user or AWS account.

", "GetDeploymentInstanceInput$deploymentId": "

The unique ID of a deployment.

", "InstanceSummary$deploymentId": "

The deployment ID.

", + "LastDeploymentInfo$deploymentId": "

The deployment ID.

", "ListDeploymentInstancesInput$deploymentId": "

The unique ID of a deployment.

", "RollbackInfo$rollbackDeploymentId": "

The ID of the deployment rollback.

", "RollbackInfo$rollbackTriggeringDeploymentId": "

The deployment ID of the deployment that was underway and triggered a rollback deployment because it failed or was stopped.

", @@ -609,7 +611,8 @@ "base": null, "refs": { "DeploymentInfo$status": "

The current state of the deployment as a whole.

", - "DeploymentStatusList$member": null + "DeploymentStatusList$member": null, + "LastDeploymentInfo$status": "

The status of the most recent deployment.

" } }, "DeploymentStatusList": { @@ -647,7 +650,7 @@ } }, "DeregisterOnPremisesInstanceInput": { - "base": "

Represents the input of a deregister on-premises instance operation.

", + "base": "

Represents the input of a DeregisterOnPremisesInstance operation.

", "refs": { } }, @@ -760,75 +763,93 @@ } }, "GetApplicationInput": { - "base": "

Represents the input of a get application operation.

", + "base": "

Represents the input of a GetApplication operation.

", "refs": { } }, "GetApplicationOutput": { - "base": "

Represents the output of a get application operation.

", + "base": "

Represents the output of a GetApplication operation.

", "refs": { } }, "GetApplicationRevisionInput": { - "base": "

Represents the input of a get application revision operation.

", + "base": "

Represents the input of a GetApplicationRevision operation.

", "refs": { } }, "GetApplicationRevisionOutput": { - "base": "

Represents the output of a get application revision operation.

", + "base": "

Represents the output of a GetApplicationRevision operation.

", "refs": { } }, "GetDeploymentConfigInput": { - "base": "

Represents the input of a get deployment configuration operation.

", + "base": "

Represents the input of a GetDeploymentConfig operation.

", "refs": { } }, "GetDeploymentConfigOutput": { - "base": "

Represents the output of a get deployment configuration operation.

", + "base": "

Represents the output of a GetDeploymentConfig operation.

", "refs": { } }, "GetDeploymentGroupInput": { - "base": "

Represents the input of a get deployment group operation.

", + "base": "

Represents the input of a GetDeploymentGroup operation.

", "refs": { } }, "GetDeploymentGroupOutput": { - "base": "

Represents the output of a get deployment group operation.

", + "base": "

Represents the output of a GetDeploymentGroup operation.

", "refs": { } }, "GetDeploymentInput": { - "base": "

Represents the input of a get deployment operation.

", + "base": "

Represents the input of a GetDeployment operation.

", "refs": { } }, "GetDeploymentInstanceInput": { - "base": "

Represents the input of a get deployment instance operation.

", + "base": "

Represents the input of a GetDeploymentInstance operation.

", "refs": { } }, "GetDeploymentInstanceOutput": { - "base": "

Represents the output of a get deployment instance operation.

", + "base": "

Represents the output of a GetDeploymentInstance operation.

", "refs": { } }, "GetDeploymentOutput": { - "base": "

Represents the output of a get deployment operation.

", + "base": "

Represents the output of a GetDeployment operation.

", "refs": { } }, "GetOnPremisesInstanceInput": { - "base": "

Represents the input of a get on-premises instance operation.

", + "base": "

Represents the input of a GetOnPremisesInstance operation.

", "refs": { } }, "GetOnPremisesInstanceOutput": { - "base": "

Represents the output of a get on-premises instance operation.

", + "base": "

Represents the output of a GetOnPremisesInstance operation.

", "refs": { } }, + "GitHubAccountTokenDoesNotExistException": { + "base": "

No GitHub account connection exists with the named specified in the call.

", + "refs": { + } + }, + "GitHubAccountTokenName": { + "base": null, + "refs": { + "ApplicationInfo$gitHubAccountName": "

The name for a connection to a GitHub account.

", + "GitHubAccountTokenNameList$member": null + } + }, + "GitHubAccountTokenNameList": { + "base": null, + "refs": { + "ListGitHubAccountTokenNamesOutput$tokenNameList": "

A list of names of connections to GitHub accounts.

" + } + }, "GitHubLocation": { "base": "

Information about the location of application artifacts stored in GitHub.

", "refs": { @@ -1203,6 +1224,13 @@ "TagFilter$Key": "

The on-premises instance tag filter key.

" } }, + "LastDeploymentInfo": { + "base": "

Information about the most recent attempted or successful deployment to a deployment group.

", + "refs": { + "DeploymentGroupInfo$lastSuccessfulDeployment": "

Information about the most recent successful deployment to the deployment group.

", + "DeploymentGroupInfo$lastAttemptedDeployment": "

Information about the most recent attempted deployment to the deployment group.

" + } + }, "LifecycleErrorCode": { "base": null, "refs": { @@ -1245,67 +1273,77 @@ } }, "ListApplicationRevisionsInput": { - "base": "

Represents the input of a list application revisions operation.

", + "base": "

Represents the input of a ListApplicationRevisions operation.

", "refs": { } }, "ListApplicationRevisionsOutput": { - "base": "

Represents the output of a list application revisions operation.

", + "base": "

Represents the output of a ListApplicationRevisions operation.

", "refs": { } }, "ListApplicationsInput": { - "base": "

Represents the input of a list applications operation.

", + "base": "

Represents the input of a ListApplications operation.

", "refs": { } }, "ListApplicationsOutput": { - "base": "

Represents the output of a list applications operation.

", + "base": "

Represents the output of a ListApplications operation.

", "refs": { } }, "ListDeploymentConfigsInput": { - "base": "

Represents the input of a list deployment configurations operation.

", + "base": "

Represents the input of a ListDeploymentConfigs operation.

", "refs": { } }, "ListDeploymentConfigsOutput": { - "base": "

Represents the output of a list deployment configurations operation.

", + "base": "

Represents the output of a ListDeploymentConfigs operation.

", "refs": { } }, "ListDeploymentGroupsInput": { - "base": "

Represents the input of a list deployment groups operation.

", + "base": "

Represents the input of a ListDeploymentGroups operation.

", "refs": { } }, "ListDeploymentGroupsOutput": { - "base": "

Represents the output of a list deployment groups operation.

", + "base": "

Represents the output of a ListDeploymentGroups operation.

", "refs": { } }, "ListDeploymentInstancesInput": { - "base": "

Represents the input of a list deployment instances operation.

", + "base": "

Represents the input of a ListDeploymentInstances operation.

", "refs": { } }, "ListDeploymentInstancesOutput": { - "base": "

Represents the output of a list deployment instances operation.

", + "base": "

Represents the output of a ListDeploymentInstances operation.

", "refs": { } }, "ListDeploymentsInput": { - "base": "

Represents the input of a list deployments operation.

", + "base": "

Represents the input of a ListDeployments operation.

", "refs": { } }, "ListDeploymentsOutput": { - "base": "

Represents the output of a list deployments operation.

", + "base": "

Represents the output of a ListDeployments operation.

", + "refs": { + } + }, + "ListGitHubAccountTokenNamesInput": { + "base": "

Represents the input of a ListGitHubAccountTokenNames operation.

", + "refs": { + } + }, + "ListGitHubAccountTokenNamesOutput": { + "base": "

Represents the output of a ListGitHubAccountTokenNames operation.

", "refs": { } }, "ListOnPremisesInstancesInput": { - "base": "

Represents the input of a list on-premises instances operation.

", + "base": "

Represents the input of a ListOnPremisesInstances operation.

", "refs": { } }, @@ -1380,6 +1418,8 @@ "ListDeploymentInstancesOutput$nextToken": "

If a large amount of information is returned, an identifier is also returned. It can be used in a subsequent list deployment instances call to return the next set of deployment instances in the list.

", "ListDeploymentsInput$nextToken": "

An identifier returned from the previous list deployments call. It can be used to return the next set of deployments in the list.

", "ListDeploymentsOutput$nextToken": "

If a large amount of information is returned, an identifier is also returned. It can be used in a subsequent list deployments call to return the next set of deployments in the list.

", + "ListGitHubAccountTokenNamesInput$nextToken": "

An identifier returned from the previous ListGitHubAccountTokenNames call. It can be used to return the next set of names in the list.

", + "ListGitHubAccountTokenNamesOutput$nextToken": "

If a large amount of information is returned, an identifier is also returned. It can be used in a subsequent ListGitHubAccountTokenNames call to return the next set of names in the list.

", "ListOnPremisesInstancesInput$nextToken": "

An identifier returned from the previous list on-premises instances call. It can be used to return the next set of on-premises instances in the list.

", "ListOnPremisesInstancesOutput$nextToken": "

If a large amount of information is returned, an identifier is also returned. It can be used in a subsequent list on-premises instances call to return the next set of on-premises instances in the list.

" } @@ -1391,7 +1431,7 @@ } }, "RegisterApplicationRevisionInput": { - "base": "

Represents the input of a register application revision operation.

", + "base": "

Represents the input of a RegisterApplicationRevision operation.

", "refs": { } }, @@ -1407,7 +1447,7 @@ } }, "RemoveTagsFromOnPremisesInstancesInput": { - "base": "

Represents the input of a remove tags from on-premises instances operation.

", + "base": "

Represents the input of a RemoveTagsFromOnPremisesInstances operation.

", "refs": { } }, @@ -1417,6 +1457,11 @@ "GitHubLocation$repository": "

The GitHub account and repository pair that stores a reference to the commit that represents the bundled artifacts for the application revision.

Specified as account/repository.

" } }, + "ResourceValidationException": { + "base": "

The specified resource could not be validated.

", + "refs": { + } + }, "RevisionDoesNotExistException": { "base": "

The named revision does not exist with the applicable IAM user or AWS account.

", "refs": { @@ -1523,12 +1568,12 @@ } }, "StopDeploymentInput": { - "base": "

Represents the input of a stop deployment operation.

", + "base": "

Represents the input of a StopDeployment operation.

", "refs": { } }, "StopDeploymentOutput": { - "base": "

Represents the output of a stop deployment operation.

", + "base": "

Represents the output of a StopDeployment operation.

", "refs": { } }, @@ -1610,6 +1655,8 @@ "InstanceInfo$registerTime": "

The time at which the on-premises instance was registered.

", "InstanceInfo$deregisterTime": "

If the on-premises instance was deregistered, the time at which the on-premises instance was deregistered.

", "InstanceSummary$lastUpdatedAt": "

A timestamp indicating when the instance information was last updated.

", + "LastDeploymentInfo$endTime": "

A timestamp indicating when the most recent deployment to the deployment group completed.

", + "LastDeploymentInfo$createTime": "

A timestamp indicating when the most recent deployment to the deployment group started.

", "LifecycleEvent$startTime": "

A timestamp indicating when the deployment lifecycle event started.

", "LifecycleEvent$endTime": "

A timestamp indicating when the deployment lifecycle event ended.

", "TimeRange$start": "

The start time of the time range.

Specify null to leave the start time open-ended.

", @@ -1665,17 +1712,17 @@ } }, "UpdateApplicationInput": { - "base": "

Represents the input of an update application operation.

", + "base": "

Represents the input of an UpdateApplication operation.

", "refs": { } }, "UpdateDeploymentGroupInput": { - "base": "

Represents the input of an update deployment group operation.

", + "base": "

Represents the input of an UpdateDeploymentGroup operation.

", "refs": { } }, "UpdateDeploymentGroupOutput": { - "base": "

Represents the output of an update deployment group operation.

", + "base": "

Represents the output of an UpdateDeploymentGroup operation.

", "refs": { } }, diff --git a/models/apis/cognito-idp/2016-04-18/api-2.json b/models/apis/cognito-idp/2016-04-18/api-2.json index 5d83073068e..237e3c01a2e 100644 --- a/models/apis/cognito-idp/2016-04-18/api-2.json +++ b/models/apis/cognito-idp/2016-04-18/api-2.json @@ -526,6 +526,24 @@ {"shape":"InternalErrorException"} ] }, + "CreateIdentityProvider":{ + "name":"CreateIdentityProvider", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"CreateIdentityProviderRequest"}, + "output":{"shape":"CreateIdentityProviderResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"DuplicateProviderException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"LimitExceededException"}, + {"shape":"InternalErrorException"} + ] + }, "CreateUserImportJob":{ "name":"CreateUserImportJob", "http":{ @@ -578,6 +596,23 @@ {"shape":"TooManyRequestsException"}, {"shape":"LimitExceededException"}, {"shape":"NotAuthorizedException"}, + {"shape":"ScopeDoesNotExistException"}, + {"shape":"InvalidOAuthFlowException"}, + {"shape":"InternalErrorException"} + ] + }, + "CreateUserPoolDomain":{ + "name":"CreateUserPoolDomain", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"CreateUserPoolDomainRequest"}, + "output":{"shape":"CreateUserPoolDomainResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"ResourceNotFoundException"}, {"shape":"InternalErrorException"} ] }, @@ -596,6 +631,22 @@ {"shape":"InternalErrorException"} ] }, + "DeleteIdentityProvider":{ + "name":"DeleteIdentityProvider", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DeleteIdentityProviderRequest"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"UnsupportedIdentityProviderException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"InternalErrorException"} + ] + }, "DeleteUser":{ "name":"DeleteUser", "http":{ @@ -666,6 +717,37 @@ {"shape":"InternalErrorException"} ] }, + "DeleteUserPoolDomain":{ + "name":"DeleteUserPoolDomain", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DeleteUserPoolDomainRequest"}, + "output":{"shape":"DeleteUserPoolDomainResponse"}, + "errors":[ + {"shape":"NotAuthorizedException"}, + {"shape":"InvalidParameterException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"InternalErrorException"} + ] + }, + "DescribeIdentityProvider":{ + "name":"DescribeIdentityProvider", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DescribeIdentityProviderRequest"}, + "output":{"shape":"DescribeIdentityProviderResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"InternalErrorException"} + ] + }, "DescribeUserImportJob":{ "name":"DescribeUserImportJob", "http":{ @@ -715,6 +797,21 @@ {"shape":"InternalErrorException"} ] }, + "DescribeUserPoolDomain":{ + "name":"DescribeUserPoolDomain", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DescribeUserPoolDomainRequest"}, + "output":{"shape":"DescribeUserPoolDomainResponse"}, + "errors":[ + {"shape":"NotAuthorizedException"}, + {"shape":"InvalidParameterException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"InternalErrorException"} + ] + }, "ForgetDevice":{ "name":"ForgetDevice", "http":{ @@ -813,6 +910,22 @@ {"shape":"InternalErrorException"} ] }, + "GetIdentityProviderByIdentifier":{ + "name":"GetIdentityProviderByIdentifier", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"GetIdentityProviderByIdentifierRequest"}, + "output":{"shape":"GetIdentityProviderByIdentifierResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"InternalErrorException"} + ] + }, "GetUser":{ "name":"GetUser", "http":{ @@ -938,6 +1051,22 @@ {"shape":"InternalErrorException"} ] }, + "ListIdentityProviders":{ + "name":"ListIdentityProviders", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"ListIdentityProvidersRequest"}, + "output":{"shape":"ListIdentityProvidersResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"InternalErrorException"} + ] + }, "ListUserImportJobs":{ "name":"ListUserImportJobs", "http":{ @@ -1188,6 +1317,23 @@ {"shape":"InternalErrorException"} ] }, + "UpdateIdentityProvider":{ + "name":"UpdateIdentityProvider", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"UpdateIdentityProviderRequest"}, + "output":{"shape":"UpdateIdentityProviderResponse"}, + "errors":[ + {"shape":"InvalidParameterException"}, + {"shape":"UnsupportedIdentityProviderException"}, + {"shape":"ResourceNotFoundException"}, + {"shape":"NotAuthorizedException"}, + {"shape":"TooManyRequestsException"}, + {"shape":"InternalErrorException"} + ] + }, "UpdateUserAttributes":{ "name":"UpdateUserAttributes", "http":{ @@ -1253,6 +1399,8 @@ {"shape":"InvalidParameterException"}, {"shape":"TooManyRequestsException"}, {"shape":"NotAuthorizedException"}, + {"shape":"ScopeDoesNotExistException"}, + {"shape":"InvalidOAuthFlowException"}, {"shape":"InternalErrorException"} ] }, @@ -1281,6 +1429,7 @@ } }, "shapes":{ + "AWSAccountIdType":{"type":"string"}, "AddCustomAttributesRequest":{ "type":"structure", "required":[ @@ -1706,6 +1855,11 @@ "type":"list", "member":{"shape":"AttributeType"} }, + "AttributeMappingType":{ + "type":"map", + "key":{"shape":"CustomAttributeNameType"}, + "value":{"shape":"StringType"} + }, "AttributeNameListType":{ "type":"list", "member":{"shape":"AttributeNameType"} @@ -1756,6 +1910,12 @@ } }, "BooleanType":{"type":"boolean"}, + "CallbackURLsListType":{ + "type":"list", + "member":{"shape":"RedirectUrlType"}, + "max":100, + "min":0 + }, "ChallengeNameType":{ "type":"string", "enum":[ @@ -1782,7 +1942,8 @@ "type":"structure", "required":[ "PreviousPassword", - "ProposedPassword" + "ProposedPassword", + "AccessToken" ], "members":{ "PreviousPassword":{"shape":"PasswordType"}, @@ -1954,6 +2115,30 @@ "Group":{"shape":"GroupType"} } }, + "CreateIdentityProviderRequest":{ + "type":"structure", + "required":[ + "UserPoolId", + "ProviderName", + "ProviderType", + "ProviderDetails" + ], + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "ProviderName":{"shape":"ProviderNameType"}, + "ProviderType":{"shape":"IdentityProviderTypeType"}, + "ProviderDetails":{"shape":"ProviderDetailsType"}, + "AttributeMapping":{"shape":"AttributeMappingType"}, + "IdpIdentifiers":{"shape":"IdpIdentifiersListType"} + } + }, + "CreateIdentityProviderResponse":{ + "type":"structure", + "required":["IdentityProvider"], + "members":{ + "IdentityProvider":{"shape":"IdentityProviderType"} + } + }, "CreateUserImportJobRequest":{ "type":"structure", "required":[ @@ -1986,7 +2171,14 @@ "RefreshTokenValidity":{"shape":"RefreshTokenValidityType"}, "ReadAttributes":{"shape":"ClientPermissionListType"}, "WriteAttributes":{"shape":"ClientPermissionListType"}, - "ExplicitAuthFlows":{"shape":"ExplicitAuthFlowsListType"} + "ExplicitAuthFlows":{"shape":"ExplicitAuthFlowsListType"}, + "SupportedIdentityProviders":{"shape":"SupportedIdentityProvidersListType"}, + "CallbackURLs":{"shape":"CallbackURLsListType"}, + "LogoutURLs":{"shape":"LogoutURLsListType"}, + "DefaultRedirectURI":{"shape":"RedirectUrlType"}, + "AllowedOAuthFlows":{"shape":"OAuthFlowsType"}, + "AllowedOAuthScopes":{"shape":"ScopeListType"}, + "AllowedOAuthFlowsUserPoolClient":{"shape":"BooleanType"} } }, "CreateUserPoolClientResponse":{ @@ -1995,6 +2187,22 @@ "UserPoolClient":{"shape":"UserPoolClientType"} } }, + "CreateUserPoolDomainRequest":{ + "type":"structure", + "required":[ + "Domain", + "UserPoolId" + ], + "members":{ + "Domain":{"shape":"DomainType"}, + "UserPoolId":{"shape":"UserPoolIdType"} + } + }, + "CreateUserPoolDomainResponse":{ + "type":"structure", + "members":{ + } + }, "CreateUserPoolRequest":{ "type":"structure", "required":["PoolName"], @@ -2047,9 +2255,23 @@ "UserPoolId":{"shape":"UserPoolIdType"} } }, + "DeleteIdentityProviderRequest":{ + "type":"structure", + "required":[ + "UserPoolId", + "ProviderName" + ], + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "ProviderName":{"shape":"ProviderNameType"} + } + }, "DeleteUserAttributesRequest":{ "type":"structure", - "required":["UserAttributeNames"], + "required":[ + "UserAttributeNames", + "AccessToken" + ], "members":{ "UserAttributeNames":{"shape":"AttributeNameListType"}, "AccessToken":{"shape":"TokenModelType"} @@ -2071,6 +2293,22 @@ "ClientId":{"shape":"ClientIdType"} } }, + "DeleteUserPoolDomainRequest":{ + "type":"structure", + "required":[ + "Domain", + "UserPoolId" + ], + "members":{ + "Domain":{"shape":"DomainType"}, + "UserPoolId":{"shape":"UserPoolIdType"} + } + }, + "DeleteUserPoolDomainResponse":{ + "type":"structure", + "members":{ + } + }, "DeleteUserPoolRequest":{ "type":"structure", "required":["UserPoolId"], @@ -2080,6 +2318,7 @@ }, "DeleteUserRequest":{ "type":"structure", + "required":["AccessToken"], "members":{ "AccessToken":{"shape":"TokenModelType"} } @@ -2095,6 +2334,24 @@ "EMAIL" ] }, + "DescribeIdentityProviderRequest":{ + "type":"structure", + "required":[ + "UserPoolId", + "ProviderName" + ], + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "ProviderName":{"shape":"ProviderNameType"} + } + }, + "DescribeIdentityProviderResponse":{ + "type":"structure", + "required":["IdentityProvider"], + "members":{ + "IdentityProvider":{"shape":"IdentityProviderType"} + } + }, "DescribeUserImportJobRequest":{ "type":"structure", "required":[ @@ -2129,6 +2386,19 @@ "UserPoolClient":{"shape":"UserPoolClientType"} } }, + "DescribeUserPoolDomainRequest":{ + "type":"structure", + "required":["Domain"], + "members":{ + "Domain":{"shape":"DomainType"} + } + }, + "DescribeUserPoolDomainResponse":{ + "type":"structure", + "members":{ + "DomainDescription":{"shape":"DomainDescriptionType"} + } + }, "DescribeUserPoolRequest":{ "type":"structure", "required":["UserPoolId"], @@ -2192,6 +2462,44 @@ "DeviceLastAuthenticatedDate":{"shape":"DateType"} } }, + "DomainDescriptionType":{ + "type":"structure", + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "AWSAccountId":{"shape":"AWSAccountIdType"}, + "Domain":{"shape":"DomainType"}, + "S3Bucket":{"shape":"S3BucketType"}, + "CloudFrontDistribution":{"shape":"ArnType"}, + "Version":{"shape":"DomainVersionType"}, + "Status":{"shape":"DomainStatusType"} + } + }, + "DomainStatusType":{ + "type":"string", + "enum":[ + "CREATING", + "DELETING", + "UPDATING", + "ACTIVE" + ] + }, + "DomainType":{ + "type":"string", + "max":1024, + "min":1 + }, + "DomainVersionType":{ + "type":"string", + "max":20, + "min":1 + }, + "DuplicateProviderException":{ + "type":"structure", + "members":{ + "message":{"shape":"MessageType"} + }, + "exception":true + }, "EmailAddressType":{ "type":"string", "pattern":"[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+@[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+" @@ -2205,7 +2513,7 @@ }, "EmailVerificationMessageType":{ "type":"string", - "max":2048, + "max":20000, "min":6, "pattern":"[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}\\s*]*\\{####\\}[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}\\s*]*" }, @@ -2307,9 +2615,30 @@ "Group":{"shape":"GroupType"} } }, + "GetIdentityProviderByIdentifierRequest":{ + "type":"structure", + "required":[ + "UserPoolId", + "IdpIdentifier" + ], + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "IdpIdentifier":{"shape":"IdpIdentifierType"} + } + }, + "GetIdentityProviderByIdentifierResponse":{ + "type":"structure", + "required":["IdentityProvider"], + "members":{ + "IdentityProvider":{"shape":"IdentityProviderType"} + } + }, "GetUserAttributeVerificationCodeRequest":{ "type":"structure", - "required":["AttributeName"], + "required":[ + "AccessToken", + "AttributeName" + ], "members":{ "AccessToken":{"shape":"TokenModelType"}, "AttributeName":{"shape":"AttributeNameType"} @@ -2323,6 +2652,7 @@ }, "GetUserRequest":{ "type":"structure", + "required":["AccessToken"], "members":{ "AccessToken":{"shape":"TokenModelType"} } @@ -2341,6 +2671,7 @@ }, "GlobalSignOutRequest":{ "type":"structure", + "required":["AccessToken"], "members":{ "AccessToken":{"shape":"TokenModelType"} } @@ -2379,6 +2710,35 @@ "CreationDate":{"shape":"DateType"} } }, + "IdentityProviderType":{ + "type":"structure", + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "ProviderName":{"shape":"ProviderNameType"}, + "ProviderType":{"shape":"IdentityProviderTypeType"}, + "ProviderDetails":{"shape":"ProviderDetailsType"}, + "AttributeMapping":{"shape":"AttributeMappingType"}, + "IdpIdentifiers":{"shape":"IdpIdentifiersListType"}, + "LastModifiedDate":{"shape":"DateType"}, + "CreationDate":{"shape":"DateType"} + } + }, + "IdentityProviderTypeType":{ + "type":"string", + "enum":["SAML"] + }, + "IdpIdentifierType":{ + "type":"string", + "max":40, + "min":1, + "pattern":"[\\w\\s+=.@-]+" + }, + "IdpIdentifiersListType":{ + "type":"list", + "member":{"shape":"IdpIdentifierType"}, + "max":50, + "min":0 + }, "InitiateAuthRequest":{ "type":"structure", "required":[ @@ -2424,6 +2784,13 @@ }, "exception":true }, + "InvalidOAuthFlowException":{ + "type":"structure", + "members":{ + "message":{"shape":"MessageType"} + }, + "exception":true + }, "InvalidParameterException":{ "type":"structure", "members":{ @@ -2511,10 +2878,32 @@ "NextToken":{"shape":"PaginationKey"} } }, + "ListIdentityProvidersRequest":{ + "type":"structure", + "required":["UserPoolId"], + "members":{ + "UserPoolId":{"shape":"UserPoolIdType"}, + "MaxResults":{"shape":"ListProvidersLimitType"}, + "NextToken":{"shape":"PaginationKeyType"} + } + }, + "ListIdentityProvidersResponse":{ + "type":"structure", + "required":["Providers"], + "members":{ + "Providers":{"shape":"ProvidersListType"}, + "NextToken":{"shape":"PaginationKeyType"} + } + }, "ListOfStringTypes":{ "type":"list", "member":{"shape":"StringType"} }, + "ListProvidersLimitType":{ + "type":"integer", + "max":60, + "min":1 + }, "ListUserImportJobsRequest":{ "type":"structure", "required":[ @@ -2603,6 +2992,12 @@ "PaginationToken":{"shape":"SearchPaginationTokenType"} } }, + "LogoutURLsListType":{ + "type":"list", + "member":{"shape":"RedirectUrlType"}, + "max":100, + "min":0 + }, "LongType":{"type":"long"}, "MFAMethodNotFoundException":{ "type":"structure", @@ -2659,6 +3054,20 @@ "MaxValue":{"shape":"StringType"} } }, + "OAuthFlowType":{ + "type":"string", + "enum":[ + "code", + "implicit", + "client_credentials" + ] + }, + "OAuthFlowsType":{ + "type":"list", + "member":{"shape":"OAuthFlowType"}, + "max":3, + "min":0 + }, "PaginationKey":{ "type":"string", "min":1, @@ -2719,6 +3128,32 @@ }, "exception":true }, + "ProviderDescription":{ + "type":"structure", + "members":{ + "ProviderName":{"shape":"ProviderNameType"}, + "ProviderType":{"shape":"IdentityProviderTypeType"}, + "LastModifiedDate":{"shape":"DateType"}, + "CreationDate":{"shape":"DateType"} + } + }, + "ProviderDetailsType":{ + "type":"map", + "key":{"shape":"StringType"}, + "value":{"shape":"StringType"} + }, + "ProviderNameType":{ + "type":"string", + "max":32, + "min":1, + "pattern":"[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+" + }, + "ProvidersListType":{ + "type":"list", + "member":{"shape":"ProviderDescription"}, + "max":50, + "min":0 + }, "QueryLimit":{ "type":"integer", "max":60, @@ -2729,6 +3164,12 @@ "max":60, "min":0 }, + "RedirectUrlType":{ + "type":"string", + "max":1024, + "min":1, + "pattern":"[\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+" + }, "RefreshTokenValidityType":{ "type":"integer", "max":3650, @@ -2781,6 +3222,12 @@ "AuthenticationResult":{"shape":"AuthenticationResultType"} } }, + "S3BucketType":{ + "type":"string", + "max":1024, + "min":3, + "pattern":"^[0-9A-Za-z\\.\\-_]*(?Using the Amazon Cognito Your User Pools API, you can create a user pool to manage directories and users. You can authenticate a user to obtain tokens related to user identity and access policies.

This API reference provides information about user pools in Amazon Cognito Your User Pools.

For more information, see the Amazon Cognito Documentation.

", + "service": "

Using the Amazon Cognito User Pools API, you can create a user pool to manage directories and users. You can authenticate a user to obtain tokens related to user identity and access policies.

This API reference provides information about user pools in Amazon Cognito User Pools.

For more information, see the Amazon Cognito Documentation.

", "operations": { "AddCustomAttributes": "

Adds additional user attributes to the user pool schema.

", "AdminAddUserToGroup": "

Adds the specified user to the specified group.

Requires developer credentials.

", "AdminConfirmSignUp": "

Confirms user registration as an admin without using a confirmation code. Works on any user.

Requires developer credentials.

", - "AdminCreateUser": "

Creates a new user in the specified user pool and sends a welcome message via email or phone (SMS). This message is based on a template that you configured in your call to CreateUserPool or UpdateUserPool. This template includes your custom sign-up instructions and placeholders for user name and temporary password.

Requires developer credentials.

", + "AdminCreateUser": "

Creates a new user in the specified user pool and sends a welcome message via email or phone (SMS). This message is based on a template that you configured in your call to CreateUserPool or UpdateUserPool. This template includes your custom sign-up instructions and placeholders for user name and temporary password.

Requires developer credentials.

", "AdminDeleteUser": "

Deletes a user as an administrator. Works on any user.

Requires developer credentials.

", "AdminDeleteUserAttributes": "

Deletes the user attributes in a user pool as an administrator. Works on any user.

Requires developer credentials.

", "AdminDisableUser": "

Disables the specified user as an administrator. Works on any user.

Requires developer credentials.

", @@ -21,35 +21,43 @@ "AdminRespondToAuthChallenge": "

Responds to an authentication challenge, as an administrator.

Requires developer credentials.

", "AdminSetUserSettings": "

Sets all the user settings for a specified user name. Works on any user.

Requires developer credentials.

", "AdminUpdateDeviceStatus": "

Updates the device status as an administrator.

Requires developer credentials.

", - "AdminUpdateUserAttributes": "

Updates the specified user's attributes, including developer attributes, as an administrator. Works on any user.

Requires developer credentials.

", + "AdminUpdateUserAttributes": "

Updates the specified user's attributes, including developer attributes, as an administrator. Works on any user.

For custom attributes, you must prepend the custom: prefix to the attribute name.

In addition to updating user attributes, this API can also be used to mark phone and email as verified.

Requires developer credentials.

", "AdminUserGlobalSignOut": "

Signs out users from all devices, as an administrator.

Requires developer credentials.

", "ChangePassword": "

Changes the password for a specified user in a user pool.

", - "ConfirmDevice": "

Confirms tracking of the device. This API call is the call that beings device tracking.

", - "ConfirmForgotPassword": "

Allows a user to enter a code provided when they reset their password to update their password.

", + "ConfirmDevice": "

Confirms tracking of the device. This API call is the call that begins device tracking.

", + "ConfirmForgotPassword": "

Allows a user to enter a confirmation code to reset a forgotten password.

", "ConfirmSignUp": "

Confirms registration of a user and handles the existing alias from a previous user.

", "CreateGroup": "

Creates a new group in the specified user pool.

Requires developer credentials.

", + "CreateIdentityProvider": "

Creates an identity provider for a user pool.

", "CreateUserImportJob": "

Creates the user import job.

", "CreateUserPool": "

Creates a new Amazon Cognito user pool and sets the password policy for the pool.

", "CreateUserPoolClient": "

Creates the user pool client.

", + "CreateUserPoolDomain": "

Creates a new domain for a user pool.

", "DeleteGroup": "

Deletes a group. Currently only groups with no members can be deleted.

Requires developer credentials.

", + "DeleteIdentityProvider": "

Deletes an identity provider for a user pool.

", "DeleteUser": "

Allows a user to delete one's self.

", "DeleteUserAttributes": "

Deletes the attributes for a user.

", "DeleteUserPool": "

Deletes the specified Amazon Cognito user pool.

", "DeleteUserPoolClient": "

Allows the developer to delete the user pool client.

", + "DeleteUserPoolDomain": "

Deletes a domain for a user pool.

", + "DescribeIdentityProvider": "

Gets information about a specific identity provider.

", "DescribeUserImportJob": "

Describes the user import job.

", "DescribeUserPool": "

Returns the configuration information and metadata of the specified user pool.

", "DescribeUserPoolClient": "

Client method for returning the configuration information and metadata of the specified user pool client.

", + "DescribeUserPoolDomain": "

Gets information about a domain.

", "ForgetDevice": "

Forgets the specified device.

", - "ForgotPassword": "

Retrieves the password for the specified client ID or username.

", + "ForgotPassword": "

Calling this API causes a message to be sent to the end user with a confirmation code that is required to change the user's password. For the Username parameter, you can use the username or user alias. If a verified phone number exists for the user, the confirmation code is sent to the phone number. Otherwise, if a verified email exists, the confirmation code is sent to the email. If neither a verified phone number nor a verified email exists, InvalidParameterException is thrown. To use the confirmation code for resetting the password, call ConfirmForgotPassword.

", "GetCSVHeader": "

Gets the header information for the .csv file to be used as input for the user import job.

", "GetDevice": "

Gets the device.

", "GetGroup": "

Gets a group.

Requires developer credentials.

", + "GetIdentityProviderByIdentifier": "

Gets the specified identity provider.

", "GetUser": "

Gets the user attributes and metadata for a user.

", "GetUserAttributeVerificationCode": "

Gets the user attribute verification code for the specified attribute name.

", "GlobalSignOut": "

Signs out users from all devices.

", "InitiateAuth": "

Initiates the authentication flow.

", "ListDevices": "

Lists the devices.

", "ListGroups": "

Lists the groups associated with a user pool.

Requires developer credentials.

", + "ListIdentityProviders": "

Lists information about all identity providers for a user pool.

", "ListUserImportJobs": "

Lists the user import jobs.

", "ListUserPoolClients": "

Lists the clients that have been created for the specified user pool.

", "ListUserPools": "

Lists the user pools associated with an AWS account.

", @@ -63,12 +71,19 @@ "StopUserImportJob": "

Stops the user import job.

", "UpdateDeviceStatus": "

Updates the device status.

", "UpdateGroup": "

Updates the specified group with the specified attributes.

Requires developer credentials.

", + "UpdateIdentityProvider": "

Updates identity provider information for a user pool.

", "UpdateUserAttributes": "

Allows a user to update a specific attribute (one at a time).

", "UpdateUserPool": "

Updates the specified user pool with the specified attributes.

", "UpdateUserPoolClient": "

Allows the developer to update the specified user pool client and password policy.

", "VerifyUserAttribute": "

Verifies the specified user attributes in the user pool.

" }, "shapes": { + "AWSAccountIdType": { + "base": null, + "refs": { + "DomainDescriptionType$AWSAccountId": "

The AWS account ID for the user pool owner.

" + } + }, "AddCustomAttributesRequest": { "base": "

Represents the request to add custom attributes.

", "refs": { @@ -97,9 +112,9 @@ "AdminCreateUserConfigType": { "base": "

The type of configuration for creating a new user profile.

", "refs": { - "CreateUserPoolRequest$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

", - "UpdateUserPoolRequest$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

", - "UserPoolType$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

" + "CreateUserPoolRequest$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

", + "UpdateUserPoolRequest$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

", + "UserPoolType$AdminCreateUserConfig": "

The configuration for AdminCreateUser requests.

" } }, "AdminCreateUserRequest": { @@ -115,7 +130,7 @@ "AdminCreateUserUnusedAccountValidityDaysType": { "base": null, "refs": { - "AdminCreateUserConfigType$UnusedAccountValidityDays": "

The user account expiration limit, in days, after which the account is no longer usable. To reset the account after that time limit, you must call AdminCreateUser again, specifying \"RESEND\" for the MessageAction parameter. The default value for this paameter is 7.

" + "AdminCreateUserConfigType$UnusedAccountValidityDays": "

The user account expiration limit, in days, after which the account is no longer usable. To reset the account after that time limit, you must call AdminCreateUser again, specifying \"RESEND\" for the MessageAction parameter. The default value for this parameter is 7.

" } }, "AdminDeleteUserAttributesRequest": { @@ -296,6 +311,7 @@ "refs": { "CreateGroupRequest$RoleArn": "

The role ARN for the group.

", "CreateUserImportJobRequest$CloudWatchLogsRoleArn": "

The role ARN for the Amazon CloudWatch Logging role for the user import job.

", + "DomainDescriptionType$CloudFrontDistribution": "

The ARN of the CloudFront distribution.

", "EmailConfigurationType$SourceArn": "

The Amazon Resource Name (ARN) of the email source.

", "GroupType$RoleArn": "

The role ARN for the group.

", "LambdaConfigType$PreSignUp": "

A pre-registration AWS Lambda trigger.

", @@ -320,23 +336,31 @@ "AttributeListType": { "base": null, "refs": { - "AdminCreateUserRequest$UserAttributes": "

An array of name-value pairs that contain user attributes and attribute values to be set for the user to be created. You can create a user without specifying any attributes other than Username. However, any attributes that you specify as required (in CreateUserPool or in the Attributes tab of the console) must be supplied either by you (in your call to AdminCreateUser) or by the user (when he or she signs up in response to your welcome message).

To send a message inviting the user to sign up, you must specify the user's email address or phone number. This can be done in your call to AdminCreateUser or in the Users tab of the Amazon Cognito console for managing your user pools.

In your call to AdminCreateUser, you can set the email_verified attribute to True, and you can set the phone_number_verified attribute to True. (You cannot do this by calling other operations such as AdminUpdateUserAttributes.)

", + "AdminCreateUserRequest$UserAttributes": "

An array of name-value pairs that contain user attributes and attribute values to be set for the user to be created. You can create a user without specifying any attributes other than Username. However, any attributes that you specify as required (in CreateUserPool or in the Attributes tab of the console) must be supplied either by you (in your call to AdminCreateUser) or by the user (when he or she signs up in response to your welcome message).

For custom attributes, you must prepend the custom: prefix to the attribute name.

To send a message inviting the user to sign up, you must specify the user's email address or phone number. This can be done in your call to AdminCreateUser or in the Users tab of the Amazon Cognito console for managing your user pools.

In your call to AdminCreateUser, you can set the email_verified attribute to True, and you can set the phone_number_verified attribute to True. (You can also do this by calling AdminUpdateUserAttributes.)

", "AdminCreateUserRequest$ValidationData": "

The user's validation data. This is an array of name-value pairs that contain user attributes and attribute values that you can use for custom validation, such as restricting the types of user accounts that can be registered. For example, you might choose to allow or disallow user sign-up based on the user's domain.

To configure custom validation, you must create a Pre Sign-up Lambda trigger for the user pool as described in the Amazon Cognito Developer Guide. The Lambda trigger receives the validation data and uses it in the validation process.

The user's validation data is not persisted.

", "AdminGetUserResponse$UserAttributes": "

An array of name-value pairs representing user attributes.

", - "AdminUpdateUserAttributesRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

", + "AdminUpdateUserAttributesRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

For custom attributes, you must prepend the custom: prefix to the attribute name.

", "DeviceType$DeviceAttributes": "

The device attributes.

", - "GetUserResponse$UserAttributes": "

An array of name-value pairs representing user attributes.

", - "SignUpRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

", + "GetUserResponse$UserAttributes": "

An array of name-value pairs representing user attributes.

For custom attributes, you must prepend the custom: prefix to the attribute name.

", + "SignUpRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

For custom attributes, you must prepend the custom: prefix to the attribute name.

", "SignUpRequest$ValidationData": "

The validation data in the request to register a user.

", - "UpdateUserAttributesRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

", + "UpdateUserAttributesRequest$UserAttributes": "

An array of name-value pairs representing user attributes.

For custom attributes, you must prepend the custom: prefix to the attribute name.

", "UserType$Attributes": "

A container with information about the user type attributes.

" } }, + "AttributeMappingType": { + "base": null, + "refs": { + "CreateIdentityProviderRequest$AttributeMapping": "

A mapping of identity provider attributes to standard and custom user pool attributes.

", + "IdentityProviderType$AttributeMapping": "

A mapping of identity provider attributes to standard and custom user pool attributes.

", + "UpdateIdentityProviderRequest$AttributeMapping": "

The identity provider attribute mapping to be changed.

" + } + }, "AttributeNameListType": { "base": null, "refs": { - "AdminDeleteUserAttributesRequest$UserAttributeNames": "

An array of strings representing the user attribute names you wish to delete.

", - "DeleteUserAttributesRequest$UserAttributeNames": "

An array of strings representing the user attribute names you wish to delete.

" + "AdminDeleteUserAttributesRequest$UserAttributeNames": "

An array of strings representing the user attribute names you wish to delete.

For custom attributes, you must prepend the custom: prefix to the attribute name.

", + "DeleteUserAttributesRequest$UserAttributeNames": "

An array of strings representing the user attribute names you wish to delete.

For custom attributes, you must prepend the custom: prefix to the attribute name.

" } }, "AttributeNameType": { @@ -366,32 +390,33 @@ "AuthFlowType": { "base": null, "refs": { - "AdminInitiateAuthRequest$AuthFlow": "

The authentication flow.

", - "InitiateAuthRequest$AuthFlow": "

The authentication flow.

" + "AdminInitiateAuthRequest$AuthFlow": "

The authentication flow for this call to execute. The API action will depend on this value. For example:

Valid values include:

", + "InitiateAuthRequest$AuthFlow": "

The authentication flow for this call to execute. The API action will depend on this value. For example:

Valid values include:

ADMIN_NO_SRP_AUTH is not a valid value.

" } }, "AuthParametersType": { "base": null, "refs": { - "AdminInitiateAuthRequest$AuthParameters": "

The authentication parameters.

", - "InitiateAuthRequest$AuthParameters": "

The authentication parameters.

" + "AdminInitiateAuthRequest$AuthParameters": "

The authentication parameters. These are inputs corresponding to the AuthFlow that you are invoking. The required values depend on the value of AuthFlow:

", + "InitiateAuthRequest$AuthParameters": "

The authentication parameters. These are inputs corresponding to the AuthFlow that you are invoking. The required values depend on the value of AuthFlow:

" } }, "AuthenticationResultType": { "base": "

The result type of the authentication result.

", "refs": { - "AdminInitiateAuthResponse$AuthenticationResult": "

The result of the authentication response.

", + "AdminInitiateAuthResponse$AuthenticationResult": "

The result of the authentication response. This is only returned if the caller does not need to pass another challenge. If the caller does need to pass another challenge before it gets tokens, ChallengeName, ChallengeParameters, and Session are returned.

", "AdminRespondToAuthChallengeResponse$AuthenticationResult": "

The result returned by the server in response to the authentication request.

", - "InitiateAuthResponse$AuthenticationResult": "

The result returned by the server in response to the request to initiate authentication.

", + "InitiateAuthResponse$AuthenticationResult": "

The result of the authentication response. This is only returned if the caller does not need to pass another challenge. If the caller does need to pass another challenge before it gets tokens, ChallengeName, ChallengeParameters, and Session are returned.

", "RespondToAuthChallengeResponse$AuthenticationResult": "

The result returned by the server in response to the request to respond to the authentication challenge.

" } }, "BooleanType": { "base": null, "refs": { - "AdminCreateUserConfigType$AllowAdminCreateUserOnly": "

Set to True if only the administrator is allowed to create user profiles. Set to False if users can sign themselves up via an app.

", + "AdminCreateUserConfigType$AllowAdminCreateUserOnly": "

Set to True if only the administrator is allowed to create user profiles. Set to False if users can sign themselves up via an app.

", "AdminGetUserResponse$Enabled": "

Indicates that the status is enabled.

", "ConfirmDeviceResponse$UserConfirmationNecessary": "

Indicates whether the user confirmation is necessary to confirm the device response.

", + "CreateUserPoolClientRequest$AllowedOAuthFlowsUserPoolClient": "

Set to True if the client is allowed to follow the OAuth protocol when interacting with Cognito user pools.

", "DeviceConfigurationType$ChallengeRequiredOnNewDevice": "

Indicates whether a challenge is required on a new device. Only applicable to a new device.

", "DeviceConfigurationType$DeviceOnlyRememberedOnUserPrompt": "

If true, a device is only remembered on user prompt.

", "PasswordPolicyType$RequireUppercase": "

In the password policy that you have set, refers to whether you have required users to use at least one uppercase letter in their password.

", @@ -402,34 +427,44 @@ "SchemaAttributeType$Mutable": "

Specifies whether the attribute can be changed once it has been created.

", "SchemaAttributeType$Required": "

Specifies whether a user pool attribute is required. If the attribute is required and the user does not provide a value, registration or sign-in will fail.

", "SignUpResponse$UserConfirmed": "

A response from the server indicating that a user registration has been confirmed.

", + "UpdateUserPoolClientRequest$AllowedOAuthFlowsUserPoolClient": "

Set to TRUE if the client is allowed to follow the OAuth protocol when interacting with Cognito user pools.

", + "UserPoolClientType$AllowedOAuthFlowsUserPoolClient": "

Set to TRUE if the client is allowed to follow the OAuth protocol when interacting with Cognito user pools.

", "UserType$Enabled": "

Specifies whether the user is enabled.

" } }, + "CallbackURLsListType": { + "base": null, + "refs": { + "CreateUserPoolClientRequest$CallbackURLs": "

A list of allowed callback URLs for the identity providers.

", + "UpdateUserPoolClientRequest$CallbackURLs": "

A list of allowed callback URLs for the identity providers.

", + "UserPoolClientType$CallbackURLs": "

A list of allowed callback URLs for the identity providers.

" + } + }, "ChallengeNameType": { "base": null, "refs": { - "AdminInitiateAuthResponse$ChallengeName": "

The name of the challenge.

", - "AdminRespondToAuthChallengeRequest$ChallengeName": "

The name of the challenge.

", - "AdminRespondToAuthChallengeResponse$ChallengeName": "

The name of the challenge.

", - "InitiateAuthResponse$ChallengeName": "

The name of the challenge.

", - "RespondToAuthChallengeRequest$ChallengeName": "

The name of the challenge.

", - "RespondToAuthChallengeResponse$ChallengeName": "

The challenge name.

" + "AdminInitiateAuthResponse$ChallengeName": "

The name of the challenge which you are responding to with this call. This is returned to you in the AdminInitiateAuth response if you need to pass another challenge.

", + "AdminRespondToAuthChallengeRequest$ChallengeName": "

The challenge name. For more information, see AdminInitiateAuth.

", + "AdminRespondToAuthChallengeResponse$ChallengeName": "

The name of the challenge. For more information, see AdminInitiateAuth.

", + "InitiateAuthResponse$ChallengeName": "

The name of the challenge which you are responding to with this call. This is returned to you in the AdminInitiateAuth response if you need to pass another challenge.

Valid values include the following. Note that all of these challenges require USERNAME and SECRET_HASH (if applicable) in the parameters.

", + "RespondToAuthChallengeRequest$ChallengeName": "

The challenge name. For more information, see InitiateAuth.

ADMIN_NO_SRP_AUTH is not a valid value.

", + "RespondToAuthChallengeResponse$ChallengeName": "

The challenge name. For more information, see InitiateAuth.

" } }, "ChallengeParametersType": { "base": null, "refs": { - "AdminInitiateAuthResponse$ChallengeParameters": "

The challenge parameters.

", - "AdminRespondToAuthChallengeResponse$ChallengeParameters": "

The challenge parameters.

", - "InitiateAuthResponse$ChallengeParameters": "

The challenge parameters.

", - "RespondToAuthChallengeResponse$ChallengeParameters": "

The challenge parameters.

" + "AdminInitiateAuthResponse$ChallengeParameters": "

The challenge parameters. These are returned to you in the AdminInitiateAuth response if you need to pass another challenge. The responses in this parameter should be used to compute inputs to the next call (AdminRespondToAuthChallenge).

All challenges require USERNAME and SECRET_HASH (if applicable).

The value of the USER_IF_FOR_SRP attribute will be the user's actual username, not an alias (such as email address or phone number), even if you specified an alias in your call to AdminInitiateAuth. This is because, in the AdminRespondToAuthChallenge API ChallengeResponses, the USERNAME attribute cannot be an alias.

", + "AdminRespondToAuthChallengeResponse$ChallengeParameters": "

The challenge parameters. For more information, see AdminInitiateAuth.

", + "InitiateAuthResponse$ChallengeParameters": "

The challenge parameters. These are returned to you in the InitiateAuth response if you need to pass another challenge. The responses in this parameter should be used to compute inputs to the next call (RespondToAuthChallenge).

All challenges require USERNAME and SECRET_HASH (if applicable).

", + "RespondToAuthChallengeResponse$ChallengeParameters": "

The challenge parameters. For more information, see InitiateAuth.

" } }, "ChallengeResponsesType": { "base": null, "refs": { - "AdminRespondToAuthChallengeRequest$ChallengeResponses": "

The challenge response.

", - "RespondToAuthChallengeRequest$ChallengeResponses": "

The responses to the authentication challenge.

" + "AdminRespondToAuthChallengeRequest$ChallengeResponses": "

The challenge responses. These are inputs corresponding to the value of ChallengeName, for example:

The value of the USERNAME attribute must be the user's actual username, not an alias (such as email address or phone number). To make this easier, the AdminInitiateAuth response includes the actual username value in the USERNAMEUSER_ID_FOR_SRP attribute, even if you specified an alias in your call to AdminInitiateAuth.

", + "RespondToAuthChallengeRequest$ChallengeResponses": "

The challenge responses. These are inputs corresponding to the value of ChallengeName, for example:

" } }, "ChangePasswordRequest": { @@ -445,16 +480,16 @@ "ClientIdType": { "base": null, "refs": { - "AdminInitiateAuthRequest$ClientId": "

The client app ID.

", - "AdminRespondToAuthChallengeRequest$ClientId": "

The client ID.

", + "AdminInitiateAuthRequest$ClientId": "

The app client ID.

", + "AdminRespondToAuthChallengeRequest$ClientId": "

The app client ID.

", "ConfirmForgotPasswordRequest$ClientId": "

The ID of the client associated with the user pool.

", "ConfirmSignUpRequest$ClientId": "

The ID of the client associated with the user pool.

", "DeleteUserPoolClientRequest$ClientId": "

The ID of the client associated with the user pool.

", "DescribeUserPoolClientRequest$ClientId": "

The ID of the client associated with the user pool.

", "ForgotPasswordRequest$ClientId": "

The ID of the client associated with the user pool.

", - "InitiateAuthRequest$ClientId": "

The client ID.

", + "InitiateAuthRequest$ClientId": "

The app client ID.

", "ResendConfirmationCodeRequest$ClientId": "

The ID of the client associated with the user pool.

", - "RespondToAuthChallengeRequest$ClientId": "

The client ID.

", + "RespondToAuthChallengeRequest$ClientId": "

The app client ID.

", "SignUpRequest$ClientId": "

The ID of the client associated with the user pool.

", "UpdateUserPoolClientRequest$ClientId": "

The ID of the client associated with the user pool.

", "UserPoolClientDescription$ClientId": "

The ID of the client associated with the user pool.

", @@ -464,8 +499,8 @@ "ClientMetadataType": { "base": null, "refs": { - "AdminInitiateAuthRequest$ClientMetadata": "

The client app metadata.

", - "InitiateAuthRequest$ClientMetadata": "

The client app's metadata.

" + "AdminInitiateAuthRequest$ClientMetadata": "

This is a random key-value pair map which can contain any key and will be passed to your PreAuthentication Lambda trigger as-is. It can be used to implement additional validations around authentication.

", + "InitiateAuthRequest$ClientMetadata": "

This is a random key-value pair map which can contain any key and will be passed to your PreAuthentication Lambda trigger as-is. It can be used to implement additional validations around authentication.

" } }, "ClientNameType": { @@ -570,7 +605,7 @@ "ConfirmationCodeType": { "base": null, "refs": { - "ConfirmForgotPasswordRequest$ConfirmationCode": "

The confirmation code sent by a user's request to retrieve a forgotten password.

", + "ConfirmForgotPasswordRequest$ConfirmationCode": "

The confirmation code sent by a user's request to retrieve a forgotten password. For more information, see ForgotPassword

", "ConfirmSignUpRequest$ConfirmationCode": "

The confirmation code sent by a user's request to confirm registration.

", "VerifyUserAttributeRequest$Code": "

The verification code in the request to verify user attributes.

" } @@ -585,6 +620,16 @@ "refs": { } }, + "CreateIdentityProviderRequest": { + "base": null, + "refs": { + } + }, + "CreateIdentityProviderResponse": { + "base": null, + "refs": { + } + }, "CreateUserImportJobRequest": { "base": "

Represents the request to create the user import job.

", "refs": { @@ -605,6 +650,16 @@ "refs": { } }, + "CreateUserPoolDomainRequest": { + "base": null, + "refs": { + } + }, + "CreateUserPoolDomainResponse": { + "base": null, + "refs": { + } + }, "CreateUserPoolRequest": { "base": "

Represents the request to create a user pool.

", "refs": { @@ -618,6 +673,7 @@ "CustomAttributeNameType": { "base": null, "refs": { + "AttributeMappingType$key": null, "SchemaAttributeType$Name": "

A schema attribute of the name type.

" } }, @@ -637,15 +693,19 @@ "DeviceType$DeviceLastAuthenticatedDate": "

The date in which the device was last authenticated.

", "GroupType$LastModifiedDate": "

The date the group was last modified.

", "GroupType$CreationDate": "

The date the group was created.

", - "UserImportJobType$CreationDate": "

The date when the user import job was created.

", + "IdentityProviderType$LastModifiedDate": "

The date the identity provider was last modified.

", + "IdentityProviderType$CreationDate": "

The date the identity provider was created.

", + "ProviderDescription$LastModifiedDate": "

The date the provider was last modified.

", + "ProviderDescription$CreationDate": "

The date the provider was added to the user pool.

", + "UserImportJobType$CreationDate": "

The date the user import job was created.

", "UserImportJobType$StartDate": "

The date when the user import job was started.

", - "UserImportJobType$CompletionDate": "

The date when the user imoprt job was completed.

", - "UserPoolClientType$LastModifiedDate": "

The last modified date from the user pool request of the client type.

", - "UserPoolClientType$CreationDate": "

The creation date from the user pool request of the client type.

", - "UserPoolDescriptionType$LastModifiedDate": "

The last modified date in a user pool description.

", - "UserPoolDescriptionType$CreationDate": "

The creation date in a user pool description.

", - "UserPoolType$LastModifiedDate": "

The last modified date of a user pool.

", - "UserPoolType$CreationDate": "

The creation date of a user pool.

", + "UserImportJobType$CompletionDate": "

The date when the user import job was completed.

", + "UserPoolClientType$LastModifiedDate": "

The date the user pool client was last modified.

", + "UserPoolClientType$CreationDate": "

The date the user pool client was created.

", + "UserPoolDescriptionType$LastModifiedDate": "

The date the user pool description was last modified.

", + "UserPoolDescriptionType$CreationDate": "

The date the user pool description was created.

", + "UserPoolType$LastModifiedDate": "

The date the user pool was last modified.

", + "UserPoolType$CreationDate": "

The date the user pool was created.

", "UserType$UserCreateDate": "

The creation date of the user.

", "UserType$UserLastModifiedDate": "

The last modified date of the user.

" } @@ -655,6 +715,11 @@ "refs": { } }, + "DeleteIdentityProviderRequest": { + "base": null, + "refs": { + } + }, "DeleteUserAttributesRequest": { "base": "

Represents the request to delete user attributes.

", "refs": { @@ -670,6 +735,16 @@ "refs": { } }, + "DeleteUserPoolDomainRequest": { + "base": null, + "refs": { + } + }, + "DeleteUserPoolDomainResponse": { + "base": null, + "refs": { + } + }, "DeleteUserPoolRequest": { "base": "

Represents the request to delete a user pool.

", "refs": { @@ -683,7 +758,7 @@ "DeliveryMediumListType": { "base": null, "refs": { - "AdminCreateUserRequest$DesiredDeliveryMediums": "

Specify \"EMAIL\" if email will be used to send the welcome message. Specify \"SMS\" if the phone number will be used. The default value is \"SMS\". More than one value can be specified.

" + "AdminCreateUserRequest$DesiredDeliveryMediums": "

Specify \"EMAIL\" if email will be used to send the welcome message. Specify \"SMS\" if the phone number will be used. The default value is \"SMS\". More than one value can be specified.

" } }, "DeliveryMediumType": { @@ -694,6 +769,16 @@ "MFAOptionType$DeliveryMedium": "

The delivery medium (email message or SMS message) to send the MFA code.

" } }, + "DescribeIdentityProviderRequest": { + "base": null, + "refs": { + } + }, + "DescribeIdentityProviderResponse": { + "base": null, + "refs": { + } + }, "DescribeUserImportJobRequest": { "base": "

Represents the request to describe the user import job.

", "refs": { @@ -714,6 +799,16 @@ "refs": { } }, + "DescribeUserPoolDomainRequest": { + "base": null, + "refs": { + } + }, + "DescribeUserPoolDomainResponse": { + "base": null, + "refs": { + } + }, "DescribeUserPoolRequest": { "base": "

Represents the request to describe the user pool.

", "refs": { @@ -788,6 +883,38 @@ "GetDeviceResponse$Device": "

The device.

" } }, + "DomainDescriptionType": { + "base": "

A container for information about a domain.

", + "refs": { + "DescribeUserPoolDomainResponse$DomainDescription": "

A domain description object containing information about the domain.

" + } + }, + "DomainStatusType": { + "base": null, + "refs": { + "DomainDescriptionType$Status": "

The domain status.

" + } + }, + "DomainType": { + "base": null, + "refs": { + "CreateUserPoolDomainRequest$Domain": "

The domain string.

", + "DeleteUserPoolDomainRequest$Domain": "

The domain string.

", + "DescribeUserPoolDomainRequest$Domain": "

The domain string.

", + "DomainDescriptionType$Domain": "

The domain string.

" + } + }, + "DomainVersionType": { + "base": null, + "refs": { + "DomainDescriptionType$Version": "

The app version.

" + } + }, + "DuplicateProviderException": { + "base": "

This exception is thrown when the provider is already supported by the user pool.

", + "refs": { + } + }, "EmailAddressType": { "base": null, "refs": { @@ -816,7 +943,7 @@ "refs": { "CreateUserPoolRequest$EmailVerificationSubject": "

A string representing the email verification subject.

", "MessageTemplateType$EmailSubject": "

The subject line for email messages.

", - "UpdateUserPoolRequest$EmailVerificationSubject": "

The subject of the email verfication message.

", + "UpdateUserPoolRequest$EmailVerificationSubject": "

The subject of the email verification message.

", "UserPoolType$EmailVerificationSubject": "

The subject of the email verification message.

" } }, @@ -842,8 +969,8 @@ "ForceAliasCreation": { "base": null, "refs": { - "AdminCreateUserRequest$ForceAliasCreation": "

This parameter is only used if the phone_number_verified or email_verified attribute is set to True. Otherwise, it is ignored.

If this parameter is set to True and the phone number or email address specified in the UserAttributes parameter already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user. The previous user will no longer be able to log in using that alias.

If this parameter is set to False, the API throws an AliasExistsException error if the alias already exists. The default value is False.

", - "ConfirmSignUpRequest$ForceAliasCreation": "

Boolean to be specified to force user confirmation irrespective of existing alias. By default set to False. If this parameter is set to True and the phone number/email used for sign up confirmation already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user being confirmed. If set to False, the API will throw an AliasExistsException error.

" + "AdminCreateUserRequest$ForceAliasCreation": "

This parameter is only used if the phone_number_verified or email_verified attribute is set to True. Otherwise, it is ignored.

If this parameter is set to True and the phone number or email address specified in the UserAttributes parameter already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user. The previous user will no longer be able to log in using that alias.

If this parameter is set to False, the API throws an AliasExistsException error if the alias already exists. The default value is False.

", + "ConfirmSignUpRequest$ForceAliasCreation": "

Boolean to be specified to force user confirmation irrespective of existing alias. By default set to False. If this parameter is set to True and the phone number/email used for sign up confirmation already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user being confirmed. If set to False, the API will throw an AliasExistsException error.

" } }, "ForgetDeviceRequest": { @@ -897,6 +1024,16 @@ "refs": { } }, + "GetIdentityProviderByIdentifierRequest": { + "base": null, + "refs": { + } + }, + "GetIdentityProviderByIdentifierResponse": { + "base": null, + "refs": { + } + }, "GetUserAttributeVerificationCodeRequest": { "base": "

Represents the request to get user attribute verification.

", "refs": { @@ -961,6 +1098,38 @@ "UpdateGroupResponse$Group": "

The group object for the group.

" } }, + "IdentityProviderType": { + "base": "

A container for information about an identity provider.

", + "refs": { + "CreateIdentityProviderResponse$IdentityProvider": "

The newly created identity provider object.

", + "DescribeIdentityProviderResponse$IdentityProvider": "

The identity provider that was deleted.

", + "GetIdentityProviderByIdentifierResponse$IdentityProvider": "

The identity provider object.

", + "UpdateIdentityProviderResponse$IdentityProvider": "

The identity provider object.

" + } + }, + "IdentityProviderTypeType": { + "base": null, + "refs": { + "CreateIdentityProviderRequest$ProviderType": "

The identity provider type.

", + "IdentityProviderType$ProviderType": "

The identity provider type.

", + "ProviderDescription$ProviderType": "

The identity provider type.

" + } + }, + "IdpIdentifierType": { + "base": null, + "refs": { + "GetIdentityProviderByIdentifierRequest$IdpIdentifier": "

The identity provider ID.

", + "IdpIdentifiersListType$member": null + } + }, + "IdpIdentifiersListType": { + "base": null, + "refs": { + "CreateIdentityProviderRequest$IdpIdentifiers": "

A list of identity provider identifiers.

", + "IdentityProviderType$IdpIdentifiers": "

A list of identity provider identifiers.

", + "UpdateIdentityProviderRequest$IdpIdentifiers": "

A list of identity provider identifiers.

" + } + }, "InitiateAuthRequest": { "base": "

Initiates the authentication request.

", "refs": { @@ -993,6 +1162,11 @@ "refs": { } }, + "InvalidOAuthFlowException": { + "base": "

This exception is thrown when the specified OAuth flow is invalid.

", + "refs": { + } + }, "InvalidParameterException": { "base": "

This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

", "refs": { @@ -1024,7 +1198,7 @@ "CreateUserPoolRequest$LambdaConfig": "

The Lambda trigger configuration information for the new user pool.

", "UpdateUserPoolRequest$LambdaConfig": "

The AWS Lambda configuration information from the request to update the user pool.

", "UserPoolDescriptionType$LambdaConfig": "

The AWS Lambda configuration information in a user pool description.

", - "UserPoolType$LambdaConfig": "

A container describing the AWS Lambda triggers associated with a user pool.

" + "UserPoolType$LambdaConfig": "

A container for the AWS Lambda triggers associated with a user pool.

" } }, "LimitExceededException": { @@ -1052,12 +1226,28 @@ "refs": { } }, + "ListIdentityProvidersRequest": { + "base": null, + "refs": { + } + }, + "ListIdentityProvidersResponse": { + "base": null, + "refs": { + } + }, "ListOfStringTypes": { "base": null, "refs": { "GetCSVHeaderResponse$CSVHeader": "

The header information for the .csv file for the user import job.

" } }, + "ListProvidersLimitType": { + "base": null, + "refs": { + "ListIdentityProvidersRequest$MaxResults": "

The maximum number of identity providers to return.

" + } + }, "ListUserImportJobsRequest": { "base": "

Represents the request to list the user import jobs.

", "refs": { @@ -1108,6 +1298,14 @@ "refs": { } }, + "LogoutURLsListType": { + "base": null, + "refs": { + "CreateUserPoolClientRequest$LogoutURLs": "

A list of allowed logout URLs for the identity providers.

", + "UpdateUserPoolClientRequest$LogoutURLs": "

A list ofallowed logout URLs for the identity providers.

", + "UserPoolClientType$LogoutURLs": "

A list ofallowed logout URLs for the identity providers.

" + } + }, "LongType": { "base": null, "refs": { @@ -1140,7 +1338,7 @@ "MessageActionType": { "base": null, "refs": { - "AdminCreateUserRequest$MessageAction": "

Set to \"RESEND\" to resend the invitation message to a user that already exists and reset the expiration limit on the user's account. Set to \"SUPPRESS\" to suppress sending the message. Only one value can be specified.

" + "AdminCreateUserRequest$MessageAction": "

Set to \"RESEND\" to resend the invitation message to a user that already exists and reset the expiration limit on the user's account. Set to \"SUPPRESS\" to suppress sending the message. Only one value can be specified.

" } }, "MessageTemplateType": { @@ -1156,11 +1354,13 @@ "CodeDeliveryFailureException$message": "

The message sent when a verification code fails to deliver successfully.

", "CodeMismatchException$message": "

The message provided when the code mismatch exception is thrown.

", "ConcurrentModificationException$message": "

The message provided when the concurrent exception is thrown.

", + "DuplicateProviderException$message": null, "ExpiredCodeException$message": "

The message returned when the expired code exception is thrown.

", "GroupExistsException$message": null, "InternalErrorException$message": "

The message returned when Amazon Cognito throws an internal error exception.

", "InvalidEmailRoleAccessPolicyException$message": "

The message returned when you have an unverified email address or the identity policy is not set on an email address that Amazon Cognito can access.

", "InvalidLambdaResponseException$message": "

The message returned when the Amazon Cognito service throws an invalid AWS Lambda response exception.

", + "InvalidOAuthFlowException$message": null, "InvalidParameterException$message": "

The message returned when the Amazon Cognito service throws an invalid parameter exception.

", "InvalidPasswordException$message": "

The message returned when the Amazon Cognito service throws an invalid user password exception.

", "InvalidSmsRoleAccessPolicyException$message": "

The message retuned when the invalid SMS role access policy exception is thrown.

", @@ -1172,9 +1372,11 @@ "PasswordResetRequiredException$message": "

The message returned when a password reset is required.

", "PreconditionNotMetException$message": "

The message returned when a precondition is not met.

", "ResourceNotFoundException$message": "

The message returned when the Amazon Cognito service returns a resource not found exception.

", + "ScopeDoesNotExistException$message": null, "TooManyFailedAttemptsException$message": "

The message returned when the Amazon Cognito service returns a too many failed attempts exception.

", "TooManyRequestsException$message": "

The message returned when the Amazon Cognito service returns a too many requests exception.

", "UnexpectedLambdaException$message": "

The message returned when the Amazon Cognito service returns an unexpected AWS Lambda exception.

", + "UnsupportedIdentityProviderException$message": null, "UnsupportedUserStateException$message": "

The message returned when the user is in an unsupported state.

", "UserImportInProgressException$message": "

The message returned when the user pool has an import job running.

", "UserLambdaValidationException$message": "

The message returned when the Amazon Cognito service returns a user validation exception with the AWS Lambda service.

", @@ -1191,7 +1393,7 @@ } }, "NotAuthorizedException": { - "base": "

This exception gets thrown when a user is not authorized.

", + "base": "

This exception is thrown when a user is not authorized.

", "refs": { } }, @@ -1201,6 +1403,20 @@ "SchemaAttributeType$NumberAttributeConstraints": "

Specifies the constraints for an attribute of the number type.

" } }, + "OAuthFlowType": { + "base": null, + "refs": { + "OAuthFlowsType$member": null + } + }, + "OAuthFlowsType": { + "base": null, + "refs": { + "CreateUserPoolClientRequest$AllowedOAuthFlows": "

Set to code to initiate a code grant flow, which provides an authorization code as the response. This code can be exchanged for access tokens with the token endpoint.

Set to token to specify that the client should get the access token (and, optionally, ID token, based on scopes) directly.

", + "UpdateUserPoolClientRequest$AllowedOAuthFlows": "

Set to code to initiate a code grant flow, which provides an authorization code as the response. This code can be exchanged for access tokens with the token endpoint.

Set to token to specify that the client should get the access token (and, optionally, ID token, based on scopes) directly.

", + "UserPoolClientType$AllowedOAuthFlows": "

Set to code to initiate a code grant flow, which provides an authorization code as the response. This code can be exchanged for access tokens with the token endpoint.

Set to token to specify that the client should get the access token (and, optionally, ID token, based on scopes) directly.

" + } + }, "PaginationKey": { "base": null, "refs": { @@ -1217,7 +1433,9 @@ "PaginationKeyType": { "base": null, "refs": { - "ListUserImportJobsRequest$PaginationToken": "

An identifier that was returned from the previous call to ListUserImportJobs, which can be used to return the next set of import jobs in the list.

", + "ListIdentityProvidersRequest$NextToken": "

A pagination token.

", + "ListIdentityProvidersResponse$NextToken": "

A pagination token.

", + "ListUserImportJobsRequest$PaginationToken": "

An identifier that was returned from the previous call to ListUserImportJobs, which can be used to return the next set of import jobs in the list.

", "ListUserImportJobsResponse$PaginationToken": "

An identifier that can be used to return the next set of user import jobs in the list.

", "ListUserPoolsRequest$NextToken": "

An identifier that was returned from the previous call to this operation, which can be used to return the next set of items in the list.

", "ListUserPoolsResponse$NextToken": "

An identifier that was returned from the previous call to this operation, which can be used to return the next set of items in the list.

" @@ -1232,7 +1450,7 @@ "PasswordPolicyType": { "base": "

The password policy type.

", "refs": { - "UserPoolPolicyType$PasswordPolicy": "

A container with information about the user pool password policy.

" + "UserPoolPolicyType$PasswordPolicy": "

A container for information about the user pool password policy.

" } }, "PasswordResetRequiredException": { @@ -1243,10 +1461,10 @@ "PasswordType": { "base": null, "refs": { - "AdminCreateUserRequest$TemporaryPassword": "

The user's temporary password. This password must conform to the password policy that you specified when you created the user pool.

The temporary password is valid only once. To complete the Admin Create User flow, the user must enter the temporary password in the sign-in page along with a new password to be used in all future sign-ins.

This parameter is not required. If you do not specify a value, Amazon Cognito generates one for you.

The temporary password can only be used until the user account expiration limit that you specified when you created the user pool. To reset the account after that time limit, you must call AdminCreateUser again, specifying \"RESEND\" for the MessageAction parameter.

", + "AdminCreateUserRequest$TemporaryPassword": "

The user's temporary password. This password must conform to the password policy that you specified when you created the user pool.

The temporary password is valid only once. To complete the Admin Create User flow, the user must enter the temporary password in the sign-in page along with a new password to be used in all future sign-ins.

This parameter is not required. If you do not specify a value, Amazon Cognito generates one for you.

The temporary password can only be used until the user account expiration limit that you specified when you created the user pool. To reset the account after that time limit, you must call AdminCreateUser again, specifying \"RESEND\" for the MessageAction parameter.

", "ChangePasswordRequest$PreviousPassword": "

The old password in the change password request.

", "ChangePasswordRequest$ProposedPassword": "

The new password in the change password request.

", - "ConfirmForgotPasswordRequest$Password": "

The password sent by sent by a user's request to retrieve a forgotten password.

", + "ConfirmForgotPasswordRequest$Password": "

The password sent by a user's request to retrieve a forgotten password.

", "SignUpRequest$Password": "

The password of the user you wish to register.

" } }, @@ -1260,7 +1478,7 @@ "PreSignedUrlType": { "base": null, "refs": { - "UserImportJobType$PreSignedUrl": "

The pre-signed URL to be used to upload the .csv file.

" + "UserImportJobType$PreSignedUrl": "

The pre-signed URL to be used to upload the .csv file.

" } }, "PrecedenceType": { @@ -1268,7 +1486,7 @@ "refs": { "CreateGroupRequest$Precedence": "

A nonnegative integer value that specifies the precedence of this group relative to the other groups that a user can belong to in the user pool. Zero is the highest precedence value. Groups with lower Precedence values take precedence over groups with higher or null Precedence values. If a user belongs to two or more groups, it is the group with the lowest precedence value whose role ARN will be used in the cognito:roles and cognito:preferred_role claims in the user's tokens.

Two groups can have the same Precedence value. If this happens, neither group takes precedence over the other. If two groups with the same Precedence have the same role ARN, that role is used in the cognito:preferred_role claim in tokens for users in each group. If the two groups have different role ARNs, the cognito:preferred_role claim is not set in users' tokens.

The default Precedence value is null.

", "GroupType$Precedence": "

A nonnegative integer value that specifies the precedence of this group relative to the other groups that a user can belong to in the user pool. If a user belongs to two or more groups, it is the group with the highest precedence whose role ARN will be used in the cognito:roles and cognito:preferred_role claims in the user's tokens. Groups with higher Precedence values take precedence over groups with lower Precedence values or with null Precedence values.

Two groups can have the same Precedence value. If this happens, neither group takes precedence over the other. If two groups with the same Precedence have the same role ARN, that role is used in the cognito:preferred_role claim in tokens for users in each group. If the two groups have different role ARNs, the cognito:preferred_role claim is not set in users' tokens.

The default Precedence value is null.

", - "UpdateGroupRequest$Precedence": "

The new precedence value for the group. For more information about this parameter, see CreateGroupRequest.

" + "UpdateGroupRequest$Precedence": "

The new precedence value for the group. For more information about this parameter, see CreateGroup.

" } }, "PreconditionNotMetException": { @@ -1276,6 +1494,38 @@ "refs": { } }, + "ProviderDescription": { + "base": "

A container for identity provider details.

", + "refs": { + "ProvidersListType$member": null + } + }, + "ProviderDetailsType": { + "base": null, + "refs": { + "CreateIdentityProviderRequest$ProviderDetails": "

The identity provider details, such as MetadataURL and MetadataFile.

", + "IdentityProviderType$ProviderDetails": "

The identity provider details, such as MetadataURL and MetadataFile.

", + "UpdateIdentityProviderRequest$ProviderDetails": "

The identity provider details to be updated, such as MetadataURL and MetadataFile.

" + } + }, + "ProviderNameType": { + "base": null, + "refs": { + "CreateIdentityProviderRequest$ProviderName": "

The identity provider name.

", + "DeleteIdentityProviderRequest$ProviderName": "

The identity provider name.

", + "DescribeIdentityProviderRequest$ProviderName": "

The identity provider name.

", + "IdentityProviderType$ProviderName": "

The identity provider name.

", + "ProviderDescription$ProviderName": "

The identity provider name.

", + "SupportedIdentityProvidersListType$member": null, + "UpdateIdentityProviderRequest$ProviderName": "

The identity provider name.

" + } + }, + "ProvidersListType": { + "base": null, + "refs": { + "ListIdentityProvidersResponse$Providers": "

A list of identity provider objects.

" + } + }, "QueryLimit": { "base": null, "refs": { @@ -1290,15 +1540,25 @@ "ListDevicesRequest$Limit": "

The limit of the device request.

", "ListGroupsRequest$Limit": "

The limit of the request to list groups.

", "ListUsersInGroupRequest$Limit": "

The limit of the request to list users.

", - "ListUsersRequest$Limit": "

The limit of the request to list users.

" + "ListUsersRequest$Limit": "

Maximum number of users to be returned.

" + } + }, + "RedirectUrlType": { + "base": null, + "refs": { + "CallbackURLsListType$member": null, + "CreateUserPoolClientRequest$DefaultRedirectURI": "

The default redirect URI. Must be in the CallbackURLs list.

", + "LogoutURLsListType$member": null, + "UpdateUserPoolClientRequest$DefaultRedirectURI": "

The default redirect URI. Must be in the CallbackURLs list.

", + "UserPoolClientType$DefaultRedirectURI": "

The default redirect URI. Must be in the CallbackURLs list.

" } }, "RefreshTokenValidityType": { "base": null, "refs": { - "CreateUserPoolClientRequest$RefreshTokenValidity": "

The validity of the refresh token, in days.

", - "UpdateUserPoolClientRequest$RefreshTokenValidity": "

The validity of the refresh token, in days.

", - "UserPoolClientType$RefreshTokenValidity": "

The validity of the refresh token, in days.

" + "CreateUserPoolClientRequest$RefreshTokenValidity": "

The time limit, in days, after which the refresh token is no longer valid and cannot be used.

", + "UpdateUserPoolClientRequest$RefreshTokenValidity": "

The time limit, in days, after which the refresh token is no longer valid and cannot be used.

", + "UserPoolClientType$RefreshTokenValidity": "

The time limit, in days, after which the refresh token is no longer valid and cannot be used.

" } }, "ResendConfirmationCodeRequest": { @@ -1326,6 +1586,12 @@ "refs": { } }, + "S3BucketType": { + "base": null, + "refs": { + "DomainDescriptionType$S3Bucket": "

The S3 bucket where the static files for this domain are stored.

" + } + }, "SchemaAttributeType": { "base": "

Contains information about the schema attribute.

", "refs": { @@ -1340,6 +1606,25 @@ "UserPoolType$SchemaAttributes": "

A container with the schema attributes of a user pool.

" } }, + "ScopeDoesNotExistException": { + "base": "

This exception is thrown when the specified scope does not exist.

", + "refs": { + } + }, + "ScopeListType": { + "base": null, + "refs": { + "CreateUserPoolClientRequest$AllowedOAuthScopes": "

A list of allowed OAuth scopes. Currently supported values are \"phone\", \"email\", \"openid\", and \"Cognito\".

", + "UpdateUserPoolClientRequest$AllowedOAuthScopes": "

A list of allowed OAuth scopes. Currently supported values are \"phone\", \"email\", \"openid\", and \"Cognito\".

", + "UserPoolClientType$AllowedOAuthScopes": "

A list of allowed OAuth scopes. Currently supported values are \"phone\", \"email\", \"openid\", and \"Cognito\".

" + } + }, + "ScopeType": { + "base": null, + "refs": { + "ScopeListType$member": null + } + }, "SearchPaginationTokenType": { "base": null, "refs": { @@ -1354,7 +1639,7 @@ "SearchedAttributeNamesListType": { "base": null, "refs": { - "ListUsersRequest$AttributesToGet": "

The attributes to get from the request to list users.

" + "ListUsersRequest$AttributesToGet": "

An array of strings, where each string is the name of a user attribute to be returned for each user in the search results. If the array is empty, all attributes are returned.

" } }, "SecretHashType": { @@ -1370,12 +1655,12 @@ "SessionType": { "base": null, "refs": { - "AdminInitiateAuthResponse$Session": "

The session.

", - "AdminRespondToAuthChallengeRequest$Session": "

The session.

", - "AdminRespondToAuthChallengeResponse$Session": "

The session.

", - "InitiateAuthResponse$Session": "

The session.

", - "RespondToAuthChallengeRequest$Session": "

The session.

", - "RespondToAuthChallengeResponse$Session": "

The session.

" + "AdminInitiateAuthResponse$Session": "

The session which should be passed both ways in challenge-response calls to the service. If AdminInitiateAuth or AdminRespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next AdminRespondToAuthChallenge API call.

", + "AdminRespondToAuthChallengeRequest$Session": "

The session which should be passed both ways in challenge-response calls to the service. If InitiateAuth or RespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next RespondToAuthChallenge API call.

", + "AdminRespondToAuthChallengeResponse$Session": "

The session which should be passed both ways in challenge-response calls to the service. If the InitiateAuth or RespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next RespondToAuthChallenge API call.

", + "InitiateAuthResponse$Session": "

The session which should be passed both ways in challenge-response calls to the service. If the InitiateAuth or RespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next RespondToAuthChallenge API call.

", + "RespondToAuthChallengeRequest$Session": "

The session which should be passed both ways in challenge-response calls to the service. If InitiateAuth or RespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next RespondToAuthChallenge API call.

", + "RespondToAuthChallengeResponse$Session": "

The session which should be passed both ways in challenge-response calls to the service. If the InitiateAuth or RespondToAuthChallenge API call determines that the caller needs to go through another challenge, they return a session with other challenge parameters. This session should be passed as it is to the next RespondToAuthChallenge API call.

" } }, "SetUserSettingsRequest": { @@ -1399,7 +1684,7 @@ } }, "SmsConfigurationType": { - "base": "

The SMS configuratoin type.

", + "base": "

The SMS configuration type.

", "refs": { "CreateUserPoolRequest$SmsConfiguration": "

The SMS configuration.

", "UpdateUserPoolRequest$SmsConfiguration": "

SMS configuration.

", @@ -1454,6 +1739,7 @@ "StringType": { "base": null, "refs": { + "AttributeMappingType$value": null, "AuthParametersType$key": null, "AuthParametersType$value": null, "AuthenticationResultType$TokenType": "

The token type of the authentication result.

", @@ -1470,15 +1756,26 @@ "NewDeviceMetadataType$DeviceGroupKey": "

The device group key.

", "NumberAttributeConstraintsType$MinValue": "

The minimum value of an attribute that is of the number data type.

", "NumberAttributeConstraintsType$MaxValue": "

The maximum value of an attribute that is of the number data type.

", + "ProviderDetailsType$key": null, + "ProviderDetailsType$value": null, + "SignUpResponse$UserSub": "

The UUID of the authenticated user. This is not the same as username.

", "SmsConfigurationType$ExternalId": "

The external ID.

", "StringAttributeConstraintsType$MinLength": "

The minimum length of an attribute value of the string type.

", "StringAttributeConstraintsType$MaxLength": "

The maximum length of an attribute value of the string type.

", "UserPoolTagsType$key": null, "UserPoolTagsType$value": null, - "UserPoolType$SmsConfigurationFailure": "

The reason why the SMS configuration cannot send the message(s) to your users.

", + "UserPoolType$SmsConfigurationFailure": "

The reason why the SMS configuration cannot send the messages to your users.

", "UserPoolType$EmailConfigurationFailure": "

The reason why the email configuration cannot send the messages to your users.

" } }, + "SupportedIdentityProvidersListType": { + "base": null, + "refs": { + "CreateUserPoolClientRequest$SupportedIdentityProviders": "

A list of provider names for the identity providers that are supported on this client.

", + "UpdateUserPoolClientRequest$SupportedIdentityProviders": "

A list of provider names for the identity providers that are supported on this client.

", + "UserPoolClientType$SupportedIdentityProviders": "

A list of provider names for the identity providers that are supported on this client.

" + } + }, "TokenModelType": { "base": null, "refs": { @@ -1502,17 +1799,22 @@ } }, "TooManyFailedAttemptsException": { - "base": "

This exception gets thrown when the user has made too many failed attempts for a given action (e.g., sign in).

", + "base": "

This exception is thrown when the user has made too many failed attempts for a given action (e.g., sign in).

", "refs": { } }, "TooManyRequestsException": { - "base": "

This exception gets thrown when the user has made too many requests for a given operation.

", + "base": "

This exception is thrown when the user has made too many requests for a given operation.

", "refs": { } }, "UnexpectedLambdaException": { - "base": "

This exception gets thrown when the Amazon Cognito service encounters an unexpected exception with the AWS Lambda service.

", + "base": "

This exception is thrown when the Amazon Cognito service encounters an unexpected exception with the AWS Lambda service.

", + "refs": { + } + }, + "UnsupportedIdentityProviderException": { + "base": "

This exception is thrown when the specified identifier is not supported.

", "refs": { } }, @@ -1541,6 +1843,16 @@ "refs": { } }, + "UpdateIdentityProviderRequest": { + "base": null, + "refs": { + } + }, + "UpdateIdentityProviderResponse": { + "base": null, + "refs": { + } + }, "UpdateUserAttributesRequest": { "base": "

Represents the request to update user attributes.

", "refs": { @@ -1574,7 +1886,7 @@ "UserFilterType": { "base": null, "refs": { - "ListUsersRequest$Filter": "

The filter for the list users request.

" + "ListUsersRequest$Filter": "

A filter string of the form \"AttributeName Filter-Type \"AttributeValue\"\". Quotation marks within the filter string must be escaped using the backslash (\\) character. For example, \"family_name = \\\"Reddy\\\"\".

If the filter string is empty, ListUsers returns all users in the user pool.

You can only search for the following standard attributes:

Custom attributes are not searchable.

For more information, see Searching for Users Using the ListUsers API and Examples of Using the ListUsers API in the Amazon Cognito Developer Guide.

" } }, "UserImportInProgressException": { @@ -1601,7 +1913,7 @@ "UserImportJobStatusType": { "base": null, "refs": { - "UserImportJobType$Status": "

The status of the user import job. One of the following:

" + "UserImportJobType$Status": "

The status of the user import job. One of the following:

" } }, "UserImportJobType": { @@ -1621,7 +1933,7 @@ } }, "UserLambdaValidationException": { - "base": "

This exception gets thrown when the Amazon Cognito service encounters a user validation exception with the AWS Lambda service.

", + "base": "

This exception is thrown when the Amazon Cognito service encounters a user validation exception with the AWS Lambda service.

", "refs": { } }, @@ -1682,30 +1994,40 @@ "AdminResetUserPasswordRequest$UserPoolId": "

The user pool ID for the user pool where you want to reset the user's password.

", "AdminRespondToAuthChallengeRequest$UserPoolId": "

The ID of the Amazon Cognito user pool.

", "AdminSetUserSettingsRequest$UserPoolId": "

The user pool ID for the user pool where you want to set the user's settings, such as MFA options.

", - "AdminUpdateDeviceStatusRequest$UserPoolId": "

The user pool ID>

", + "AdminUpdateDeviceStatusRequest$UserPoolId": "

The user pool ID.

", "AdminUpdateUserAttributesRequest$UserPoolId": "

The user pool ID for the user pool where you want to update user attributes.

", "AdminUserGlobalSignOutRequest$UserPoolId": "

The user pool ID.

", "CreateGroupRequest$UserPoolId": "

The user pool ID for the user pool.

", + "CreateIdentityProviderRequest$UserPoolId": "

The user pool ID.

", "CreateUserImportJobRequest$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", "CreateUserPoolClientRequest$UserPoolId": "

The user pool ID for the user pool where you want to create a user pool client.

", + "CreateUserPoolDomainRequest$UserPoolId": "

The user pool ID.

", "DeleteGroupRequest$UserPoolId": "

The user pool ID for the user pool.

", + "DeleteIdentityProviderRequest$UserPoolId": "

The user pool ID.

", "DeleteUserPoolClientRequest$UserPoolId": "

The user pool ID for the user pool where you want to delete the client.

", + "DeleteUserPoolDomainRequest$UserPoolId": "

The user pool ID.

", "DeleteUserPoolRequest$UserPoolId": "

The user pool ID for the user pool you want to delete.

", + "DescribeIdentityProviderRequest$UserPoolId": "

The user pool ID.

", "DescribeUserImportJobRequest$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", "DescribeUserPoolClientRequest$UserPoolId": "

The user pool ID for the user pool you want to describe.

", "DescribeUserPoolRequest$UserPoolId": "

The user pool ID for the user pool you want to describe.

", + "DomainDescriptionType$UserPoolId": "

The user pool ID.

", "GetCSVHeaderRequest$UserPoolId": "

The user pool ID for the user pool that the users are to be imported into.

", "GetCSVHeaderResponse$UserPoolId": "

The user pool ID for the user pool that the users are to be imported into.

", "GetGroupRequest$UserPoolId": "

The user pool ID for the user pool.

", + "GetIdentityProviderByIdentifierRequest$UserPoolId": "

The user pool ID.

", "GroupType$UserPoolId": "

The user pool ID for the user pool.

", + "IdentityProviderType$UserPoolId": "

The user pool ID.

", "ListGroupsRequest$UserPoolId": "

The user pool ID for the user pool.

", + "ListIdentityProvidersRequest$UserPoolId": "

The user pool ID.

", "ListUserImportJobsRequest$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", "ListUserPoolClientsRequest$UserPoolId": "

The user pool ID for the user pool where you want to list user pool clients.

", "ListUsersInGroupRequest$UserPoolId": "

The user pool ID for the user pool.

", - "ListUsersRequest$UserPoolId": "

The user pool ID for which you want to list users.

", + "ListUsersRequest$UserPoolId": "

The user pool ID for the user pool on which the search should be performed.

", "StartUserImportJobRequest$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", "StopUserImportJobRequest$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", "UpdateGroupRequest$UserPoolId": "

The user pool ID for the user pool.

", + "UpdateIdentityProviderRequest$UserPoolId": "

The user pool ID.

", "UpdateUserPoolClientRequest$UserPoolId": "

The user pool ID for the user pool where you want to update the user pool client.

", "UpdateUserPoolRequest$UserPoolId": "

The user pool ID for the user pool you want to update.

", "UserImportJobType$UserPoolId": "

The user pool ID for the user pool that the users are being imported into.

", @@ -1742,11 +2064,11 @@ "refs": { "CreateUserPoolRequest$Policies": "

The policies associated with the new user pool.

", "UpdateUserPoolRequest$Policies": "

A container with the policies you wish to update in a user pool.

", - "UserPoolType$Policies": "

A container describing the policies associated with a user pool.

" + "UserPoolType$Policies": "

A container for the policies associated with a user pool.

" } }, "UserPoolTaggingException": { - "base": "

This exception gets thrown when a user pool tag cannot be set or updated.

", + "base": "

This exception is thrown when a user pool tag cannot be set or updated.

", "refs": { } }, @@ -1759,7 +2081,7 @@ } }, "UserPoolType": { - "base": "

A container with information about the user pool type.

", + "base": "

A container for information about the user pool type.

", "refs": { "CreateUserPoolResponse$UserPool": "

A container for the user pool details.

", "DescribeUserPoolResponse$UserPool": "

The container of metadata returned by the server to describe the pool.

" @@ -1793,7 +2115,7 @@ "AdminDeleteUserAttributesRequest$Username": "

The user name of the user from which you would like to delete attributes.

", "AdminDeleteUserRequest$Username": "

The user name of the user you wish to delete.

", "AdminDisableUserRequest$Username": "

The user name of the user you wish to disable.

", - "AdminEnableUserRequest$Username": "

The user name of the user you wish to ebable.

", + "AdminEnableUserRequest$Username": "

The user name of the user you wish to enable.

", "AdminForgetDeviceRequest$Username": "

The user name.

", "AdminGetDeviceRequest$Username": "

The user name.

", "AdminGetUserRequest$Username": "

The user name of the user you wish to retrieve.

", diff --git a/models/apis/cognito-idp/2016-04-18/paginators-1.json b/models/apis/cognito-idp/2016-04-18/paginators-1.json new file mode 100644 index 00000000000..5677bd8e4a2 --- /dev/null +++ b/models/apis/cognito-idp/2016-04-18/paginators-1.json @@ -0,0 +1,4 @@ +{ + "pagination": { + } +} diff --git a/models/apis/elasticloadbalancingv2/2015-12-01/api-2.json b/models/apis/elasticloadbalancingv2/2015-12-01/api-2.json index a062dbe3c45..4d3ea63fe45 100644 --- a/models/apis/elasticloadbalancingv2/2015-12-01/api-2.json +++ b/models/apis/elasticloadbalancingv2/2015-12-01/api-2.json @@ -406,7 +406,9 @@ {"shape":"TargetGroupAssociationLimitException"}, {"shape":"RuleNotFoundException"}, {"shape":"OperationNotPermittedException"}, - {"shape":"TooManyRegistrationsForTargetIdException"} + {"shape":"TooManyRegistrationsForTargetIdException"}, + {"shape":"TooManyTargetsException"}, + {"shape":"TargetGroupNotFoundException"} ] }, "ModifyTargetGroup":{ @@ -856,13 +858,16 @@ "type":"structure", "members":{ "ListenerArn":{"shape":"ListenerArn"}, - "RuleArns":{"shape":"RuleArns"} + "RuleArns":{"shape":"RuleArns"}, + "Marker":{"shape":"Marker"}, + "PageSize":{"shape":"PageSize"} } }, "DescribeRulesOutput":{ "type":"structure", "members":{ - "Rules":{"shape":"Rules"} + "Rules":{"shape":"Rules"}, + "NextMarker":{"shape":"Marker"} } }, "DescribeSSLPoliciesInput":{ diff --git a/models/apis/elasticloadbalancingv2/2015-12-01/docs-2.json b/models/apis/elasticloadbalancingv2/2015-12-01/docs-2.json index 0f771841605..4c09965eb2a 100644 --- a/models/apis/elasticloadbalancingv2/2015-12-01/docs-2.json +++ b/models/apis/elasticloadbalancingv2/2015-12-01/docs-2.json @@ -632,6 +632,8 @@ "DescribeListenersOutput$NextMarker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", "DescribeLoadBalancersInput$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", "DescribeLoadBalancersOutput$NextMarker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", + "DescribeRulesInput$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", + "DescribeRulesOutput$NextMarker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", "DescribeSSLPoliciesInput$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", "DescribeSSLPoliciesOutput$NextMarker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", "DescribeTargetGroupsInput$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", @@ -719,6 +721,7 @@ "DescribeAccountLimitsInput$PageSize": "

The maximum number of results to return with this call.

", "DescribeListenersInput$PageSize": "

The maximum number of results to return with this call.

", "DescribeLoadBalancersInput$PageSize": "

The maximum number of results to return with this call.

", + "DescribeRulesInput$PageSize": "

The maximum number of results to return with this call.

", "DescribeSSLPoliciesInput$PageSize": "

The maximum number of results to return with this call.

", "DescribeTargetGroupsInput$PageSize": "

The maximum number of results to return with this call.

" } diff --git a/models/apis/kinesisanalytics/2015-08-14/api-2.json b/models/apis/kinesisanalytics/2015-08-14/api-2.json index eb2b1f89e14..bb891d3a9bb 100644 --- a/models/apis/kinesisanalytics/2015-08-14/api-2.json +++ b/models/apis/kinesisanalytics/2015-08-14/api-2.json @@ -1,7 +1,6 @@ { "version":"2.0", "metadata":{ - "uid":"kinesisanalytics-2015-08-14", "apiVersion":"2015-08-14", "endpointPrefix":"kinesisanalytics", "jsonVersion":"1.1", @@ -10,9 +9,25 @@ "serviceFullName":"Amazon Kinesis Analytics", "signatureVersion":"v4", "targetPrefix":"KinesisAnalytics_20150814", - "timestampFormat":"unixTimestamp" + "timestampFormat":"unixTimestamp", + "uid":"kinesisanalytics-2015-08-14" }, "operations":{ + "AddApplicationCloudWatchLoggingOption":{ + "name":"AddApplicationCloudWatchLoggingOption", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"AddApplicationCloudWatchLoggingOptionRequest"}, + "output":{"shape":"AddApplicationCloudWatchLoggingOptionResponse"}, + "errors":[ + {"shape":"ResourceNotFoundException"}, + {"shape":"ResourceInUseException"}, + {"shape":"InvalidArgumentException"}, + {"shape":"ConcurrentModificationException"} + ] + }, "AddApplicationInput":{ "name":"AddApplicationInput", "http":{ @@ -87,6 +102,21 @@ {"shape":"ResourceInUseException"} ] }, + "DeleteApplicationCloudWatchLoggingOption":{ + "name":"DeleteApplicationCloudWatchLoggingOption", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DeleteApplicationCloudWatchLoggingOptionRequest"}, + "output":{"shape":"DeleteApplicationCloudWatchLoggingOptionResponse"}, + "errors":[ + {"shape":"ResourceNotFoundException"}, + {"shape":"ResourceInUseException"}, + {"shape":"InvalidArgumentException"}, + {"shape":"ConcurrentModificationException"} + ] + }, "DeleteApplicationOutput":{ "name":"DeleteApplicationOutput", "http":{ @@ -98,6 +128,7 @@ "errors":[ {"shape":"ResourceNotFoundException"}, {"shape":"ResourceInUseException"}, + {"shape":"InvalidArgumentException"}, {"shape":"ConcurrentModificationException"} ] }, @@ -197,6 +228,24 @@ } }, "shapes":{ + "AddApplicationCloudWatchLoggingOptionRequest":{ + "type":"structure", + "required":[ + "ApplicationName", + "CurrentApplicationVersionId", + "CloudWatchLoggingOption" + ], + "members":{ + "ApplicationName":{"shape":"ApplicationName"}, + "CurrentApplicationVersionId":{"shape":"ApplicationVersionId"}, + "CloudWatchLoggingOption":{"shape":"CloudWatchLoggingOption"} + } + }, + "AddApplicationCloudWatchLoggingOptionResponse":{ + "type":"structure", + "members":{ + } + }, "AddApplicationInputRequest":{ "type":"structure", "required":[ @@ -279,6 +328,7 @@ "InputDescriptions":{"shape":"InputDescriptions"}, "OutputDescriptions":{"shape":"OutputDescriptions"}, "ReferenceDataSourceDescriptions":{"shape":"ReferenceDataSourceDescriptions"}, + "CloudWatchLoggingOptionDescriptions":{"shape":"CloudWatchLoggingOptionDescriptions"}, "ApplicationCode":{"shape":"ApplicationCode"}, "ApplicationVersionId":{"shape":"ApplicationVersionId"} } @@ -323,7 +373,8 @@ "InputUpdates":{"shape":"InputUpdates"}, "ApplicationCodeUpdate":{"shape":"ApplicationCode"}, "OutputUpdates":{"shape":"OutputUpdates"}, - "ReferenceDataSourceUpdates":{"shape":"ReferenceDataSourceUpdates"} + "ReferenceDataSourceUpdates":{"shape":"ReferenceDataSourceUpdates"}, + "CloudWatchLoggingOptionUpdates":{"shape":"CloudWatchLoggingOptionUpdates"} } }, "ApplicationVersionId":{ @@ -349,6 +400,50 @@ "RecordColumnDelimiter":{"shape":"RecordColumnDelimiter"} } }, + "CloudWatchLoggingOption":{ + "type":"structure", + "required":[ + "LogStreamARN", + "RoleARN" + ], + "members":{ + "LogStreamARN":{"shape":"LogStreamARN"}, + "RoleARN":{"shape":"RoleARN"} + } + }, + "CloudWatchLoggingOptionDescription":{ + "type":"structure", + "required":[ + "LogStreamARN", + "RoleARN" + ], + "members":{ + "CloudWatchLoggingOptionId":{"shape":"Id"}, + "LogStreamARN":{"shape":"LogStreamARN"}, + "RoleARN":{"shape":"RoleARN"} + } + }, + "CloudWatchLoggingOptionDescriptions":{ + "type":"list", + "member":{"shape":"CloudWatchLoggingOptionDescription"} + }, + "CloudWatchLoggingOptionUpdate":{ + "type":"structure", + "required":["CloudWatchLoggingOptionId"], + "members":{ + "CloudWatchLoggingOptionId":{"shape":"Id"}, + "LogStreamARNUpdate":{"shape":"LogStreamARN"}, + "RoleARNUpdate":{"shape":"RoleARN"} + } + }, + "CloudWatchLoggingOptionUpdates":{ + "type":"list", + "member":{"shape":"CloudWatchLoggingOptionUpdate"} + }, + "CloudWatchLoggingOptions":{ + "type":"list", + "member":{"shape":"CloudWatchLoggingOption"} + }, "CodeValidationException":{ "type":"structure", "members":{ @@ -371,6 +466,7 @@ "ApplicationDescription":{"shape":"ApplicationDescription"}, "Inputs":{"shape":"Inputs"}, "Outputs":{"shape":"Outputs"}, + "CloudWatchLoggingOptions":{"shape":"CloudWatchLoggingOptions"}, "ApplicationCode":{"shape":"ApplicationCode"} } }, @@ -381,6 +477,24 @@ "ApplicationSummary":{"shape":"ApplicationSummary"} } }, + "DeleteApplicationCloudWatchLoggingOptionRequest":{ + "type":"structure", + "required":[ + "ApplicationName", + "CurrentApplicationVersionId", + "CloudWatchLoggingOptionId" + ], + "members":{ + "ApplicationName":{"shape":"ApplicationName"}, + "CurrentApplicationVersionId":{"shape":"ApplicationVersionId"}, + "CloudWatchLoggingOptionId":{"shape":"Id"} + } + }, + "DeleteApplicationCloudWatchLoggingOptionResponse":{ + "type":"structure", + "members":{ + } + }, "DeleteApplicationOutputRequest":{ "type":"structure", "required":[ @@ -754,6 +868,12 @@ "HasMoreApplications":{"shape":"BooleanObject"} } }, + "LogStreamARN":{ + "type":"string", + "max":2048, + "min":1, + "pattern":"arn:.*" + }, "MappingParameters":{ "type":"structure", "members":{ @@ -833,7 +953,10 @@ "SqlType":{"shape":"RecordColumnSqlType"} } }, - "RecordColumnDelimiter":{"type":"string"}, + "RecordColumnDelimiter":{ + "type":"string", + "min":1 + }, "RecordColumnMapping":{"type":"string"}, "RecordColumnName":{ "type":"string", @@ -865,7 +988,10 @@ "CSV" ] }, - "RecordRowDelimiter":{"type":"string"}, + "RecordRowDelimiter":{ + "type":"string", + "min":1 + }, "RecordRowPath":{"type":"string"}, "ReferenceDataSource":{ "type":"structure", diff --git a/models/apis/kinesisanalytics/2015-08-14/docs-2.json b/models/apis/kinesisanalytics/2015-08-14/docs-2.json index 5f02814f0c6..06e6949c069 100644 --- a/models/apis/kinesisanalytics/2015-08-14/docs-2.json +++ b/models/apis/kinesisanalytics/2015-08-14/docs-2.json @@ -2,11 +2,13 @@ "version": "2.0", "service": null, "operations": { + "AddApplicationCloudWatchLoggingOption": "

Adds a CloudWatch log stream to monitor application configuration errors. For more information about using CloudWatch log streams with Amazon Kinesis Analytics applications, see Monitoring Configuration Errors.

", "AddApplicationInput": "

Adds a streaming source to your Amazon Kinesis application. For conceptual information, see Configuring Application Input.

You can add a streaming source either when you create an application or you can use this operation to add a streaming source after you create an application. For more information, see CreateApplication.

Any configuration update, including adding a streaming source using this operation, results in a new version of the application. You can use the DescribeApplication operation to find the current application version.

This operation requires permissions to perform the kinesisanalytics:AddApplicationInput action.

", "AddApplicationOutput": "

Adds an external destination to your Amazon Kinesis Analytics application.

If you want Amazon Kinesis Analytics to deliver data from an in-application stream within your application to an external destination (such as an Amazon Kinesis stream or a Firehose delivery stream), you add the relevant configuration to your application using this operation. You can configure one or more outputs for your application. Each output configuration maps an in-application stream and an external destination.

You can use one of the output configurations to deliver data from your in-application error stream to an external destination so that you can analyze the errors. For conceptual information, see Understanding Application Output (Destination).

Note that any configuration update, including adding a streaming source using this operation, results in a new version of the application. You can use the DescribeApplication operation to find the current application version.

For the limits on the number of application inputs and outputs you can configure, see Limits.

This operation requires permissions to perform the kinesisanalytics:AddApplicationOutput action.

", "AddApplicationReferenceDataSource": "

Adds a reference data source to an existing application.

Amazon Kinesis Analytics reads reference data (that is, an Amazon S3 object) and creates an in-application table within your application. In the request, you provide the source (S3 bucket name and object key name), name of the in-application table to create, and the necessary mapping information that describes how data in Amazon S3 object maps to columns in the resulting in-application table.

For conceptual information, see Configuring Application Input. For the limits on data sources you can add to your application, see Limits.

This operation requires permissions to perform the kinesisanalytics:AddApplicationOutput action.

", - "CreateApplication": "

Creates an Amazon Kinesis Analytics application. You can configure each application with one streaming source as input, application code to process the input, and up to five streaming destinations where you want Amazon Kinesis Analytics to write the output data from your application. For an overview, see How it Works.

In the input configuration, you map the streaming source to an in-application stream, which you can think of as a constantly updating table. In the mapping, you must provide a schema for the in-application stream and map each data column in the in-application stream to a data element in the streaming source, with the option of renaming, casting and dropping columns as desired.

Your application code is one or more SQL statements that read input data, transform it, and generate output. Your application code can create one or more SQL artifacts like SQL streams or pumps.

In the output configuration, you can configure the application to write data from in-application streams created in your applications to up to five streaming destinations.

To read data from your source stream or write data to destination streams, Amazon Kinesis Analytics needs your permissions. You grant these permissions by creating IAM roles. This operation requires permissions to perform the kinesisanalytics:CreateApplication action.

For introductory exercises to create an Amazon Kinesis Analytics application, see Getting Started.

", + "CreateApplication": "

Creates an Amazon Kinesis Analytics application. You can configure each application with one streaming source as input, application code to process the input, and up to five streaming destinations where you want Amazon Kinesis Analytics to write the output data from your application. For an overview, see How it Works.

In the input configuration, you map the streaming source to an in-application stream, which you can think of as a constantly updating table. In the mapping, you must provide a schema for the in-application stream and map each data column in the in-application stream to a data element in the streaming source.

Your application code is one or more SQL statements that read input data, transform it, and generate output. Your application code can create one or more SQL artifacts like SQL streams or pumps.

In the output configuration, you can configure the application to write data from in-application streams created in your applications to up to five streaming destinations.

To read data from your source stream or write data to destination streams, Amazon Kinesis Analytics needs your permissions. You grant these permissions by creating IAM roles. This operation requires permissions to perform the kinesisanalytics:CreateApplication action.

For introductory exercises to create an Amazon Kinesis Analytics application, see Getting Started.

", "DeleteApplication": "

Deletes the specified application. Amazon Kinesis Analytics halts application execution and deletes the application, including any application artifacts (such as in-application streams, reference table, and application code).

This operation requires permissions to perform the kinesisanalytics:DeleteApplication action.

", + "DeleteApplicationCloudWatchLoggingOption": "

Deletes a CloudWatch log stream from an application. For more information about using CloudWatch log streams with Amazon Kinesis Analytics applications, see Monitoring Configuration Errors.

", "DeleteApplicationOutput": "

Deletes output destination configuration from your application configuration. Amazon Kinesis Analytics will no longer write data from the corresponding in-application stream to the external output destination.

This operation requires permissions to perform the kinesisanalytics:DeleteApplicationOutput action.

", "DeleteApplicationReferenceDataSource": "

Deletes a reference data source configuration from the specified application configuration.

If the application is running, Amazon Kinesis Analytics immediately removes the in-application table that you created using the AddApplicationReferenceDataSource operation.

This operation requires permissions to perform the kinesisanalytics.DeleteApplicationReferenceDataSource action.

", "DescribeApplication": "

Returns information about a specific Amazon Kinesis Analytics application.

If you want to retrieve a list of all applications in your account, use the ListApplications operation.

This operation requires permissions to perform the kinesisanalytics:DescribeApplication action. You can use DescribeApplication to get the current application versionId, which you need to call other operations such as Update.

", @@ -14,9 +16,19 @@ "ListApplications": "

Returns a list of Amazon Kinesis Analytics applications in your account. For each application, the response includes the application name, Amazon Resource Name (ARN), and status. If the response returns the HasMoreApplications value as true, you can send another request by adding the ExclusiveStartApplicationName in the request body, and set the value of this to the last application name from the previous response.

If you want detailed information about a specific application, use DescribeApplication.

This operation requires permissions to perform the kinesisanalytics:ListApplications action.

", "StartApplication": "

Starts the specified Amazon Kinesis Analytics application. After creating an application, you must exclusively call this operation to start your application.

After the application starts, it begins consuming the input data, processes it, and writes the output to the configured destination.

The application status must be READY for you to start an application. You can get the application status in the console or using the DescribeApplication operation.

After you start the application, you can stop the application from processing the input by calling the StopApplication operation.

This operation requires permissions to perform the kinesisanalytics:StartApplication action.

", "StopApplication": "

Stops the application from processing input data. You can stop an application only if it is in the running state. You can use the DescribeApplication operation to find the application state. After the application is stopped, Amazon Kinesis Analytics stops reading data from the input, the application stops processing data, and there is no output written to the destination.

This operation requires permissions to perform the kinesisanalytics:StopApplication action.

", - "UpdateApplication": "

Updates an existing Kinesis Analytics application. Using this API, you can update application code, input configuration, and output configuration.

Note that Kinesis Analytics updates the CurrentApplicationVersionId each time you update your application.

This opeation requires permission for the kinesisanalytics:UpdateApplication action.

" + "UpdateApplication": "

Updates an existing Amazon Kinesis Analytics application. Using this API, you can update application code, input configuration, and output configuration.

Note that Amazon Kinesis Analytics updates the CurrentApplicationVersionId each time you update your application.

This operation requires permission for the kinesisanalytics:UpdateApplication action.

" }, "shapes": { + "AddApplicationCloudWatchLoggingOptionRequest": { + "base": null, + "refs": { + } + }, + "AddApplicationCloudWatchLoggingOptionResponse": { + "base": null, + "refs": { + } + }, "AddApplicationInputRequest": { "base": "

", "refs": { @@ -52,7 +64,7 @@ "refs": { "ApplicationDetail$ApplicationCode": "

Returns the application code that you provided to perform data analysis on any of the in-application streams in your application.

", "ApplicationUpdate$ApplicationCodeUpdate": "

Describes application code updates.

", - "CreateApplicationRequest$ApplicationCode": "

One or more SQL statements that read input data, transform it, and generate output. For example, you can write a SQL statement that reads input data and generates a running average of the number of advertisement clicks by vendor.

You can also provide a series of SQL statements, where output of one statement can be used as the input for the next statement.

Note that the application code must create the streams with names specified in the Outputs. For example, if your Outputs defines output streams named ExampleOutputStream1 and ExampleOutputStream2, then your application code must create these streams.

" + "CreateApplicationRequest$ApplicationCode": "

One or more SQL statements that read input data, transform it, and generate output. For example, you can write a SQL statement that reads data from one in-application stream, generates a running average of the number of advertisement clicks by vendor, and insert resulting rows in another in-application stream using pumps. For more inforamtion about the typical pattern, see Application Code.

You can provide such series of SQL statements, where output of one statement can be used as the input for the next statement. You store intermediate results by creating in-application streams and pumps.

Note that the application code must create the streams with names specified in the Outputs. For example, if your Outputs defines output streams named ExampleOutputStream1 and ExampleOutputStream2, then your application code must create these streams.

" } }, "ApplicationDescription": { @@ -71,12 +83,14 @@ "ApplicationName": { "base": null, "refs": { + "AddApplicationCloudWatchLoggingOptionRequest$ApplicationName": "

The Amazon Kinesis Analytics application name.

", "AddApplicationInputRequest$ApplicationName": "

Name of your existing Amazon Kinesis Analytics application to which you want to add the streaming source.

", "AddApplicationOutputRequest$ApplicationName": "

Name of the application to which you want to add the output configuration.

", "AddApplicationReferenceDataSourceRequest$ApplicationName": "

Name of an existing application.

", "ApplicationDetail$ApplicationName": "

Name of the application.

", "ApplicationSummary$ApplicationName": "

Name of the application.

", "CreateApplicationRequest$ApplicationName": "

Name of your Amazon Kinesis Analytics application (for example, sample-app).

", + "DeleteApplicationCloudWatchLoggingOptionRequest$ApplicationName": "

The Amazon Kinesis Analytics application name.

", "DeleteApplicationOutputRequest$ApplicationName": "

Amazon Kinesis Analytics application name.

", "DeleteApplicationReferenceDataSourceRequest$ApplicationName": "

Name of an existing application.

", "DeleteApplicationRequest$ApplicationName": "

Name of the Amazon Kinesis Analytics application to delete.

", @@ -84,7 +98,7 @@ "ListApplicationsRequest$ExclusiveStartApplicationName": "

Name of the application to start the list with. When using pagination to retrieve the list, you don't need to specify this parameter in the first request. However, in subsequent requests, you add the last application name from the previous response to get the next page of applications.

", "StartApplicationRequest$ApplicationName": "

Name of the application.

", "StopApplicationRequest$ApplicationName": "

Name of the running application to stop.

", - "UpdateApplicationRequest$ApplicationName": "

Name of the Kinesis Analytics application to update.

" + "UpdateApplicationRequest$ApplicationName": "

Name of the Amazon Kinesis Analytics application to update.

" } }, "ApplicationStatus": { @@ -108,7 +122,7 @@ } }, "ApplicationUpdate": { - "base": "

Describes updates to apply to an existing Kinesis Analytics application.

", + "base": "

Describes updates to apply to an existing Amazon Kinesis Analytics application.

", "refs": { "UpdateApplicationRequest$ApplicationUpdate": "

Describes application updates.

" } @@ -116,10 +130,12 @@ "ApplicationVersionId": { "base": null, "refs": { + "AddApplicationCloudWatchLoggingOptionRequest$CurrentApplicationVersionId": "

The version ID of the Amazon Kinesis Analytics application.

", "AddApplicationInputRequest$CurrentApplicationVersionId": "

Current version of your Amazon Kinesis Analytics application. You can use the DescribeApplication operation to find the current application version.

", "AddApplicationOutputRequest$CurrentApplicationVersionId": "

Version of the application to which you want add the output configuration. You can use the DescribeApplication operation to get the current application version. If the version specified is not the current version, the ConcurrentModificationException is returned.

", "AddApplicationReferenceDataSourceRequest$CurrentApplicationVersionId": "

Version of the application for which you are adding the reference data source. You can use the DescribeApplication operation to get the current application version. If the version specified is not the current version, the ConcurrentModificationException is returned.

", "ApplicationDetail$ApplicationVersionId": "

Provides the current application version.

", + "DeleteApplicationCloudWatchLoggingOptionRequest$CurrentApplicationVersionId": "

The version ID of the Amazon Kinesis Analytics application.

", "DeleteApplicationOutputRequest$CurrentApplicationVersionId": "

Amazon Kinesis Analytics application version. You can use the DescribeApplication operation to get the current application version. If the version specified is not the current version, the ConcurrentModificationException is returned.

", "DeleteApplicationReferenceDataSourceRequest$CurrentApplicationVersionId": "

Version of the application. You can use the DescribeApplication operation to get the current application version. If the version specified is not the current version, the ConcurrentModificationException is returned.

", "UpdateApplicationRequest$CurrentApplicationVersionId": "

The current application version ID. You can use the DescribeApplication operation to get this value.

" @@ -145,6 +161,43 @@ "MappingParameters$CSVMappingParameters": "

Provides additional mapping information when the record format uses delimiters (for example, CSV).

" } }, + "CloudWatchLoggingOption": { + "base": "

Provides a description of CloudWatch logging options, including the log stream ARN and the role ARN.

", + "refs": { + "AddApplicationCloudWatchLoggingOptionRequest$CloudWatchLoggingOption": "

Provide the CloudWatch log stream ARN and the IAM role ARN. Note: To write application messages to CloudWatch, the IAM role used must have the PutLogEvents policy action enabled.

", + "CloudWatchLoggingOptions$member": null + } + }, + "CloudWatchLoggingOptionDescription": { + "base": "

Description of the CloudWatch logging option.

", + "refs": { + "CloudWatchLoggingOptionDescriptions$member": null + } + }, + "CloudWatchLoggingOptionDescriptions": { + "base": null, + "refs": { + "ApplicationDetail$CloudWatchLoggingOptionDescriptions": "

Describes the CloudWatch log streams configured to receive application messages. For more information about using CloudWatch log streams with Amazon Kinesis Analytics applications, see Monitoring Configuration Errors.

" + } + }, + "CloudWatchLoggingOptionUpdate": { + "base": "

Describes CloudWatch logging option updates.

", + "refs": { + "CloudWatchLoggingOptionUpdates$member": null + } + }, + "CloudWatchLoggingOptionUpdates": { + "base": null, + "refs": { + "ApplicationUpdate$CloudWatchLoggingOptionUpdates": "

Describes application CloudWatch logging option updates.

" + } + }, + "CloudWatchLoggingOptions": { + "base": null, + "refs": { + "CreateApplicationRequest$CloudWatchLoggingOptions": "

Use this parameter to configure a CloudWatch log stream to monitor application configuration errors. For more information, see Monitoring Configuration Errors.

" + } + }, "CodeValidationException": { "base": "

User-provided application code (query) is invalid. This can be a simple syntax error.

", "refs": { @@ -165,6 +218,16 @@ "refs": { } }, + "DeleteApplicationCloudWatchLoggingOptionRequest": { + "base": null, + "refs": { + } + }, + "DeleteApplicationCloudWatchLoggingOptionResponse": { + "base": null, + "refs": { + } + }, "DeleteApplicationOutputRequest": { "base": "

", "refs": { @@ -248,6 +311,9 @@ "Id": { "base": null, "refs": { + "CloudWatchLoggingOptionDescription$CloudWatchLoggingOptionId": "

ID of the CloudWatch logging option description.

", + "CloudWatchLoggingOptionUpdate$CloudWatchLoggingOptionId": "

ID of the CloudWatch logging option to update

", + "DeleteApplicationCloudWatchLoggingOptionRequest$CloudWatchLoggingOptionId": "

The CloudWatchLoggingOptionId of the CloudWatch logging option to delete. You can use the DescribeApplication operation to get the CloudWatchLoggingOptionId.

", "DeleteApplicationOutputRequest$OutputId": "

The ID of the configuration to delete. Each output configuration that is added to the application, either when the application is created or later using the AddApplicationOutput operation, has a unique ID. You need to provide the ID to uniquely identify the output configuration that you want to delete from the application configuration. You can use the DescribeApplication operation to get the specific OutputId.

", "DeleteApplicationReferenceDataSourceRequest$ReferenceId": "

ID of the reference data source. When you add a reference data source to your application using the AddApplicationReferenceDataSource, Amazon Kinesis Analytics assigns an ID. You can use the DescribeApplication operation to get the reference ID.

", "InputConfiguration$Id": "

Input source ID. You can get this ID by calling the DescribeApplication operation.

", @@ -263,9 +329,9 @@ "base": null, "refs": { "InAppStreamNames$member": null, - "Input$NamePrefix": "

Name prefix to use when creating in-application stream. Suppose you specify a prefix \"MyInApplicationStream\". Kinesis Analytics will then create one or more (as per the InputParallelism count you specified) in-application streams with names \"MyInApplicationStream_001\", \"MyInApplicationStream_002\" and so on.

", + "Input$NamePrefix": "

Name prefix to use when creating in-application stream. Suppose you specify a prefix \"MyInApplicationStream\". Amazon Kinesis Analytics will then create one or more (as per the InputParallelism count you specified) in-application streams with names \"MyInApplicationStream_001\", \"MyInApplicationStream_002\" and so on.

", "InputDescription$NamePrefix": "

In-application name prefix.

", - "InputUpdate$NamePrefixUpdate": "

Name prefix for in-application stream(s) that Kinesis Analytics creates for the specific streaming source.

", + "InputUpdate$NamePrefixUpdate": "

Name prefix for in-application streams that Amazon Kinesis Analytics creates for the specific streaming source.

", "Output$Name": "

Name of the in-application stream.

", "OutputDescription$Name": "

Name of the in-application stream configured as output.

", "OutputUpdate$NameUpdate": "

If you want to specify a different in-application stream for this output configuration, use this field to specify the new in-application stream name.

" @@ -288,7 +354,7 @@ "Input": { "base": "

When you configure the application input, you specify the streaming source, the in-application stream name that is created, and the mapping between the two. For more information, see Configuring Application Input.

", "refs": { - "AddApplicationInputRequest$Input": null, + "AddApplicationInputRequest$Input": "

", "Inputs$member": null } }, @@ -317,7 +383,7 @@ } }, "InputParallelism": { - "base": "

Describes the number of in-application streams to create for a given streaming source. For information about parallellism, see Configuring Application Input.

", + "base": "

Describes the number of in-application streams to create for a given streaming source. For information about parallelism, see Configuring Application Input.

", "refs": { "Input$InputParallelism": "

Describes the number of in-application streams to create.

Data from your source will be routed to these in-application input streams.

(see Configuring Application Input.

", "InputDescription$InputParallelism": "

Describes the configured parallelism (number of in-application streams mapped to the streaming source).

" @@ -333,7 +399,7 @@ "InputParallelismUpdate": { "base": "

Provides updates to the parallelism count.

", "refs": { - "InputUpdate$InputParallelismUpdate": "

Describes the parallelism updates (the number in-application streams Kinesis Analytics creates for the specific streaming source).

" + "InputUpdate$InputParallelismUpdate": "

Describes the parallelism updates (the number in-application streams Amazon Kinesis Analytics creates for the specific streaming source).

" } }, "InputSchemaUpdate": { @@ -345,7 +411,7 @@ "InputStartingPosition": { "base": null, "refs": { - "InputStartingPositionConfiguration$InputStartingPosition": "

The starting position on the stream.

" + "InputStartingPositionConfiguration$InputStartingPosition": "

The starting position on the stream.

" } }, "InputStartingPositionConfiguration": { @@ -483,6 +549,14 @@ "refs": { } }, + "LogStreamARN": { + "base": null, + "refs": { + "CloudWatchLoggingOption$LogStreamARN": "

ARN of the CloudWatch log to receive application messages.

", + "CloudWatchLoggingOptionDescription$LogStreamARN": "

ARN of the CloudWatch log to receive application messages.

", + "CloudWatchLoggingOptionUpdate$LogStreamARNUpdate": "

ARN of the CloudWatch log to receive application messages.

" + } + }, "MappingParameters": { "base": "

When configuring application input at the time of creating or updating an application, provides additional mapping information specific to the record format (such as JSON, CSV, or record fields delimited by some delimiter) on the streaming source.

", "refs": { @@ -490,7 +564,7 @@ } }, "Output": { - "base": "

Describes application output configuration in which you identify an in-application stream and a destination where you want the in-application stream data to be written. The destination can be an Amazon Kinesis stream or an Amazon Kinesis Firehose delivery stream.

You can configure your application to write output to up to five destinations.

", + "base": "

Describes application output configuration in which you identify an in-application stream and a destination where you want the in-application stream data to be written. The destination can be an Amazon Kinesis stream or an Amazon Kinesis Firehose delivery stream.

For limits on how many destinations an application can write and other limitations, see Limits.

", "refs": { "AddApplicationOutputRequest$Output": "

An array of objects, each describing one output configuration. In the output configuration, you specify the name of an in-application stream, a destination (that is, an Amazon Kinesis stream or an Amazon Kinesis Firehose delivery stream), and record the formation to use when writing to the destination.

", "Outputs$member": null @@ -688,13 +762,16 @@ } }, "ResourceProvisionedThroughputExceededException": { - "base": "

Discovery failed to get a record from the streaming source because of the Kinesis Streams ProvisionedThroughputExceededException.

", + "base": "

Discovery failed to get a record from the streaming source because of the Amazon Kinesis Streams ProvisionedThroughputExceededException. For more information, see GetRecords in the Amazon Kinesis Streams API Reference.

", "refs": { } }, "RoleARN": { "base": null, "refs": { + "CloudWatchLoggingOption$RoleARN": "

IAM ARN of the role to use to send application messages. Note: To write application messages to CloudWatch, the IAM role used must have the PutLogEvents policy action enabled.

", + "CloudWatchLoggingOptionDescription$RoleARN": "

IAM ARN of the role to use to send application messages. Note: To write application messages to CloudWatch, the IAM role used must have the PutLogEvents policy action enabled.

", + "CloudWatchLoggingOptionUpdate$RoleARNUpdate": "

IAM ARN of the role to use to send application messages. Note: To write application messages to CloudWatch, the IAM role used must have the PutLogEvents policy action enabled.

", "DiscoverInputSchemaRequest$RoleARN": "

ARN of the IAM role that Amazon Kinesis Analytics can assume to access the stream on your behalf.

", "KinesisFirehoseInput$RoleARN": "

ARN of the IAM role that Amazon Kinesis Analytics can assume to access the stream on your behalf. You need to make sure the role has necessary permissions to access the stream.

", "KinesisFirehoseInputDescription$RoleARN": "

ARN of the IAM role that Amazon Kinesis Analytics assumes to access the stream.

", @@ -771,7 +848,7 @@ } }, "UnableToDetectSchemaException": { - "base": "

Data format is not valid, Kinesis Analytics is not able to detect schema for the given streaming source.

", + "base": "

Data format is not valid, Amazon Kinesis Analytics is not able to detect schema for the given streaming source.

", "refs": { } }, diff --git a/models/apis/kinesisanalytics/2015-08-14/paginators-1.json b/models/apis/kinesisanalytics/2015-08-14/paginators-1.json new file mode 100644 index 00000000000..5677bd8e4a2 --- /dev/null +++ b/models/apis/kinesisanalytics/2015-08-14/paginators-1.json @@ -0,0 +1,4 @@ +{ + "pagination": { + } +} diff --git a/models/apis/lex-models/2017-04-19/docs-2.json b/models/apis/lex-models/2017-04-19/docs-2.json index 171da4cb0c3..94d1f22bdd3 100644 --- a/models/apis/lex-models/2017-04-19/docs-2.json +++ b/models/apis/lex-models/2017-04-19/docs-2.json @@ -104,7 +104,7 @@ "DeleteBotChannelAssociationRequest$name": "

The name of the association. The name is case sensitive.

", "GetBotChannelAssociationRequest$name": "

The name of the association between the bot and the channel. The name is case sensitive.

", "GetBotChannelAssociationResponse$name": "

The name of the association between the bot and the channel.

", - "GetBotChannelAssociationsRequest$nameContains": "

Substring to match in channel association names. An association will be returned if any part of its name matches the substring. For example, \"xyz\" matches both \"xyzabc\" and \"abcxyz.\"

" + "GetBotChannelAssociationsRequest$nameContains": "

Substring to match in channel association names. An association will be returned if any part of its name matches the substring. For example, \"xyz\" matches both \"xyzabc\" and \"abcxyz.\" To return all bot channel associations, use a hyphen (\"-\") as the nameContains parameter.

" } }, "BotMetadata": { @@ -974,7 +974,7 @@ "ConflictException$message": null, "CreateBotVersionRequest$checksum": "

Identifies a specific revision of the $LATEST version of the bot. If you specify a checksum and the $LATEST version of the bot has a different checksum, a PreconditionFailedException exception is returned and Amazon Lex doesn't publish a new version. If you don't specify a checksum, Amazon Lex publishes the $LATEST version.

", "CreateBotVersionResponse$failureReason": "

If status is FAILED, Amazon Lex provides the reason that it failed to build the bot.

", - "CreateBotVersionResponse$voiceId": "

The Amazon Parrot voice ID that Amazon Lex uses for voice interactions with the user.

", + "CreateBotVersionResponse$voiceId": "

The Amazon Polly voice ID that Amazon Lex uses for voice interactions with the user.

", "CreateBotVersionResponse$checksum": "

Checksum identifying the version of the bot that was created.

", "CreateIntentVersionRequest$checksum": "

Checksum of the $LATEST version of the intent that should be used to create the new version. If you specify a checksum and the $LATEST version of the intent has a different checksum, Amazon Lex returns a PreconditionFailedException exception and doesn't publish a new version. If you don't specify a checksum, Amazon Lex publishes the $LATEST version.

", "CreateIntentVersionResponse$checksum": "

Checksum of the intent version created.

", @@ -983,7 +983,7 @@ "GetBotAliasResponse$checksum": "

Checksum of the bot alias.

", "GetBotRequest$versionOrAlias": "

The version or alias of the bot.

", "GetBotResponse$failureReason": "

If status is FAILED, Amazon Lex explains why it failed to build the bot.

", - "GetBotResponse$voiceId": "

The Amazon Parrot voice ID that Amazon Lex uses for voice interaction with the user. For more information, see .

", + "GetBotResponse$voiceId": "

The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the user. For more information, see .

", "GetBotResponse$checksum": "

Checksum of the bot used to identify a specific revision of the bot's $LATEST version.

", "GetBuiltinIntentsRequest$signatureContains": "

Substring to match in built-in intent signatures. An intent will be returned if any part of its signature matches the substring. For example, \"xyz\" matches both \"xyzabc\" and \"abcxyz.\" To find the signature for an intent, see Standard Built-in Intents in the Alexa Skills Kit.

", "GetBuiltinSlotTypesRequest$signatureContains": "

Substring to match in built-in slot type signatures. A slot type will be returned if any part of its signature matches the substring. For example, \"xyz\" matches both \"xyzabc\" and \"abcxyz.\"

", @@ -996,10 +996,10 @@ "PreconditionFailedException$message": null, "PutBotAliasRequest$checksum": "

Identifies a specific revision of the $LATEST version.

When you create a new bot alias, leave the checksum field blank. If you specify a checksum you get a BadRequestException exception.

When you want to update a bot alias, set the checksum field to the checksum of the most recent revision of the $LATEST version. If you don't specify the checksum field, or if the checksum does not match the $LATEST version, you get a PreconditionFailedException exception.

", "PutBotAliasResponse$checksum": "

The checksum for the current version of the alias.

", - "PutBotRequest$voiceId": "

The Amazon Parrot voice ID that you want Amazon Lex to use for voice interactions with the user. The locale configured for the voice must match the locale of the bot. For more information, see Voice in the Amazon Polly Developer Guide.

", + "PutBotRequest$voiceId": "

The Amazon Polly voice ID that you want Amazon Lex to use for voice interactions with the user. The locale configured for the voice must match the locale of the bot. For more information, see Voice in the Amazon Polly Developer Guide.

", "PutBotRequest$checksum": "

Identifies a specific revision of the $LATEST version.

When you create a new bot, leave the checksum field blank. If you specify a checksum you get a BadRequestException exception.

When you want to update a bot, set the checksum field to the checksum of the most recent revision of the $LATEST version. If you don't specify the checksum field, or if the checksum does not match the $LATEST version, you get a PreconditionFailedException exception.

", "PutBotResponse$failureReason": "

If status is FAILED, Amazon Lex provides the reason that it failed to build the bot.

", - "PutBotResponse$voiceId": "

The Amazon Parrot voice ID that Amazon Lex uses for voice interaction with the user. For more information, see .

", + "PutBotResponse$voiceId": "

The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the user. For more information, see .

", "PutBotResponse$checksum": "

Checksum of the bot that you created.

", "PutIntentRequest$checksum": "

Identifies a specific revision of the $LATEST version.

When you create a new intent, leave the checksum field blank. If you specify a checksum you get a BadRequestException exception.

When you want to update a intent, set the checksum field to the checksum of the most recent revision of the $LATEST version. If you don't specify the checksum field, or if the checksum does not match the $LATEST version, you get a PreconditionFailedException exception.

", "PutIntentResponse$checksum": "

Checksum of the $LATESTversion of the intent created or updated.

", diff --git a/models/apis/lex-models/2017-04-19/examples-1.json b/models/apis/lex-models/2017-04-19/examples-1.json index 0ea7e3b0bbe..4a56e6e1476 100644 --- a/models/apis/lex-models/2017-04-19/examples-1.json +++ b/models/apis/lex-models/2017-04-19/examples-1.json @@ -1,5 +1,758 @@ { "version": "1.0", "examples": { + "GetBot": [ + { + "input": { + "name": "DocOrderPizza", + "versionOrAlias": "$LATEST" + }, + "output": { + "version": "$LATEST", + "name": "DocOrderPizzaBot", + "abortStatement": { + "messages": [ + { + "content": "I don't understand. Can you try again?", + "contentType": "PlainText" + }, + { + "content": "I'm sorry, I don't understand.", + "contentType": "PlainText" + } + ] + }, + "checksum": "20172ee3-fa06-49b2-bbc5-667c090303e9", + "childDirected": true, + "clarificationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "I'm sorry, I didn't hear that. Can you repeate what you just said?", + "contentType": "PlainText" + }, + { + "content": "Can you say that again?", + "contentType": "PlainText" + } + ] + }, + "createdDate": 1494360160.133, + "description": "Orders a pizza from a local pizzeria.", + "idleSessionTTLInSeconds": 300, + "intents": [ + { + "intentName": "DocOrderPizza", + "intentVersion": "$LATEST" + } + ], + "lastUpdatedDate": 1494360160.133, + "locale": "en-US", + "status": "NOT_BUILT" + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get configuration information for a bot.", + "id": "to-get-information-about-a-bot-1494431724188", + "title": "To get information about a bot" + } + ], + "GetBots": [ + { + "input": { + "maxResults": 5, + "nextToken": "" + }, + "output": { + "bots": [ + { + "version": "$LATEST", + "name": "DocOrderPizzaBot", + "createdDate": 1494360160.133, + "description": "Orders a pizza from a local pizzeria.", + "lastUpdatedDate": 1494360160.133, + "status": "NOT_BUILT" + } + ] + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get a list of all of the bots in your account.", + "id": "to-get-a-list-of-bots-1494432220036", + "title": "To get a list of bots" + } + ], + "GetIntent": [ + { + "input": { + "version": "$LATEST", + "name": "DocOrderPizza" + }, + "output": { + "version": "$LATEST", + "name": "DocOrderPizza", + "checksum": "ca9bc13d-afc8-4706-bbaf-091f7a5935d6", + "conclusionStatement": { + "messages": [ + { + "content": "All right, I ordered you a {Crust} crust {Type} pizza with {Sauce} sauce.", + "contentType": "PlainText" + }, + { + "content": "OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way.", + "contentType": "PlainText" + } + ], + "responseCard": "foo" + }, + "confirmationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "Should I order your {Crust} crust {Type} pizza with {Sauce} sauce?", + "contentType": "PlainText" + } + ] + }, + "createdDate": 1494359783.453, + "description": "Order a pizza from a local pizzeria.", + "fulfillmentActivity": { + "type": "ReturnIntent" + }, + "lastUpdatedDate": 1494359783.453, + "rejectionStatement": { + "messages": [ + { + "content": "Ok, I'll cancel your order.", + "contentType": "PlainText" + }, + { + "content": "I cancelled your order.", + "contentType": "PlainText" + } + ] + }, + "sampleUtterances": [ + "Order me a pizza.", + "Order me a {Type} pizza.", + "I want a {Crust} crust {Type} pizza", + "I want a {Crust} crust {Type} pizza with {Sauce} sauce." + ], + "slots": [ + { + "name": "Type", + "description": "The type of pizza to order.", + "priority": 1, + "sampleUtterances": [ + "Get me a {Type} pizza.", + "A {Type} pizza please.", + "I'd like a {Type} pizza." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of pizza would you like?", + "contentType": "PlainText" + }, + { + "content": "Vegie or cheese pizza?", + "contentType": "PlainText" + }, + { + "content": "I can get you a vegie or a cheese pizza.", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Crust", + "description": "The type of pizza crust to order.", + "priority": 2, + "sampleUtterances": [ + "Make it a {Crust} crust.", + "I'd like a {Crust} crust." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaCrustType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of crust would you like?", + "contentType": "PlainText" + }, + { + "content": "Thick or thin crust?", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Sauce", + "description": "The type of sauce to use on the pizza.", + "priority": 3, + "sampleUtterances": [ + "Make it {Sauce} sauce.", + "I'd like {Sauce} sauce." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaSauceType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "White or red sauce?", + "contentType": "PlainText" + }, + { + "content": "Garlic or tomato sauce?", + "contentType": "PlainText" + } + ] + } + } + ] + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get information about an intent.", + "id": "to-get-a-information-about-an-intent-1494432574147", + "title": "To get a information about an intent" + } + ], + "GetIntents": [ + { + "input": { + "maxResults": 10, + "nextToken": "" + }, + "output": { + "intents": [ + { + "version": "$LATEST", + "name": "DocOrderPizza", + "createdDate": 1494359783.453, + "description": "Order a pizza from a local pizzeria.", + "lastUpdatedDate": 1494359783.453 + } + ] + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get a list of all of the intents in your account.", + "id": "to-get-a-list-of-intents-1494432416363", + "title": "To get a list of intents" + } + ], + "GetSlotType": [ + { + "input": { + "version": "$LATEST", + "name": "DocPizzaCrustType" + }, + "output": { + "version": "$LATEST", + "name": "DocPizzaCrustType", + "checksum": "210b3d5a-90a3-4b22-ac7e-f50c2c71095f", + "createdDate": 1494359274.403, + "description": "Available crust types", + "enumerationValues": [ + { + "value": "thick" + }, + { + "value": "thin" + } + ], + "lastUpdatedDate": 1494359274.403 + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get information about a slot type.", + "id": "to-get-information-about-a-slot-type-1494432961004", + "title": "To get information about a slot type" + } + ], + "GetSlotTypes": [ + { + "input": { + "maxResults": 10, + "nextToken": "" + }, + "output": { + "slotTypes": [ + { + "version": "$LATEST", + "name": "DocPizzaCrustType", + "createdDate": 1494359274.403, + "description": "Available crust types", + "lastUpdatedDate": 1494359274.403 + }, + { + "version": "$LATEST", + "name": "DocPizzaSauceType", + "createdDate": 1494356442.23, + "description": "Available pizza sauces", + "lastUpdatedDate": 1494356442.23 + }, + { + "version": "$LATEST", + "name": "DocPizzaType", + "createdDate": 1494359198.656, + "description": "Available pizzas", + "lastUpdatedDate": 1494359198.656 + } + ] + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to get a list of all of the slot types in your account.", + "id": "to-get-a-list-of-slot-types-1494432757458", + "title": "To get a list of slot types" + } + ], + "PutBot": [ + { + "input": { + "name": "DocOrderPizzaBot", + "abortStatement": { + "messages": [ + { + "content": "I don't understand. Can you try again?", + "contentType": "PlainText" + }, + { + "content": "I'm sorry, I don't understand.", + "contentType": "PlainText" + } + ] + }, + "childDirected": true, + "clarificationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "I'm sorry, I didn't hear that. Can you repeate what you just said?", + "contentType": "PlainText" + }, + { + "content": "Can you say that again?", + "contentType": "PlainText" + } + ] + }, + "description": "Orders a pizza from a local pizzeria.", + "idleSessionTTLInSeconds": 300, + "intents": [ + { + "intentName": "DocOrderPizza", + "intentVersion": "$LATEST" + } + ], + "locale": "en-US", + "processBehavior": "SAVE" + }, + "output": { + "version": "$LATEST", + "name": "DocOrderPizzaBot", + "abortStatement": { + "messages": [ + { + "content": "I don't understand. Can you try again?", + "contentType": "PlainText" + }, + { + "content": "I'm sorry, I don't understand.", + "contentType": "PlainText" + } + ] + }, + "checksum": "20172ee3-fa06-49b2-bbc5-667c090303e9", + "childDirected": true, + "clarificationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "I'm sorry, I didn't hear that. Can you repeate what you just said?", + "contentType": "PlainText" + }, + { + "content": "Can you say that again?", + "contentType": "PlainText" + } + ] + }, + "createdDate": 1494360160.133, + "description": "Orders a pizza from a local pizzeria.", + "idleSessionTTLInSeconds": 300, + "intents": [ + { + "intentName": "DocOrderPizza", + "intentVersion": "$LATEST" + } + ], + "lastUpdatedDate": 1494360160.133, + "locale": "en-US", + "status": "NOT_BUILT" + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to create a bot for ordering pizzas.", + "id": "to-create-a-bot-1494360003886", + "title": "To create a bot" + } + ], + "PutIntent": [ + { + "input": { + "name": "DocOrderPizza", + "conclusionStatement": { + "messages": [ + { + "content": "All right, I ordered you a {Crust} crust {Type} pizza with {Sauce} sauce.", + "contentType": "PlainText" + }, + { + "content": "OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way.", + "contentType": "PlainText" + } + ], + "responseCard": "foo" + }, + "confirmationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "Should I order your {Crust} crust {Type} pizza with {Sauce} sauce?", + "contentType": "PlainText" + } + ] + }, + "description": "Order a pizza from a local pizzeria.", + "fulfillmentActivity": { + "type": "ReturnIntent" + }, + "rejectionStatement": { + "messages": [ + { + "content": "Ok, I'll cancel your order.", + "contentType": "PlainText" + }, + { + "content": "I cancelled your order.", + "contentType": "PlainText" + } + ] + }, + "sampleUtterances": [ + "Order me a pizza.", + "Order me a {Type} pizza.", + "I want a {Crust} crust {Type} pizza", + "I want a {Crust} crust {Type} pizza with {Sauce} sauce." + ], + "slots": [ + { + "name": "Type", + "description": "The type of pizza to order.", + "priority": 1, + "sampleUtterances": [ + "Get me a {Type} pizza.", + "A {Type} pizza please.", + "I'd like a {Type} pizza." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of pizza would you like?", + "contentType": "PlainText" + }, + { + "content": "Vegie or cheese pizza?", + "contentType": "PlainText" + }, + { + "content": "I can get you a vegie or a cheese pizza.", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Crust", + "description": "The type of pizza crust to order.", + "priority": 2, + "sampleUtterances": [ + "Make it a {Crust} crust.", + "I'd like a {Crust} crust." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaCrustType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of crust would you like?", + "contentType": "PlainText" + }, + { + "content": "Thick or thin crust?", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Sauce", + "description": "The type of sauce to use on the pizza.", + "priority": 3, + "sampleUtterances": [ + "Make it {Sauce} sauce.", + "I'd like {Sauce} sauce." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaSauceType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "White or red sauce?", + "contentType": "PlainText" + }, + { + "content": "Garlic or tomato sauce?", + "contentType": "PlainText" + } + ] + } + } + ] + }, + "output": { + "version": "$LATEST", + "name": "DocOrderPizza", + "checksum": "ca9bc13d-afc8-4706-bbaf-091f7a5935d6", + "conclusionStatement": { + "messages": [ + { + "content": "All right, I ordered you a {Crust} crust {Type} pizza with {Sauce} sauce.", + "contentType": "PlainText" + }, + { + "content": "OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way.", + "contentType": "PlainText" + } + ], + "responseCard": "foo" + }, + "confirmationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "Should I order your {Crust} crust {Type} pizza with {Sauce} sauce?", + "contentType": "PlainText" + } + ] + }, + "createdDate": 1494359783.453, + "description": "Order a pizza from a local pizzeria.", + "fulfillmentActivity": { + "type": "ReturnIntent" + }, + "lastUpdatedDate": 1494359783.453, + "rejectionStatement": { + "messages": [ + { + "content": "Ok, I'll cancel your order.", + "contentType": "PlainText" + }, + { + "content": "I cancelled your order.", + "contentType": "PlainText" + } + ] + }, + "sampleUtterances": [ + "Order me a pizza.", + "Order me a {Type} pizza.", + "I want a {Crust} crust {Type} pizza", + "I want a {Crust} crust {Type} pizza with {Sauce} sauce." + ], + "slots": [ + { + "name": "Sauce", + "description": "The type of sauce to use on the pizza.", + "priority": 3, + "sampleUtterances": [ + "Make it {Sauce} sauce.", + "I'd like {Sauce} sauce." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaSauceType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "White or red sauce?", + "contentType": "PlainText" + }, + { + "content": "Garlic or tomato sauce?", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Type", + "description": "The type of pizza to order.", + "priority": 1, + "sampleUtterances": [ + "Get me a {Type} pizza.", + "A {Type} pizza please.", + "I'd like a {Type} pizza." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of pizza would you like?", + "contentType": "PlainText" + }, + { + "content": "Vegie or cheese pizza?", + "contentType": "PlainText" + }, + { + "content": "I can get you a vegie or a cheese pizza.", + "contentType": "PlainText" + } + ] + } + }, + { + "name": "Crust", + "description": "The type of pizza crust to order.", + "priority": 2, + "sampleUtterances": [ + "Make it a {Crust} crust.", + "I'd like a {Crust} crust." + ], + "slotConstraint": "Required", + "slotType": "DocPizzaCrustType", + "slotTypeVersion": "$LATEST", + "valueElicitationPrompt": { + "maxAttempts": 1, + "messages": [ + { + "content": "What type of crust would you like?", + "contentType": "PlainText" + }, + { + "content": "Thick or thin crust?", + "contentType": "PlainText" + } + ] + } + } + ] + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to create an intent for ordering pizzas.", + "id": "to-create-an-intent-1494358144659", + "title": "To create an intent" + } + ], + "PutSlotType": [ + { + "input": { + "name": "PizzaSauceType", + "description": "Available pizza sauces", + "enumerationValues": [ + { + "value": "red" + }, + { + "value": "white" + } + ] + }, + "output": { + "version": "$LATEST", + "name": "DocPizzaSauceType", + "checksum": "cfd00ed1-775d-4357-947c-aca7e73b44ba", + "createdDate": 1494356442.23, + "description": "Available pizza sauces", + "enumerationValues": [ + { + "value": "red" + }, + { + "value": "white" + } + ], + "lastUpdatedDate": 1494356442.23 + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "This example shows how to create a slot type that describes pizza sauces.", + "id": "to-create-a-slot-type-1494357262258", + "title": "To Create a Slot Type" + } + ] } } diff --git a/models/apis/rds/2014-10-31/api-2.json b/models/apis/rds/2014-10-31/api-2.json index a00178cb44f..e289f9ebf3b 100644 --- a/models/apis/rds/2014-10-31/api-2.json +++ b/models/apis/rds/2014-10-31/api-2.json @@ -1501,6 +1501,50 @@ {"shape":"AuthorizationNotFoundFault"}, {"shape":"InvalidDBSecurityGroupStateFault"} ] + }, + "StartDBInstance":{ + "name":"StartDBInstance", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"StartDBInstanceMessage"}, + "output":{ + "shape":"StartDBInstanceResult", + "resultWrapper":"StartDBInstanceResult" + }, + "errors":[ + {"shape":"DBInstanceNotFoundFault"}, + {"shape":"InvalidDBInstanceStateFault"}, + {"shape":"InsufficientDBInstanceCapacityFault"}, + {"shape":"DBSubnetGroupNotFoundFault"}, + {"shape":"DBSubnetGroupDoesNotCoverEnoughAZs"}, + {"shape":"InvalidDBClusterStateFault"}, + {"shape":"InvalidSubnet"}, + {"shape":"InvalidVPCNetworkStateFault"}, + {"shape":"DBClusterNotFoundFault"}, + {"shape":"AuthorizationNotFoundFault"}, + {"shape":"KMSKeyNotAccessibleFault"} + ] + }, + "StopDBInstance":{ + "name":"StopDBInstance", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"StopDBInstanceMessage"}, + "output":{ + "shape":"StopDBInstanceResult", + "resultWrapper":"StopDBInstanceResult" + }, + "errors":[ + {"shape":"DBInstanceNotFoundFault"}, + {"shape":"InvalidDBInstanceStateFault"}, + {"shape":"DBSnapshotAlreadyExistsFault"}, + {"shape":"SnapshotQuotaExceededFault"}, + {"shape":"InvalidDBClusterStateFault"} + ] } }, "shapes":{ @@ -4941,6 +4985,33 @@ "db-cluster-snapshot" ] }, + "StartDBInstanceMessage":{ + "type":"structure", + "required":["DBInstanceIdentifier"], + "members":{ + "DBInstanceIdentifier":{"shape":"String"} + } + }, + "StartDBInstanceResult":{ + "type":"structure", + "members":{ + "DBInstance":{"shape":"DBInstance"} + } + }, + "StopDBInstanceMessage":{ + "type":"structure", + "required":["DBInstanceIdentifier"], + "members":{ + "DBInstanceIdentifier":{"shape":"String"}, + "DBSnapshotIdentifier":{"shape":"String"} + } + }, + "StopDBInstanceResult":{ + "type":"structure", + "members":{ + "DBInstance":{"shape":"DBInstance"} + } + }, "StorageQuotaExceededFault":{ "type":"structure", "members":{ diff --git a/models/apis/rds/2014-10-31/docs-2.json b/models/apis/rds/2014-10-31/docs-2.json index 3cb192a96e1..f0467e930d4 100644 --- a/models/apis/rds/2014-10-31/docs-2.json +++ b/models/apis/rds/2014-10-31/docs-2.json @@ -88,7 +88,9 @@ "RestoreDBClusterToPointInTime": "

Restores a DB cluster to an arbitrary point in time. Users can restore to any point in time before LatestRestorableTime for up to BackupRetentionPeriod days. The target DB cluster is created from the source DB cluster with the same configuration as the original DB cluster, except that the new DB cluster is created with the default DB security group.

For more information on Amazon Aurora, see Aurora on Amazon RDS in the Amazon RDS User Guide.

", "RestoreDBInstanceFromDBSnapshot": "

Creates a new DB instance from a DB snapshot. The target database is created from the source database restore point with the most of original configuration with the default security group and the default DB parameter group. By default, the new DB instance is created as a single-AZ deployment except when the instance is a SQL Server instance that has an option group that is associated with mirroring; in this case, the instance becomes a mirrored AZ deployment and not a single-AZ deployment.

If your intent is to replace your original DB instance with the new, restored DB instance, then rename your original DB instance before you call the RestoreDBInstanceFromDBSnapshot action. RDS does not allow two DB instances with the same name. Once you have renamed your original DB instance with a different identifier, then you can pass the original name of the DB instance as the DBInstanceIdentifier in the call to the RestoreDBInstanceFromDBSnapshot action. The result is that you will replace the original DB instance with the DB instance created from the snapshot.

If you are restoring from a shared manual DB snapshot, the DBSnapshotIdentifier must be the ARN of the shared DB snapshot.

", "RestoreDBInstanceToPointInTime": "

Restores a DB instance to an arbitrary point in time. You can restore to any point in time before the time identified by the LatestRestorableTime property. You can restore to a point up to the number of days specified by the BackupRetentionPeriod property.

The target database is created with most of the original configuration, but in a system-selected availability zone, with the default security group, the default subnet group, and the default DB parameter group. By default, the new DB instance is created as a single-AZ deployment except when the instance is a SQL Server instance that has an option group that is associated with mirroring; in this case, the instance becomes a mirrored deployment and not a single-AZ deployment.

", - "RevokeDBSecurityGroupIngress": "

Revokes ingress from a DBSecurityGroup for previously authorized IP ranges or EC2 or VPC Security Groups. Required parameters for this API are one of CIDRIP, EC2SecurityGroupId for VPC, or (EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId).

" + "RevokeDBSecurityGroupIngress": "

Revokes ingress from a DBSecurityGroup for previously authorized IP ranges or EC2 or VPC Security Groups. Required parameters for this API are one of CIDRIP, EC2SecurityGroupId for VPC, or (EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId).

", + "StartDBInstance": "

Starts a DB instance that was stopped using the AWS console, the stop-db-instance AWS CLI command, or the StopDBInstance action. For more information, see Stopping and Starting a DB instance in the AWS RDS user guide.

", + "StopDBInstance": "

Stops a DB instance. When you stop a DB instance, Amazon RDS retains the DB instance's metadata, including its endpoint, DB parameter group, and option group membership. Amazon RDS also retains the transaction logs so you can do a point-in-time restore if necessary. For more information, see Stopping and Starting a DB instance in the AWS RDS user guide.

" }, "shapes": { "AccountAttributesMessage": { @@ -701,7 +703,9 @@ "PromoteReadReplicaResult$DBInstance": null, "RebootDBInstanceResult$DBInstance": null, "RestoreDBInstanceFromDBSnapshotResult$DBInstance": null, - "RestoreDBInstanceToPointInTimeResult$DBInstance": null + "RestoreDBInstanceToPointInTimeResult$DBInstance": null, + "StartDBInstanceResult$DBInstance": null, + "StopDBInstanceResult$DBInstance": null } }, "DBInstanceAlreadyExistsFault": { @@ -2232,6 +2236,26 @@ "Event$SourceType": "

Specifies the source type for this event.

" } }, + "StartDBInstanceMessage": { + "base": null, + "refs": { + } + }, + "StartDBInstanceResult": { + "base": null, + "refs": { + } + }, + "StopDBInstanceMessage": { + "base": null, + "refs": { + } + }, + "StopDBInstanceResult": { + "base": null, + "refs": { + } + }, "StorageQuotaExceededFault": { "base": "

Request would result in user exceeding the allowed amount of storage available across all DB instances.

", "refs": { @@ -2287,7 +2311,7 @@ "CopyOptionGroupMessage$TargetOptionGroupIdentifier": "

The identifier for the copied option group.

Constraints:

Example: my-option-group

", "CopyOptionGroupMessage$TargetOptionGroupDescription": "

The description for the copied option group.

", "CreateDBClusterMessage$CharacterSetName": "

A value that indicates that the DB cluster should be associated with the specified CharacterSet.

", - "CreateDBClusterMessage$DatabaseName": "

The name for your database of up to 8 alpha-numeric characters. If you do not provide a name, Amazon RDS will not create a database in the DB cluster you are creating.

", + "CreateDBClusterMessage$DatabaseName": "

The name for your database of up to 64 alpha-numeric characters. If you do not provide a name, Amazon RDS will not create a database in the DB cluster you are creating.

", "CreateDBClusterMessage$DBClusterIdentifier": "

The DB cluster identifier. This parameter is stored as a lowercase string.

Constraints:

Example: my-cluster1

", "CreateDBClusterMessage$DBClusterParameterGroupName": "

The name of the DB cluster parameter group to associate with this DB cluster. If this argument is omitted, default.aurora5.6 will be used.

Constraints:

", "CreateDBClusterMessage$DBSubnetGroupName": "

A DB subnet group to associate with this DB cluster.

Constraints: Must contain no more than 255 alphanumeric characters, periods, underscores, spaces, or hyphens. Must not be default.

Example: mySubnetgroup

", @@ -2306,7 +2330,7 @@ "CreateDBClusterParameterGroupMessage$Description": "

The description for the DB cluster parameter group.

", "CreateDBClusterSnapshotMessage$DBClusterSnapshotIdentifier": "

The identifier of the DB cluster snapshot. This parameter is stored as a lowercase string.

Constraints:

Example: my-cluster1-snapshot1

", "CreateDBClusterSnapshotMessage$DBClusterIdentifier": "

The identifier of the DB cluster to create a snapshot for. This parameter is not case-sensitive.

Constraints:

Example: my-cluster1

", - "CreateDBInstanceMessage$DBName": "

The meaning of this parameter differs according to the database engine you use.

Type: String

MySQL

The name of the database to create when the DB instance is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

MariaDB

The name of the database to create when the DB instance is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

PostgreSQL

The name of the database to create when the DB instance is created. If this parameter is not specified, the default \"postgres\" database is created in the DB instance.

Constraints:

Oracle

The Oracle System ID (SID) of the created DB instance.

Default: ORCL

Constraints:

SQL Server

Not applicable. Must be null.

Amazon Aurora

The name of the database to create when the primary instance of the DB cluster is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

", + "CreateDBInstanceMessage$DBName": "

The meaning of this parameter differs according to the database engine you use.

Type: String

MySQL

The name of the database to create when the DB instance is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

MariaDB

The name of the database to create when the DB instance is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

PostgreSQL

The name of the database to create when the DB instance is created. If this parameter is not specified, the default \"postgres\" database is created in the DB instance.

Constraints:

Oracle

The Oracle System ID (SID) of the created DB instance. If you specify null, the default value ORCL is used. You can't specify the string NULL, or any other reserved word, for DBName.

Default: ORCL

Constraints:

SQL Server

Not applicable. Must be null.

Amazon Aurora

The name of the database to create when the primary instance of the DB cluster is created. If this parameter is not specified, no database is created in the DB instance.

Constraints:

", "CreateDBInstanceMessage$DBInstanceIdentifier": "

The DB instance identifier. This parameter is stored as a lowercase string.

Constraints:

Example: mydbinstance

", "CreateDBInstanceMessage$DBInstanceClass": "

The compute and memory capacity of the DB instance. Note that not all instance classes are available in all regions for all DB engines.

Valid Values: db.t1.micro | db.m1.small | db.m1.medium | db.m1.large | db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge | db.m3.medium | db.m3.large | db.m3.xlarge | db.m3.2xlarge | db.m4.large | db.m4.xlarge | db.m4.2xlarge | db.m4.4xlarge | db.m4.10xlarge | db.r3.large | db.r3.xlarge | db.r3.2xlarge | db.r3.4xlarge | db.r3.8xlarge | db.t2.micro | db.t2.small | db.t2.medium | db.t2.large

", "CreateDBInstanceMessage$Engine": "

The name of the database engine to be used for this instance.

Valid Values: mysql | mariadb | oracle-se1 | oracle-se2 | oracle-se | oracle-ee | sqlserver-ee | sqlserver-se | sqlserver-ex | sqlserver-web | postgres | aurora

Not every database engine is available for every AWS region.

", @@ -2317,7 +2341,7 @@ "CreateDBInstanceMessage$PreferredMaintenanceWindow": "

The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC). For more information, see DB Instance Maintenance.

Format: ddd:hh24:mi-ddd:hh24:mi

Default: A 30-minute window selected at random from an 8-hour block of time per region, occurring on a random day of the week. To see the time blocks available, see Adjusting the Preferred Maintenance Window in the Amazon RDS User Guide.

Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun

Constraints: Minimum 30-minute window.

", "CreateDBInstanceMessage$DBParameterGroupName": "

The name of the DB parameter group to associate with this DB instance. If this argument is omitted, the default DBParameterGroup for the specified engine will be used.

Constraints:

", "CreateDBInstanceMessage$PreferredBackupWindow": "

The daily time range during which automated backups are created if automated backups are enabled, using the BackupRetentionPeriod parameter. For more information, see DB Instance Backups.

Default: A 30-minute window selected at random from an 8-hour block of time per region. To see the time blocks available, see Adjusting the Preferred DB Instance Maintenance Window.

Constraints:

", - "CreateDBInstanceMessage$EngineVersion": "

The version number of the database engine to use.

The following are the database engines and major and minor versions that are available with Amazon RDS. Not every database engine is available for every AWS region.

Amazon Aurora

MariaDB

Microsoft SQL Server 2016

Microsoft SQL Server 2014

Microsoft SQL Server 2012

Microsoft SQL Server 2008 R2

MySQL

Oracle 12c

Oracle 11g

PostgreSQL

", + "CreateDBInstanceMessage$EngineVersion": "

The version number of the database engine to use.

The following are the database engines and major and minor versions that are available with Amazon RDS. Not every database engine is available for every AWS region.

Amazon Aurora

MariaDB

Microsoft SQL Server 2016

Microsoft SQL Server 2014

Microsoft SQL Server 2012

Microsoft SQL Server 2008 R2

MySQL

Oracle 12c

Oracle 11g

PostgreSQL

", "CreateDBInstanceMessage$LicenseModel": "

License model information for this DB instance.

Valid values: license-included | bring-your-own-license | general-public-license

", "CreateDBInstanceMessage$OptionGroupName": "

Indicates that the DB instance should be associated with the specified option group.

Permanent options, such as the TDE option for Oracle Advanced Security TDE, cannot be removed from an option group, and that option group cannot be removed from a DB instance once it is associated with a DB instance

", "CreateDBInstanceMessage$CharacterSetName": "

For supported engines, indicates that the DB instance should be associated with the specified CharacterSet.

", @@ -2814,6 +2838,9 @@ "SourceRegion$Endpoint": "

The source region endpoint.

", "SourceRegion$Status": "

The status of the source region.

", "SourceRegionMessage$Marker": "

An optional pagination token provided by a previous request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by MaxRecords.

", + "StartDBInstanceMessage$DBInstanceIdentifier": "

The user-supplied instance identifier.

", + "StopDBInstanceMessage$DBInstanceIdentifier": "

The user-supplied instance identifier.

", + "StopDBInstanceMessage$DBSnapshotIdentifier": "

The user-supplied instance identifier of the DB Snapshot created immediately before the DB instance is stopped.

", "Subnet$SubnetIdentifier": "

Specifies the identifier of the subnet.

", "Subnet$SubnetStatus": "

Specifies the status of the subnet.

", "SubnetIdentifierList$member": null, diff --git a/models/apis/workdocs/2016-05-01/api-2.json b/models/apis/workdocs/2016-05-01/api-2.json index cc03e6253b8..c63d1348e84 100644 --- a/models/apis/workdocs/2016-05-01/api-2.json +++ b/models/apis/workdocs/2016-05-01/api-2.json @@ -60,6 +60,44 @@ {"shape":"ServiceUnavailableException"} ] }, + "CreateComment":{ + "name":"CreateComment", + "http":{ + "method":"POST", + "requestUri":"/api/v1/documents/{DocumentId}/versions/{VersionId}/comment", + "responseCode":201 + }, + "input":{"shape":"CreateCommentRequest"}, + "output":{"shape":"CreateCommentResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"ProhibitedStateException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"}, + {"shape":"DocumentLockedForCommentsException"} + ] + }, + "CreateCustomMetadata":{ + "name":"CreateCustomMetadata", + "http":{ + "method":"PUT", + "requestUri":"/api/v1/resources/{ResourceId}/customMetadata", + "responseCode":200 + }, + "input":{"shape":"CreateCustomMetadataRequest"}, + "output":{"shape":"CreateCustomMetadataResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"ProhibitedStateException"}, + {"shape":"CustomMetadataLimitExceededException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"} + ] + }, "CreateFolder":{ "name":"CreateFolder", "http":{ @@ -80,6 +118,24 @@ {"shape":"ServiceUnavailableException"} ] }, + "CreateLabels":{ + "name":"CreateLabels", + "http":{ + "method":"PUT", + "requestUri":"/api/v1/resources/{ResourceId}/labels", + "responseCode":200 + }, + "input":{"shape":"CreateLabelsRequest"}, + "output":{"shape":"CreateLabelsResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"}, + {"shape":"TooManyLabelsException"} + ] + }, "CreateNotificationSubscription":{ "name":"CreateNotificationSubscription", "http":{ @@ -128,6 +184,42 @@ {"shape":"ServiceUnavailableException"} ] }, + "DeleteComment":{ + "name":"DeleteComment", + "http":{ + "method":"DELETE", + "requestUri":"/api/v1/documents/{DocumentId}/versions/{VersionId}/comment/{CommentId}", + "responseCode":204 + }, + "input":{"shape":"DeleteCommentRequest"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"ProhibitedStateException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"}, + {"shape":"DocumentLockedForCommentsException"} + ] + }, + "DeleteCustomMetadata":{ + "name":"DeleteCustomMetadata", + "http":{ + "method":"DELETE", + "requestUri":"/api/v1/resources/{ResourceId}/customMetadata", + "responseCode":200 + }, + "input":{"shape":"DeleteCustomMetadataRequest"}, + "output":{"shape":"DeleteCustomMetadataResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"ProhibitedStateException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"} + ] + }, "DeleteDocument":{ "name":"DeleteDocument", "http":{ @@ -180,6 +272,23 @@ {"shape":"ServiceUnavailableException"} ] }, + "DeleteLabels":{ + "name":"DeleteLabels", + "http":{ + "method":"DELETE", + "requestUri":"/api/v1/resources/{ResourceId}/labels", + "responseCode":200 + }, + "input":{"shape":"DeleteLabelsRequest"}, + "output":{"shape":"DeleteLabelsResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"} + ] + }, "DeleteNotificationSubscription":{ "name":"DeleteNotificationSubscription", "http":{ @@ -211,6 +320,24 @@ {"shape":"ServiceUnavailableException"} ] }, + "DescribeComments":{ + "name":"DescribeComments", + "http":{ + "method":"GET", + "requestUri":"/api/v1/documents/{DocumentId}/versions/{VersionId}/comments", + "responseCode":200 + }, + "input":{"shape":"DescribeCommentsRequest"}, + "output":{"shape":"DescribeCommentsResponse"}, + "errors":[ + {"shape":"EntityNotExistsException"}, + {"shape":"ProhibitedStateException"}, + {"shape":"UnauthorizedOperationException"}, + {"shape":"UnauthorizedResourceAccessException"}, + {"shape":"FailedDependencyException"}, + {"shape":"ServiceUnavailableException"} + ] + }, "DescribeDocumentVersions":{ "name":"DescribeDocumentVersions", "http":{ @@ -403,7 +530,9 @@ {"shape":"UnauthorizedOperationException"}, {"shape":"UnauthorizedResourceAccessException"}, {"shape":"FailedDependencyException"}, - {"shape":"ServiceUnavailableException"} + {"shape":"ServiceUnavailableException"}, + {"shape":"DraftUploadOutOfSyncException"}, + {"shape":"ResourceAlreadyCheckedOutException"} ] }, "RemoveAllResourcePermissions":{ @@ -523,6 +652,11 @@ "VersionId" ], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -543,6 +677,11 @@ "shape":"IdType", "location":"uri", "locationName":"UserId" + }, + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" } } }, @@ -559,6 +698,11 @@ "Principals" ], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "ResourceId":{ "shape":"ResourceIdType", "location":"uri", @@ -573,6 +717,59 @@ "ShareResults":{"shape":"ShareResultsList"} } }, + "AuthenticationHeaderType":{ + "type":"string", + "max":8199, + "min":1, + "sensitive":true + }, + "BooleanType":{"type":"boolean"}, + "Comment":{ + "type":"structure", + "required":["CommentId"], + "members":{ + "CommentId":{"shape":"CommentIdType"}, + "ParentId":{"shape":"CommentIdType"}, + "ThreadId":{"shape":"CommentIdType"}, + "Text":{"shape":"CommentTextType"}, + "Contributor":{"shape":"User"}, + "CreatedTimestamp":{"shape":"TimestampType"}, + "Status":{"shape":"CommentStatusType"}, + "Visibility":{"shape":"CommentVisibilityType"}, + "RecipientId":{"shape":"IdType"} + } + }, + "CommentIdType":{ + "type":"string", + "max":128, + "min":1, + "pattern":"[\\w+-.@]+" + }, + "CommentList":{ + "type":"list", + "member":{"shape":"Comment"} + }, + "CommentStatusType":{ + "type":"string", + "enum":[ + "DRAFT", + "PUBLISHED", + "DELETED" + ] + }, + "CommentTextType":{ + "type":"string", + "max":2048, + "min":1, + "sensitive":true + }, + "CommentVisibilityType":{ + "type":"string", + "enum":[ + "PUBLIC", + "PRIVATE" + ] + }, "ConcurrentModificationException":{ "type":"structure", "members":{ @@ -581,10 +778,81 @@ "error":{"httpStatusCode":409}, "exception":true }, + "CreateCommentRequest":{ + "type":"structure", + "required":[ + "DocumentId", + "VersionId", + "Text" + ], + "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "DocumentId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"DocumentId" + }, + "VersionId":{ + "shape":"DocumentVersionIdType", + "location":"uri", + "locationName":"VersionId" + }, + "ParentId":{"shape":"CommentIdType"}, + "ThreadId":{"shape":"CommentIdType"}, + "Text":{"shape":"CommentTextType"}, + "Visibility":{"shape":"CommentVisibilityType"}, + "NotifyCollaborators":{"shape":"BooleanType"} + } + }, + "CreateCommentResponse":{ + "type":"structure", + "members":{ + "Comment":{"shape":"Comment"} + } + }, + "CreateCustomMetadataRequest":{ + "type":"structure", + "required":[ + "ResourceId", + "CustomMetadata" + ], + "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "ResourceId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"ResourceId" + }, + "VersionId":{ + "shape":"DocumentVersionIdType", + "location":"querystring", + "locationName":"versionid" + }, + "CustomMetadata":{"shape":"CustomMetadataMap"} + } + }, + "CreateCustomMetadataResponse":{ + "type":"structure", + "members":{ + } + }, "CreateFolderRequest":{ "type":"structure", "required":["ParentFolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "Name":{"shape":"ResourceNameType"}, "ParentFolderId":{"shape":"ResourceIdType"} } @@ -595,6 +863,31 @@ "Metadata":{"shape":"FolderMetadata"} } }, + "CreateLabelsRequest":{ + "type":"structure", + "required":[ + "ResourceId", + "Labels" + ], + "members":{ + "ResourceId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"ResourceId" + }, + "Labels":{"shape":"Labels"}, + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + } + } + }, + "CreateLabelsResponse":{ + "type":"structure", + "members":{ + } + }, "CreateNotificationSubscriptionRequest":{ "type":"structure", "required":[ @@ -631,11 +924,17 @@ "members":{ "OrganizationId":{"shape":"IdType"}, "Username":{"shape":"UsernameType"}, + "EmailAddress":{"shape":"EmailAddressType"}, "GivenName":{"shape":"UserAttributeValueType"}, "Surname":{"shape":"UserAttributeValueType"}, "Password":{"shape":"PasswordType"}, "TimeZoneId":{"shape":"TimeZoneIdType"}, - "StorageRule":{"shape":"StorageRuleType"} + "StorageRule":{"shape":"StorageRuleType"}, + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + } } }, "CreateUserResponse":{ @@ -644,6 +943,38 @@ "User":{"shape":"User"} } }, + "CustomMetadataKeyList":{ + "type":"list", + "member":{"shape":"CustomMetadataKeyType"}, + "max":8 + }, + "CustomMetadataKeyType":{ + "type":"string", + "max":56, + "min":1, + "pattern":"[a-zA-Z0-9_-][a-zA-Z0-9 _-]*" + }, + "CustomMetadataLimitExceededException":{ + "type":"structure", + "members":{ + "Message":{"shape":"ErrorMessageType"} + }, + "error":{"httpStatusCode":429}, + "exception":true + }, + "CustomMetadataMap":{ + "type":"map", + "key":{"shape":"CustomMetadataKeyType"}, + "value":{"shape":"CustomMetadataValueType"}, + "max":8, + "min":1 + }, + "CustomMetadataValueType":{ + "type":"string", + "max":56, + "min":1, + "pattern":"[a-zA-Z0-9_-][a-zA-Z0-9 _-]*" + }, "DeactivateUserRequest":{ "type":"structure", "required":["UserId"], @@ -652,6 +983,11 @@ "shape":"IdType", "location":"uri", "locationName":"UserId" + }, + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" } } }, @@ -662,10 +998,81 @@ "error":{"httpStatusCode":409}, "exception":true }, + "DeleteCommentRequest":{ + "type":"structure", + "required":[ + "DocumentId", + "VersionId", + "CommentId" + ], + "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "DocumentId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"DocumentId" + }, + "VersionId":{ + "shape":"DocumentVersionIdType", + "location":"uri", + "locationName":"VersionId" + }, + "CommentId":{ + "shape":"CommentIdType", + "location":"uri", + "locationName":"CommentId" + } + } + }, + "DeleteCustomMetadataRequest":{ + "type":"structure", + "required":["ResourceId"], + "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "ResourceId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"ResourceId" + }, + "VersionId":{ + "shape":"DocumentVersionIdType", + "location":"querystring", + "locationName":"versionId" + }, + "Keys":{ + "shape":"CustomMetadataKeyList", + "location":"querystring", + "locationName":"keys" + }, + "DeleteAll":{ + "shape":"BooleanType", + "location":"querystring", + "locationName":"deleteAll" + } + } + }, + "DeleteCustomMetadataResponse":{ + "type":"structure", + "members":{ + } + }, "DeleteDocumentRequest":{ "type":"structure", "required":["DocumentId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -677,6 +1084,11 @@ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"ResourceIdType", "location":"uri", @@ -688,6 +1100,11 @@ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"ResourceIdType", "location":"uri", @@ -695,6 +1112,37 @@ } } }, + "DeleteLabelsRequest":{ + "type":"structure", + "required":["ResourceId"], + "members":{ + "ResourceId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"ResourceId" + }, + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "Labels":{ + "shape":"Labels", + "location":"querystring", + "locationName":"labels" + }, + "DeleteAll":{ + "shape":"BooleanType", + "location":"querystring", + "locationName":"deleteAll" + } + } + }, + "DeleteLabelsResponse":{ + "type":"structure", + "members":{ + } + }, "DeleteNotificationSubscriptionRequest":{ "type":"structure", "required":[ @@ -718,6 +1166,11 @@ "type":"structure", "required":["UserId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "UserId":{ "shape":"IdType", "location":"uri", @@ -725,10 +1178,56 @@ } } }, + "DescribeCommentsRequest":{ + "type":"structure", + "required":[ + "DocumentId", + "VersionId" + ], + "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, + "DocumentId":{ + "shape":"ResourceIdType", + "location":"uri", + "locationName":"DocumentId" + }, + "VersionId":{ + "shape":"DocumentVersionIdType", + "location":"uri", + "locationName":"VersionId" + }, + "Limit":{ + "shape":"LimitType", + "location":"querystring", + "locationName":"limit" + }, + "Marker":{ + "shape":"MarkerType", + "location":"querystring", + "locationName":"marker" + } + } + }, + "DescribeCommentsResponse":{ + "type":"structure", + "members":{ + "Comments":{"shape":"CommentList"}, + "Marker":{"shape":"MarkerType"} + } + }, "DescribeDocumentVersionsRequest":{ "type":"structure", "required":["DocumentId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -767,6 +1266,11 @@ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"ResourceIdType", "location":"uri", @@ -844,6 +1348,11 @@ "type":"structure", "required":["ResourceId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "ResourceId":{ "shape":"ResourceIdType", "location":"uri", @@ -871,6 +1380,11 @@ "DescribeUsersRequest":{ "type":"structure", "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "OrganizationId":{ "shape":"IdType", "location":"querystring", @@ -931,6 +1445,14 @@ "max":128, "min":1 }, + "DocumentLockedForCommentsException":{ + "type":"structure", + "members":{ + "Message":{"shape":"ErrorMessageType"} + }, + "error":{"httpStatusCode":409}, + "exception":true + }, "DocumentMetadata":{ "type":"structure", "members":{ @@ -940,7 +1462,8 @@ "CreatedTimestamp":{"shape":"TimestampType"}, "ModifiedTimestamp":{"shape":"TimestampType"}, "LatestVersionMetadata":{"shape":"DocumentVersionMetadata"}, - "ResourceState":{"shape":"ResourceStateType"} + "ResourceState":{"shape":"ResourceStateType"}, + "Labels":{"shape":"Labels"} } }, "DocumentMetadataList":{ @@ -1011,6 +1534,14 @@ "type":"string", "enum":["ACTIVE"] }, + "DraftUploadOutOfSyncException":{ + "type":"structure", + "members":{ + "Message":{"shape":"ErrorMessageType"} + }, + "error":{"httpStatusCode":409}, + "exception":true + }, "EmailAddressType":{ "type":"string", "max":256, @@ -1071,7 +1602,10 @@ "CreatedTimestamp":{"shape":"TimestampType"}, "ModifiedTimestamp":{"shape":"TimestampType"}, "ResourceState":{"shape":"ResourceStateType"}, - "Signature":{"shape":"HashType"} + "Signature":{"shape":"HashType"}, + "Labels":{"shape":"Labels"}, + "Size":{"shape":"SizeType"}, + "LatestVersionSize":{"shape":"SizeType"} } }, "FolderMetadataList":{ @@ -1082,6 +1616,11 @@ "type":"structure", "required":["DocumentId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"IdType", "location":"uri", @@ -1114,17 +1653,28 @@ "type":"structure", "required":["DocumentId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", "locationName":"DocumentId" + }, + "IncludeCustomMetadata":{ + "shape":"BooleanType", + "location":"querystring", + "locationName":"includeCustomMetadata" } } }, "GetDocumentResponse":{ "type":"structure", "members":{ - "Metadata":{"shape":"DocumentMetadata"} + "Metadata":{"shape":"DocumentMetadata"}, + "CustomMetadata":{"shape":"CustomMetadataMap"} } }, "GetDocumentVersionRequest":{ @@ -1134,6 +1684,11 @@ "VersionId" ], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -1148,19 +1703,30 @@ "shape":"FieldNamesType", "location":"querystring", "locationName":"fields" + }, + "IncludeCustomMetadata":{ + "shape":"BooleanType", + "location":"querystring", + "locationName":"includeCustomMetadata" } } }, "GetDocumentVersionResponse":{ "type":"structure", "members":{ - "Metadata":{"shape":"DocumentVersionMetadata"} + "Metadata":{"shape":"DocumentVersionMetadata"}, + "CustomMetadata":{"shape":"CustomMetadataMap"} } }, "GetFolderPathRequest":{ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"IdType", "location":"uri", @@ -1193,17 +1759,28 @@ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"ResourceIdType", "location":"uri", "locationName":"FolderId" + }, + "IncludeCustomMetadata":{ + "shape":"BooleanType", + "location":"querystring", + "locationName":"includeCustomMetadata" } } }, "GetFolderResponse":{ "type":"structure", "members":{ - "Metadata":{"shape":"FolderMetadata"} + "Metadata":{"shape":"FolderMetadata"}, + "CustomMetadata":{"shape":"CustomMetadataMap"} } }, "HashType":{ @@ -1241,6 +1818,11 @@ "type":"structure", "required":["ParentFolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "Id":{"shape":"ResourceIdType"}, "Name":{"shape":"ResourceNameType"}, "ContentCreatedTimestamp":{"shape":"TimestampType"}, @@ -1273,6 +1855,17 @@ "error":{"httpStatusCode":405}, "exception":true }, + "Label":{ + "type":"string", + "max":20, + "min":1, + "pattern":"[a-zA-Z0-9_-][a-zA-Z0-9 _-]*" + }, + "Labels":{ + "type":"list", + "member":{"shape":"Label"}, + "max":20 + }, "LimitExceededException":{ "type":"structure", "members":{ @@ -1302,6 +1895,12 @@ "default" ] }, + "MarkerType":{ + "type":"string", + "max":2048, + "min":1, + "pattern":"[\\u0000-\\u00FF]+" + }, "MessageType":{ "type":"string", "max":2048, @@ -1380,6 +1979,11 @@ "type":"structure", "required":["ResourceId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "ResourceId":{ "shape":"ResourceIdType", "location":"uri", @@ -1394,6 +1998,11 @@ "PrincipalId" ], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "ResourceId":{ "shape":"ResourceIdType", "location":"uri", @@ -1411,6 +2020,14 @@ } } }, + "ResourceAlreadyCheckedOutException":{ + "type":"structure", + "members":{ + "Message":{"shape":"ErrorMessageType"} + }, + "error":{"httpStatusCode":409}, + "exception":true + }, "ResourceIdType":{ "type":"string", "max":128, @@ -1594,6 +2211,14 @@ "min":1 }, "TimestampType":{"type":"timestamp"}, + "TooManyLabelsException":{ + "type":"structure", + "members":{ + "Message":{"shape":"ErrorMessageType"} + }, + "error":{"httpStatusCode":429}, + "exception":true + }, "TooManySubscriptionsException":{ "type":"structure", "members":{ @@ -1621,6 +2246,11 @@ "type":"structure", "required":["DocumentId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -1638,6 +2268,11 @@ "VersionId" ], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "DocumentId":{ "shape":"ResourceIdType", "location":"uri", @@ -1655,6 +2290,11 @@ "type":"structure", "required":["FolderId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "FolderId":{ "shape":"ResourceIdType", "location":"uri", @@ -1669,6 +2309,11 @@ "type":"structure", "required":["UserId"], "members":{ + "AuthenticationToken":{ + "shape":"AuthenticationHeaderType", + "location":"header", + "locationName":"Authentication" + }, "UserId":{ "shape":"IdType", "location":"uri", @@ -1775,7 +2420,7 @@ "type":"string", "max":256, "min":1, - "pattern":"[\\w\\-.]+(@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]+)?" + "pattern":"[\\w\\-+.]+(@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]+)?" } } } diff --git a/models/apis/workdocs/2016-05-01/docs-2.json b/models/apis/workdocs/2016-05-01/docs-2.json index 085477f8f6a..276b4eb2ea3 100644 --- a/models/apis/workdocs/2016-05-01/docs-2.json +++ b/models/apis/workdocs/2016-05-01/docs-2.json @@ -2,24 +2,31 @@ "version": "2.0", "service": "

The WorkDocs API is designed for the following use cases:

All Amazon WorkDocs APIs are Amazon authenticated, certificate-signed APIs. They not only require the use of the AWS SDK, but also allow for the exclusive use of IAM users and roles to help facilitate access, trust, and permission policies. By creating a role and allowing an IAM user to access the Amazon WorkDocs site, the IAM user gains full administrative visibility into the entire Amazon WorkDocs site (or as set in the IAM policy). This includes, but is not limited to, the ability to modify file permissions and upload any file to any user. This allows developers to perform the three use cases above, as well as give users the ability to grant access on a selective basis using the IAM model.

", "operations": { - "AbortDocumentVersionUpload": "

Aborts the upload of the specified document version that was previously initiated by InitiateDocumentVersionUpload. The client should make this call only when it no longer intends or fails to upload the document version.

", + "AbortDocumentVersionUpload": "

Aborts the upload of the specified document version that was previously initiated by InitiateDocumentVersionUpload. The client should make this call only when it no longer intends to upload the document version, or fails to do so.

", "ActivateUser": "

Activates the specified user. Only active users can access Amazon WorkDocs.

", "AddResourcePermissions": "

Creates a set of permissions for the specified folder or document. The resource permissions are overwritten if the principals already have different permissions.

", + "CreateComment": "

Adds a new comment to the specified document version.

", + "CreateCustomMetadata": "

Adds one or more custom properties to the specified resource (a folder, document, or version).

", "CreateFolder": "

Creates a folder with the specified name and parent folder.

", + "CreateLabels": "

Adds the specified list of labels to the given resource (a document or folder)

", "CreateNotificationSubscription": "

Configure WorkDocs to use Amazon SNS notifications.

The endpoint receives a confirmation message, and must confirm the subscription. For more information, see Confirm the Subscription in the Amazon Simple Notification Service Developer Guide.

", "CreateUser": "

Creates a user in a Simple AD or Microsoft AD directory. The status of a newly created user is \"ACTIVE\". New users can access Amazon WorkDocs.

", "DeactivateUser": "

Deactivates the specified user, which revokes the user's access to Amazon WorkDocs.

", + "DeleteComment": "

Deletes the specified comment from the document version.

", + "DeleteCustomMetadata": "

Deletes custom metadata from the specified resource.

", "DeleteDocument": "

Permanently deletes the specified document and its associated metadata.

", "DeleteFolder": "

Permanently deletes the specified folder and its contents.

", "DeleteFolderContents": "

Deletes the contents of the specified folder.

", + "DeleteLabels": "

Deletes the specified list of labels from a resource.

", "DeleteNotificationSubscription": "

Deletes the specified subscription from the specified organization.

", "DeleteUser": "

Deletes the specified user from a Simple AD or Microsoft AD directory.

", + "DescribeComments": "

List all the comments for the specified document version.

", "DescribeDocumentVersions": "

Retrieves the document versions for the specified document.

By default, only active versions are returned.

", - "DescribeFolderContents": "

Describes the contents of the specified folder, including its documents and sub-folders.

By default, Amazon WorkDocs returns the first 100 active document and folder metadata items. If there are more results, the response includes a marker that you can use to request the next set of results. You can also request initialized documents.

", + "DescribeFolderContents": "

Describes the contents of the specified folder, including its documents and subfolders.

By default, Amazon WorkDocs returns the first 100 active document and folder metadata items. If there are more results, the response includes a marker that you can use to request the next set of results. You can also request initialized documents.

", "DescribeNotificationSubscriptions": "

Lists the specified notification subscriptions.

", "DescribeResourcePermissions": "

Describes the permissions of a specified resource.

", "DescribeUsers": "

Describes the specified users. You can describe all users or filter the results (for example, by status or organization).

By default, Amazon WorkDocs returns the first 24 active or pending users. If there are more results, the response includes a marker that you can use to request the next set of results.

", - "GetDocument": "

Retrieves the specified document object.

", + "GetDocument": "

Retrieves details of a document.

", "GetDocumentPath": "

Retrieves the path information (the hierarchy from the root folder) for the requested document.

By default, Amazon WorkDocs returns a maximum of 100 levels upwards from the requested document and only includes the IDs of the parent folders in the path. You can limit the maximum number of levels. You can also request the names of the parent folders.

", "GetDocumentVersion": "

Retrieves version metadata for the specified document.

", "GetFolder": "

Retrieves the metadata of the specified folder.

", @@ -27,7 +34,7 @@ "InitiateDocumentVersionUpload": "

Creates a new document object and version object.

The client specifies the parent folder ID and name of the document to upload. The ID is optionally specified when creating a new version of an existing document. This is the first step to upload a document. Next, upload the document to the URL returned from the call, and then call UpdateDocumentVersion.

To cancel the document upload, call AbortDocumentVersionUpload.

", "RemoveAllResourcePermissions": "

Removes all the permissions from the specified resource.

", "RemoveResourcePermission": "

Removes the permission for the specified principal from the specified resource.

", - "UpdateDocument": "

Updates the specified attributes of the specified document. The user must have access to both the document and its parent folder, if applicable.

", + "UpdateDocument": "

Updates the specified attributes of a document. The user must have access to both the document and its parent folder, if applicable.

", "UpdateDocumentVersion": "

Changes the status of the document version to ACTIVE.

Amazon WorkDocs also sets its document container to ACTIVE. This is the last step in a document upload, after the client uploads the document to an S3-presigned URL returned by InitiateDocumentVersionUpload.

", "UpdateFolder": "

Updates the specified attributes of the specified folder. The user must have access to both the folder and its parent folder, if applicable.

", "UpdateUser": "

Updates the specified attributes of the specified user, and grants or revokes administrative privileges to the Amazon WorkDocs site.

" @@ -58,11 +65,124 @@ "refs": { } }, + "AuthenticationHeaderType": { + "base": null, + "refs": { + "AbortDocumentVersionUploadRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "ActivateUserRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "AddResourcePermissionsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "CreateCommentRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "CreateCustomMetadataRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "CreateFolderRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "CreateLabelsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "CreateUserRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeactivateUserRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteCommentRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteCustomMetadataRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteDocumentRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteFolderContentsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteFolderRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteLabelsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DeleteUserRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DescribeCommentsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DescribeDocumentVersionsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DescribeFolderContentsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DescribeResourcePermissionsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "DescribeUsersRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "GetDocumentPathRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "GetDocumentRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "GetDocumentVersionRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "GetFolderPathRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "GetFolderRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "InitiateDocumentVersionUploadRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "RemoveAllResourcePermissionsRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "RemoveResourcePermissionRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "UpdateDocumentRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "UpdateDocumentVersionRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "UpdateFolderRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

", + "UpdateUserRequest$AuthenticationToken": "

Amazon WorkDocs authentication token. This field should not be set when using administrative API actions, as in accessing the API using AWS credentials.

" + } + }, + "BooleanType": { + "base": null, + "refs": { + "CreateCommentRequest$NotifyCollaborators": "

Set this parameter to TRUE to send an email out to the document collaborators after the comment is created.

", + "DeleteCustomMetadataRequest$DeleteAll": "

Flag to indicate removal of all custom metadata properties from the specified resource.

", + "DeleteLabelsRequest$DeleteAll": "

Flag to request removal of all labels from the specified resource.

", + "GetDocumentRequest$IncludeCustomMetadata": "

Set this to TRUE to include custom metadata in the response.

", + "GetDocumentVersionRequest$IncludeCustomMetadata": "

Set this to TRUE to include custom metadata in the response.

", + "GetFolderRequest$IncludeCustomMetadata": "

Set to TRUE to include custom metadata in the response.

" + } + }, + "Comment": { + "base": "

Describes a comment.

", + "refs": { + "CommentList$member": null, + "CreateCommentResponse$Comment": "

The comment that has been created.

" + } + }, + "CommentIdType": { + "base": null, + "refs": { + "Comment$CommentId": "

The ID of the comment.

", + "Comment$ParentId": "

The ID of the parent comment.

", + "Comment$ThreadId": "

The ID of the root comment in the thread.

", + "CreateCommentRequest$ParentId": "

The ID of the parent comment.

", + "CreateCommentRequest$ThreadId": "

The ID of the root comment in the thread.

", + "DeleteCommentRequest$CommentId": "

The ID of the comment.

" + } + }, + "CommentList": { + "base": null, + "refs": { + "DescribeCommentsResponse$Comments": "

The list of comments for the specified document version.

" + } + }, + "CommentStatusType": { + "base": null, + "refs": { + "Comment$Status": "

The status of the comment.

" + } + }, + "CommentTextType": { + "base": null, + "refs": { + "Comment$Text": "

The text of the comment.

", + "CreateCommentRequest$Text": "

The text of the comment.

" + } + }, + "CommentVisibilityType": { + "base": null, + "refs": { + "Comment$Visibility": "

The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the comment author and document owner and co-owners, or PUBLIC, where the comment is visible to document owners, co-owners, and contributors.

", + "CreateCommentRequest$Visibility": "

The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the comment author and document owner and co-owners, or PUBLIC, where the comment is visible to document owners, co-owners, and contributors.

" + } + }, "ConcurrentModificationException": { "base": "

The resource hierarchy is changing.

", "refs": { } }, + "CreateCommentRequest": { + "base": null, + "refs": { + } + }, + "CreateCommentResponse": { + "base": null, + "refs": { + } + }, + "CreateCustomMetadataRequest": { + "base": null, + "refs": { + } + }, + "CreateCustomMetadataResponse": { + "base": null, + "refs": { + } + }, "CreateFolderRequest": { "base": null, "refs": { @@ -73,6 +193,16 @@ "refs": { } }, + "CreateLabelsRequest": { + "base": null, + "refs": { + } + }, + "CreateLabelsResponse": { + "base": null, + "refs": { + } + }, "CreateNotificationSubscriptionRequest": { "base": null, "refs": { @@ -93,6 +223,39 @@ "refs": { } }, + "CustomMetadataKeyList": { + "base": null, + "refs": { + "DeleteCustomMetadataRequest$Keys": "

List of properties to remove.

" + } + }, + "CustomMetadataKeyType": { + "base": null, + "refs": { + "CustomMetadataKeyList$member": null, + "CustomMetadataMap$key": null + } + }, + "CustomMetadataLimitExceededException": { + "base": "

The limit has been reached on the number of custom properties for the specified resource.

", + "refs": { + } + }, + "CustomMetadataMap": { + "base": null, + "refs": { + "CreateCustomMetadataRequest$CustomMetadata": "

Custom metadata in the form of name-value pairs.

", + "GetDocumentResponse$CustomMetadata": "

The custom metadata on the document.

", + "GetDocumentVersionResponse$CustomMetadata": "

The custom metadata on the document version.

", + "GetFolderResponse$CustomMetadata": "

The custom metadata on the folder.

" + } + }, + "CustomMetadataValueType": { + "base": null, + "refs": { + "CustomMetadataMap$value": null + } + }, "DeactivateUserRequest": { "base": null, "refs": { @@ -103,6 +266,21 @@ "refs": { } }, + "DeleteCommentRequest": { + "base": null, + "refs": { + } + }, + "DeleteCustomMetadataRequest": { + "base": null, + "refs": { + } + }, + "DeleteCustomMetadataResponse": { + "base": null, + "refs": { + } + }, "DeleteDocumentRequest": { "base": null, "refs": { @@ -118,6 +296,16 @@ "refs": { } }, + "DeleteLabelsRequest": { + "base": null, + "refs": { + } + }, + "DeleteLabelsResponse": { + "base": null, + "refs": { + } + }, "DeleteNotificationSubscriptionRequest": { "base": null, "refs": { @@ -128,6 +316,16 @@ "refs": { } }, + "DescribeCommentsRequest": { + "base": null, + "refs": { + } + }, + "DescribeCommentsResponse": { + "base": null, + "refs": { + } + }, "DescribeDocumentVersionsRequest": { "base": null, "refs": { @@ -185,11 +383,16 @@ "InitiateDocumentVersionUploadRequest$ContentType": "

The content type of the document.

" } }, + "DocumentLockedForCommentsException": { + "base": "

This exception is thrown when the document is locked for comments and user tries to create or delete a comment on that document.

", + "refs": { + } + }, "DocumentMetadata": { "base": "

Describes the document.

", "refs": { "DocumentMetadataList$member": null, - "GetDocumentResponse$Metadata": "

The document object.

", + "GetDocumentResponse$Metadata": "

The metadata details of the document.

", "InitiateDocumentVersionUploadResponse$Metadata": "

The document metadata.

" } }, @@ -233,6 +436,11 @@ "base": null, "refs": { "AbortDocumentVersionUploadRequest$VersionId": "

The ID of the version.

", + "CreateCommentRequest$VersionId": "

The ID of the document version.

", + "CreateCustomMetadataRequest$VersionId": "

The ID of the version, if the custom metadata is being added to a document version.

", + "DeleteCommentRequest$VersionId": "

The ID of the document version.

", + "DeleteCustomMetadataRequest$VersionId": "

The ID of the version, if the custom metadata is being deleted from a document version.

", + "DescribeCommentsRequest$VersionId": "

The ID of the document version.

", "DocumentVersionMetadata$Id": "

The ID of the version.

", "GetDocumentVersionRequest$VersionId": "

The version ID of the document.

", "UpdateDocumentVersionRequest$VersionId": "

The version ID of the document.

" @@ -258,9 +466,15 @@ "UpdateDocumentVersionRequest$VersionStatus": "

The status of the version.

" } }, + "DraftUploadOutOfSyncException": { + "base": "

This exception is thrown when a valid checkout ID is not presented on document version upload calls for a document that has been checked out from Web client.

", + "refs": { + } + }, "EmailAddressType": { "base": null, "refs": { + "CreateUserRequest$EmailAddress": "

The email address of the user.

", "User$EmailAddress": "

The email address of the user.

" } }, @@ -284,6 +498,9 @@ "base": null, "refs": { "ConcurrentModificationException$Message": null, + "CustomMetadataLimitExceededException$Message": null, + "DocumentLockedForCommentsException$Message": null, + "DraftUploadOutOfSyncException$Message": null, "EntityAlreadyExistsException$Message": null, "EntityNotExistsException$Message": null, "FailedDependencyException$Message": null, @@ -292,9 +509,11 @@ "InvalidOperationException$Message": null, "LimitExceededException$Message": null, "ProhibitedStateException$Message": null, + "ResourceAlreadyCheckedOutException$Message": null, "ServiceUnavailableException$Message": null, "StorageLimitExceededException$Message": null, "StorageLimitWillExceedException$Message": null, + "TooManyLabelsException$Message": null, "TooManySubscriptionsException$Message": null, "UnauthorizedResourceAccessException$Message": null } @@ -311,7 +530,7 @@ "DescribeDocumentVersionsRequest$Fields": "

Specify \"SOURCE\" to include initialized versions and a URL for the source document.

", "DescribeFolderContentsRequest$Include": "

The contents to include. Specify \"INITIALIZED\" to include initialized documents.

", "DescribeUsersRequest$Fields": "

A comma-separated list of values. Specify \"STORAGE_METADATA\" to include the user storage quota and utilization information.

", - "GetDocumentPathRequest$Fields": "

A comma-separated list of values. Specify \"NAME\" to include the names of the parent folders.

", + "GetDocumentPathRequest$Fields": "

A comma-separated list of values. Specify NAME to include the names of the parent folders.

", "GetDocumentVersionRequest$Fields": "

A comma-separated list of values. Specify \"SOURCE\" to include a URL for the source document.

", "GetFolderPathRequest$Fields": "

A comma-separated list of values. Specify \"NAME\" to include the names of the parent folders.

" } @@ -333,7 +552,7 @@ "FolderMetadataList": { "base": null, "refs": { - "DescribeFolderContentsResponse$Folders": "

The sub-folders in the specified folder.

" + "DescribeFolderContentsResponse$Folders": "

The subfolders in the specified folder.

" } }, "GetDocumentPathRequest": { @@ -409,6 +628,7 @@ "base": null, "refs": { "ActivateUserRequest$UserId": "

The ID of the user.

", + "Comment$RecipientId": "

If the comment is a reply to another user's comment, this field contains the user ID of the user being replied to.

", "CreateNotificationSubscriptionRequest$OrganizationId": "

The ID of the organization.

", "CreateUserRequest$OrganizationId": "

The ID of the organization.

", "DeactivateUserRequest$UserId": "

The ID of the user.

", @@ -459,14 +679,30 @@ "refs": { } }, + "Label": { + "base": null, + "refs": { + "Labels$member": null + } + }, + "Labels": { + "base": null, + "refs": { + "CreateLabelsRequest$Labels": "

List of labels to add to the resource.

", + "DeleteLabelsRequest$Labels": "

List of labels to delete from the resource.

", + "DocumentMetadata$Labels": "

List of labels on the document.

", + "FolderMetadata$Labels": "

List of labels on the folder.

" + } + }, "LimitExceededException": { - "base": "

You've exceeded the maximum of 100,000 folders under the parent folder.

", + "base": "

The maximum of 100,000 folders under the parent folder has been exceeded.

", "refs": { } }, "LimitType": { "base": null, "refs": { + "DescribeCommentsRequest$Limit": "

The maximum number of items to return.

", "DescribeDocumentVersionsRequest$Limit": "

The maximum number of versions to return with this call.

", "DescribeFolderContentsRequest$Limit": "

The maximum number of items to return with this call.

", "DescribeNotificationSubscriptionsRequest$Limit": "

The maximum number of items to return with this call.

", @@ -483,6 +719,13 @@ "User$Locale": "

The locale of the user.

" } }, + "MarkerType": { + "base": null, + "refs": { + "DescribeCommentsRequest$Marker": "

The marker for the next set of results. This marker was received from a previous call.

", + "DescribeCommentsResponse$Marker": "

The marker for the next set of results. This marker was received from a previous call.

" + } + }, "MessageType": { "base": null, "refs": { @@ -507,7 +750,7 @@ "refs": { "DescribeDocumentVersionsRequest$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", "DescribeDocumentVersionsResponse$Marker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", - "DescribeFolderContentsRequest$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", + "DescribeFolderContentsRequest$Marker": "

The marker for the next set of results. This marker was received from a previous call.

", "DescribeFolderContentsResponse$Marker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", "DescribeNotificationSubscriptionsRequest$Marker": "

The marker for the next set of results. (You received this marker from a previous call.)

", "DescribeNotificationSubscriptionsResponse$Marker": "

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

", @@ -578,15 +821,27 @@ "refs": { } }, + "ResourceAlreadyCheckedOutException": { + "base": null, + "refs": { + } + }, "ResourceIdType": { "base": null, "refs": { "AbortDocumentVersionUploadRequest$DocumentId": "

The ID of the document.

", "AddResourcePermissionsRequest$ResourceId": "

The ID of the resource.

", + "CreateCommentRequest$DocumentId": "

The ID of the document.

", + "CreateCustomMetadataRequest$ResourceId": "

The ID of the resource.

", "CreateFolderRequest$ParentFolderId": "

The ID of the parent folder.

", + "CreateLabelsRequest$ResourceId": "

The ID of the resource.

", + "DeleteCommentRequest$DocumentId": "

The ID of the document.

", + "DeleteCustomMetadataRequest$ResourceId": "

The ID of the resource, either a document or folder.

", "DeleteDocumentRequest$DocumentId": "

The ID of the document.

", "DeleteFolderContentsRequest$FolderId": "

The ID of the folder.

", "DeleteFolderRequest$FolderId": "

The ID of the folder.

", + "DeleteLabelsRequest$ResourceId": "

The ID of the resource.

", + "DescribeCommentsRequest$DocumentId": "

The ID of the document.

", "DescribeDocumentVersionsRequest$DocumentId": "

The ID of the document.

", "DescribeFolderContentsRequest$FolderId": "

The ID of the folder.

", "DescribeResourcePermissionsRequest$ResourceId": "

The ID of the resource.

", @@ -594,7 +849,7 @@ "DocumentMetadata$ParentFolderId": "

The ID of the parent folder.

", "FolderMetadata$Id": "

The ID of the folder.

", "FolderMetadata$ParentFolderId": "

The ID of the parent folder.

", - "GetDocumentRequest$DocumentId": "

The ID of the document object.

", + "GetDocumentRequest$DocumentId": "

The ID of the document.

", "GetDocumentVersionRequest$DocumentId": "

The ID of the document.

", "GetFolderRequest$FolderId": "

The ID of the folder.

", "InitiateDocumentVersionUploadRequest$Id": "

The ID of the document.

", @@ -723,6 +978,8 @@ "refs": { "DescribeUsersResponse$TotalNumberOfUsers": "

The total number of users included in the results.

", "DocumentVersionMetadata$Size": "

The size of the document, in bytes.

", + "FolderMetadata$Size": null, + "FolderMetadata$LatestVersionSize": null, "InitiateDocumentVersionUploadRequest$DocumentSizeInBytes": "

The size of the document, in bytes.

", "UserStorageMetadata$StorageUtilizedInBytes": "

The amount of storage utilized, in bytes.

" } @@ -795,6 +1052,7 @@ "TimestampType": { "base": null, "refs": { + "Comment$CreatedTimestamp": "

The time that the comment was created.

", "DocumentMetadata$CreatedTimestamp": "

The time when the document was created.

", "DocumentMetadata$ModifiedTimestamp": "

The time when the document was updated.

", "DocumentVersionMetadata$CreatedTimestamp": "

The time stamp when the document was first uploaded.

", @@ -809,6 +1067,11 @@ "User$ModifiedTimestamp": "

The time when the user was modified.

" } }, + "TooManyLabelsException": { + "base": "

The limit has been reached on the number of labels for the specified resource.

", + "refs": { + } + }, "TooManySubscriptionsException": { "base": "

You've reached the limit on the number of subscriptions for the WorkDocs instance.

", "refs": { @@ -867,6 +1130,7 @@ "base": "

Describes a user.

", "refs": { "ActivateUserResponse$User": "

The user information.

", + "Comment$Contributor": "

The details of the user who made the comment.

", "CreateUserResponse$User": "

The user information.

", "OrganizationUserList$member": null, "UpdateUserResponse$User": "

The user information.

" diff --git a/models/endpoints/endpoints.json b/models/endpoints/endpoints.json index dd4b532eb1a..2e3a545dba6 100644 --- a/models/endpoints/endpoints.json +++ b/models/endpoints/endpoints.json @@ -127,6 +127,13 @@ "us-west-2" : { } } }, + "athena" : { + "endpoints" : { + "us-east-1" : { }, + "us-east-2" : { }, + "us-west-2" : { } + } + }, "autoscaling" : { "defaults" : { "protocols" : [ "http", "https" ] @@ -150,7 +157,9 @@ }, "batch" : { "endpoints" : { - "us-east-1" : { } + "eu-west-1" : { }, + "us-east-1" : { }, + "us-west-2" : { } } }, "budgets" : { @@ -267,6 +276,10 @@ }, "codecommit" : { "endpoints" : { + "ap-northeast-1" : { }, + "ap-southeast-1" : { }, + "ap-southeast-2" : { }, + "eu-central-1" : { }, "eu-west-1" : { }, "us-east-1" : { }, "us-east-2" : { }, @@ -862,6 +875,10 @@ }, "lightsail" : { "endpoints" : { + "ap-northeast-1" : { }, + "ap-south-1" : { }, + "ap-southeast-1" : { }, + "ap-southeast-2" : { }, "eu-central-1" : { }, "eu-west-1" : { }, "eu-west-2" : { }, @@ -1259,10 +1276,13 @@ "endpoints" : { "ap-northeast-1" : { }, "ap-northeast-2" : { }, + "ap-south-1" : { }, "ap-southeast-1" : { }, "ap-southeast-2" : { }, + "ca-central-1" : { }, "eu-central-1" : { }, "eu-west-1" : { }, + "eu-west-2" : { }, "sa-east-1" : { }, "us-east-1" : { }, "us-east-2" : { }, @@ -1725,6 +1745,11 @@ "us-gov-west-1" : { } } }, + "codedeploy" : { + "endpoints" : { + "us-gov-west-1" : { } + } + }, "config" : { "endpoints" : { "us-gov-west-1" : { } diff --git a/private/model/api/api.go b/private/model/api/api.go index 6e52c033630..46e54f859b3 100644 --- a/private/model/api/api.go +++ b/private/model/api/api.go @@ -23,6 +23,7 @@ type API struct { Shapes map[string]*Shape Waiters []Waiter Documentation string + Examples Examples // Set to true to avoid removing unused shapes NoRemoveUnusedShapes bool diff --git a/private/model/api/example.go b/private/model/api/example.go new file mode 100644 index 00000000000..db8ff24aef4 --- /dev/null +++ b/private/model/api/example.go @@ -0,0 +1,523 @@ +// +build codegen + +package api + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + "reflect" + "sort" + "strings" + "text/template" + + "github.com/aws/aws-sdk-go/private/util" +) + +type Examples map[string][]Example + +// ExamplesDefinition is the structural representation of the examples-1.json file +type ExamplesDefinition struct { + *API `json:"-"` + Examples Examples `json:"examples"` +} + +// Example is a single entry within the examples-1.json file. +type Example struct { + API *API `json:"-"` + Operation *Operation `json:"-"` + OperationName string `json:"-"` + Index string `json:"-"` + VisitedErrors map[string]struct{} `json:"-"` + Title string `json:"title"` + Description string `json:"description"` + ID string `json:"id"` + Comments Comments `json:"comments"` + Input map[string]interface{} `json:"input"` + Output map[string]interface{} `json:"output"` +} + +type Comments struct { + Input map[string]interface{} `json:"input"` + Output map[string]interface{} `json:"output"` +} + +var exampleFuncMap = template.FuncMap{ + "commentify": commentify, + "wrap": wrap, + "generateExampleInput": generateExampleInput, + "generateTypes": generateTypes, +} + +var exampleCustomizations = map[string]template.FuncMap{} + +var exampleTmpls = template.Must(template.New("example").Funcs(exampleFuncMap).Parse(` +{{ generateTypes . }} +{{ commentify (wrap .Title 80 false) }} +// +{{ commentify (wrap .Description 80 false) }} +func Example{{ .API.StructName }}_{{ .MethodName }}() { + svc := {{ .API.PackageName }}.New(session.New()) + input := &{{ .API.PackageName }}.{{ .Operation.InputRef.Shape.ShapeName }} { + {{ generateExampleInput . -}} + } + + result, err := svc.{{ .OperationName }}(input) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + {{ range $_, $ref := .Operation.ErrorRefs -}} + {{ if not ($.HasVisitedError $ref) -}} + case {{ .API.PackageName }}.{{ $ref.Shape.ErrorCodeName }}: + fmt.Println({{ .API.PackageName }}.{{ $ref.Shape.ErrorCodeName }}, aerr.Error()) + {{ end -}} + {{ end -}} + default: + fmt.Println(aerr.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) +} +`)) + +// Names will return the name of the example. This will also be the name of the operation +// that is to be tested. +func (exs Examples) Names() []string { + names := make([]string, 0, len(exs)) + for k := range exs { + names = append(names, k) + } + + sort.Strings(names) + return names +} + +func (exs Examples) GoCode() string { + buf := bytes.NewBuffer(nil) + for _, opName := range exs.Names() { + examples := exs[opName] + for _, ex := range examples { + buf.WriteString(util.GoFmt(ex.GoCode())) + buf.WriteString("\n") + } + } + return buf.String() +} + +// ExampleCode will generate the example code for the given Example shape. +func (ex Example) GoCode() string { + var buf bytes.Buffer + m := exampleFuncMap + if fMap, ok := exampleCustomizations[ex.API.PackageName()]; ok { + m = fMap + } + tmpl := exampleTmpls.Funcs(m) + if err := tmpl.ExecuteTemplate(&buf, "example", &ex); err != nil { + panic(err) + } + + return strings.TrimSpace(buf.String()) +} + +func generateExampleInput(ex Example) string { + if ex.Operation.HasInput() { + return buildShape(&ex.Operation.InputRef, ex.Input, false) + } + return "" +} + +// generateTypes will generate no types for default examples, but customizations may +// require their own defined types. +func generateTypes(ex Example) string { + return "" +} + +// 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 { + order = append(order, k) + } + sort.Strings(order) + + ret := "" + for _, name := range order { + if name == "" { + continue + } + shape := shapes[name] + + // If the shape isn't a map, we want to export the value, since every field + // defined in our shapes are exported. + if len(name) > 0 && !isMap && strings.ToLower(name[0:1]) == name[0:1] { + name = strings.Title(name) + } + + memName := name + if isMap { + memName = fmt.Sprintf("%q", memName) + } + + 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) + } + } + return ret +} + +func buildList(ref *ShapeRef, name, memName string, v []interface{}) string { + ret := "" + + if len(v) == 0 || ref == nil { + return "" + } + + t := "" + dataType := "" + format := "" + isComplex := false + passRef := ref + + if ref.Shape.MemberRefs[name] != nil { + t = getType(ref.Shape.MemberRefs[name].Shape.MemberRef.Shape) + dataType = ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type + passRef = ref.Shape.MemberRefs[name] + if dataType == "map" { + t = fmt.Sprintf("map[string]%s.%s", ref.API.PackageName(), ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef.Shape.ShapeName) + passRef = &ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef + } + } else if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil { + t = getType(ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef.Shape) + dataType = ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type + passRef = &ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef + } else { + t = getType(ref.Shape.MemberRef.Shape) + dataType = ref.Shape.MemberRef.Shape.Type + passRef = &ref.Shape.MemberRef + } + + switch v[0].(type) { + case string: + format = "%s" + case bool: + format = "%t" + case float64: + if dataType == "integer" || dataType == "int64" { + format = "%d" + } else { + format = "%f" + } + default: + if ref.Shape.MemberRefs[name] != nil { + } else { + passRef = ref.Shape.MemberRef.Shape.MemberRefs[name] + + // if passRef is nil that means we are either in a map or within a nested array + if passRef == nil { + 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 { + if dataType == "integer" || dataType == "int64" || dataType == "long" { + elem = int(elem.(float64)) + } + 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 { + return "" + } else if ref.Shape.MemberRefs[name] == nil { + if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil { + return correctType(memName, ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.Type, shape) + } + if ref.Shape.Type != "structure" && ref.Shape.Type != "map" { + return correctType(memName, ref.Shape.Type, shape) + } + return "" + } + + switch v := shape.(type) { + case bool: + 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 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: + t := ref.Shape.MemberRefs[name].Shape.Type + switch t { + case "timestamp": + return parseTimeString(ref, memName, fmt.Sprintf("%s", v)) + 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) + } + default: + return convertToCorrectType(memName, t, v) + } + default: + panic(fmt.Errorf("Unsupported scalar type: %v", reflect.TypeOf(v))) + } + return "" +} + +func correctType(memName string, t string, value interface{}) string { + if value == nil { + return "" + } + + v := "" + switch value.(type) { + case string: + v = value.(string) + case int: + v = fmt.Sprintf("%d", value.(int)) + case float64: + if t == "integer" || t == "long" || t == "int64" { + v = fmt.Sprintf("%d", int(value.(float64))) + } else { + v = fmt.Sprintf("%f", value.(float64)) + } + case bool: + v = fmt.Sprintf("%t", value.(bool)) + } + + return convertToCorrectType(memName, t, 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", "int64": + 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 := "", "" + if ref == nil { + return buildShape(nil, v, true) + } + + member := ref.Shape.MemberRefs[name] + + if member != nil && member.Shape != nil { + shapeName = ref.Shape.MemberRefs[name].Shape.ShapeName + t = ref.Shape.MemberRefs[name].Shape.Type + } else { + shapeName = ref.Shape.ShapeName + t = ref.Shape.Type + } + + switch t { + case "structure": + passRef := ref.Shape.MemberRefs[name] + // passRef will be nil if the entry is a map. In that case + // we want to pass the reference, because the previous call + // passed the value reference. + if passRef == nil { + passRef = ref + } + return fmt.Sprintf(`%s: &%s.%s{ + %s + }, + `, memName, ref.API.PackageName(), shapeName, buildShape(passRef, v, false)) + case "map": + shapeType := getNestedType(ref.Shape.MemberRefs[name].Shape.ValueRef.Shape) + return fmt.Sprintf(`%s: map[string]%s{ + %s + }, + `, name, shapeType, buildShape(&ref.Shape.MemberRefs[name].Shape.ValueRef, v, true)) + } + + return "" +} + +// 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) + defer f.Close() + if err != nil { + panic(err) + } + err = json.NewDecoder(f).Decode(&p) + if err != nil { + panic(err) + } + + p.setup() +} + +func (p *ExamplesDefinition) setup() { + keys := p.Examples.Names() + for _, n := range keys { + examples := p.Examples[n] + for i, e := range examples { + n = p.ExportableName(n) + e.OperationName = n + e.API = p.API + e.Index = fmt.Sprintf("shared%02d", i) + e.VisitedErrors = map[string]struct{}{} + op := p.API.Operations[e.OperationName] + e.OperationName = p.ExportableName(e.OperationName) + e.Operation = op + p.Examples[n][i] = e + } + } + + p.API.Examples = p.Examples +} + +var exampleHeader = template.Must(template.New("exampleHeader").Parse(` +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/{{ .PackageName }}" +) + +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 +} + +`)) + +// ExamplesGoCode will return a code representation of the entry within the +// examples.json file. +func (a *API) ExamplesGoCode() string { + var buf bytes.Buffer + if err := exampleHeader.ExecuteTemplate(&buf, "exampleHeader", &a); err != nil { + panic(err) + } + + code := a.Examples.GoCode() + if len(code) == 0 { + return "" + } + + buf.WriteString(code) + return buf.String() +} + +// TODO: In the operation docuentation where we list errors, this needs to be done +// there as well. +func (ex *Example) HasVisitedError(errRef *ShapeRef) bool { + errName := errRef.Shape.ErrorCodeName() + _, ok := ex.VisitedErrors[errName] + ex.VisitedErrors[errName] = struct{}{} + return ok +} + +func getNestedType(shape *Shape) string { + switch shape.Type { + case "string": + return "*string" + case "integer", "int64": + return "*int64" + case "bool": + return "*bool" + case "list": + return fmt.Sprintf("[]%s", getNestedType(shape.MemberRef.Shape)) + case "structure": + return fmt.Sprintf("*%s.%s", shape.API.PackageName(), shape.ShapeName) + default: + panic("Unsupported shape " + shape.Type) + } +} + +func getType(shape *Shape) string { + switch shape.Type { + case "string": + return "string" + case "integer", "int64": + return "int64" + case "bool": + return "bool" + case "structure": + return fmt.Sprintf("%s.%s", shape.API.PackageName(), shape.ShapeName) + case "map": + return fmt.Sprintf("map[string]%s.%s", shape.API.PackageName(), shape.ShapeName) + default: + panic("Unsupported shape " + shape.Type) + } +} + +func parseTimeString(ref *ShapeRef, memName, v string) string { + if ref.Location == "header" { + return fmt.Sprintf("%s: parseTime(%q, %q),\n", memName, "Mon, 2 Jan 2006 15:04:05 GMT", v) + } else { + switch ref.API.Metadata.Protocol { + case "json", "rest-json": + return fmt.Sprintf("%s: time.Unix(int64(%s), 0).UTC()", memName, v) + case "rest-xml", "ec2", "query": + return fmt.Sprintf("%s: parseTime(%q, %q),\n", memName, "2006-01-02T15:04:05Z", v) + default: + panic("Unsupported time type: " + ref.API.Metadata.Protocol) + } + } +} + +func (ex *Example) MethodName() string { + return fmt.Sprintf("%s_%s", ex.OperationName, ex.Index) +} diff --git a/private/model/api/example_test.go b/private/model/api/example_test.go new file mode 100644 index 00000000000..8ab153ab604 --- /dev/null +++ b/private/model/api/example_test.go @@ -0,0 +1,204 @@ +// +build 1.6,codegen + +package api + +import ( + "encoding/json" + "testing" +) + +func buildAPI() *API { + a := &API{} + + stringShape := &Shape{ + API: a, + ShapeName: "string", + Type: "string", + } + stringShapeRef := &ShapeRef{ + API: a, + ShapeName: "string", + Shape: stringShape, + } + + intShape := &Shape{ + API: a, + ShapeName: "int", + Type: "int", + } + intShapeRef := &ShapeRef{ + API: a, + ShapeName: "int", + Shape: intShape, + } + + input := &Shape{ + API: a, + ShapeName: "FooInput", + MemberRefs: map[string]*ShapeRef{ + "BarShape": stringShapeRef, + }, + } + output := &Shape{ + API: a, + ShapeName: "FooOutput", + MemberRefs: map[string]*ShapeRef{ + "BazShape": intShapeRef, + }, + } + + inputRef := ShapeRef{ + API: a, + ShapeName: "FooInput", + Shape: input, + } + outputRef := ShapeRef{ + API: a, + ShapeName: "Foooutput", + Shape: output, + } + + operations := map[string]*Operation{ + "Foo": &Operation{ + API: a, + Name: "Foo", + ExportedName: "Foo", + InputRef: inputRef, + OutputRef: outputRef, + }, + } + + a.Operations = operations + a.Shapes = map[string]*Shape{ + "FooInput": input, + "FooOutput": output, + } + a.Metadata = Metadata{ + ServiceAbbreviation: "FooService", + } + + a.Setup() + return a +} + +func TestExampleGeneration(t *testing.T) { + example := ` +{ + "version": "1.0", + "examples": { + "Foo": [ + { + "input": { + "BarShape": "Hello world" + }, + "output": { + "BazShape": 1 + }, + "comments": { + "input": { + }, + "output": { + } + }, + "description": "Foo bar baz qux", + "title": "I pity the foo" + } + ] + } +} + ` + a := buildAPI() + def := &ExamplesDefinition{} + err := json.Unmarshal([]byte(example), def) + if err != nil { + t.Error(err) + } + def.API = a + + def.setup() + 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_shared00() { + svc := fooservice.New(session.New()) + 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() { + default: + fmt.Println(aerr.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) +} +` + if expected != a.ExamplesGoCode() { + t.Log([]byte(expected)) + t.Log([]byte(a.ExamplesGoCode())) + t.Errorf("Expected:\n%s\nReceived:\n%s\n", expected, a.ExamplesGoCode()) + } +} + +func TestBuildShape(t *testing.T) { + a := buildAPI() + cases := []struct { + defs map[string]interface{} + expected string + }{ + { + defs: map[string]interface{}{ + "barShape": "Hello World", + }, + expected: "BarShape: aws.String(\"Hello World\"),\n", + }, + { + defs: map[string]interface{}{ + "BarShape": "Hello World", + }, + expected: "BarShape: aws.String(\"Hello World\"),\n", + }, + } + + for _, c := range cases { + ref := a.Operations["Foo"].InputRef + shapeStr := buildShape(&ref, c.defs, false) + if c.expected != shapeStr { + t.Errorf("Expected:\n%s\nReceived:\n%s", c.expected, shapeStr) + } + } +} diff --git a/private/model/cli/gen-api/main.go b/private/model/cli/gen-api/main.go index 48dc6beb772..28ce74fe28d 100644 --- a/private/model/cli/gen-api/main.go +++ b/private/model/cli/gen-api/main.go @@ -62,6 +62,13 @@ func newGenerateInfo(modelFile, svcPath, svcImportPath string) *generateInfo { fmt.Println("waiters-2.json error:", err) } + examplesFile := strings.Replace(modelFile, "api-2.json", "examples-1.json", -1) + if _, err := os.Stat(waitersFile); err == nil { + g.API.AttachExamples(examplesFile) + } else if !os.IsNotExist(err) { + fmt.Println("examples-1.json error:", err) + } + // pkgDocAddonsFile := strings.Replace(modelFile, "api-2.json", "go-pkg-doc.gotmpl", -1) // if _, err := os.Stat(pkgDocAddonsFile); err == nil { // g.API.AttachPackageDocAddons(pkgDocAddonsFile) @@ -185,11 +192,11 @@ func writeServiceFiles(g *generateInfo, filename string) { // write files for service client and API Must(writeServiceDocFile(g)) Must(writeAPIFile(g)) - Must(writeExamplesFile(g)) Must(writeServiceFile(g)) Must(writeInterfaceFile(g)) Must(writeWaitersFile(g)) Must(writeAPIErrorsFile(g)) + Must(writeExamplesFile(g)) } // Must will panic if the error passed in is not nil. @@ -223,12 +230,16 @@ func writeServiceDocFile(g *generateInfo) error { // writeExamplesFile writes out the service example file. func writeExamplesFile(g *generateInfo) error { - return writeGoFile(filepath.Join(g.PackageDir, "examples_test.go"), - codeLayout, - "", - g.API.PackageName()+"_test", - g.API.ExampleGoCode(), - ) + code := g.API.ExamplesGoCode() + if len(code) > 0 { + return writeGoFile(filepath.Join(g.PackageDir, "examples_test.go"), + codeLayout, + "", + g.API.PackageName()+"_test", + code, + ) + } + return nil } // writeServiceFile writes out the service initialization file. 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..f439ea96877 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.Tag{ + { + Key: aws.String("Role"), + PropagateAtLaunch: aws.Bool(true), + 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("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("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.Tag{ + { + 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{ +// 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.Filter{ - { // Required - Name: aws.String("XmlString"), + { + 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/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/codedeploy/api.go b/service/codedeploy/api.go index 673707b32a4..7fe90f906af 100644 --- a/service/codedeploy/api.go +++ b/service/codedeploy/api.go @@ -3146,6 +3146,89 @@ func (c *CodeDeploy) ListDeploymentsPagesWithContext(ctx aws.Context, input *Lis return p.Err() } +const opListGitHubAccountTokenNames = "ListGitHubAccountTokenNames" + +// ListGitHubAccountTokenNamesRequest generates a "aws/request.Request" representing the +// client's request for the ListGitHubAccountTokenNames operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See ListGitHubAccountTokenNames for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the ListGitHubAccountTokenNames method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the ListGitHubAccountTokenNamesRequest method. +// req, resp := client.ListGitHubAccountTokenNamesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListGitHubAccountTokenNames +func (c *CodeDeploy) ListGitHubAccountTokenNamesRequest(input *ListGitHubAccountTokenNamesInput) (req *request.Request, output *ListGitHubAccountTokenNamesOutput) { + op := &request.Operation{ + Name: opListGitHubAccountTokenNames, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ListGitHubAccountTokenNamesInput{} + } + + output = &ListGitHubAccountTokenNamesOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListGitHubAccountTokenNames API operation for AWS CodeDeploy. +// +// Lists the names of stored connections to GitHub accounts. +// +// 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. +// +// See the AWS API reference guide for AWS CodeDeploy's +// API operation ListGitHubAccountTokenNames for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidNextTokenException "InvalidNextTokenException" +// The next token was specified in an invalid format. +// +// * ErrCodeResourceValidationException "ResourceValidationException" +// The specified resource could not be validated. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListGitHubAccountTokenNames +func (c *CodeDeploy) ListGitHubAccountTokenNames(input *ListGitHubAccountTokenNamesInput) (*ListGitHubAccountTokenNamesOutput, error) { + req, out := c.ListGitHubAccountTokenNamesRequest(input) + return out, req.Send() +} + +// ListGitHubAccountTokenNamesWithContext is the same as ListGitHubAccountTokenNames with the addition of +// the ability to pass a context and additional request options. +// +// See ListGitHubAccountTokenNames for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CodeDeploy) ListGitHubAccountTokenNamesWithContext(ctx aws.Context, input *ListGitHubAccountTokenNamesInput, opts ...request.Option) (*ListGitHubAccountTokenNamesOutput, error) { + req, out := c.ListGitHubAccountTokenNamesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opListOnPremisesInstances = "ListOnPremisesInstances" // ListOnPremisesInstancesRequest generates a "aws/request.Request" representing the @@ -4153,6 +4236,9 @@ type ApplicationInfo struct { // The time at which the application was created. CreateTime *time.Time `locationName:"createTime" type:"timestamp" timestampFormat:"unix"` + // The name for a connection to a GitHub account. + GitHubAccountName *string `locationName:"gitHubAccountName" type:"string"` + // True if the user has authenticated with GitHub for the specified application; // otherwise, false. LinkedToGitHub *bool `locationName:"linkedToGitHub" type:"boolean"` @@ -4186,6 +4272,12 @@ func (s *ApplicationInfo) SetCreateTime(v time.Time) *ApplicationInfo { return s } +// SetGitHubAccountName sets the GitHubAccountName field's value. +func (s *ApplicationInfo) SetGitHubAccountName(v string) *ApplicationInfo { + s.GitHubAccountName = &v + return s +} + // SetLinkedToGitHub sets the LinkedToGitHub field's value. func (s *ApplicationInfo) SetLinkedToGitHub(v bool) *ApplicationInfo { s.LinkedToGitHub = &v @@ -4262,7 +4354,7 @@ func (s *AutoScalingGroup) SetName(v string) *AutoScalingGroup { return s } -// Represents the input of a batch get application revisions operation. +// Represents the input of a BatchGetApplicationRevisions operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetApplicationRevisionsInput type BatchGetApplicationRevisionsInput struct { _ struct{} `type:"structure"` @@ -4319,7 +4411,7 @@ func (s *BatchGetApplicationRevisionsInput) SetRevisions(v []*RevisionLocation) return s } -// Represents the output of a batch get application revisions operation. +// Represents the output of a BatchGetApplicationRevisions operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetApplicationRevisionsOutput type BatchGetApplicationRevisionsOutput struct { _ struct{} `type:"structure"` @@ -4362,7 +4454,7 @@ func (s *BatchGetApplicationRevisionsOutput) SetRevisions(v []*RevisionInfo) *Ba return s } -// Represents the input of a batch get applications operation. +// Represents the input of a BatchGetApplications operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetApplicationsInput type BatchGetApplicationsInput struct { _ struct{} `type:"structure"` @@ -4387,7 +4479,7 @@ func (s *BatchGetApplicationsInput) SetApplicationNames(v []*string) *BatchGetAp return s } -// Represents the output of a batch get applications operation. +// Represents the output of a BatchGetApplications operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetApplicationsOutput type BatchGetApplicationsOutput struct { _ struct{} `type:"structure"` @@ -4412,7 +4504,7 @@ func (s *BatchGetApplicationsOutput) SetApplicationsInfo(v []*ApplicationInfo) * return s } -// Represents the input of a batch get deployment groups operation. +// Represents the input of a BatchGetDeploymentGroups operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentGroupsInput type BatchGetDeploymentGroupsInput struct { _ struct{} `type:"structure"` @@ -4470,7 +4562,7 @@ func (s *BatchGetDeploymentGroupsInput) SetDeploymentGroupNames(v []*string) *Ba return s } -// Represents the output of a batch get deployment groups operation. +// Represents the output of a BatchGetDeploymentGroups operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentGroupsOutput type BatchGetDeploymentGroupsOutput struct { _ struct{} `type:"structure"` @@ -4504,7 +4596,7 @@ func (s *BatchGetDeploymentGroupsOutput) SetErrorMessage(v string) *BatchGetDepl return s } -// Represents the input of a batch get deployment instances operation. +// Represents the input of a BatchGetDeploymentInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentInstancesInput type BatchGetDeploymentInstancesInput struct { _ struct{} `type:"structure"` @@ -4558,7 +4650,7 @@ func (s *BatchGetDeploymentInstancesInput) SetInstanceIds(v []*string) *BatchGet return s } -// Represents the output of a batch get deployment instance operation. +// Represents the output of a BatchGetDeploymentInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentInstancesOutput type BatchGetDeploymentInstancesOutput struct { _ struct{} `type:"structure"` @@ -4592,7 +4684,7 @@ func (s *BatchGetDeploymentInstancesOutput) SetInstancesSummary(v []*InstanceSum return s } -// Represents the input of a batch get deployments operation. +// Represents the input of a BatchGetDeployments operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentsInput type BatchGetDeploymentsInput struct { _ struct{} `type:"structure"` @@ -4617,7 +4709,7 @@ func (s *BatchGetDeploymentsInput) SetDeploymentIds(v []*string) *BatchGetDeploy return s } -// Represents the output of a batch get deployments operation. +// Represents the output of a BatchGetDeployments operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetDeploymentsOutput type BatchGetDeploymentsOutput struct { _ struct{} `type:"structure"` @@ -4642,7 +4734,7 @@ func (s *BatchGetDeploymentsOutput) SetDeploymentsInfo(v []*DeploymentInfo) *Bat return s } -// Represents the input of a batch get on-premises instances operation. +// Represents the input of a BatchGetOnPremisesInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetOnPremisesInstancesInput type BatchGetOnPremisesInstancesInput struct { _ struct{} `type:"structure"` @@ -4667,7 +4759,7 @@ func (s *BatchGetOnPremisesInstancesInput) SetInstanceNames(v []*string) *BatchG return s } -// Represents the output of a batch get on-premises instances operation. +// Represents the output of a BatchGetOnPremisesInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/BatchGetOnPremisesInstancesOutput type BatchGetOnPremisesInstancesOutput struct { _ struct{} `type:"structure"` @@ -4820,7 +4912,7 @@ func (s ContinueDeploymentOutput) GoString() string { return s.String() } -// Represents the input of a create application operation. +// Represents the input of a CreateApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateApplicationInput type CreateApplicationInput struct { _ struct{} `type:"structure"` @@ -4864,7 +4956,7 @@ func (s *CreateApplicationInput) SetApplicationName(v string) *CreateApplication return s } -// Represents the output of a create application operation. +// Represents the output of a CreateApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateApplicationOutput type CreateApplicationOutput struct { _ struct{} `type:"structure"` @@ -4889,7 +4981,7 @@ func (s *CreateApplicationOutput) SetApplicationId(v string) *CreateApplicationO return s } -// Represents the input of a create deployment configuration operation. +// Represents the input of a CreateDeploymentConfig operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentConfigInput type CreateDeploymentConfigInput struct { _ struct{} `type:"structure"` @@ -4959,7 +5051,7 @@ func (s *CreateDeploymentConfigInput) SetMinimumHealthyHosts(v *MinimumHealthyHo return s } -// Represents the output of a create deployment configuration operation. +// Represents the output of a CreateDeploymentConfig operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentConfigOutput type CreateDeploymentConfigOutput struct { _ struct{} `type:"structure"` @@ -4984,7 +5076,7 @@ func (s *CreateDeploymentConfigOutput) SetDeploymentConfigId(v string) *CreateDe return s } -// Represents the input of a create deployment group operation. +// Represents the input of a CreateDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentGroupInput type CreateDeploymentGroupInput struct { _ struct{} `type:"structure"` @@ -5171,7 +5263,7 @@ func (s *CreateDeploymentGroupInput) SetTriggerConfigurations(v []*TriggerConfig return s } -// Represents the output of a create deployment group operation. +// Represents the output of a CreateDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentGroupOutput type CreateDeploymentGroupOutput struct { _ struct{} `type:"structure"` @@ -5196,7 +5288,7 @@ func (s *CreateDeploymentGroupOutput) SetDeploymentGroupId(v string) *CreateDepl return s } -// Represents the input of a create deployment operation. +// Represents the input of a CreateDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentInput type CreateDeploymentInput struct { _ struct{} `type:"structure"` @@ -5356,7 +5448,7 @@ func (s *CreateDeploymentInput) SetUpdateOutdatedInstancesOnly(v bool) *CreateDe return s } -// Represents the output of a create deployment operation. +// Represents the output of a CreateDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/CreateDeploymentOutput type CreateDeploymentOutput struct { _ struct{} `type:"structure"` @@ -5381,7 +5473,7 @@ func (s *CreateDeploymentOutput) SetDeploymentId(v string) *CreateDeploymentOutp return s } -// Represents the input of a delete application operation. +// Represents the input of a DeleteApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/DeleteApplicationInput type DeleteApplicationInput struct { _ struct{} `type:"structure"` @@ -5440,7 +5532,7 @@ func (s DeleteApplicationOutput) GoString() string { return s.String() } -// Represents the input of a delete deployment configuration operation. +// Represents the input of a DeleteDeploymentConfig operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/DeleteDeploymentConfigInput type DeleteDeploymentConfigInput struct { _ struct{} `type:"structure"` @@ -5499,7 +5591,7 @@ func (s DeleteDeploymentConfigOutput) GoString() string { return s.String() } -// Represents the input of a delete deployment group operation. +// Represents the input of a DeleteDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/DeleteDeploymentGroupInput type DeleteDeploymentGroupInput struct { _ struct{} `type:"structure"` @@ -5560,7 +5652,7 @@ func (s *DeleteDeploymentGroupInput) SetDeploymentGroupName(v string) *DeleteDep return s } -// Represents the output of a delete deployment group operation. +// Represents the output of a DeleteDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/DeleteDeploymentGroupOutput type DeleteDeploymentGroupOutput struct { _ struct{} `type:"structure"` @@ -5679,6 +5771,14 @@ type DeploymentGroupInfo struct { // The Amazon EC2 tags on which to filter. Ec2TagFilters []*EC2TagFilter `locationName:"ec2TagFilters" type:"list"` + // Information about the most recent attempted deployment to the deployment + // group. + LastAttemptedDeployment *LastDeploymentInfo `locationName:"lastAttemptedDeployment" type:"structure"` + + // Information about the most recent successful deployment to the deployment + // group. + LastSuccessfulDeployment *LastDeploymentInfo `locationName:"lastSuccessfulDeployment" type:"structure"` + // Information about the load balancer to use in a deployment. LoadBalancerInfo *LoadBalancerInfo `locationName:"loadBalancerInfo" type:"structure"` @@ -5766,6 +5866,18 @@ func (s *DeploymentGroupInfo) SetEc2TagFilters(v []*EC2TagFilter) *DeploymentGro return s } +// SetLastAttemptedDeployment sets the LastAttemptedDeployment field's value. +func (s *DeploymentGroupInfo) SetLastAttemptedDeployment(v *LastDeploymentInfo) *DeploymentGroupInfo { + s.LastAttemptedDeployment = v + return s +} + +// SetLastSuccessfulDeployment sets the LastSuccessfulDeployment field's value. +func (s *DeploymentGroupInfo) SetLastSuccessfulDeployment(v *LastDeploymentInfo) *DeploymentGroupInfo { + s.LastSuccessfulDeployment = v + return s +} + // SetLoadBalancerInfo sets the LoadBalancerInfo field's value. func (s *DeploymentGroupInfo) SetLoadBalancerInfo(v *LoadBalancerInfo) *DeploymentGroupInfo { s.LoadBalancerInfo = v @@ -6231,7 +6343,7 @@ func (s *DeploymentStyle) SetDeploymentType(v string) *DeploymentStyle { return s } -// Represents the input of a deregister on-premises instance operation. +// Represents the input of a DeregisterOnPremisesInstance operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/DeregisterOnPremisesInstanceInput type DeregisterOnPremisesInstanceInput struct { _ struct{} `type:"structure"` @@ -6568,7 +6680,7 @@ func (s *GenericRevisionInfo) SetRegisterTime(v time.Time) *GenericRevisionInfo return s } -// Represents the input of a get application operation. +// Represents the input of a GetApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetApplicationInput type GetApplicationInput struct { _ struct{} `type:"structure"` @@ -6612,7 +6724,7 @@ func (s *GetApplicationInput) SetApplicationName(v string) *GetApplicationInput return s } -// Represents the output of a get application operation. +// Represents the output of a GetApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetApplicationOutput type GetApplicationOutput struct { _ struct{} `type:"structure"` @@ -6637,7 +6749,7 @@ func (s *GetApplicationOutput) SetApplication(v *ApplicationInfo) *GetApplicatio return s } -// Represents the input of a get application revision operation. +// Represents the input of a GetApplicationRevision operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetApplicationRevisionInput type GetApplicationRevisionInput struct { _ struct{} `type:"structure"` @@ -6694,7 +6806,7 @@ func (s *GetApplicationRevisionInput) SetRevision(v *RevisionLocation) *GetAppli return s } -// Represents the output of a get application revision operation. +// Represents the output of a GetApplicationRevision operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetApplicationRevisionOutput type GetApplicationRevisionOutput struct { _ struct{} `type:"structure"` @@ -6737,7 +6849,7 @@ func (s *GetApplicationRevisionOutput) SetRevisionInfo(v *GenericRevisionInfo) * return s } -// Represents the input of a get deployment configuration operation. +// Represents the input of a GetDeploymentConfig operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentConfigInput type GetDeploymentConfigInput struct { _ struct{} `type:"structure"` @@ -6781,7 +6893,7 @@ func (s *GetDeploymentConfigInput) SetDeploymentConfigName(v string) *GetDeploym return s } -// Represents the output of a get deployment configuration operation. +// Represents the output of a GetDeploymentConfig operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentConfigOutput type GetDeploymentConfigOutput struct { _ struct{} `type:"structure"` @@ -6806,7 +6918,7 @@ func (s *GetDeploymentConfigOutput) SetDeploymentConfigInfo(v *DeploymentConfigI return s } -// Represents the input of a get deployment group operation. +// Represents the input of a GetDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentGroupInput type GetDeploymentGroupInput struct { _ struct{} `type:"structure"` @@ -6867,7 +6979,7 @@ func (s *GetDeploymentGroupInput) SetDeploymentGroupName(v string) *GetDeploymen return s } -// Represents the output of a get deployment group operation. +// Represents the output of a GetDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentGroupOutput type GetDeploymentGroupOutput struct { _ struct{} `type:"structure"` @@ -6892,7 +7004,7 @@ func (s *GetDeploymentGroupOutput) SetDeploymentGroupInfo(v *DeploymentGroupInfo return s } -// Represents the input of a get deployment operation. +// Represents the input of a GetDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentInput type GetDeploymentInput struct { _ struct{} `type:"structure"` @@ -6932,7 +7044,7 @@ func (s *GetDeploymentInput) SetDeploymentId(v string) *GetDeploymentInput { return s } -// Represents the input of a get deployment instance operation. +// Represents the input of a GetDeploymentInstance operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentInstanceInput type GetDeploymentInstanceInput struct { _ struct{} `type:"structure"` @@ -6986,7 +7098,7 @@ func (s *GetDeploymentInstanceInput) SetInstanceId(v string) *GetDeploymentInsta return s } -// Represents the output of a get deployment instance operation. +// Represents the output of a GetDeploymentInstance operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentInstanceOutput type GetDeploymentInstanceOutput struct { _ struct{} `type:"structure"` @@ -7011,7 +7123,7 @@ func (s *GetDeploymentInstanceOutput) SetInstanceSummary(v *InstanceSummary) *Ge return s } -// Represents the output of a get deployment operation. +// Represents the output of a GetDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetDeploymentOutput type GetDeploymentOutput struct { _ struct{} `type:"structure"` @@ -7036,7 +7148,7 @@ func (s *GetDeploymentOutput) SetDeploymentInfo(v *DeploymentInfo) *GetDeploymen return s } -// Represents the input of a get on-premises instance operation. +// Represents the input of a GetOnPremisesInstance operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetOnPremisesInstanceInput type GetOnPremisesInstanceInput struct { _ struct{} `type:"structure"` @@ -7076,7 +7188,7 @@ func (s *GetOnPremisesInstanceInput) SetInstanceName(v string) *GetOnPremisesIns return s } -// Represents the output of a get on-premises instance operation. +// Represents the output of a GetOnPremisesInstance operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/GetOnPremisesInstanceOutput type GetOnPremisesInstanceOutput struct { _ struct{} `type:"structure"` @@ -7338,6 +7450,61 @@ func (s *InstanceSummary) SetStatus(v string) *InstanceSummary { return s } +// Information about the most recent attempted or successful deployment to a +// deployment group. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/LastDeploymentInfo +type LastDeploymentInfo struct { + _ struct{} `type:"structure"` + + // A timestamp indicating when the most recent deployment to the deployment + // group started. + CreateTime *time.Time `locationName:"createTime" type:"timestamp" timestampFormat:"unix"` + + // The deployment ID. + DeploymentId *string `locationName:"deploymentId" type:"string"` + + // A timestamp indicating when the most recent deployment to the deployment + // group completed. + EndTime *time.Time `locationName:"endTime" type:"timestamp" timestampFormat:"unix"` + + // The status of the most recent deployment. + Status *string `locationName:"status" type:"string" enum:"DeploymentStatus"` +} + +// String returns the string representation +func (s LastDeploymentInfo) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LastDeploymentInfo) GoString() string { + return s.String() +} + +// SetCreateTime sets the CreateTime field's value. +func (s *LastDeploymentInfo) SetCreateTime(v time.Time) *LastDeploymentInfo { + s.CreateTime = &v + return s +} + +// SetDeploymentId sets the DeploymentId field's value. +func (s *LastDeploymentInfo) SetDeploymentId(v string) *LastDeploymentInfo { + s.DeploymentId = &v + return s +} + +// SetEndTime sets the EndTime field's value. +func (s *LastDeploymentInfo) SetEndTime(v time.Time) *LastDeploymentInfo { + s.EndTime = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *LastDeploymentInfo) SetStatus(v string) *LastDeploymentInfo { + s.Status = &v + return s +} + // Information about a deployment lifecycle event. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/LifecycleEvent type LifecycleEvent struct { @@ -7412,7 +7579,7 @@ func (s *LifecycleEvent) SetStatus(v string) *LifecycleEvent { return s } -// Represents the input of a list application revisions operation. +// Represents the input of a ListApplicationRevisions operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListApplicationRevisionsInput type ListApplicationRevisionsInput struct { _ struct{} `type:"structure"` @@ -7539,7 +7706,7 @@ func (s *ListApplicationRevisionsInput) SetSortOrder(v string) *ListApplicationR return s } -// Represents the output of a list application revisions operation. +// Represents the output of a ListApplicationRevisions operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListApplicationRevisionsOutput type ListApplicationRevisionsOutput struct { _ struct{} `type:"structure"` @@ -7575,7 +7742,7 @@ func (s *ListApplicationRevisionsOutput) SetRevisions(v []*RevisionLocation) *Li return s } -// Represents the input of a list applications operation. +// Represents the input of a ListApplications operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListApplicationsInput type ListApplicationsInput struct { _ struct{} `type:"structure"` @@ -7601,7 +7768,7 @@ func (s *ListApplicationsInput) SetNextToken(v string) *ListApplicationsInput { return s } -// Represents the output of a list applications operation. +// Represents the output of a ListApplications operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListApplicationsOutput type ListApplicationsOutput struct { _ struct{} `type:"structure"` @@ -7637,7 +7804,7 @@ func (s *ListApplicationsOutput) SetNextToken(v string) *ListApplicationsOutput return s } -// Represents the input of a list deployment configurations operation. +// Represents the input of a ListDeploymentConfigs operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentConfigsInput type ListDeploymentConfigsInput struct { _ struct{} `type:"structure"` @@ -7664,7 +7831,7 @@ func (s *ListDeploymentConfigsInput) SetNextToken(v string) *ListDeploymentConfi return s } -// Represents the output of a list deployment configurations operation. +// Represents the output of a ListDeploymentConfigs operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentConfigsOutput type ListDeploymentConfigsOutput struct { _ struct{} `type:"structure"` @@ -7701,7 +7868,7 @@ func (s *ListDeploymentConfigsOutput) SetNextToken(v string) *ListDeploymentConf return s } -// Represents the input of a list deployment groups operation. +// Represents the input of a ListDeploymentGroups operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentGroupsInput type ListDeploymentGroupsInput struct { _ struct{} `type:"structure"` @@ -7755,7 +7922,7 @@ func (s *ListDeploymentGroupsInput) SetNextToken(v string) *ListDeploymentGroups return s } -// Represents the output of a list deployment groups operation. +// Represents the output of a ListDeploymentGroups operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentGroupsOutput type ListDeploymentGroupsOutput struct { _ struct{} `type:"structure"` @@ -7800,7 +7967,7 @@ func (s *ListDeploymentGroupsOutput) SetNextToken(v string) *ListDeploymentGroup return s } -// Represents the input of a list deployment instances operation. +// Represents the input of a ListDeploymentInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentInstancesInput type ListDeploymentInstancesInput struct { _ struct{} `type:"structure"` @@ -7882,7 +8049,7 @@ func (s *ListDeploymentInstancesInput) SetNextToken(v string) *ListDeploymentIns return s } -// Represents the output of a list deployment instances operation. +// Represents the output of a ListDeploymentInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentInstancesOutput type ListDeploymentInstancesOutput struct { _ struct{} `type:"structure"` @@ -7918,7 +8085,7 @@ func (s *ListDeploymentInstancesOutput) SetNextToken(v string) *ListDeploymentIn return s } -// Represents the input of a list deployments operation. +// Represents the input of a ListDeployments operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentsInput type ListDeploymentsInput struct { _ struct{} `type:"structure"` @@ -8009,7 +8176,7 @@ func (s *ListDeploymentsInput) SetNextToken(v string) *ListDeploymentsInput { return s } -// Represents the output of a list deployments operation. +// Represents the output of a ListDeployments operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListDeploymentsOutput type ListDeploymentsOutput struct { _ struct{} `type:"structure"` @@ -8045,7 +8212,69 @@ func (s *ListDeploymentsOutput) SetNextToken(v string) *ListDeploymentsOutput { return s } -// Represents the input of a list on-premises instances operation. +// Represents the input of a ListGitHubAccountTokenNames operation. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListGitHubAccountTokenNamesInput +type ListGitHubAccountTokenNamesInput struct { + _ struct{} `type:"structure"` + + // An identifier returned from the previous ListGitHubAccountTokenNames call. + // It can be used to return the next set of names in the list. + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListGitHubAccountTokenNamesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListGitHubAccountTokenNamesInput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListGitHubAccountTokenNamesInput) SetNextToken(v string) *ListGitHubAccountTokenNamesInput { + s.NextToken = &v + return s +} + +// Represents the output of a ListGitHubAccountTokenNames operation. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListGitHubAccountTokenNamesOutput +type ListGitHubAccountTokenNamesOutput struct { + _ struct{} `type:"structure"` + + // If a large amount of information is returned, an identifier is also returned. + // It can be used in a subsequent ListGitHubAccountTokenNames call to return + // the next set of names in the list. + NextToken *string `locationName:"nextToken" type:"string"` + + // A list of names of connections to GitHub accounts. + TokenNameList []*string `locationName:"tokenNameList" type:"list"` +} + +// String returns the string representation +func (s ListGitHubAccountTokenNamesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListGitHubAccountTokenNamesOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListGitHubAccountTokenNamesOutput) SetNextToken(v string) *ListGitHubAccountTokenNamesOutput { + s.NextToken = &v + return s +} + +// SetTokenNameList sets the TokenNameList field's value. +func (s *ListGitHubAccountTokenNamesOutput) SetTokenNameList(v []*string) *ListGitHubAccountTokenNamesOutput { + s.TokenNameList = v + return s +} + +// Represents the input of a ListOnPremisesInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/ListOnPremisesInstancesInput type ListOnPremisesInstancesInput struct { _ struct{} `type:"structure"` @@ -8217,7 +8446,7 @@ func (s *MinimumHealthyHosts) SetValue(v int64) *MinimumHealthyHosts { return s } -// Represents the input of a register application revision operation. +// Represents the input of a RegisterApplicationRevision operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/RegisterApplicationRevisionInput type RegisterApplicationRevisionInput struct { _ struct{} `type:"structure"` @@ -8373,7 +8602,7 @@ func (s RegisterOnPremisesInstanceOutput) GoString() string { return s.String() } -// Represents the input of a remove tags from on-premises instances operation. +// Represents the input of a RemoveTagsFromOnPremisesInstances operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/RemoveTagsFromOnPremisesInstancesInput type RemoveTagsFromOnPremisesInstancesInput struct { _ struct{} `type:"structure"` @@ -8687,7 +8916,7 @@ func (s SkipWaitTimeForInstanceTerminationOutput) GoString() string { return s.String() } -// Represents the input of a stop deployment operation. +// Represents the input of a StopDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/StopDeploymentInput type StopDeploymentInput struct { _ struct{} `type:"structure"` @@ -8738,7 +8967,7 @@ func (s *StopDeploymentInput) SetDeploymentId(v string) *StopDeploymentInput { return s } -// Represents the output of a stop deployment operation. +// Represents the output of a StopDeployment operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/StopDeploymentOutput type StopDeploymentOutput struct { _ struct{} `type:"structure"` @@ -8978,7 +9207,7 @@ func (s *TriggerConfig) SetTriggerTargetArn(v string) *TriggerConfig { return s } -// Represents the input of an update application operation. +// Represents the input of an UpdateApplication operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/UpdateApplicationInput type UpdateApplicationInput struct { _ struct{} `type:"structure"` @@ -9043,7 +9272,7 @@ func (s UpdateApplicationOutput) GoString() string { return s.String() } -// Represents the input of an update deployment group operation. +// Represents the input of an UpdateDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/UpdateDeploymentGroupInput type UpdateDeploymentGroupInput struct { _ struct{} `type:"structure"` @@ -9230,7 +9459,7 @@ func (s *UpdateDeploymentGroupInput) SetTriggerConfigurations(v []*TriggerConfig return s } -// Represents the output of an update deployment group operation. +// Represents the output of an UpdateDeploymentGroup operation. // Please also see https://docs.aws.amazon.com/goto/WebAPI/codedeploy-2014-10-06/UpdateDeploymentGroupOutput type UpdateDeploymentGroupOutput struct { _ struct{} `type:"structure"` diff --git a/service/codedeploy/codedeployiface/interface.go b/service/codedeploy/codedeployiface/interface.go index a698bc735b8..c7d8620a95d 100644 --- a/service/codedeploy/codedeployiface/interface.go +++ b/service/codedeploy/codedeployiface/interface.go @@ -194,6 +194,10 @@ type CodeDeployAPI interface { ListDeploymentsPages(*codedeploy.ListDeploymentsInput, func(*codedeploy.ListDeploymentsOutput, bool) bool) error ListDeploymentsPagesWithContext(aws.Context, *codedeploy.ListDeploymentsInput, func(*codedeploy.ListDeploymentsOutput, bool) bool, ...request.Option) error + ListGitHubAccountTokenNames(*codedeploy.ListGitHubAccountTokenNamesInput) (*codedeploy.ListGitHubAccountTokenNamesOutput, error) + ListGitHubAccountTokenNamesWithContext(aws.Context, *codedeploy.ListGitHubAccountTokenNamesInput, ...request.Option) (*codedeploy.ListGitHubAccountTokenNamesOutput, error) + ListGitHubAccountTokenNamesRequest(*codedeploy.ListGitHubAccountTokenNamesInput) (*request.Request, *codedeploy.ListGitHubAccountTokenNamesOutput) + ListOnPremisesInstances(*codedeploy.ListOnPremisesInstancesInput) (*codedeploy.ListOnPremisesInstancesOutput, error) ListOnPremisesInstancesWithContext(aws.Context, *codedeploy.ListOnPremisesInstancesInput, ...request.Option) (*codedeploy.ListOnPremisesInstancesOutput, error) ListOnPremisesInstancesRequest(*codedeploy.ListOnPremisesInstancesInput) (*request.Request, *codedeploy.ListOnPremisesInstancesOutput) diff --git a/service/codedeploy/errors.go b/service/codedeploy/errors.go index 1e1e41c655a..cf425556c37 100644 --- a/service/codedeploy/errors.go +++ b/service/codedeploy/errors.go @@ -467,6 +467,12 @@ const ( // Use only one ARN type. ErrCodeMultipleIamArnsProvidedException = "MultipleIamArnsProvidedException" + // ErrCodeResourceValidationException for service response error code + // "ResourceValidationException". + // + // The specified resource could not be validated. + ErrCodeResourceValidationException = "ResourceValidationException" + // ErrCodeRevisionDoesNotExistException for service response error code // "RevisionDoesNotExistException". // diff --git a/service/codedeploy/examples_test.go b/service/codedeploy/examples_test.go index 8c5fcdbe23e..493bc4b2442 100644 --- a/service/codedeploy/examples_test.go +++ b/service/codedeploy/examples_test.go @@ -832,6 +832,27 @@ func ExampleCodeDeploy_ListDeployments() { fmt.Println(resp) } +func ExampleCodeDeploy_ListGitHubAccountTokenNames() { + sess := session.Must(session.NewSession()) + + svc := codedeploy.New(sess) + + params := &codedeploy.ListGitHubAccountTokenNamesInput{ + NextToken: aws.String("NextToken"), + } + resp, err := svc.ListGitHubAccountTokenNames(params) + + if err != nil { + // Print the error, cast err to awserr.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()) diff --git a/service/cognitoidentityprovider/api.go b/service/cognitoidentityprovider/api.go index 4349f0b3e6f..840b4ae35ca 100644 --- a/service/cognitoidentityprovider/api.go +++ b/service/cognitoidentityprovider/api.go @@ -78,11 +78,11 @@ func (c *CognitoIdentityProvider) AddCustomAttributesRequest(input *AddCustomAtt // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserImportInProgressException "UserImportInProgressException" // This exception is thrown when you are trying to modify a user pool while @@ -181,11 +181,11 @@ func (c *CognitoIdentityProvider) AdminAddUserToGroupRequest(input *AdminAddUser // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -282,18 +282,18 @@ func (c *CognitoIdentityProvider) AdminConfirmSignUpRequest(input *AdminConfirmS // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyFailedAttemptsException "TooManyFailedAttemptsException" -// This exception gets thrown when the user has made too many failed attempts +// This exception is thrown when the user has made too many failed attempts // for a given action (e.g., sign in). // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -301,8 +301,8 @@ func (c *CognitoIdentityProvider) AdminConfirmSignUpRequest(input *AdminConfirmS // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -383,9 +383,9 @@ func (c *CognitoIdentityProvider) AdminCreateUserRequest(input *AdminCreateUserI // // Creates a new user in the specified user pool and sends a welcome message // via email or phone (SMS). This message is based on a template that you configured -// in your call to CreateUserPool or UpdateUserPool. This template includes -// your custom sign-up instructions and placeholders for user name and temporary -// password. +// in your call to CreateUserPool (API_CreateUserPool.html) or UpdateUserPool +// (API_UpdateUserPool.html). This template includes your custom sign-up instructions +// and placeholders for user name and temporary password. // // Requires developer credentials. // @@ -420,11 +420,11 @@ func (c *CognitoIdentityProvider) AdminCreateUserRequest(input *AdminCreateUserI // This exception is thrown when a verification code fails to deliver successfully. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -445,11 +445,11 @@ func (c *CognitoIdentityProvider) AdminCreateUserRequest(input *AdminCreateUserI // the SMS configuration for the user pool. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUnsupportedUserStateException "UnsupportedUserStateException" // The request failed because the user is in an unsupported state. @@ -547,11 +547,11 @@ func (c *CognitoIdentityProvider) AdminDeleteUserRequest(input *AdminDeleteUserI // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -648,11 +648,11 @@ func (c *CognitoIdentityProvider) AdminDeleteUserAttributesRequest(input *AdminD // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -748,11 +748,11 @@ func (c *CognitoIdentityProvider) AdminDisableUserRequest(input *AdminDisableUse // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -848,11 +848,11 @@ func (c *CognitoIdentityProvider) AdminEnableUserRequest(input *AdminEnableUserI // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -953,11 +953,11 @@ func (c *CognitoIdentityProvider) AdminForgetDeviceRequest(input *AdminForgetDev // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -1056,14 +1056,14 @@ func (c *CognitoIdentityProvider) AdminGetDeviceRequest(input *AdminGetDeviceInp // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/AdminGetDevice func (c *CognitoIdentityProvider) AdminGetDevice(input *AdminGetDeviceInput) (*AdminGetDeviceOutput, error) { @@ -1154,11 +1154,11 @@ func (c *CognitoIdentityProvider) AdminGetUserRequest(input *AdminGetUserInput) // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -1254,24 +1254,24 @@ func (c *CognitoIdentityProvider) AdminInitiateAuthRequest(input *AdminInitiateA // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -1392,14 +1392,14 @@ func (c *CognitoIdentityProvider) AdminListDevicesRequest(input *AdminListDevice // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/AdminListDevices func (c *CognitoIdentityProvider) AdminListDevices(input *AdminListDevicesInput) (*AdminListDevicesOutput, error) { @@ -1489,11 +1489,11 @@ func (c *CognitoIdentityProvider) AdminListGroupsForUserRequest(input *AdminList // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -1591,11 +1591,11 @@ func (c *CognitoIdentityProvider) AdminRemoveUserFromGroupRequest(input *AdminRe // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -1702,23 +1702,23 @@ func (c *CognitoIdentityProvider) AdminResetUserPasswordRequest(input *AdminRese // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" // This exception is thrown when the Amazon Cognito service encounters an invalid // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -1818,7 +1818,7 @@ func (c *CognitoIdentityProvider) AdminRespondToAuthChallengeRequest(input *Admi // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeCodeMismatchException "CodeMismatchException" // This exception is thrown if the provided code does not match what the server @@ -1828,15 +1828,15 @@ func (c *CognitoIdentityProvider) AdminRespondToAuthChallengeRequest(input *Admi // This exception is thrown if a code has expired. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeInvalidPasswordException "InvalidPasswordException" // This exception is thrown when the Amazon Cognito service encounters an invalid // password. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -1844,8 +1844,8 @@ func (c *CognitoIdentityProvider) AdminRespondToAuthChallengeRequest(input *Admi // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. @@ -1970,7 +1970,7 @@ func (c *CognitoIdentityProvider) AdminSetUserSettingsRequest(input *AdminSetUse // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -2069,11 +2069,11 @@ func (c *CognitoIdentityProvider) AdminUpdateDeviceStatusRequest(input *AdminUpd // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -2151,6 +2151,12 @@ func (c *CognitoIdentityProvider) AdminUpdateUserAttributesRequest(input *AdminU // Updates the specified user's attributes, including developer attributes, // as an administrator. Works on any user. // +// For custom attributes, you must prepend the custom: prefix to the attribute +// name. +// +// In addition to updating user attributes, this API can also be used to mark +// phone and email as verified. +// // Requires developer credentials. // // Returns awserr.Error for service API and SDK errors. Use runtime type assertions @@ -2170,11 +2176,11 @@ func (c *CognitoIdentityProvider) AdminUpdateUserAttributesRequest(input *AdminU // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -2188,11 +2194,11 @@ func (c *CognitoIdentityProvider) AdminUpdateUserAttributesRequest(input *AdminU // already exists. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -2288,11 +2294,11 @@ func (c *CognitoIdentityProvider) AdminUserGlobalSignOutRequest(input *AdminUser // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserNotFoundException "UserNotFoundException" // This exception is thrown when a user is not found. @@ -2391,11 +2397,11 @@ func (c *CognitoIdentityProvider) ChangePasswordRequest(input *ChangePasswordInp // password. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -2480,7 +2486,7 @@ func (c *CognitoIdentityProvider) ConfirmDeviceRequest(input *ConfirmDeviceInput // ConfirmDevice API operation for Amazon Cognito Identity Provider. // -// Confirms tracking of the device. This API call is the call that beings device +// Confirms tracking of the device. This API call is the call that begins device // tracking. // // Returns awserr.Error for service API and SDK errors. Use runtime type assertions @@ -2500,7 +2506,7 @@ func (c *CognitoIdentityProvider) ConfirmDeviceRequest(input *ConfirmDeviceInput // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidPasswordException "InvalidPasswordException" // This exception is thrown when the Amazon Cognito service encounters an invalid @@ -2518,8 +2524,8 @@ func (c *CognitoIdentityProvider) ConfirmDeviceRequest(input *ConfirmDeviceInput // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -2601,8 +2607,7 @@ func (c *CognitoIdentityProvider) ConfirmForgotPasswordRequest(input *ConfirmFor // ConfirmForgotPassword API operation for Amazon Cognito Identity Provider. // -// Allows a user to enter a code provided when they reset their password to -// update their password. +// Allows a user to enter a confirmation code to reset a forgotten password. // // 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 @@ -2617,11 +2622,11 @@ func (c *CognitoIdentityProvider) ConfirmForgotPasswordRequest(input *ConfirmFor // requested resource. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidParameterException "InvalidParameterException" @@ -2633,7 +2638,7 @@ func (c *CognitoIdentityProvider) ConfirmForgotPasswordRequest(input *ConfirmFor // password. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeCodeMismatchException "CodeMismatchException" // This exception is thrown if the provided code does not match what the server @@ -2643,7 +2648,7 @@ func (c *CognitoIdentityProvider) ConfirmForgotPasswordRequest(input *ConfirmFor // This exception is thrown if a code has expired. // // * ErrCodeTooManyFailedAttemptsException "TooManyFailedAttemptsException" -// This exception gets thrown when the user has made too many failed attempts +// This exception is thrown when the user has made too many failed attempts // for a given action (e.g., sign in). // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -2651,8 +2656,8 @@ func (c *CognitoIdentityProvider) ConfirmForgotPasswordRequest(input *ConfirmFor // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -2755,18 +2760,18 @@ func (c *CognitoIdentityProvider) ConfirmSignUpRequest(input *ConfirmSignUpInput // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyFailedAttemptsException "TooManyFailedAttemptsException" -// This exception gets thrown when the user has made too many failed attempts +// This exception is thrown when the user has made too many failed attempts // for a given action (e.g., sign in). // // * ErrCodeCodeMismatchException "CodeMismatchException" @@ -2787,8 +2792,8 @@ func (c *CognitoIdentityProvider) ConfirmSignUpRequest(input *ConfirmSignUpInput // already exists. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -2892,15 +2897,15 @@ func (c *CognitoIdentityProvider) CreateGroupRequest(input *CreateGroupInput) (r // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS // resource. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -2927,6 +2932,109 @@ func (c *CognitoIdentityProvider) CreateGroupWithContext(ctx aws.Context, input return out, req.Send() } +const opCreateIdentityProvider = "CreateIdentityProvider" + +// CreateIdentityProviderRequest generates a "aws/request.Request" representing the +// client's request for the CreateIdentityProvider operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See CreateIdentityProvider for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the CreateIdentityProvider method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the CreateIdentityProviderRequest method. +// req, resp := client.CreateIdentityProviderRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateIdentityProvider +func (c *CognitoIdentityProvider) CreateIdentityProviderRequest(input *CreateIdentityProviderInput) (req *request.Request, output *CreateIdentityProviderOutput) { + op := &request.Operation{ + Name: opCreateIdentityProvider, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateIdentityProviderInput{} + } + + output = &CreateIdentityProviderOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateIdentityProvider API operation for Amazon Cognito Identity Provider. +// +// Creates an identity provider for a user pool. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation CreateIdentityProvider for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeDuplicateProviderException "DuplicateProviderException" +// This exception is thrown when the provider is already supported by the user +// pool. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeLimitExceededException "LimitExceededException" +// This exception is thrown when a user exceeds the limit for a requested AWS +// resource. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateIdentityProvider +func (c *CognitoIdentityProvider) CreateIdentityProvider(input *CreateIdentityProviderInput) (*CreateIdentityProviderOutput, error) { + req, out := c.CreateIdentityProviderRequest(input) + return out, req.Send() +} + +// CreateIdentityProviderWithContext is the same as CreateIdentityProvider with the addition of +// the ability to pass a context and additional request options. +// +// See CreateIdentityProvider for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) CreateIdentityProviderWithContext(ctx aws.Context, input *CreateIdentityProviderInput, opts ...request.Option) (*CreateIdentityProviderOutput, error) { + req, out := c.CreateIdentityProviderRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opCreateUserImportJob = "CreateUserImportJob" // CreateUserImportJobRequest generates a "aws/request.Request" representing the @@ -2991,14 +3099,14 @@ func (c *CognitoIdentityProvider) CreateUserImportJobRequest(input *CreateUserIm // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePreconditionNotMetException "PreconditionNotMetException" // This exception is thrown when a precondition is not met. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -3090,8 +3198,8 @@ func (c *CognitoIdentityProvider) CreateUserPoolRequest(input *CreateUserPoolInp // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -3112,10 +3220,10 @@ func (c *CognitoIdentityProvider) CreateUserPoolRequest(input *CreateUserPoolInp // identity. HTTP status code: 400. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserPoolTaggingException "UserPoolTaggingException" -// This exception gets thrown when a user pool tag cannot be set or updated. +// This exception is thrown when a user pool tag cannot be set or updated. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -3206,15 +3314,21 @@ func (c *CognitoIdentityProvider) CreateUserPoolClientRequest(input *CreateUserP // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS // resource. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. +// +// * ErrCodeScopeDoesNotExistException "ScopeDoesNotExistException" +// This exception is thrown when the specified scope does not exist. +// +// * ErrCodeInvalidOAuthFlowException "InvalidOAuthFlowException" +// This exception is thrown when the specified OAuth flow is invalid. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -3241,6 +3355,97 @@ func (c *CognitoIdentityProvider) CreateUserPoolClientWithContext(ctx aws.Contex return out, req.Send() } +const opCreateUserPoolDomain = "CreateUserPoolDomain" + +// CreateUserPoolDomainRequest generates a "aws/request.Request" representing the +// client's request for the CreateUserPoolDomain operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See CreateUserPoolDomain for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the CreateUserPoolDomain method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the CreateUserPoolDomainRequest method. +// req, resp := client.CreateUserPoolDomainRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserPoolDomain +func (c *CognitoIdentityProvider) CreateUserPoolDomainRequest(input *CreateUserPoolDomainInput) (req *request.Request, output *CreateUserPoolDomainOutput) { + op := &request.Operation{ + Name: opCreateUserPoolDomain, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateUserPoolDomainInput{} + } + + output = &CreateUserPoolDomainOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateUserPoolDomain API operation for Amazon Cognito Identity Provider. +// +// Creates a new domain for a user pool. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation CreateUserPoolDomain for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserPoolDomain +func (c *CognitoIdentityProvider) CreateUserPoolDomain(input *CreateUserPoolDomainInput) (*CreateUserPoolDomainOutput, error) { + req, out := c.CreateUserPoolDomainRequest(input) + return out, req.Send() +} + +// CreateUserPoolDomainWithContext is the same as CreateUserPoolDomain with the addition of +// the ability to pass a context and additional request options. +// +// See CreateUserPoolDomain for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) CreateUserPoolDomainWithContext(ctx aws.Context, input *CreateUserPoolDomainInput, opts ...request.Option) (*CreateUserPoolDomainOutput, error) { + req, out := c.CreateUserPoolDomainRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDeleteGroup = "DeleteGroup" // DeleteGroupRequest generates a "aws/request.Request" representing the @@ -3309,11 +3514,11 @@ func (c *CognitoIdentityProvider) DeleteGroupRequest(input *DeleteGroupInput) (r // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -3340,6 +3545,106 @@ func (c *CognitoIdentityProvider) DeleteGroupWithContext(ctx aws.Context, input return out, req.Send() } +const opDeleteIdentityProvider = "DeleteIdentityProvider" + +// DeleteIdentityProviderRequest generates a "aws/request.Request" representing the +// client's request for the DeleteIdentityProvider operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DeleteIdentityProvider for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DeleteIdentityProvider method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DeleteIdentityProviderRequest method. +// req, resp := client.DeleteIdentityProviderRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteIdentityProvider +func (c *CognitoIdentityProvider) DeleteIdentityProviderRequest(input *DeleteIdentityProviderInput) (req *request.Request, output *DeleteIdentityProviderOutput) { + op := &request.Operation{ + Name: opDeleteIdentityProvider, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteIdentityProviderInput{} + } + + output = &DeleteIdentityProviderOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Remove(jsonrpc.UnmarshalHandler) + req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeleteIdentityProvider API operation for Amazon Cognito Identity Provider. +// +// Deletes an identity provider for a user pool. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation DeleteIdentityProvider for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeUnsupportedIdentityProviderException "UnsupportedIdentityProviderException" +// This exception is thrown when the specified identifier is not supported. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteIdentityProvider +func (c *CognitoIdentityProvider) DeleteIdentityProvider(input *DeleteIdentityProviderInput) (*DeleteIdentityProviderOutput, error) { + req, out := c.DeleteIdentityProviderRequest(input) + return out, req.Send() +} + +// DeleteIdentityProviderWithContext is the same as DeleteIdentityProvider with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteIdentityProvider for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) DeleteIdentityProviderWithContext(ctx aws.Context, input *DeleteIdentityProviderInput, opts ...request.Option) (*DeleteIdentityProviderOutput, error) { + req, out := c.DeleteIdentityProviderRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDeleteUser = "DeleteUser" // DeleteUserRequest generates a "aws/request.Request" representing the @@ -3407,11 +3712,11 @@ func (c *CognitoIdentityProvider) DeleteUserRequest(input *DeleteUserInput) (req // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -3512,11 +3817,11 @@ func (c *CognitoIdentityProvider) DeleteUserAttributesRequest(input *DeleteUserA // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -3618,11 +3923,11 @@ func (c *CognitoIdentityProvider) DeleteUserPoolRequest(input *DeleteUserPoolInp // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserImportInProgressException "UserImportInProgressException" // This exception is thrown when you are trying to modify a user pool while @@ -3719,11 +4024,11 @@ func (c *CognitoIdentityProvider) DeleteUserPoolClientRequest(input *DeleteUserP // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -3750,105 +4055,291 @@ func (c *CognitoIdentityProvider) DeleteUserPoolClientWithContext(ctx aws.Contex return out, req.Send() } -const opDescribeUserImportJob = "DescribeUserImportJob" +const opDeleteUserPoolDomain = "DeleteUserPoolDomain" -// DescribeUserImportJobRequest generates a "aws/request.Request" representing the -// client's request for the DescribeUserImportJob operation. The "output" return +// DeleteUserPoolDomainRequest generates a "aws/request.Request" representing the +// client's request for the DeleteUserPoolDomain operation. The "output" return // value can be used to capture response data after the request's "Send" method // is called. // -// See DescribeUserImportJob for usage and error information. +// See DeleteUserPoolDomain for usage and error information. // // Creating a request object using this method should be used when you want to inject // custom logic into the request's lifecycle using a custom handler, or if you want to // access properties on the request object before or after sending the request. If -// you just want the service response, call the DescribeUserImportJob method directly +// you just want the service response, call the DeleteUserPoolDomain method directly // instead. // // Note: You must call the "Send" method on the returned request object in order // to execute the request. // -// // Example sending a request using the DescribeUserImportJobRequest method. -// req, resp := client.DescribeUserImportJobRequest(params) +// // Example sending a request using the DeleteUserPoolDomainRequest method. +// req, resp := client.DeleteUserPoolDomainRequest(params) // // err := req.Send() // if err == nil { // resp is now filled // fmt.Println(resp) // } // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserImportJob -func (c *CognitoIdentityProvider) DescribeUserImportJobRequest(input *DescribeUserImportJobInput) (req *request.Request, output *DescribeUserImportJobOutput) { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolDomain +func (c *CognitoIdentityProvider) DeleteUserPoolDomainRequest(input *DeleteUserPoolDomainInput) (req *request.Request, output *DeleteUserPoolDomainOutput) { op := &request.Operation{ - Name: opDescribeUserImportJob, + Name: opDeleteUserPoolDomain, HTTPMethod: "POST", HTTPPath: "/", } if input == nil { - input = &DescribeUserImportJobInput{} + input = &DeleteUserPoolDomainInput{} } - output = &DescribeUserImportJobOutput{} + output = &DeleteUserPoolDomainOutput{} req = c.newRequest(op, input, output) return } -// DescribeUserImportJob API operation for Amazon Cognito Identity Provider. +// DeleteUserPoolDomain API operation for Amazon Cognito Identity Provider. // -// Describes the user import job. +// Deletes a domain for a user pool. // // 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. // // See the AWS API reference guide for Amazon Cognito Identity Provider's -// API operation DescribeUserImportJob for usage and error information. +// API operation DeleteUserPoolDomain for usage and error information. // // Returned Error Codes: -// * ErrCodeResourceNotFoundException "ResourceNotFoundException" -// This exception is thrown when the Amazon Cognito service cannot find the -// requested resource. +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidParameterException "InvalidParameterException" // This exception is thrown when the Amazon Cognito service encounters an invalid // parameter. // -// * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. -// -// * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserImportJob -func (c *CognitoIdentityProvider) DescribeUserImportJob(input *DescribeUserImportJobInput) (*DescribeUserImportJobOutput, error) { - req, out := c.DescribeUserImportJobRequest(input) +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolDomain +func (c *CognitoIdentityProvider) DeleteUserPoolDomain(input *DeleteUserPoolDomainInput) (*DeleteUserPoolDomainOutput, error) { + req, out := c.DeleteUserPoolDomainRequest(input) return out, req.Send() } -// DescribeUserImportJobWithContext is the same as DescribeUserImportJob with the addition of +// DeleteUserPoolDomainWithContext is the same as DeleteUserPoolDomain with the addition of // the ability to pass a context and additional request options. // -// See DescribeUserImportJob for details on how to use this API operation. +// See DeleteUserPoolDomain for details on how to use this API operation. // // The context must be non-nil and will be used for request cancellation. If // the context is nil a panic will occur. In the future the SDK may create // sub-contexts for http.Requests. See https://golang.org/pkg/context/ // for more information on using Contexts. -func (c *CognitoIdentityProvider) DescribeUserImportJobWithContext(ctx aws.Context, input *DescribeUserImportJobInput, opts ...request.Option) (*DescribeUserImportJobOutput, error) { - req, out := c.DescribeUserImportJobRequest(input) +func (c *CognitoIdentityProvider) DeleteUserPoolDomainWithContext(ctx aws.Context, input *DeleteUserPoolDomainInput, opts ...request.Option) (*DeleteUserPoolDomainOutput, error) { + req, out := c.DeleteUserPoolDomainRequest(input) req.SetContext(ctx) req.ApplyOptions(opts...) return out, req.Send() } -const opDescribeUserPool = "DescribeUserPool" +const opDescribeIdentityProvider = "DescribeIdentityProvider" -// DescribeUserPoolRequest generates a "aws/request.Request" representing the -// client's request for the DescribeUserPool operation. The "output" return +// DescribeIdentityProviderRequest generates a "aws/request.Request" representing the +// client's request for the DescribeIdentityProvider operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DescribeIdentityProvider for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DescribeIdentityProvider method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DescribeIdentityProviderRequest method. +// req, resp := client.DescribeIdentityProviderRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeIdentityProvider +func (c *CognitoIdentityProvider) DescribeIdentityProviderRequest(input *DescribeIdentityProviderInput) (req *request.Request, output *DescribeIdentityProviderOutput) { + op := &request.Operation{ + Name: opDescribeIdentityProvider, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeIdentityProviderInput{} + } + + output = &DescribeIdentityProviderOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeIdentityProvider API operation for Amazon Cognito Identity Provider. +// +// Gets information about a specific identity provider. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation DescribeIdentityProvider for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeIdentityProvider +func (c *CognitoIdentityProvider) DescribeIdentityProvider(input *DescribeIdentityProviderInput) (*DescribeIdentityProviderOutput, error) { + req, out := c.DescribeIdentityProviderRequest(input) + return out, req.Send() +} + +// DescribeIdentityProviderWithContext is the same as DescribeIdentityProvider with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeIdentityProvider for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) DescribeIdentityProviderWithContext(ctx aws.Context, input *DescribeIdentityProviderInput, opts ...request.Option) (*DescribeIdentityProviderOutput, error) { + req, out := c.DescribeIdentityProviderRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeUserImportJob = "DescribeUserImportJob" + +// DescribeUserImportJobRequest generates a "aws/request.Request" representing the +// client's request for the DescribeUserImportJob operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DescribeUserImportJob for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DescribeUserImportJob method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DescribeUserImportJobRequest method. +// req, resp := client.DescribeUserImportJobRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserImportJob +func (c *CognitoIdentityProvider) DescribeUserImportJobRequest(input *DescribeUserImportJobInput) (req *request.Request, output *DescribeUserImportJobOutput) { + op := &request.Operation{ + Name: opDescribeUserImportJob, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeUserImportJobInput{} + } + + output = &DescribeUserImportJobOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeUserImportJob API operation for Amazon Cognito Identity Provider. +// +// Describes the user import job. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation DescribeUserImportJob for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserImportJob +func (c *CognitoIdentityProvider) DescribeUserImportJob(input *DescribeUserImportJobInput) (*DescribeUserImportJobOutput, error) { + req, out := c.DescribeUserImportJobRequest(input) + return out, req.Send() +} + +// DescribeUserImportJobWithContext is the same as DescribeUserImportJob with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeUserImportJob for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) DescribeUserImportJobWithContext(ctx aws.Context, input *DescribeUserImportJobInput, opts ...request.Option) (*DescribeUserImportJobOutput, error) { + req, out := c.DescribeUserImportJobRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeUserPool = "DescribeUserPool" + +// DescribeUserPoolRequest generates a "aws/request.Request" representing the +// client's request for the DescribeUserPool operation. The "output" return // value can be used to capture response data after the request's "Send" method // is called. // @@ -3910,14 +4401,14 @@ func (c *CognitoIdentityProvider) DescribeUserPoolRequest(input *DescribeUserPoo // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserPoolTaggingException "UserPoolTaggingException" -// This exception gets thrown when a user pool tag cannot be set or updated. +// This exception is thrown when a user pool tag cannot be set or updated. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -4009,11 +4500,11 @@ func (c *CognitoIdentityProvider) DescribeUserPoolClientRequest(input *DescribeU // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -4040,6 +4531,97 @@ func (c *CognitoIdentityProvider) DescribeUserPoolClientWithContext(ctx aws.Cont return out, req.Send() } +const opDescribeUserPoolDomain = "DescribeUserPoolDomain" + +// DescribeUserPoolDomainRequest generates a "aws/request.Request" representing the +// client's request for the DescribeUserPoolDomain operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DescribeUserPoolDomain for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DescribeUserPoolDomain method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DescribeUserPoolDomainRequest method. +// req, resp := client.DescribeUserPoolDomainRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserPoolDomain +func (c *CognitoIdentityProvider) DescribeUserPoolDomainRequest(input *DescribeUserPoolDomainInput) (req *request.Request, output *DescribeUserPoolDomainOutput) { + op := &request.Operation{ + Name: opDescribeUserPoolDomain, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeUserPoolDomainInput{} + } + + output = &DescribeUserPoolDomainOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeUserPoolDomain API operation for Amazon Cognito Identity Provider. +// +// Gets information about a domain. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation DescribeUserPoolDomain for usage and error information. +// +// Returned Error Codes: +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserPoolDomain +func (c *CognitoIdentityProvider) DescribeUserPoolDomain(input *DescribeUserPoolDomainInput) (*DescribeUserPoolDomainOutput, error) { + req, out := c.DescribeUserPoolDomainRequest(input) + return out, req.Send() +} + +// DescribeUserPoolDomainWithContext is the same as DescribeUserPoolDomain with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeUserPoolDomain for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) DescribeUserPoolDomainWithContext(ctx aws.Context, input *DescribeUserPoolDomainInput, opts ...request.Option) (*DescribeUserPoolDomainOutput, error) { + req, out := c.DescribeUserPoolDomainRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opForgetDevice = "ForgetDevice" // ForgetDeviceRequest generates a "aws/request.Request" representing the @@ -4106,11 +4688,11 @@ func (c *CognitoIdentityProvider) ForgetDeviceRequest(input *ForgetDeviceInput) // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. @@ -4195,7 +4777,14 @@ func (c *CognitoIdentityProvider) ForgotPasswordRequest(input *ForgotPasswordInp // ForgotPassword API operation for Amazon Cognito Identity Provider. // -// Retrieves the password for the specified client ID or username. +// Calling this API causes a message to be sent to the end user with a confirmation +// code that is required to change the user's password. For the Username parameter, +// you can use the username or user alias. If a verified phone number exists +// for the user, the confirmation code is sent to the phone number. Otherwise, +// if a verified email exists, the confirmation code is sent to the email. If +// neither a verified phone number nor a verified email exists, InvalidParameterException +// is thrown. To use the confirmation code for resetting the password, call +// ConfirmForgotPassword (API_ConfirmForgotPassword.html). // // 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 @@ -4214,23 +4803,23 @@ func (c *CognitoIdentityProvider) ForgotPasswordRequest(input *ForgotPasswordInp // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" // This exception is thrown when the Amazon Cognito service encounters an invalid // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -4349,11 +4938,11 @@ func (c *CognitoIdentityProvider) GetCSVHeaderRequest(input *GetCSVHeaderInput) // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -4447,11 +5036,11 @@ func (c *CognitoIdentityProvider) GetDeviceRequest(input *GetDeviceInput) (req * // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -4553,11 +5142,11 @@ func (c *CognitoIdentityProvider) GetGroupRequest(input *GetGroupInput) (req *re // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -4584,76 +5173,171 @@ func (c *CognitoIdentityProvider) GetGroupWithContext(ctx aws.Context, input *Ge return out, req.Send() } -const opGetUser = "GetUser" +const opGetIdentityProviderByIdentifier = "GetIdentityProviderByIdentifier" -// GetUserRequest generates a "aws/request.Request" representing the -// client's request for the GetUser operation. The "output" return +// GetIdentityProviderByIdentifierRequest generates a "aws/request.Request" representing the +// client's request for the GetIdentityProviderByIdentifier operation. The "output" return // value can be used to capture response data after the request's "Send" method // is called. // -// See GetUser for usage and error information. +// See GetIdentityProviderByIdentifier for usage and error information. // // Creating a request object using this method should be used when you want to inject // custom logic into the request's lifecycle using a custom handler, or if you want to // access properties on the request object before or after sending the request. If -// you just want the service response, call the GetUser method directly +// you just want the service response, call the GetIdentityProviderByIdentifier method directly // instead. // // Note: You must call the "Send" method on the returned request object in order // to execute the request. // -// // Example sending a request using the GetUserRequest method. -// req, resp := client.GetUserRequest(params) +// // Example sending a request using the GetIdentityProviderByIdentifierRequest method. +// req, resp := client.GetIdentityProviderByIdentifierRequest(params) // // err := req.Send() // if err == nil { // resp is now filled // fmt.Println(resp) // } // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetUser -func (c *CognitoIdentityProvider) GetUserRequest(input *GetUserInput) (req *request.Request, output *GetUserOutput) { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetIdentityProviderByIdentifier +func (c *CognitoIdentityProvider) GetIdentityProviderByIdentifierRequest(input *GetIdentityProviderByIdentifierInput) (req *request.Request, output *GetIdentityProviderByIdentifierOutput) { op := &request.Operation{ - Name: opGetUser, + Name: opGetIdentityProviderByIdentifier, HTTPMethod: "POST", HTTPPath: "/", } if input == nil { - input = &GetUserInput{} + input = &GetIdentityProviderByIdentifierInput{} } - output = &GetUserOutput{} + output = &GetIdentityProviderByIdentifierOutput{} req = c.newRequest(op, input, output) - req.Config.Credentials = credentials.AnonymousCredentials return } -// GetUser API operation for Amazon Cognito Identity Provider. +// GetIdentityProviderByIdentifier API operation for Amazon Cognito Identity Provider. // -// Gets the user attributes and metadata for a user. +// Gets the specified identity provider. // // 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. // // See the AWS API reference guide for Amazon Cognito Identity Provider's -// API operation GetUser for usage and error information. +// API operation GetIdentityProviderByIdentifier for usage and error information. // // Returned Error Codes: -// * ErrCodeResourceNotFoundException "ResourceNotFoundException" -// This exception is thrown when the Amazon Cognito service cannot find the -// requested resource. -// // * ErrCodeInvalidParameterException "InvalidParameterException" // This exception is thrown when the Amazon Cognito service encounters an invalid // parameter. // -// * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. -// -// * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetIdentityProviderByIdentifier +func (c *CognitoIdentityProvider) GetIdentityProviderByIdentifier(input *GetIdentityProviderByIdentifierInput) (*GetIdentityProviderByIdentifierOutput, error) { + req, out := c.GetIdentityProviderByIdentifierRequest(input) + return out, req.Send() +} + +// GetIdentityProviderByIdentifierWithContext is the same as GetIdentityProviderByIdentifier with the addition of +// the ability to pass a context and additional request options. +// +// See GetIdentityProviderByIdentifier for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) GetIdentityProviderByIdentifierWithContext(ctx aws.Context, input *GetIdentityProviderByIdentifierInput, opts ...request.Option) (*GetIdentityProviderByIdentifierOutput, error) { + req, out := c.GetIdentityProviderByIdentifierRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetUser = "GetUser" + +// GetUserRequest generates a "aws/request.Request" representing the +// client's request for the GetUser operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See GetUser for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the GetUser method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the GetUserRequest method. +// req, resp := client.GetUserRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetUser +func (c *CognitoIdentityProvider) GetUserRequest(input *GetUserInput) (req *request.Request, output *GetUserOutput) { + op := &request.Operation{ + Name: opGetUser, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetUserInput{} + } + + output = &GetUserOutput{} + req = c.newRequest(op, input, output) + req.Config.Credentials = credentials.AnonymousCredentials + return +} + +// GetUser API operation for Amazon Cognito Identity Provider. +// +// Gets the user attributes and metadata for a user. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation GetUser for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -4754,18 +5438,18 @@ func (c *CognitoIdentityProvider) GetUserAttributeVerificationCodeRequest(input // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -4891,11 +5575,11 @@ func (c *CognitoIdentityProvider) GlobalSignOutRequest(input *GlobalSignOutInput // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -4992,21 +5676,21 @@ func (c *CognitoIdentityProvider) InitiateAuthRequest(input *InitiateAuthInput) // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -5111,14 +5795,14 @@ func (c *CognitoIdentityProvider) ListDevicesRequest(input *ListDevicesInput) (r // requested resource. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -5220,11 +5904,11 @@ func (c *CognitoIdentityProvider) ListGroupsRequest(input *ListGroupsInput) (req // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5251,6 +5935,101 @@ func (c *CognitoIdentityProvider) ListGroupsWithContext(ctx aws.Context, input * return out, req.Send() } +const opListIdentityProviders = "ListIdentityProviders" + +// ListIdentityProvidersRequest generates a "aws/request.Request" representing the +// client's request for the ListIdentityProviders operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See ListIdentityProviders for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the ListIdentityProviders method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the ListIdentityProvidersRequest method. +// req, resp := client.ListIdentityProvidersRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListIdentityProviders +func (c *CognitoIdentityProvider) ListIdentityProvidersRequest(input *ListIdentityProvidersInput) (req *request.Request, output *ListIdentityProvidersOutput) { + op := &request.Operation{ + Name: opListIdentityProviders, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ListIdentityProvidersInput{} + } + + output = &ListIdentityProvidersOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListIdentityProviders API operation for Amazon Cognito Identity Provider. +// +// Lists information about all identity providers for a user pool. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation ListIdentityProviders for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListIdentityProviders +func (c *CognitoIdentityProvider) ListIdentityProviders(input *ListIdentityProvidersInput) (*ListIdentityProvidersOutput, error) { + req, out := c.ListIdentityProvidersRequest(input) + return out, req.Send() +} + +// ListIdentityProvidersWithContext is the same as ListIdentityProviders with the addition of +// the ability to pass a context and additional request options. +// +// See ListIdentityProviders for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) ListIdentityProvidersWithContext(ctx aws.Context, input *ListIdentityProvidersInput, opts ...request.Option) (*ListIdentityProvidersOutput, error) { + req, out := c.ListIdentityProvidersRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opListUserImportJobs = "ListUserImportJobs" // ListUserImportJobsRequest generates a "aws/request.Request" representing the @@ -5315,11 +6094,11 @@ func (c *CognitoIdentityProvider) ListUserImportJobsRequest(input *ListUserImpor // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5410,11 +6189,11 @@ func (c *CognitoIdentityProvider) ListUserPoolClientsRequest(input *ListUserPool // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5501,11 +6280,11 @@ func (c *CognitoIdentityProvider) ListUserPoolsRequest(input *ListUserPoolsInput // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5596,11 +6375,11 @@ func (c *CognitoIdentityProvider) ListUsersRequest(input *ListUsersInput) (req * // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5693,11 +6472,11 @@ func (c *CognitoIdentityProvider) ListUsersInGroupRequest(input *ListUsersInGrou // requested resource. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -5790,23 +6569,23 @@ func (c *CognitoIdentityProvider) ResendConfirmationCodeRequest(input *ResendCon // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" // This exception is thrown when the Amazon Cognito service encounters an invalid // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -5921,7 +6700,7 @@ func (c *CognitoIdentityProvider) RespondToAuthChallengeRequest(input *RespondTo // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeCodeMismatchException "CodeMismatchException" // This exception is thrown if the provided code does not match what the server @@ -5931,11 +6710,11 @@ func (c *CognitoIdentityProvider) RespondToAuthChallengeRequest(input *RespondTo // This exception is thrown if a code has expired. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidPasswordException "InvalidPasswordException" @@ -5947,8 +6726,8 @@ func (c *CognitoIdentityProvider) RespondToAuthChallengeRequest(input *RespondTo // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. @@ -6074,7 +6853,7 @@ func (c *CognitoIdentityProvider) SetUserSettingsRequest(input *SetUserSettingsI // parameter. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -6176,15 +6955,15 @@ func (c *CognitoIdentityProvider) SignUpRequest(input *SignUpInput) (req *reques // parameter. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidPasswordException "InvalidPasswordException" // This exception is thrown when the Amazon Cognito service encounters an invalid @@ -6199,8 +6978,8 @@ func (c *CognitoIdentityProvider) SignUpRequest(input *SignUpInput) (req *reques // already exists in the user pool. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -6308,8 +7087,8 @@ func (c *CognitoIdentityProvider) StartUserImportJobRequest(input *StartUserImpo // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -6318,7 +7097,7 @@ func (c *CognitoIdentityProvider) StartUserImportJobRequest(input *StartUserImpo // This exception is thrown when a precondition is not met. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/StartUserImportJob func (c *CognitoIdentityProvider) StartUserImportJob(input *StartUserImportJobInput) (*StartUserImportJobOutput, error) { @@ -6406,8 +7185,8 @@ func (c *CognitoIdentityProvider) StopUserImportJobRequest(input *StopUserImport // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -6416,7 +7195,7 @@ func (c *CognitoIdentityProvider) StopUserImportJobRequest(input *StopUserImport // This exception is thrown when a precondition is not met. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/StopUserImportJob func (c *CognitoIdentityProvider) StopUserImportJob(input *StopUserImportJobInput) (*StopUserImportJobOutput, error) { @@ -6504,14 +7283,14 @@ func (c *CognitoIdentityProvider) UpdateDeviceStatusRequest(input *UpdateDeviceS // requested resource. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInvalidUserPoolConfigurationException "InvalidUserPoolConfigurationException" // This exception is thrown when the user pool configuration is invalid. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodePasswordResetRequiredException "PasswordResetRequiredException" // This exception is thrown when a password reset is required. @@ -6613,11 +7392,11 @@ func (c *CognitoIdentityProvider) UpdateGroupRequest(input *UpdateGroupInput) (r // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -6644,6 +7423,104 @@ func (c *CognitoIdentityProvider) UpdateGroupWithContext(ctx aws.Context, input return out, req.Send() } +const opUpdateIdentityProvider = "UpdateIdentityProvider" + +// UpdateIdentityProviderRequest generates a "aws/request.Request" representing the +// client's request for the UpdateIdentityProvider operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See UpdateIdentityProvider for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the UpdateIdentityProvider method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the UpdateIdentityProviderRequest method. +// req, resp := client.UpdateIdentityProviderRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UpdateIdentityProvider +func (c *CognitoIdentityProvider) UpdateIdentityProviderRequest(input *UpdateIdentityProviderInput) (req *request.Request, output *UpdateIdentityProviderOutput) { + op := &request.Operation{ + Name: opUpdateIdentityProvider, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UpdateIdentityProviderInput{} + } + + output = &UpdateIdentityProviderOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateIdentityProvider API operation for Amazon Cognito Identity Provider. +// +// Updates identity provider information for a user pool. +// +// 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. +// +// See the AWS API reference guide for Amazon Cognito Identity Provider's +// API operation UpdateIdentityProvider for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameterException" +// This exception is thrown when the Amazon Cognito service encounters an invalid +// parameter. +// +// * ErrCodeUnsupportedIdentityProviderException "UnsupportedIdentityProviderException" +// This exception is thrown when the specified identifier is not supported. +// +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// This exception is thrown when the Amazon Cognito service cannot find the +// requested resource. +// +// * ErrCodeNotAuthorizedException "NotAuthorizedException" +// This exception is thrown when a user is not authorized. +// +// * ErrCodeTooManyRequestsException "TooManyRequestsException" +// This exception is thrown when the user has made too many requests for a given +// operation. +// +// * ErrCodeInternalErrorException "InternalErrorException" +// This exception is thrown when Amazon Cognito encounters an internal error. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UpdateIdentityProvider +func (c *CognitoIdentityProvider) UpdateIdentityProvider(input *UpdateIdentityProviderInput) (*UpdateIdentityProviderOutput, error) { + req, out := c.UpdateIdentityProviderRequest(input) + return out, req.Send() +} + +// UpdateIdentityProviderWithContext is the same as UpdateIdentityProvider with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateIdentityProvider for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *CognitoIdentityProvider) UpdateIdentityProviderWithContext(ctx aws.Context, input *UpdateIdentityProviderInput, opts ...request.Option) (*UpdateIdentityProviderOutput, error) { + req, out := c.UpdateIdentityProviderRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opUpdateUserAttributes = "UpdateUserAttributes" // UpdateUserAttributesRequest generates a "aws/request.Request" representing the @@ -6716,14 +7593,14 @@ func (c *CognitoIdentityProvider) UpdateUserAttributesRequest(input *UpdateUserA // This exception is thrown if a code has expired. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUnexpectedLambdaException "UnexpectedLambdaException" -// This exception gets thrown when the Amazon Cognito service encounters an -// unexpected exception with the AWS Lambda service. +// This exception is thrown when the Amazon Cognito service encounters an unexpected +// exception with the AWS Lambda service. // // * ErrCodeUserLambdaValidationException "UserLambdaValidationException" -// This exception gets thrown when the Amazon Cognito service encounters a user +// This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. // // * ErrCodeInvalidLambdaResponseException "InvalidLambdaResponseException" @@ -6731,8 +7608,8 @@ func (c *CognitoIdentityProvider) UpdateUserAttributesRequest(input *UpdateUserA // AWS Lambda response. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeAliasExistsException "AliasExistsException" // This exception is thrown when a user tries to confirm the account with an @@ -6858,11 +7735,11 @@ func (c *CognitoIdentityProvider) UpdateUserPoolRequest(input *UpdateUserPoolInp // This exception is thrown if two or more modifications are happening concurrently. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeUserImportInProgressException "UserImportInProgressException" // This exception is thrown when you are trying to modify a user pool while @@ -6882,7 +7759,7 @@ func (c *CognitoIdentityProvider) UpdateUserPoolRequest(input *UpdateUserPoolInp // the SMS configuration for the user pool. // // * ErrCodeUserPoolTaggingException "UserPoolTaggingException" -// This exception gets thrown when a user pool tag cannot be set or updated. +// This exception is thrown when a user pool tag cannot be set or updated. // // * ErrCodeInvalidEmailRoleAccessPolicyException "InvalidEmailRoleAccessPolicyException" // This exception is thrown when Amazon Cognito is not allowed to use your email @@ -6975,11 +7852,17 @@ func (c *CognitoIdentityProvider) UpdateUserPoolClientRequest(input *UpdateUserP // parameter. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. +// +// * ErrCodeScopeDoesNotExistException "ScopeDoesNotExistException" +// This exception is thrown when the specified scope does not exist. +// +// * ErrCodeInvalidOAuthFlowException "InvalidOAuthFlowException" +// This exception is thrown when the specified OAuth flow is invalid. // // * ErrCodeInternalErrorException "InternalErrorException" // This exception is thrown when Amazon Cognito encounters an internal error. @@ -7078,11 +7961,11 @@ func (c *CognitoIdentityProvider) VerifyUserAttributeRequest(input *VerifyUserAt // This exception is thrown if a code has expired. // // * ErrCodeNotAuthorizedException "NotAuthorizedException" -// This exception gets thrown when a user is not authorized. +// This exception is thrown when a user is not authorized. // // * ErrCodeTooManyRequestsException "TooManyRequestsException" -// This exception gets thrown when the user has made too many requests for a -// given operation. +// This exception is thrown when the user has made too many requests for a given +// operation. // // * ErrCodeLimitExceededException "LimitExceededException" // This exception is thrown when a user exceeds the limit for a requested AWS @@ -7390,7 +8273,7 @@ type AdminCreateUserConfigType struct { // The user account expiration limit, in days, after which the account is no // longer usable. To reset the account after that time limit, you must call // AdminCreateUser again, specifying "RESEND" for the MessageAction parameter. - // The default value for this paameter is 7. + // The default value for this parameter is 7. UnusedAccountValidityDays *int64 `type:"integer"` } @@ -7484,9 +8367,12 @@ type AdminCreateUserInput struct { // An array of name-value pairs that contain user attributes and attribute values // to be set for the user to be created. You can create a user without specifying // any attributes other than Username. However, any attributes that you specify - // as required (in CreateUserPool or in the Attributes tab of the console) must - // be supplied either by you (in your call to AdminCreateUser) or by the user - // (when he or she signs up in response to your welcome message). + // as required (in CreateUserPool (API_CreateUserPool.html) or in the Attributes + // tab of the console) must be supplied either by you (in your call to AdminCreateUser) + // or by the user (when he or she signs up in response to your welcome message). + // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. // // To send a message inviting the user to sign up, you must specify the user's // email address or phone number. This can be done in your call to AdminCreateUser @@ -7495,7 +8381,7 @@ type AdminCreateUserInput struct { // // In your call to AdminCreateUser, you can set the email_verified attribute // to True, and you can set the phone_number_verified attribute to True. (You - // cannot do this by calling other operations such as AdminUpdateUserAttributes.) + // can also do this by calling AdminUpdateUserAttributes (API_AdminUpdateUserAttributes.html).) // // * email: The email address of the user to whom the message that contains // the code and username will be sent. Required if the email_verified attribute @@ -7670,6 +8556,9 @@ type AdminDeleteUserAttributesInput struct { // An array of strings representing the user attribute names you wish to delete. // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. + // // UserAttributeNames is a required field UserAttributeNames []*string `type:"list" required:"true"` @@ -7916,7 +8805,7 @@ type AdminEnableUserInput struct { // UserPoolId is a required field UserPoolId *string `min:"1" type:"string" required:"true"` - // The user name of the user you wish to ebable. + // The user name of the user you wish to enable. // // Username is a required field Username *string `min:"1" type:"string" required:"true"` @@ -8337,20 +9226,57 @@ func (s *AdminGetUserOutput) SetUsername(v string) *AdminGetUserOutput { type AdminInitiateAuthInput struct { _ struct{} `type:"structure"` - // The authentication flow. + // The authentication flow for this call to execute. The API action will depend + // on this value. For example: + // + // * REFRESH_TOKEN_AUTH will take in a valid refresh token and return new + // tokens. + // + // * USER_SRP_AUTH will take in USERNAME and SRPA and return the SRP variables + // to be used for next challenge execution. + // + // Valid values include: + // + // * USER_SRP_AUTH: Authentication flow for the Secure Remote Password (SRP) + // protocol. + // + // * REFRESH_TOKEN_AUTH/REFRESH_TOKEN: Authentication flow for refreshing + // the access token and ID token by supplying a valid refresh token. + // + // * CUSTOM_AUTH: Custom authentication flow. + // + // * ADMIN_NO_SRP_AUTH: Non-SRP authentication flow; you can pass in the + // USERNAME and PASSWORD directly if the flow is enabled for calling the + // app client. // // AuthFlow is a required field AuthFlow *string `type:"string" required:"true" enum:"AuthFlowType"` - // The authentication parameters. + // The authentication parameters. These are inputs corresponding to the AuthFlow + // that you are invoking. The required values depend on the value of AuthFlow: + // + // * For USER_SRP_AUTH: USERNAME (required), SRPA (required), SECRET_HASH + // (required if the app client is configured with a client secret), DEVICE_KEY + // + // * For REFRESH_TOKEN_AUTH/REFRESH_TOKEN: USERNAME (required), SECRET_HASH + // (required if the app client is configured with a client secret), REFRESH_TOKEN + // (required), DEVICE_KEY + // + // * For ADMIN_NO_SRP_AUTH: USERNAME (required), SECRET_HASH (if app client + // is configured with client secret), PASSWORD (required), DEVICE_KEY + // + // * For CUSTOM_AUTH: USERNAME (required), SECRET_HASH (if app client is + // configured with client secret), DEVICE_KEY AuthParameters map[string]*string `type:"map"` - // The client app ID. + // The app client ID. // // ClientId is a required field ClientId *string `min:"1" type:"string" required:"true"` - // The client app metadata. + // This is a random key-value pair map which can contain any key and will be + // passed to your PreAuthentication Lambda trigger as-is. It can be used to + // implement additional validations around authentication. ClientMetadata map[string]*string `type:"map"` // The ID of the Amazon Cognito user pool. @@ -8429,16 +9355,59 @@ func (s *AdminInitiateAuthInput) SetUserPoolId(v string) *AdminInitiateAuthInput type AdminInitiateAuthOutput struct { _ struct{} `type:"structure"` - // The result of the authentication response. + // The result of the authentication response. This is only returned if the caller + // does not need to pass another challenge. If the caller does need to pass + // another challenge before it gets tokens, ChallengeName, ChallengeParameters, + // and Session are returned. AuthenticationResult *AuthenticationResultType `type:"structure"` - // The name of the challenge. + // The name of the challenge which you are responding to with this call. This + // is returned to you in the AdminInitiateAuth response if you need to pass + // another challenge. + // + // * SMS_MFA: Next challenge is to supply an SMS_MFA_CODE, delivered via + // SMS. + // + // * PASSWORD_VERIFIER: Next challenge is to supply PASSWORD_CLAIM_SIGNATURE, + // PASSWORD_CLAIM_SECRET_BLOCK, and TIMESTAMP after the client-side SRP calculations. + // + // * CUSTOM_CHALLENGE: This is returned if your custom authentication flow + // determines that the user should pass another challenge before tokens are + // issued. + // + // * DEVICE_SRP_AUTH: If device tracking was enabled on your user pool and + // the previous challenges were passed, this challenge is returned so that + // Amazon Cognito can start tracking this device. + // + // * DEVICE_PASSWORD_VERIFIER: Similar to PASSWORD_VERIFIER, but for devices + // only. + // + // * ADMIN_NO_SRP_AUTH: This is returned if you need to authenticate with + // USERNAME and PASSWORD directly. An app client must be enabled to use this + // flow. + // + // * NEW_PASSWORD_REQUIRED: For users which are required to change their + // passwords after successful first login. This challenge should be passed + // with NEW_PASSWORD and any other required attributes. ChallengeName *string `type:"string" enum:"ChallengeNameType"` - // The challenge parameters. + // The challenge parameters. These are returned to you in the AdminInitiateAuth + // response if you need to pass another challenge. The responses in this parameter + // should be used to compute inputs to the next call (AdminRespondToAuthChallenge). + // + // All challenges require USERNAME and SECRET_HASH (if applicable). + // + // The value of the USER_IF_FOR_SRP attribute will be the user's actual username, + // not an alias (such as email address or phone number), even if you specified + // an alias in your call to AdminInitiateAuth. This is because, in the AdminRespondToAuthChallenge + // API ChallengeResponses, the USERNAME attribute cannot be an alias. ChallengeParameters map[string]*string `type:"map"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If AdminInitiateAuth or AdminRespondToAuthChallenge API call + // determines that the caller needs to go through another challenge, they return + // a session with other challenge parameters. This session should be passed + // as it is to the next AdminRespondToAuthChallenge API call. Session *string `min:"20" type:"string"` } @@ -8878,20 +9847,44 @@ func (s AdminResetUserPasswordOutput) GoString() string { type AdminRespondToAuthChallengeInput struct { _ struct{} `type:"structure"` - // The name of the challenge. + // The challenge name. For more information, see AdminInitiateAuth (API_AdminInitiateAuth.html). // // ChallengeName is a required field ChallengeName *string `type:"string" required:"true" enum:"ChallengeNameType"` - // The challenge response. + // The challenge responses. These are inputs corresponding to the value of ChallengeName, + // for example: + // + // * SMS_MFA: SMS_MFA_CODE, USERNAME, SECRET_HASH (if app client is configured + // with client secret). + // + // * PASSWORD_VERIFIER: PASSWORD_CLAIM_SIGNATURE, PASSWORD_CLAIM_SECRET_BLOCK, + // TIMESTAMP, USERNAME, SECRET_HASH (if app client is configured with client + // secret). + // + // * ADMIN_NO_SRP_AUTH: PASSWORD, USERNAME, SECRET_HASH (if app client is + // configured with client secret). + // + // * NEW_PASSWORD_REQUIRED: NEW_PASSWORD, any other required attributes, + // USERNAME, SECRET_HASH (if app client is configured with client secret). + // + // + // The value of the USERNAME attribute must be the user's actual username, not + // an alias (such as email address or phone number). To make this easier, the + // AdminInitiateAuth response includes the actual username value in the USERNAMEUSER_ID_FOR_SRP + // attribute, even if you specified an alias in your call to AdminInitiateAuth. ChallengeResponses map[string]*string `type:"map"` - // The client ID. + // The app client ID. // // ClientId is a required field ClientId *string `min:"1" type:"string" required:"true"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If InitiateAuth or RespondToAuthChallenge API call determines + // that the caller needs to go through another challenge, they return a session + // with other challenge parameters. This session should be passed as it is to + // the next RespondToAuthChallenge API call. Session *string `min:"20" type:"string"` // The ID of the Amazon Cognito user pool. @@ -8976,13 +9969,18 @@ type AdminRespondToAuthChallengeOutput struct { // The result returned by the server in response to the authentication request. AuthenticationResult *AuthenticationResultType `type:"structure"` - // The name of the challenge. + // The name of the challenge. For more information, see AdminInitiateAuth (API_AdminInitiateAuth.html). ChallengeName *string `type:"string" enum:"ChallengeNameType"` - // The challenge parameters. + // The challenge parameters. For more information, see AdminInitiateAuth (API_AdminInitiateAuth.html). ChallengeParameters map[string]*string `type:"map"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If the InitiateAuth (API_InitiateAuth.html) or RespondToAuthChallenge + // (API_RespondToAuthChallenge.html) API call determines that the caller needs + // to go through another challenge, they return a session with other challenge + // parameters. This session should be passed as it is to the next RespondToAuthChallenge + // API call. Session *string `min:"20" type:"string"` } @@ -9134,7 +10132,7 @@ type AdminUpdateDeviceStatusInput struct { // The status indicating whether a device has been remembered or not. DeviceRememberedStatus *string `type:"string" enum:"DeviceRememberedStatusType"` - // The user pool ID> + // The user pool ID. // // UserPoolId is a required field UserPoolId *string `min:"1" type:"string" required:"true"` @@ -9230,6 +10228,9 @@ type AdminUpdateUserAttributesInput struct { // An array of name-value pairs representing user attributes. // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. + // // UserAttributes is a required field UserAttributes []*AttributeType `type:"list" required:"true"` @@ -9528,7 +10529,9 @@ type ChangePasswordInput struct { _ struct{} `type:"structure"` // The access token in the change password request. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` // The old password in the change password request. // @@ -9554,6 +10557,9 @@ func (s ChangePasswordInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *ChangePasswordInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "ChangePasswordInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } if s.PreviousPassword == nil { invalidParams.Add(request.NewErrParamRequired("PreviousPassword")) } @@ -9765,11 +10771,12 @@ type ConfirmForgotPasswordInput struct { ClientId *string `min:"1" type:"string" required:"true"` // The confirmation code sent by a user's request to retrieve a forgotten password. + // For more information, see ForgotPassword (API_ForgotPassword.html) // // ConfirmationCode is a required field ConfirmationCode *string `min:"1" type:"string" required:"true"` - // The password sent by sent by a user's request to retrieve a forgotten password. + // The password sent by a user's request to retrieve a forgotten password. // // Password is a required field Password *string `min:"6" type:"string" required:"true"` @@ -10126,6 +11133,138 @@ func (s *CreateGroupOutput) SetGroup(v *GroupType) *CreateGroupOutput { return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateIdentityProviderRequest +type CreateIdentityProviderInput struct { + _ struct{} `type:"structure"` + + // A mapping of identity provider attributes to standard and custom user pool + // attributes. + AttributeMapping map[string]*string `type:"map"` + + // A list of identity provider identifiers. + IdpIdentifiers []*string `type:"list"` + + // The identity provider details, such as MetadataURL and MetadataFile. + // + // ProviderDetails is a required field + ProviderDetails map[string]*string `type:"map" required:"true"` + + // The identity provider name. + // + // ProviderName is a required field + ProviderName *string `min:"1" type:"string" required:"true"` + + // The identity provider type. + // + // ProviderType is a required field + ProviderType *string `type:"string" required:"true" enum:"IdentityProviderTypeType"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateIdentityProviderInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateIdentityProviderInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateIdentityProviderInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateIdentityProviderInput"} + if s.ProviderDetails == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderDetails")) + } + if s.ProviderName == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderName")) + } + if s.ProviderName != nil && len(*s.ProviderName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ProviderName", 1)) + } + if s.ProviderType == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderType")) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributeMapping sets the AttributeMapping field's value. +func (s *CreateIdentityProviderInput) SetAttributeMapping(v map[string]*string) *CreateIdentityProviderInput { + s.AttributeMapping = v + return s +} + +// SetIdpIdentifiers sets the IdpIdentifiers field's value. +func (s *CreateIdentityProviderInput) SetIdpIdentifiers(v []*string) *CreateIdentityProviderInput { + s.IdpIdentifiers = v + return s +} + +// SetProviderDetails sets the ProviderDetails field's value. +func (s *CreateIdentityProviderInput) SetProviderDetails(v map[string]*string) *CreateIdentityProviderInput { + s.ProviderDetails = v + return s +} + +// SetProviderName sets the ProviderName field's value. +func (s *CreateIdentityProviderInput) SetProviderName(v string) *CreateIdentityProviderInput { + s.ProviderName = &v + return s +} + +// SetProviderType sets the ProviderType field's value. +func (s *CreateIdentityProviderInput) SetProviderType(v string) *CreateIdentityProviderInput { + s.ProviderType = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *CreateIdentityProviderInput) SetUserPoolId(v string) *CreateIdentityProviderInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateIdentityProviderResponse +type CreateIdentityProviderOutput struct { + _ struct{} `type:"structure"` + + // The newly created identity provider object. + // + // IdentityProvider is a required field + IdentityProvider *IdentityProviderType `type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateIdentityProviderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateIdentityProviderOutput) GoString() string { + return s.String() +} + +// SetIdentityProvider sets the IdentityProvider field's value. +func (s *CreateIdentityProviderOutput) SetIdentityProvider(v *IdentityProviderType) *CreateIdentityProviderOutput { + s.IdentityProvider = v + return s +} + // Represents the request to create the user import job. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserImportJobRequest type CreateUserImportJobInput struct { @@ -10234,11 +11373,33 @@ func (s *CreateUserImportJobOutput) SetUserImportJob(v *UserImportJobType) *Crea type CreateUserPoolClientInput struct { _ struct{} `type:"structure"` + // Set to code to initiate a code grant flow, which provides an authorization + // code as the response. This code can be exchanged for access tokens with the + // token endpoint. + // + // Set to token to specify that the client should get the access token (and, + // optionally, ID token, based on scopes) directly. + AllowedOAuthFlows []*string `type:"list"` + + // Set to True if the client is allowed to follow the OAuth protocol when interacting + // with Cognito user pools. + AllowedOAuthFlowsUserPoolClient *bool `type:"boolean"` + + // A list of allowed OAuth scopes. Currently supported values are "phone", "email", + // "openid", and "Cognito". + AllowedOAuthScopes []*string `type:"list"` + + // A list of allowed callback URLs for the identity providers. + CallbackURLs []*string `type:"list"` + // The client name for the user pool client you would like to create. // // ClientName is a required field ClientName *string `min:"1" type:"string" required:"true"` + // The default redirect URI. Must be in the CallbackURLs list. + DefaultRedirectURI *string `min:"1" type:"string"` + // The explicit authentication flows. ExplicitAuthFlows []*string `type:"list"` @@ -10246,12 +11407,20 @@ type CreateUserPoolClientInput struct { // client being created. GenerateSecret *bool `type:"boolean"` + // A list of allowed logout URLs for the identity providers. + LogoutURLs []*string `type:"list"` + // The read attributes. ReadAttributes []*string `type:"list"` - // The validity of the refresh token, in days. + // The time limit, in days, after which the refresh token is no longer valid + // and cannot be used. RefreshTokenValidity *int64 `type:"integer"` + // A list of provider names for the identity providers that are supported on + // this client. + SupportedIdentityProviders []*string `type:"list"` + // The user pool ID for the user pool where you want to create a user pool client. // // UserPoolId is a required field @@ -10280,6 +11449,9 @@ func (s *CreateUserPoolClientInput) Validate() error { if s.ClientName != nil && len(*s.ClientName) < 1 { invalidParams.Add(request.NewErrParamMinLen("ClientName", 1)) } + if s.DefaultRedirectURI != nil && len(*s.DefaultRedirectURI) < 1 { + invalidParams.Add(request.NewErrParamMinLen("DefaultRedirectURI", 1)) + } if s.UserPoolId == nil { invalidParams.Add(request.NewErrParamRequired("UserPoolId")) } @@ -10293,12 +11465,42 @@ func (s *CreateUserPoolClientInput) Validate() error { return nil } +// SetAllowedOAuthFlows sets the AllowedOAuthFlows field's value. +func (s *CreateUserPoolClientInput) SetAllowedOAuthFlows(v []*string) *CreateUserPoolClientInput { + s.AllowedOAuthFlows = v + return s +} + +// SetAllowedOAuthFlowsUserPoolClient sets the AllowedOAuthFlowsUserPoolClient field's value. +func (s *CreateUserPoolClientInput) SetAllowedOAuthFlowsUserPoolClient(v bool) *CreateUserPoolClientInput { + s.AllowedOAuthFlowsUserPoolClient = &v + return s +} + +// SetAllowedOAuthScopes sets the AllowedOAuthScopes field's value. +func (s *CreateUserPoolClientInput) SetAllowedOAuthScopes(v []*string) *CreateUserPoolClientInput { + s.AllowedOAuthScopes = v + return s +} + +// SetCallbackURLs sets the CallbackURLs field's value. +func (s *CreateUserPoolClientInput) SetCallbackURLs(v []*string) *CreateUserPoolClientInput { + s.CallbackURLs = v + return s +} + // SetClientName sets the ClientName field's value. func (s *CreateUserPoolClientInput) SetClientName(v string) *CreateUserPoolClientInput { s.ClientName = &v return s } +// SetDefaultRedirectURI sets the DefaultRedirectURI field's value. +func (s *CreateUserPoolClientInput) SetDefaultRedirectURI(v string) *CreateUserPoolClientInput { + s.DefaultRedirectURI = &v + return s +} + // SetExplicitAuthFlows sets the ExplicitAuthFlows field's value. func (s *CreateUserPoolClientInput) SetExplicitAuthFlows(v []*string) *CreateUserPoolClientInput { s.ExplicitAuthFlows = v @@ -10311,6 +11513,12 @@ func (s *CreateUserPoolClientInput) SetGenerateSecret(v bool) *CreateUserPoolCli return s } +// SetLogoutURLs sets the LogoutURLs field's value. +func (s *CreateUserPoolClientInput) SetLogoutURLs(v []*string) *CreateUserPoolClientInput { + s.LogoutURLs = v + return s +} + // SetReadAttributes sets the ReadAttributes field's value. func (s *CreateUserPoolClientInput) SetReadAttributes(v []*string) *CreateUserPoolClientInput { s.ReadAttributes = v @@ -10323,6 +11531,12 @@ func (s *CreateUserPoolClientInput) SetRefreshTokenValidity(v int64) *CreateUser return s } +// SetSupportedIdentityProviders sets the SupportedIdentityProviders field's value. +func (s *CreateUserPoolClientInput) SetSupportedIdentityProviders(v []*string) *CreateUserPoolClientInput { + s.SupportedIdentityProviders = v + return s +} + // SetUserPoolId sets the UserPoolId field's value. func (s *CreateUserPoolClientInput) SetUserPoolId(v string) *CreateUserPoolClientInput { s.UserPoolId = &v @@ -10360,6 +11574,80 @@ func (s *CreateUserPoolClientOutput) SetUserPoolClient(v *UserPoolClientType) *C return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserPoolDomainRequest +type CreateUserPoolDomainInput struct { + _ struct{} `type:"structure"` + + // The domain string. + // + // Domain is a required field + Domain *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateUserPoolDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateUserPoolDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateUserPoolDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateUserPoolDomainInput"} + if s.Domain == nil { + invalidParams.Add(request.NewErrParamRequired("Domain")) + } + if s.Domain != nil && len(*s.Domain) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Domain", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomain sets the Domain field's value. +func (s *CreateUserPoolDomainInput) SetDomain(v string) *CreateUserPoolDomainInput { + s.Domain = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *CreateUserPoolDomainInput) SetUserPoolId(v string) *CreateUserPoolDomainInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserPoolDomainResponse +type CreateUserPoolDomainOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s CreateUserPoolDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateUserPoolDomainOutput) GoString() string { + return s.String() +} + // Represents the request to create a user pool. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/CreateUserPoolRequest type CreateUserPoolInput struct { @@ -10691,16 +11979,95 @@ func (s DeleteGroupOutput) GoString() string { return s.String() } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteIdentityProviderRequest +type DeleteIdentityProviderInput struct { + _ struct{} `type:"structure"` + + // The identity provider name. + // + // ProviderName is a required field + ProviderName *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteIdentityProviderInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteIdentityProviderInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteIdentityProviderInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteIdentityProviderInput"} + if s.ProviderName == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderName")) + } + if s.ProviderName != nil && len(*s.ProviderName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ProviderName", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetProviderName sets the ProviderName field's value. +func (s *DeleteIdentityProviderInput) SetProviderName(v string) *DeleteIdentityProviderInput { + s.ProviderName = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *DeleteIdentityProviderInput) SetUserPoolId(v string) *DeleteIdentityProviderInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteIdentityProviderOutput +type DeleteIdentityProviderOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteIdentityProviderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteIdentityProviderOutput) GoString() string { + return s.String() +} + // Represents the request to delete user attributes. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserAttributesRequest type DeleteUserAttributesInput struct { _ struct{} `type:"structure"` // The access token used in the request to delete user attributes. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` // An array of strings representing the user attribute names you wish to delete. // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. + // // UserAttributeNames is a required field UserAttributeNames []*string `type:"list" required:"true"` } @@ -10718,6 +12085,9 @@ func (s DeleteUserAttributesInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeleteUserAttributesInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeleteUserAttributesInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } if s.UserAttributeNames == nil { invalidParams.Add(request.NewErrParamRequired("UserAttributeNames")) } @@ -10762,7 +12132,9 @@ type DeleteUserInput struct { _ struct{} `type:"structure"` // The access token from a request to delete a user. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` } // String returns the string representation @@ -10775,6 +12147,19 @@ func (s DeleteUserInput) GoString() string { return s.String() } +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteUserInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteUserInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + // SetAccessToken sets the AccessToken field's value. func (s *DeleteUserInput) SetAccessToken(v string) *DeleteUserInput { s.AccessToken = &v @@ -10871,8 +12256,82 @@ func (s DeleteUserPoolClientOutput) GoString() string { return s.String() } -// Represents the request to delete a user pool. -// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolRequest +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolDomainRequest +type DeleteUserPoolDomainInput struct { + _ struct{} `type:"structure"` + + // The domain string. + // + // Domain is a required field + Domain *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteUserPoolDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteUserPoolDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteUserPoolDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteUserPoolDomainInput"} + if s.Domain == nil { + invalidParams.Add(request.NewErrParamRequired("Domain")) + } + if s.Domain != nil && len(*s.Domain) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Domain", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomain sets the Domain field's value. +func (s *DeleteUserPoolDomainInput) SetDomain(v string) *DeleteUserPoolDomainInput { + s.Domain = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *DeleteUserPoolDomainInput) SetUserPoolId(v string) *DeleteUserPoolDomainInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolDomainResponse +type DeleteUserPoolDomainOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteUserPoolDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteUserPoolDomainOutput) GoString() string { + return s.String() +} + +// Represents the request to delete a user pool. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DeleteUserPoolRequest type DeleteUserPoolInput struct { _ struct{} `type:"structure"` @@ -10929,6 +12388,91 @@ func (s DeleteUserPoolOutput) GoString() string { return s.String() } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeIdentityProviderRequest +type DescribeIdentityProviderInput struct { + _ struct{} `type:"structure"` + + // The identity provider name. + // + // ProviderName is a required field + ProviderName *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeIdentityProviderInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeIdentityProviderInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeIdentityProviderInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeIdentityProviderInput"} + if s.ProviderName == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderName")) + } + if s.ProviderName != nil && len(*s.ProviderName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ProviderName", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetProviderName sets the ProviderName field's value. +func (s *DescribeIdentityProviderInput) SetProviderName(v string) *DescribeIdentityProviderInput { + s.ProviderName = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *DescribeIdentityProviderInput) SetUserPoolId(v string) *DescribeIdentityProviderInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeIdentityProviderResponse +type DescribeIdentityProviderOutput struct { + _ struct{} `type:"structure"` + + // The identity provider that was deleted. + // + // IdentityProvider is a required field + IdentityProvider *IdentityProviderType `type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeIdentityProviderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeIdentityProviderOutput) GoString() string { + return s.String() +} + +// SetIdentityProvider sets the IdentityProvider field's value. +func (s *DescribeIdentityProviderOutput) SetIdentityProvider(v *IdentityProviderType) *DescribeIdentityProviderOutput { + s.IdentityProvider = v + return s +} + // Represents the request to describe the user import job. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserImportJobRequest type DescribeUserImportJobInput struct { @@ -11101,6 +12645,72 @@ func (s *DescribeUserPoolClientOutput) SetUserPoolClient(v *UserPoolClientType) return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserPoolDomainRequest +type DescribeUserPoolDomainInput struct { + _ struct{} `type:"structure"` + + // The domain string. + // + // Domain is a required field + Domain *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeUserPoolDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeUserPoolDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeUserPoolDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeUserPoolDomainInput"} + if s.Domain == nil { + invalidParams.Add(request.NewErrParamRequired("Domain")) + } + if s.Domain != nil && len(*s.Domain) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Domain", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomain sets the Domain field's value. +func (s *DescribeUserPoolDomainInput) SetDomain(v string) *DescribeUserPoolDomainInput { + s.Domain = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserPoolDomainResponse +type DescribeUserPoolDomainOutput struct { + _ struct{} `type:"structure"` + + // A domain description object containing information about the domain. + DomainDescription *DomainDescriptionType `type:"structure"` +} + +// String returns the string representation +func (s DescribeUserPoolDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeUserPoolDomainOutput) GoString() string { + return s.String() +} + +// SetDomainDescription sets the DomainDescription field's value. +func (s *DescribeUserPoolDomainOutput) SetDomainDescription(v *DomainDescriptionType) *DescribeUserPoolDomainOutput { + s.DomainDescription = v + return s +} + // Represents the request to describe the user pool. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DescribeUserPoolRequest type DescribeUserPoolInput struct { @@ -11299,6 +12909,85 @@ func (s *DeviceType) SetDeviceLastModifiedDate(v time.Time) *DeviceType { return s } +// A container for information about a domain. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/DomainDescriptionType +type DomainDescriptionType struct { + _ struct{} `type:"structure"` + + // The AWS account ID for the user pool owner. + AWSAccountId *string `type:"string"` + + // The ARN of the CloudFront distribution. + CloudFrontDistribution *string `min:"20" type:"string"` + + // The domain string. + Domain *string `min:"1" type:"string"` + + // The S3 bucket where the static files for this domain are stored. + S3Bucket *string `min:"3" type:"string"` + + // The domain status. + Status *string `type:"string" enum:"DomainStatusType"` + + // The user pool ID. + UserPoolId *string `min:"1" type:"string"` + + // The app version. + Version *string `min:"1" type:"string"` +} + +// String returns the string representation +func (s DomainDescriptionType) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DomainDescriptionType) GoString() string { + return s.String() +} + +// SetAWSAccountId sets the AWSAccountId field's value. +func (s *DomainDescriptionType) SetAWSAccountId(v string) *DomainDescriptionType { + s.AWSAccountId = &v + return s +} + +// SetCloudFrontDistribution sets the CloudFrontDistribution field's value. +func (s *DomainDescriptionType) SetCloudFrontDistribution(v string) *DomainDescriptionType { + s.CloudFrontDistribution = &v + return s +} + +// SetDomain sets the Domain field's value. +func (s *DomainDescriptionType) SetDomain(v string) *DomainDescriptionType { + s.Domain = &v + return s +} + +// SetS3Bucket sets the S3Bucket field's value. +func (s *DomainDescriptionType) SetS3Bucket(v string) *DomainDescriptionType { + s.S3Bucket = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *DomainDescriptionType) SetStatus(v string) *DomainDescriptionType { + s.Status = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *DomainDescriptionType) SetUserPoolId(v string) *DomainDescriptionType { + s.UserPoolId = &v + return s +} + +// SetVersion sets the Version field's value. +func (s *DomainDescriptionType) SetVersion(v string) *DomainDescriptionType { + s.Version = &v + return s +} + // The email configuration type. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/EmailConfigurationType type EmailConfigurationType struct { @@ -11755,6 +13444,91 @@ func (s *GetGroupOutput) SetGroup(v *GroupType) *GetGroupOutput { return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetIdentityProviderByIdentifierRequest +type GetIdentityProviderByIdentifierInput struct { + _ struct{} `type:"structure"` + + // The identity provider ID. + // + // IdpIdentifier is a required field + IdpIdentifier *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetIdentityProviderByIdentifierInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetIdentityProviderByIdentifierInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetIdentityProviderByIdentifierInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetIdentityProviderByIdentifierInput"} + if s.IdpIdentifier == nil { + invalidParams.Add(request.NewErrParamRequired("IdpIdentifier")) + } + if s.IdpIdentifier != nil && len(*s.IdpIdentifier) < 1 { + invalidParams.Add(request.NewErrParamMinLen("IdpIdentifier", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetIdpIdentifier sets the IdpIdentifier field's value. +func (s *GetIdentityProviderByIdentifierInput) SetIdpIdentifier(v string) *GetIdentityProviderByIdentifierInput { + s.IdpIdentifier = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *GetIdentityProviderByIdentifierInput) SetUserPoolId(v string) *GetIdentityProviderByIdentifierInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetIdentityProviderByIdentifierResponse +type GetIdentityProviderByIdentifierOutput struct { + _ struct{} `type:"structure"` + + // The identity provider object. + // + // IdentityProvider is a required field + IdentityProvider *IdentityProviderType `type:"structure" required:"true"` +} + +// String returns the string representation +func (s GetIdentityProviderByIdentifierOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetIdentityProviderByIdentifierOutput) GoString() string { + return s.String() +} + +// SetIdentityProvider sets the IdentityProvider field's value. +func (s *GetIdentityProviderByIdentifierOutput) SetIdentityProvider(v *IdentityProviderType) *GetIdentityProviderByIdentifierOutput { + s.IdentityProvider = v + return s +} + // Represents the request to get user attribute verification. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/GetUserAttributeVerificationCodeRequest type GetUserAttributeVerificationCodeInput struct { @@ -11762,7 +13536,9 @@ type GetUserAttributeVerificationCodeInput struct { // The access token returned by the server response to get the user attribute // verification code. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` // The attribute name returned by the server response to get the user attribute // verification code. @@ -11784,6 +13560,9 @@ func (s GetUserAttributeVerificationCodeInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetUserAttributeVerificationCodeInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetUserAttributeVerificationCodeInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } if s.AttributeName == nil { invalidParams.Add(request.NewErrParamRequired("AttributeName")) } @@ -11843,7 +13622,9 @@ type GetUserInput struct { // The access token returned by the server response to get information about // the user. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` } // String returns the string representation @@ -11856,6 +13637,19 @@ func (s GetUserInput) GoString() string { return s.String() } +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetUserInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetUserInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + // SetAccessToken sets the AccessToken field's value. func (s *GetUserInput) SetAccessToken(v string) *GetUserInput { s.AccessToken = &v @@ -11873,6 +13667,9 @@ type GetUserOutput struct { // An array of name-value pairs representing user attributes. // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. + // // UserAttributes is a required field UserAttributes []*AttributeType `type:"list" required:"true"` @@ -11916,7 +13713,9 @@ type GlobalSignOutInput struct { _ struct{} `type:"structure"` // The access token. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` } // String returns the string representation @@ -11929,6 +13728,19 @@ func (s GlobalSignOutInput) GoString() string { return s.String() } +// Validate inspects the fields of the type to determine if they are valid. +func (s *GlobalSignOutInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GlobalSignOutInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + // SetAccessToken sets the AccessToken field's value. func (s *GlobalSignOutInput) SetAccessToken(v string) *GlobalSignOutInput { s.AccessToken = &v @@ -12043,25 +13855,146 @@ func (s *GroupType) SetUserPoolId(v string) *GroupType { return s } +// A container for information about an identity provider. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/IdentityProviderType +type IdentityProviderType struct { + _ struct{} `type:"structure"` + + // A mapping of identity provider attributes to standard and custom user pool + // attributes. + AttributeMapping map[string]*string `type:"map"` + + // The date the identity provider was created. + CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` + + // A list of identity provider identifiers. + IdpIdentifiers []*string `type:"list"` + + // The date the identity provider was last modified. + LastModifiedDate *time.Time `type:"timestamp" timestampFormat:"unix"` + + // The identity provider details, such as MetadataURL and MetadataFile. + ProviderDetails map[string]*string `type:"map"` + + // The identity provider name. + ProviderName *string `min:"1" type:"string"` + + // The identity provider type. + ProviderType *string `type:"string" enum:"IdentityProviderTypeType"` + + // The user pool ID. + UserPoolId *string `min:"1" type:"string"` +} + +// String returns the string representation +func (s IdentityProviderType) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s IdentityProviderType) GoString() string { + return s.String() +} + +// SetAttributeMapping sets the AttributeMapping field's value. +func (s *IdentityProviderType) SetAttributeMapping(v map[string]*string) *IdentityProviderType { + s.AttributeMapping = v + return s +} + +// SetCreationDate sets the CreationDate field's value. +func (s *IdentityProviderType) SetCreationDate(v time.Time) *IdentityProviderType { + s.CreationDate = &v + return s +} + +// SetIdpIdentifiers sets the IdpIdentifiers field's value. +func (s *IdentityProviderType) SetIdpIdentifiers(v []*string) *IdentityProviderType { + s.IdpIdentifiers = v + return s +} + +// SetLastModifiedDate sets the LastModifiedDate field's value. +func (s *IdentityProviderType) SetLastModifiedDate(v time.Time) *IdentityProviderType { + s.LastModifiedDate = &v + return s +} + +// SetProviderDetails sets the ProviderDetails field's value. +func (s *IdentityProviderType) SetProviderDetails(v map[string]*string) *IdentityProviderType { + s.ProviderDetails = v + return s +} + +// SetProviderName sets the ProviderName field's value. +func (s *IdentityProviderType) SetProviderName(v string) *IdentityProviderType { + s.ProviderName = &v + return s +} + +// SetProviderType sets the ProviderType field's value. +func (s *IdentityProviderType) SetProviderType(v string) *IdentityProviderType { + s.ProviderType = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *IdentityProviderType) SetUserPoolId(v string) *IdentityProviderType { + s.UserPoolId = &v + return s +} + // Initiates the authentication request. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/InitiateAuthRequest type InitiateAuthInput struct { _ struct{} `type:"structure"` - // The authentication flow. + // The authentication flow for this call to execute. The API action will depend + // on this value. For example: + // + // * REFRESH_TOKEN_AUTH will take in a valid refresh token and return new + // tokens. + // + // * USER_SRP_AUTH will take in USERNAME and SRPA and return the SRP variables + // to be used for next challenge execution. + // + // Valid values include: + // + // * USER_SRP_AUTH: Authentication flow for the Secure Remote Password (SRP) + // protocol. + // + // * REFRESH_TOKEN_AUTH/REFRESH_TOKEN: Authentication flow for refreshing + // the access token and ID token by supplying a valid refresh token. + // + // * CUSTOM_AUTH: Custom authentication flow. + // + // ADMIN_NO_SRP_AUTH is not a valid value. // // AuthFlow is a required field AuthFlow *string `type:"string" required:"true" enum:"AuthFlowType"` - // The authentication parameters. + // The authentication parameters. These are inputs corresponding to the AuthFlow + // that you are invoking. The required values depend on the value of AuthFlow: + // + // * For USER_SRP_AUTH: USERNAME (required), SRPA (required), SECRET_HASH + // (required if the app client is configured with a client secret), DEVICE_KEY + // + // * For REFRESH_TOKEN_AUTH/REFRESH_TOKEN: USERNAME (required), SECRET_HASH + // (required if the app client is configured with a client secret), REFRESH_TOKEN + // (required), DEVICE_KEY + // + // * For CUSTOM_AUTH: USERNAME (required), SECRET_HASH (if app client is + // configured with client secret), DEVICE_KEY AuthParameters map[string]*string `type:"map"` - // The client ID. + // The app client ID. // // ClientId is a required field ClientId *string `min:"1" type:"string" required:"true"` - // The client app's metadata. + // This is a random key-value pair map which can contain any key and will be + // passed to your PreAuthentication Lambda trigger as-is. It can be used to + // implement additional validations around authentication. ClientMetadata map[string]*string `type:"map"` } @@ -12123,17 +14056,54 @@ func (s *InitiateAuthInput) SetClientMetadata(v map[string]*string) *InitiateAut type InitiateAuthOutput struct { _ struct{} `type:"structure"` - // The result returned by the server in response to the request to initiate - // authentication. + // The result of the authentication response. This is only returned if the caller + // does not need to pass another challenge. If the caller does need to pass + // another challenge before it gets tokens, ChallengeName, ChallengeParameters, + // and Session are returned. AuthenticationResult *AuthenticationResultType `type:"structure"` - // The name of the challenge. + // The name of the challenge which you are responding to with this call. This + // is returned to you in the AdminInitiateAuth response if you need to pass + // another challenge. + // + // Valid values include the following. Note that all of these challenges require + // USERNAME and SECRET_HASH (if applicable) in the parameters. + // + // * SMS_MFA: Next challenge is to supply an SMS_MFA_CODE, delivered via + // SMS. + // + // * PASSWORD_VERIFIER: Next challenge is to supply PASSWORD_CLAIM_SIGNATURE, + // PASSWORD_CLAIM_SECRET_BLOCK, and TIMESTAMP after the client-side SRP calculations. + // + // * CUSTOM_CHALLENGE: This is returned if your custom authentication flow + // determines that the user should pass another challenge before tokens are + // issued. + // + // * DEVICE_SRP_AUTH: If device tracking was enabled on your user pool and + // the previous challenges were passed, this challenge is returned so that + // Amazon Cognito can start tracking this device. + // + // * DEVICE_PASSWORD_VERIFIER: Similar to PASSWORD_VERIFIER, but for devices + // only. + // + // * NEW_PASSWORD_REQUIRED: For users which are required to change their + // passwords after successful first login. This challenge should be passed + // with NEW_PASSWORD and any other required attributes. ChallengeName *string `type:"string" enum:"ChallengeNameType"` - // The challenge parameters. + // The challenge parameters. These are returned to you in the InitiateAuth response + // if you need to pass another challenge. The responses in this parameter should + // be used to compute inputs to the next call (RespondToAuthChallenge). + // + // All challenges require USERNAME and SECRET_HASH (if applicable). ChallengeParameters map[string]*string `type:"map"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If the InitiateAuth (API_InitiateAuth.html) or RespondToAuthChallenge + // (API_RespondToAuthChallenge.html) API call determines that the caller needs + // to go through another challenge, they return a session with other challenge + // parameters. This session should be passed as it is to the next RespondToAuthChallenge + // API call. Session *string `min:"20" type:"string"` } @@ -12399,25 +14369,125 @@ type ListGroupsInput struct { // which can be used to return the next set of items in the list. NextToken *string `min:"1" type:"string"` - // The user pool ID for the user pool. + // The user pool ID for the user pool. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListGroupsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListGroupsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListGroupsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListGroupsInput"} + if s.NextToken != nil && len(*s.NextToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("NextToken", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListGroupsInput) SetLimit(v int64) *ListGroupsInput { + s.Limit = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListGroupsInput) SetNextToken(v string) *ListGroupsInput { + s.NextToken = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *ListGroupsInput) SetUserPoolId(v string) *ListGroupsInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListGroupsResponse +type ListGroupsOutput struct { + _ struct{} `type:"structure"` + + // The group objects for the groups. + Groups []*GroupType `type:"list"` + + // An identifier that was returned from the previous call to this operation, + // which can be used to return the next set of items in the list. + NextToken *string `min:"1" type:"string"` +} + +// String returns the string representation +func (s ListGroupsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListGroupsOutput) GoString() string { + return s.String() +} + +// SetGroups sets the Groups field's value. +func (s *ListGroupsOutput) SetGroups(v []*GroupType) *ListGroupsOutput { + s.Groups = v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListGroupsOutput) SetNextToken(v string) *ListGroupsOutput { + s.NextToken = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListIdentityProvidersRequest +type ListIdentityProvidersInput struct { + _ struct{} `type:"structure"` + + // The maximum number of identity providers to return. + MaxResults *int64 `min:"1" type:"integer"` + + // A pagination token. + NextToken *string `min:"1" type:"string"` + + // The user pool ID. // // UserPoolId is a required field UserPoolId *string `min:"1" type:"string" required:"true"` } // String returns the string representation -func (s ListGroupsInput) String() string { +func (s ListIdentityProvidersInput) String() string { return awsutil.Prettify(s) } // GoString returns the string representation -func (s ListGroupsInput) GoString() string { +func (s ListIdentityProvidersInput) GoString() string { return s.String() } // Validate inspects the fields of the type to determine if they are valid. -func (s *ListGroupsInput) Validate() error { - invalidParams := request.ErrInvalidParams{Context: "ListGroupsInput"} +func (s *ListIdentityProvidersInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListIdentityProvidersInput"} + if s.MaxResults != nil && *s.MaxResults < 1 { + invalidParams.Add(request.NewErrParamMinValue("MaxResults", 1)) + } if s.NextToken != nil && len(*s.NextToken) < 1 { invalidParams.Add(request.NewErrParamMinLen("NextToken", 1)) } @@ -12434,55 +14504,56 @@ func (s *ListGroupsInput) Validate() error { return nil } -// SetLimit sets the Limit field's value. -func (s *ListGroupsInput) SetLimit(v int64) *ListGroupsInput { - s.Limit = &v +// SetMaxResults sets the MaxResults field's value. +func (s *ListIdentityProvidersInput) SetMaxResults(v int64) *ListIdentityProvidersInput { + s.MaxResults = &v return s } // SetNextToken sets the NextToken field's value. -func (s *ListGroupsInput) SetNextToken(v string) *ListGroupsInput { +func (s *ListIdentityProvidersInput) SetNextToken(v string) *ListIdentityProvidersInput { s.NextToken = &v return s } // SetUserPoolId sets the UserPoolId field's value. -func (s *ListGroupsInput) SetUserPoolId(v string) *ListGroupsInput { +func (s *ListIdentityProvidersInput) SetUserPoolId(v string) *ListIdentityProvidersInput { s.UserPoolId = &v return s } -// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListGroupsResponse -type ListGroupsOutput struct { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ListIdentityProvidersResponse +type ListIdentityProvidersOutput struct { _ struct{} `type:"structure"` - // The group objects for the groups. - Groups []*GroupType `type:"list"` - - // An identifier that was returned from the previous call to this operation, - // which can be used to return the next set of items in the list. + // A pagination token. NextToken *string `min:"1" type:"string"` + + // A list of identity provider objects. + // + // Providers is a required field + Providers []*ProviderDescription `type:"list" required:"true"` } // String returns the string representation -func (s ListGroupsOutput) String() string { +func (s ListIdentityProvidersOutput) String() string { return awsutil.Prettify(s) } // GoString returns the string representation -func (s ListGroupsOutput) GoString() string { +func (s ListIdentityProvidersOutput) GoString() string { return s.String() } -// SetGroups sets the Groups field's value. -func (s *ListGroupsOutput) SetGroups(v []*GroupType) *ListGroupsOutput { - s.Groups = v +// SetNextToken sets the NextToken field's value. +func (s *ListIdentityProvidersOutput) SetNextToken(v string) *ListIdentityProvidersOutput { + s.NextToken = &v return s } -// SetNextToken sets the NextToken field's value. -func (s *ListGroupsOutput) SetNextToken(v string) *ListGroupsOutput { - s.NextToken = &v +// SetProviders sets the Providers field's value. +func (s *ListIdentityProvidersOutput) SetProviders(v []*ProviderDescription) *ListIdentityProvidersOutput { + s.Providers = v return s } @@ -12911,20 +14982,61 @@ func (s *ListUsersInGroupOutput) SetUsers(v []*UserType) *ListUsersInGroupOutput type ListUsersInput struct { _ struct{} `type:"structure"` - // The attributes to get from the request to list users. + // An array of strings, where each string is the name of a user attribute to + // be returned for each user in the search results. If the array is empty, all + // attributes are returned. AttributesToGet []*string `type:"list"` - // The filter for the list users request. + // A filter string of the form "AttributeNameFilter-Type "AttributeValue"". + // Quotation marks within the filter string must be escaped using the backslash + // (\) character. For example, "family_name = \"Reddy\"". + // + // * AttributeName: The name of the attribute to search for. You can only + // search for one attribute at a time. + // + // * Filter-Type: For an exact match, use =, for example, "given_name = \"Jon\"". + // For a prefix ("starts with") match, use ^=, for example, "given_name ^= + // \"Jon\"". + // + // * AttributeValue: The attribute value that must be matched for each user. + // + // If the filter string is empty, ListUsers returns all users in the user pool. + // + // You can only search for the following standard attributes: + // + // * username (case-sensitive) + // + // * email + // + // * phone_number + // + // * name + // + // * given_name + // + // * family_name + // + // * preferred_username + // + // * cognito:user_status (called Enabled in the Console) (case-sensitive) + // + // * status (case-insensitive) + // + // Custom attributes are not searchable. + // + // For more information, see Searching for Users Using the ListUsers API (http://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-using-listusers-api) + // and Examples of Using the ListUsers API (http://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-listusers-api-examples) + // in the Amazon Cognito Developer Guide. Filter *string `type:"string"` - // The limit of the request to list users. + // Maximum number of users to be returned. Limit *int64 `type:"integer"` // An identifier that was returned from the previous call to this operation, // which can be used to return the next set of items in the list. PaginationToken *string `min:"1" type:"string"` - // The user pool ID for which you want to list users. + // The user pool ID for the user pool on which the search should be performed. // // UserPoolId is a required field UserPoolId *string `min:"1" type:"string" required:"true"` @@ -13281,6 +15393,58 @@ func (s *PasswordPolicyType) SetRequireUppercase(v bool) *PasswordPolicyType { return s } +// A container for identity provider details. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ProviderDescription +type ProviderDescription struct { + _ struct{} `type:"structure"` + + // The date the provider was added to the user pool. + CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` + + // The date the provider was last modified. + LastModifiedDate *time.Time `type:"timestamp" timestampFormat:"unix"` + + // The identity provider name. + ProviderName *string `min:"1" type:"string"` + + // The identity provider type. + ProviderType *string `type:"string" enum:"IdentityProviderTypeType"` +} + +// String returns the string representation +func (s ProviderDescription) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ProviderDescription) GoString() string { + return s.String() +} + +// SetCreationDate sets the CreationDate field's value. +func (s *ProviderDescription) SetCreationDate(v time.Time) *ProviderDescription { + s.CreationDate = &v + return s +} + +// SetLastModifiedDate sets the LastModifiedDate field's value. +func (s *ProviderDescription) SetLastModifiedDate(v time.Time) *ProviderDescription { + s.LastModifiedDate = &v + return s +} + +// SetProviderName sets the ProviderName field's value. +func (s *ProviderDescription) SetProviderName(v string) *ProviderDescription { + s.ProviderName = &v + return s +} + +// SetProviderType sets the ProviderType field's value. +func (s *ProviderDescription) SetProviderType(v string) *ProviderDescription { + s.ProviderType = &v + return s +} + // Represents the request to resend the confirmation code. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/ResendConfirmationCodeRequest type ResendConfirmationCodeInput struct { @@ -13386,20 +15550,37 @@ func (s *ResendConfirmationCodeOutput) SetCodeDeliveryDetails(v *CodeDeliveryDet type RespondToAuthChallengeInput struct { _ struct{} `type:"structure"` - // The name of the challenge. + // The challenge name. For more information, see InitiateAuth (API_InitiateAuth.html). + // + // ADMIN_NO_SRP_AUTH is not a valid value. // // ChallengeName is a required field ChallengeName *string `type:"string" required:"true" enum:"ChallengeNameType"` - // The responses to the authentication challenge. + // The challenge responses. These are inputs corresponding to the value of ChallengeName, + // for example: + // + // * SMS_MFA: SMS_MFA_CODE, USERNAME, SECRET_HASH (if app client is configured + // with client secret). + // + // * PASSWORD_VERIFIER: PASSWORD_CLAIM_SIGNATURE, PASSWORD_CLAIM_SECRET_BLOCK, + // TIMESTAMP, USERNAME, SECRET_HASH (if app client is configured with client + // secret). + // + // * NEW_PASSWORD_REQUIRED: NEW_PASSWORD, any other required attributes, + // USERNAME, SECRET_HASH (if app client is configured with client secret). ChallengeResponses map[string]*string `type:"map"` - // The client ID. + // The app client ID. // // ClientId is a required field ClientId *string `min:"1" type:"string" required:"true"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If InitiateAuth or RespondToAuthChallenge API call determines + // that the caller needs to go through another challenge, they return a session + // with other challenge parameters. This session should be passed as it is to + // the next RespondToAuthChallenge API call. Session *string `min:"20" type:"string"` } @@ -13468,13 +15649,18 @@ type RespondToAuthChallengeOutput struct { // the authentication challenge. AuthenticationResult *AuthenticationResultType `type:"structure"` - // The challenge name. + // The challenge name. For more information, see InitiateAuth (API_InitiateAuth.html). ChallengeName *string `type:"string" enum:"ChallengeNameType"` - // The challenge parameters. + // The challenge parameters. For more information, see InitiateAuth (API_InitiateAuth.html). ChallengeParameters map[string]*string `type:"map"` - // The session. + // The session which should be passed both ways in challenge-response calls + // to the service. If the InitiateAuth (API_InitiateAuth.html) or RespondToAuthChallenge + // (API_RespondToAuthChallenge.html) API call determines that the caller needs + // to go through another challenge, they return a session with other challenge + // parameters. This session should be passed as it is to the next RespondToAuthChallenge + // API call. Session *string `min:"20" type:"string"` } @@ -13706,6 +15892,9 @@ type SignUpInput struct { SecretHash *string `min:"1" type:"string"` // An array of name-value pairs representing user attributes. + // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. UserAttributes []*AttributeType `type:"list"` // The user name of the user you wish to register. @@ -13824,7 +16013,14 @@ type SignUpOutput struct { CodeDeliveryDetails *CodeDeliveryDetailsType `type:"structure"` // A response from the server indicating that a user registration has been confirmed. - UserConfirmed *bool `type:"boolean"` + // + // UserConfirmed is a required field + UserConfirmed *bool `type:"boolean" required:"true"` + + // The UUID of the authenticated user. This is not the same as username. + // + // UserSub is a required field + UserSub *string `type:"string" required:"true"` } // String returns the string representation @@ -13849,7 +16045,13 @@ func (s *SignUpOutput) SetUserConfirmed(v bool) *SignUpOutput { return s } -// The SMS configuratoin type. +// SetUserSub sets the UserSub field's value. +func (s *SignUpOutput) SetUserSub(v string) *SignUpOutput { + s.UserSub = &v + return s +} + +// The SMS configuration type. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/SmsConfigurationType type SmsConfigurationType struct { _ struct{} `type:"structure"` @@ -14203,7 +16405,7 @@ type UpdateGroupInput struct { GroupName *string `min:"1" type:"string" required:"true"` // The new precedence value for the group. For more information about this parameter, - // see CreateGroupRequest (API_CreateGroupRequeste.html). + // see CreateGroup (API_CreateGroup.html). Precedence *int64 `type:"integer"` // The new role ARN for the group. This is used for setting the cognito:roles @@ -14305,16 +16507,133 @@ func (s *UpdateGroupOutput) SetGroup(v *GroupType) *UpdateGroupOutput { return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UpdateIdentityProviderRequest +type UpdateIdentityProviderInput struct { + _ struct{} `type:"structure"` + + // The identity provider attribute mapping to be changed. + AttributeMapping map[string]*string `type:"map"` + + // A list of identity provider identifiers. + IdpIdentifiers []*string `type:"list"` + + // The identity provider details to be updated, such as MetadataURL and MetadataFile. + ProviderDetails map[string]*string `type:"map"` + + // The identity provider name. + // + // ProviderName is a required field + ProviderName *string `min:"1" type:"string" required:"true"` + + // The user pool ID. + // + // UserPoolId is a required field + UserPoolId *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateIdentityProviderInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateIdentityProviderInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateIdentityProviderInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateIdentityProviderInput"} + if s.ProviderName == nil { + invalidParams.Add(request.NewErrParamRequired("ProviderName")) + } + if s.ProviderName != nil && len(*s.ProviderName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ProviderName", 1)) + } + if s.UserPoolId == nil { + invalidParams.Add(request.NewErrParamRequired("UserPoolId")) + } + if s.UserPoolId != nil && len(*s.UserPoolId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("UserPoolId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributeMapping sets the AttributeMapping field's value. +func (s *UpdateIdentityProviderInput) SetAttributeMapping(v map[string]*string) *UpdateIdentityProviderInput { + s.AttributeMapping = v + return s +} + +// SetIdpIdentifiers sets the IdpIdentifiers field's value. +func (s *UpdateIdentityProviderInput) SetIdpIdentifiers(v []*string) *UpdateIdentityProviderInput { + s.IdpIdentifiers = v + return s +} + +// SetProviderDetails sets the ProviderDetails field's value. +func (s *UpdateIdentityProviderInput) SetProviderDetails(v map[string]*string) *UpdateIdentityProviderInput { + s.ProviderDetails = v + return s +} + +// SetProviderName sets the ProviderName field's value. +func (s *UpdateIdentityProviderInput) SetProviderName(v string) *UpdateIdentityProviderInput { + s.ProviderName = &v + return s +} + +// SetUserPoolId sets the UserPoolId field's value. +func (s *UpdateIdentityProviderInput) SetUserPoolId(v string) *UpdateIdentityProviderInput { + s.UserPoolId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UpdateIdentityProviderResponse +type UpdateIdentityProviderOutput struct { + _ struct{} `type:"structure"` + + // The identity provider object. + // + // IdentityProvider is a required field + IdentityProvider *IdentityProviderType `type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateIdentityProviderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateIdentityProviderOutput) GoString() string { + return s.String() +} + +// SetIdentityProvider sets the IdentityProvider field's value. +func (s *UpdateIdentityProviderOutput) SetIdentityProvider(v *IdentityProviderType) *UpdateIdentityProviderOutput { + s.IdentityProvider = v + return s +} + // Represents the request to update user attributes. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UpdateUserAttributesRequest type UpdateUserAttributesInput struct { _ struct{} `type:"structure"` // The access token for the request to update user attributes. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` // An array of name-value pairs representing user attributes. // + // For custom attributes, you must prepend the custom: prefix to the attribute + // name. + // // UserAttributes is a required field UserAttributes []*AttributeType `type:"list" required:"true"` } @@ -14332,6 +16651,9 @@ func (s UpdateUserAttributesInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *UpdateUserAttributesInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "UpdateUserAttributesInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } if s.UserAttributes == nil { invalidParams.Add(request.NewErrParamRequired("UserAttributes")) } @@ -14395,6 +16717,25 @@ func (s *UpdateUserAttributesOutput) SetCodeDeliveryDetailsList(v []*CodeDeliver type UpdateUserPoolClientInput struct { _ struct{} `type:"structure"` + // Set to code to initiate a code grant flow, which provides an authorization + // code as the response. This code can be exchanged for access tokens with the + // token endpoint. + // + // Set to token to specify that the client should get the access token (and, + // optionally, ID token, based on scopes) directly. + AllowedOAuthFlows []*string `type:"list"` + + // Set to TRUE if the client is allowed to follow the OAuth protocol when interacting + // with Cognito user pools. + AllowedOAuthFlowsUserPoolClient *bool `type:"boolean"` + + // A list of allowed OAuth scopes. Currently supported values are "phone", "email", + // "openid", and "Cognito". + AllowedOAuthScopes []*string `type:"list"` + + // A list of allowed callback URLs for the identity providers. + CallbackURLs []*string `type:"list"` + // The ID of the client associated with the user pool. // // ClientId is a required field @@ -14403,15 +16744,26 @@ type UpdateUserPoolClientInput struct { // The client name from the update user pool client request. ClientName *string `min:"1" type:"string"` + // The default redirect URI. Must be in the CallbackURLs list. + DefaultRedirectURI *string `min:"1" type:"string"` + // Explicit authentication flows. ExplicitAuthFlows []*string `type:"list"` + // A list ofallowed logout URLs for the identity providers. + LogoutURLs []*string `type:"list"` + // The read-only attributes of the user pool. ReadAttributes []*string `type:"list"` - // The validity of the refresh token, in days. + // The time limit, in days, after which the refresh token is no longer valid + // and cannot be used. RefreshTokenValidity *int64 `type:"integer"` + // A list of provider names for the identity providers that are supported on + // this client. + SupportedIdentityProviders []*string `type:"list"` + // The user pool ID for the user pool where you want to update the user pool // client. // @@ -14444,6 +16796,9 @@ func (s *UpdateUserPoolClientInput) Validate() error { if s.ClientName != nil && len(*s.ClientName) < 1 { invalidParams.Add(request.NewErrParamMinLen("ClientName", 1)) } + if s.DefaultRedirectURI != nil && len(*s.DefaultRedirectURI) < 1 { + invalidParams.Add(request.NewErrParamMinLen("DefaultRedirectURI", 1)) + } if s.UserPoolId == nil { invalidParams.Add(request.NewErrParamRequired("UserPoolId")) } @@ -14457,6 +16812,30 @@ func (s *UpdateUserPoolClientInput) Validate() error { return nil } +// SetAllowedOAuthFlows sets the AllowedOAuthFlows field's value. +func (s *UpdateUserPoolClientInput) SetAllowedOAuthFlows(v []*string) *UpdateUserPoolClientInput { + s.AllowedOAuthFlows = v + return s +} + +// SetAllowedOAuthFlowsUserPoolClient sets the AllowedOAuthFlowsUserPoolClient field's value. +func (s *UpdateUserPoolClientInput) SetAllowedOAuthFlowsUserPoolClient(v bool) *UpdateUserPoolClientInput { + s.AllowedOAuthFlowsUserPoolClient = &v + return s +} + +// SetAllowedOAuthScopes sets the AllowedOAuthScopes field's value. +func (s *UpdateUserPoolClientInput) SetAllowedOAuthScopes(v []*string) *UpdateUserPoolClientInput { + s.AllowedOAuthScopes = v + return s +} + +// SetCallbackURLs sets the CallbackURLs field's value. +func (s *UpdateUserPoolClientInput) SetCallbackURLs(v []*string) *UpdateUserPoolClientInput { + s.CallbackURLs = v + return s +} + // SetClientId sets the ClientId field's value. func (s *UpdateUserPoolClientInput) SetClientId(v string) *UpdateUserPoolClientInput { s.ClientId = &v @@ -14469,12 +16848,24 @@ func (s *UpdateUserPoolClientInput) SetClientName(v string) *UpdateUserPoolClien return s } +// SetDefaultRedirectURI sets the DefaultRedirectURI field's value. +func (s *UpdateUserPoolClientInput) SetDefaultRedirectURI(v string) *UpdateUserPoolClientInput { + s.DefaultRedirectURI = &v + return s +} + // SetExplicitAuthFlows sets the ExplicitAuthFlows field's value. func (s *UpdateUserPoolClientInput) SetExplicitAuthFlows(v []*string) *UpdateUserPoolClientInput { s.ExplicitAuthFlows = v return s } +// SetLogoutURLs sets the LogoutURLs field's value. +func (s *UpdateUserPoolClientInput) SetLogoutURLs(v []*string) *UpdateUserPoolClientInput { + s.LogoutURLs = v + return s +} + // SetReadAttributes sets the ReadAttributes field's value. func (s *UpdateUserPoolClientInput) SetReadAttributes(v []*string) *UpdateUserPoolClientInput { s.ReadAttributes = v @@ -14487,6 +16878,12 @@ func (s *UpdateUserPoolClientInput) SetRefreshTokenValidity(v int64) *UpdateUser return s } +// SetSupportedIdentityProviders sets the SupportedIdentityProviders field's value. +func (s *UpdateUserPoolClientInput) SetSupportedIdentityProviders(v []*string) *UpdateUserPoolClientInput { + s.SupportedIdentityProviders = v + return s +} + // SetUserPoolId sets the UserPoolId field's value. func (s *UpdateUserPoolClientInput) SetUserPoolId(v string) *UpdateUserPoolClientInput { s.UserPoolId = &v @@ -14547,7 +16944,7 @@ type UpdateUserPoolInput struct { // The contents of the email verification message. EmailVerificationMessage *string `min:"6" type:"string"` - // The subject of the email verfication message. + // The subject of the email verification message. EmailVerificationSubject *string `min:"1" type:"string"` // The AWS Lambda configuration information from the request to update the user @@ -14761,13 +17158,13 @@ type UserImportJobType struct { // Amazon Cognito Developer Guide. CloudWatchLogsRoleArn *string `min:"20" type:"string"` - // The date when the user imoprt job was completed. + // The date when the user import job was completed. CompletionDate *time.Time `type:"timestamp" timestampFormat:"unix"` // The message returned when the user import job is completed. CompletionMessage *string `min:"1" type:"string"` - // The date when the user import job was created. + // The date the user import job was created. CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` // The number of users that could not be imported. @@ -14956,6 +17353,25 @@ func (s *UserPoolClientDescription) SetUserPoolId(v string) *UserPoolClientDescr type UserPoolClientType struct { _ struct{} `type:"structure"` + // Set to code to initiate a code grant flow, which provides an authorization + // code as the response. This code can be exchanged for access tokens with the + // token endpoint. + // + // Set to token to specify that the client should get the access token (and, + // optionally, ID token, based on scopes) directly. + AllowedOAuthFlows []*string `type:"list"` + + // Set to TRUE if the client is allowed to follow the OAuth protocol when interacting + // with Cognito user pools. + AllowedOAuthFlowsUserPoolClient *bool `type:"boolean"` + + // A list of allowed OAuth scopes. Currently supported values are "phone", "email", + // "openid", and "Cognito". + AllowedOAuthScopes []*string `type:"list"` + + // A list of allowed callback URLs for the identity providers. + CallbackURLs []*string `type:"list"` + // The ID of the client associated with the user pool. ClientId *string `min:"1" type:"string"` @@ -14965,21 +17381,32 @@ type UserPoolClientType struct { // The client secret from the user pool request of the client type. ClientSecret *string `min:"1" type:"string"` - // The creation date from the user pool request of the client type. + // The date the user pool client was created. CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` + // The default redirect URI. Must be in the CallbackURLs list. + DefaultRedirectURI *string `min:"1" type:"string"` + // The explicit authentication flows. ExplicitAuthFlows []*string `type:"list"` - // The last modified date from the user pool request of the client type. + // The date the user pool client was last modified. LastModifiedDate *time.Time `type:"timestamp" timestampFormat:"unix"` + // A list ofallowed logout URLs for the identity providers. + LogoutURLs []*string `type:"list"` + // The Read-only attributes. ReadAttributes []*string `type:"list"` - // The validity of the refresh token, in days. + // The time limit, in days, after which the refresh token is no longer valid + // and cannot be used. RefreshTokenValidity *int64 `type:"integer"` + // A list of provider names for the identity providers that are supported on + // this client. + SupportedIdentityProviders []*string `type:"list"` + // The user pool ID for the user pool client. UserPoolId *string `min:"1" type:"string"` @@ -14997,6 +17424,30 @@ func (s UserPoolClientType) GoString() string { return s.String() } +// SetAllowedOAuthFlows sets the AllowedOAuthFlows field's value. +func (s *UserPoolClientType) SetAllowedOAuthFlows(v []*string) *UserPoolClientType { + s.AllowedOAuthFlows = v + return s +} + +// SetAllowedOAuthFlowsUserPoolClient sets the AllowedOAuthFlowsUserPoolClient field's value. +func (s *UserPoolClientType) SetAllowedOAuthFlowsUserPoolClient(v bool) *UserPoolClientType { + s.AllowedOAuthFlowsUserPoolClient = &v + return s +} + +// SetAllowedOAuthScopes sets the AllowedOAuthScopes field's value. +func (s *UserPoolClientType) SetAllowedOAuthScopes(v []*string) *UserPoolClientType { + s.AllowedOAuthScopes = v + return s +} + +// SetCallbackURLs sets the CallbackURLs field's value. +func (s *UserPoolClientType) SetCallbackURLs(v []*string) *UserPoolClientType { + s.CallbackURLs = v + return s +} + // SetClientId sets the ClientId field's value. func (s *UserPoolClientType) SetClientId(v string) *UserPoolClientType { s.ClientId = &v @@ -15021,6 +17472,12 @@ func (s *UserPoolClientType) SetCreationDate(v time.Time) *UserPoolClientType { return s } +// SetDefaultRedirectURI sets the DefaultRedirectURI field's value. +func (s *UserPoolClientType) SetDefaultRedirectURI(v string) *UserPoolClientType { + s.DefaultRedirectURI = &v + return s +} + // SetExplicitAuthFlows sets the ExplicitAuthFlows field's value. func (s *UserPoolClientType) SetExplicitAuthFlows(v []*string) *UserPoolClientType { s.ExplicitAuthFlows = v @@ -15033,6 +17490,12 @@ func (s *UserPoolClientType) SetLastModifiedDate(v time.Time) *UserPoolClientTyp return s } +// SetLogoutURLs sets the LogoutURLs field's value. +func (s *UserPoolClientType) SetLogoutURLs(v []*string) *UserPoolClientType { + s.LogoutURLs = v + return s +} + // SetReadAttributes sets the ReadAttributes field's value. func (s *UserPoolClientType) SetReadAttributes(v []*string) *UserPoolClientType { s.ReadAttributes = v @@ -15045,6 +17508,12 @@ func (s *UserPoolClientType) SetRefreshTokenValidity(v int64) *UserPoolClientTyp return s } +// SetSupportedIdentityProviders sets the SupportedIdentityProviders field's value. +func (s *UserPoolClientType) SetSupportedIdentityProviders(v []*string) *UserPoolClientType { + s.SupportedIdentityProviders = v + return s +} + // SetUserPoolId sets the UserPoolId field's value. func (s *UserPoolClientType) SetUserPoolId(v string) *UserPoolClientType { s.UserPoolId = &v @@ -15062,7 +17531,7 @@ func (s *UserPoolClientType) SetWriteAttributes(v []*string) *UserPoolClientType type UserPoolDescriptionType struct { _ struct{} `type:"structure"` - // The creation date in a user pool description. + // The date the user pool description was created. CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` // The ID in a user pool description. @@ -15071,7 +17540,7 @@ type UserPoolDescriptionType struct { // The AWS Lambda configuration information in a user pool description. LambdaConfig *LambdaConfigType `type:"structure"` - // The last modified date in a user pool description. + // The date the user pool description was last modified. LastModifiedDate *time.Time `type:"timestamp" timestampFormat:"unix"` // The name in a user pool description. @@ -15132,7 +17601,7 @@ func (s *UserPoolDescriptionType) SetStatus(v string) *UserPoolDescriptionType { type UserPoolPolicyType struct { _ struct{} `type:"structure"` - // A container with information about the user pool password policy. + // A container for information about the user pool password policy. PasswordPolicy *PasswordPolicyType `type:"structure"` } @@ -15167,7 +17636,7 @@ func (s *UserPoolPolicyType) SetPasswordPolicy(v *PasswordPolicyType) *UserPoolP return s } -// A container with information about the user pool type. +// A container for information about the user pool type. // Please also see https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/UserPoolType type UserPoolType struct { _ struct{} `type:"structure"` @@ -15181,7 +17650,7 @@ type UserPoolType struct { // Specifies the attributes that are auto-verified in a user pool. AutoVerifiedAttributes []*string `type:"list"` - // The creation date of a user pool. + // The date the user pool was created. CreationDate *time.Time `type:"timestamp" timestampFormat:"unix"` // The device configuration. @@ -15205,10 +17674,10 @@ type UserPoolType struct { // The ID of the user pool. Id *string `min:"1" type:"string"` - // A container describing the AWS Lambda triggers associated with a user pool. + // A container for the AWS Lambda triggers associated with a user pool. LambdaConfig *LambdaConfigType `type:"structure"` - // The last modified date of a user pool. + // The date the user pool was last modified. LastModifiedDate *time.Time `type:"timestamp" timestampFormat:"unix"` // Can be one of the following values: @@ -15225,7 +17694,7 @@ type UserPoolType struct { // The name of the user pool. Name *string `min:"1" type:"string"` - // A container describing the policies associated with a user pool. + // A container for the policies associated with a user pool. Policies *UserPoolPolicyType `type:"structure"` // A container with the schema attributes of a user pool. @@ -15237,7 +17706,7 @@ type UserPoolType struct { // The SMS configuration. SmsConfiguration *SmsConfigurationType `type:"structure"` - // The reason why the SMS configuration cannot send the message(s) to your users. + // The reason why the SMS configuration cannot send the messages to your users. SmsConfigurationFailure *string `type:"string"` // The contents of the SMS verification message. @@ -15494,7 +17963,9 @@ type VerifyUserAttributeInput struct { _ struct{} `type:"structure"` // Represents the access token of the request to verify user attributes. - AccessToken *string `type:"string"` + // + // AccessToken is a required field + AccessToken *string `type:"string" required:"true"` // The attribute name in the request to verify user attributes. // @@ -15520,6 +17991,9 @@ func (s VerifyUserAttributeInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *VerifyUserAttributeInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "VerifyUserAttributeInput"} + if s.AccessToken == nil { + invalidParams.Add(request.NewErrParamRequired("AccessToken")) + } if s.AttributeName == nil { invalidParams.Add(request.NewErrParamRequired("AttributeName")) } @@ -15655,6 +18129,20 @@ const ( DeviceRememberedStatusTypeNotRemembered = "not_remembered" ) +const ( + // DomainStatusTypeCreating is a DomainStatusType enum value + DomainStatusTypeCreating = "CREATING" + + // DomainStatusTypeDeleting is a DomainStatusType enum value + DomainStatusTypeDeleting = "DELETING" + + // DomainStatusTypeUpdating is a DomainStatusType enum value + DomainStatusTypeUpdating = "UPDATING" + + // DomainStatusTypeActive is a DomainStatusType enum value + DomainStatusTypeActive = "ACTIVE" +) + const ( // ExplicitAuthFlowsTypeAdminNoSrpAuth is a ExplicitAuthFlowsType enum value ExplicitAuthFlowsTypeAdminNoSrpAuth = "ADMIN_NO_SRP_AUTH" @@ -15663,6 +18151,11 @@ const ( ExplicitAuthFlowsTypeCustomAuthFlowOnly = "CUSTOM_AUTH_FLOW_ONLY" ) +const ( + // IdentityProviderTypeTypeSaml is a IdentityProviderTypeType enum value + IdentityProviderTypeTypeSaml = "SAML" +) + const ( // MessageActionTypeResend is a MessageActionType enum value MessageActionTypeResend = "RESEND" @@ -15671,6 +18164,17 @@ const ( MessageActionTypeSuppress = "SUPPRESS" ) +const ( + // OAuthFlowTypeCode is a OAuthFlowType enum value + OAuthFlowTypeCode = "code" + + // OAuthFlowTypeImplicit is a OAuthFlowType enum value + OAuthFlowTypeImplicit = "implicit" + + // OAuthFlowTypeClientCredentials is a OAuthFlowType enum value + OAuthFlowTypeClientCredentials = "client_credentials" +) + const ( // StatusTypeEnabled is a StatusType enum value StatusTypeEnabled = "Enabled" diff --git a/service/cognitoidentityprovider/cognitoidentityprovideriface/interface.go b/service/cognitoidentityprovider/cognitoidentityprovideriface/interface.go index 84684ff258c..6d72d458070 100644 --- a/service/cognitoidentityprovider/cognitoidentityprovideriface/interface.go +++ b/service/cognitoidentityprovider/cognitoidentityprovideriface/interface.go @@ -164,6 +164,10 @@ type CognitoIdentityProviderAPI interface { CreateGroupWithContext(aws.Context, *cognitoidentityprovider.CreateGroupInput, ...request.Option) (*cognitoidentityprovider.CreateGroupOutput, error) CreateGroupRequest(*cognitoidentityprovider.CreateGroupInput) (*request.Request, *cognitoidentityprovider.CreateGroupOutput) + CreateIdentityProvider(*cognitoidentityprovider.CreateIdentityProviderInput) (*cognitoidentityprovider.CreateIdentityProviderOutput, error) + CreateIdentityProviderWithContext(aws.Context, *cognitoidentityprovider.CreateIdentityProviderInput, ...request.Option) (*cognitoidentityprovider.CreateIdentityProviderOutput, error) + CreateIdentityProviderRequest(*cognitoidentityprovider.CreateIdentityProviderInput) (*request.Request, *cognitoidentityprovider.CreateIdentityProviderOutput) + CreateUserImportJob(*cognitoidentityprovider.CreateUserImportJobInput) (*cognitoidentityprovider.CreateUserImportJobOutput, error) CreateUserImportJobWithContext(aws.Context, *cognitoidentityprovider.CreateUserImportJobInput, ...request.Option) (*cognitoidentityprovider.CreateUserImportJobOutput, error) CreateUserImportJobRequest(*cognitoidentityprovider.CreateUserImportJobInput) (*request.Request, *cognitoidentityprovider.CreateUserImportJobOutput) @@ -176,10 +180,18 @@ type CognitoIdentityProviderAPI interface { CreateUserPoolClientWithContext(aws.Context, *cognitoidentityprovider.CreateUserPoolClientInput, ...request.Option) (*cognitoidentityprovider.CreateUserPoolClientOutput, error) CreateUserPoolClientRequest(*cognitoidentityprovider.CreateUserPoolClientInput) (*request.Request, *cognitoidentityprovider.CreateUserPoolClientOutput) + CreateUserPoolDomain(*cognitoidentityprovider.CreateUserPoolDomainInput) (*cognitoidentityprovider.CreateUserPoolDomainOutput, error) + CreateUserPoolDomainWithContext(aws.Context, *cognitoidentityprovider.CreateUserPoolDomainInput, ...request.Option) (*cognitoidentityprovider.CreateUserPoolDomainOutput, error) + CreateUserPoolDomainRequest(*cognitoidentityprovider.CreateUserPoolDomainInput) (*request.Request, *cognitoidentityprovider.CreateUserPoolDomainOutput) + DeleteGroup(*cognitoidentityprovider.DeleteGroupInput) (*cognitoidentityprovider.DeleteGroupOutput, error) DeleteGroupWithContext(aws.Context, *cognitoidentityprovider.DeleteGroupInput, ...request.Option) (*cognitoidentityprovider.DeleteGroupOutput, error) DeleteGroupRequest(*cognitoidentityprovider.DeleteGroupInput) (*request.Request, *cognitoidentityprovider.DeleteGroupOutput) + DeleteIdentityProvider(*cognitoidentityprovider.DeleteIdentityProviderInput) (*cognitoidentityprovider.DeleteIdentityProviderOutput, error) + DeleteIdentityProviderWithContext(aws.Context, *cognitoidentityprovider.DeleteIdentityProviderInput, ...request.Option) (*cognitoidentityprovider.DeleteIdentityProviderOutput, error) + DeleteIdentityProviderRequest(*cognitoidentityprovider.DeleteIdentityProviderInput) (*request.Request, *cognitoidentityprovider.DeleteIdentityProviderOutput) + DeleteUser(*cognitoidentityprovider.DeleteUserInput) (*cognitoidentityprovider.DeleteUserOutput, error) DeleteUserWithContext(aws.Context, *cognitoidentityprovider.DeleteUserInput, ...request.Option) (*cognitoidentityprovider.DeleteUserOutput, error) DeleteUserRequest(*cognitoidentityprovider.DeleteUserInput) (*request.Request, *cognitoidentityprovider.DeleteUserOutput) @@ -196,6 +208,14 @@ type CognitoIdentityProviderAPI interface { DeleteUserPoolClientWithContext(aws.Context, *cognitoidentityprovider.DeleteUserPoolClientInput, ...request.Option) (*cognitoidentityprovider.DeleteUserPoolClientOutput, error) DeleteUserPoolClientRequest(*cognitoidentityprovider.DeleteUserPoolClientInput) (*request.Request, *cognitoidentityprovider.DeleteUserPoolClientOutput) + DeleteUserPoolDomain(*cognitoidentityprovider.DeleteUserPoolDomainInput) (*cognitoidentityprovider.DeleteUserPoolDomainOutput, error) + DeleteUserPoolDomainWithContext(aws.Context, *cognitoidentityprovider.DeleteUserPoolDomainInput, ...request.Option) (*cognitoidentityprovider.DeleteUserPoolDomainOutput, error) + DeleteUserPoolDomainRequest(*cognitoidentityprovider.DeleteUserPoolDomainInput) (*request.Request, *cognitoidentityprovider.DeleteUserPoolDomainOutput) + + DescribeIdentityProvider(*cognitoidentityprovider.DescribeIdentityProviderInput) (*cognitoidentityprovider.DescribeIdentityProviderOutput, error) + DescribeIdentityProviderWithContext(aws.Context, *cognitoidentityprovider.DescribeIdentityProviderInput, ...request.Option) (*cognitoidentityprovider.DescribeIdentityProviderOutput, error) + DescribeIdentityProviderRequest(*cognitoidentityprovider.DescribeIdentityProviderInput) (*request.Request, *cognitoidentityprovider.DescribeIdentityProviderOutput) + DescribeUserImportJob(*cognitoidentityprovider.DescribeUserImportJobInput) (*cognitoidentityprovider.DescribeUserImportJobOutput, error) DescribeUserImportJobWithContext(aws.Context, *cognitoidentityprovider.DescribeUserImportJobInput, ...request.Option) (*cognitoidentityprovider.DescribeUserImportJobOutput, error) DescribeUserImportJobRequest(*cognitoidentityprovider.DescribeUserImportJobInput) (*request.Request, *cognitoidentityprovider.DescribeUserImportJobOutput) @@ -208,6 +228,10 @@ type CognitoIdentityProviderAPI interface { DescribeUserPoolClientWithContext(aws.Context, *cognitoidentityprovider.DescribeUserPoolClientInput, ...request.Option) (*cognitoidentityprovider.DescribeUserPoolClientOutput, error) DescribeUserPoolClientRequest(*cognitoidentityprovider.DescribeUserPoolClientInput) (*request.Request, *cognitoidentityprovider.DescribeUserPoolClientOutput) + DescribeUserPoolDomain(*cognitoidentityprovider.DescribeUserPoolDomainInput) (*cognitoidentityprovider.DescribeUserPoolDomainOutput, error) + DescribeUserPoolDomainWithContext(aws.Context, *cognitoidentityprovider.DescribeUserPoolDomainInput, ...request.Option) (*cognitoidentityprovider.DescribeUserPoolDomainOutput, error) + DescribeUserPoolDomainRequest(*cognitoidentityprovider.DescribeUserPoolDomainInput) (*request.Request, *cognitoidentityprovider.DescribeUserPoolDomainOutput) + ForgetDevice(*cognitoidentityprovider.ForgetDeviceInput) (*cognitoidentityprovider.ForgetDeviceOutput, error) ForgetDeviceWithContext(aws.Context, *cognitoidentityprovider.ForgetDeviceInput, ...request.Option) (*cognitoidentityprovider.ForgetDeviceOutput, error) ForgetDeviceRequest(*cognitoidentityprovider.ForgetDeviceInput) (*request.Request, *cognitoidentityprovider.ForgetDeviceOutput) @@ -228,6 +252,10 @@ type CognitoIdentityProviderAPI interface { GetGroupWithContext(aws.Context, *cognitoidentityprovider.GetGroupInput, ...request.Option) (*cognitoidentityprovider.GetGroupOutput, error) GetGroupRequest(*cognitoidentityprovider.GetGroupInput) (*request.Request, *cognitoidentityprovider.GetGroupOutput) + GetIdentityProviderByIdentifier(*cognitoidentityprovider.GetIdentityProviderByIdentifierInput) (*cognitoidentityprovider.GetIdentityProviderByIdentifierOutput, error) + GetIdentityProviderByIdentifierWithContext(aws.Context, *cognitoidentityprovider.GetIdentityProviderByIdentifierInput, ...request.Option) (*cognitoidentityprovider.GetIdentityProviderByIdentifierOutput, error) + GetIdentityProviderByIdentifierRequest(*cognitoidentityprovider.GetIdentityProviderByIdentifierInput) (*request.Request, *cognitoidentityprovider.GetIdentityProviderByIdentifierOutput) + GetUser(*cognitoidentityprovider.GetUserInput) (*cognitoidentityprovider.GetUserOutput, error) GetUserWithContext(aws.Context, *cognitoidentityprovider.GetUserInput, ...request.Option) (*cognitoidentityprovider.GetUserOutput, error) GetUserRequest(*cognitoidentityprovider.GetUserInput) (*request.Request, *cognitoidentityprovider.GetUserOutput) @@ -252,6 +280,10 @@ type CognitoIdentityProviderAPI interface { ListGroupsWithContext(aws.Context, *cognitoidentityprovider.ListGroupsInput, ...request.Option) (*cognitoidentityprovider.ListGroupsOutput, error) ListGroupsRequest(*cognitoidentityprovider.ListGroupsInput) (*request.Request, *cognitoidentityprovider.ListGroupsOutput) + ListIdentityProviders(*cognitoidentityprovider.ListIdentityProvidersInput) (*cognitoidentityprovider.ListIdentityProvidersOutput, error) + ListIdentityProvidersWithContext(aws.Context, *cognitoidentityprovider.ListIdentityProvidersInput, ...request.Option) (*cognitoidentityprovider.ListIdentityProvidersOutput, error) + ListIdentityProvidersRequest(*cognitoidentityprovider.ListIdentityProvidersInput) (*request.Request, *cognitoidentityprovider.ListIdentityProvidersOutput) + ListUserImportJobs(*cognitoidentityprovider.ListUserImportJobsInput) (*cognitoidentityprovider.ListUserImportJobsOutput, error) ListUserImportJobsWithContext(aws.Context, *cognitoidentityprovider.ListUserImportJobsInput, ...request.Option) (*cognitoidentityprovider.ListUserImportJobsOutput, error) ListUserImportJobsRequest(*cognitoidentityprovider.ListUserImportJobsInput) (*request.Request, *cognitoidentityprovider.ListUserImportJobsOutput) @@ -304,6 +336,10 @@ type CognitoIdentityProviderAPI interface { UpdateGroupWithContext(aws.Context, *cognitoidentityprovider.UpdateGroupInput, ...request.Option) (*cognitoidentityprovider.UpdateGroupOutput, error) UpdateGroupRequest(*cognitoidentityprovider.UpdateGroupInput) (*request.Request, *cognitoidentityprovider.UpdateGroupOutput) + UpdateIdentityProvider(*cognitoidentityprovider.UpdateIdentityProviderInput) (*cognitoidentityprovider.UpdateIdentityProviderOutput, error) + UpdateIdentityProviderWithContext(aws.Context, *cognitoidentityprovider.UpdateIdentityProviderInput, ...request.Option) (*cognitoidentityprovider.UpdateIdentityProviderOutput, error) + UpdateIdentityProviderRequest(*cognitoidentityprovider.UpdateIdentityProviderInput) (*request.Request, *cognitoidentityprovider.UpdateIdentityProviderOutput) + UpdateUserAttributes(*cognitoidentityprovider.UpdateUserAttributesInput) (*cognitoidentityprovider.UpdateUserAttributesOutput, error) UpdateUserAttributesWithContext(aws.Context, *cognitoidentityprovider.UpdateUserAttributesInput, ...request.Option) (*cognitoidentityprovider.UpdateUserAttributesOutput, error) UpdateUserAttributesRequest(*cognitoidentityprovider.UpdateUserAttributesInput) (*request.Request, *cognitoidentityprovider.UpdateUserAttributesOutput) diff --git a/service/cognitoidentityprovider/doc.go b/service/cognitoidentityprovider/doc.go index cac793ba887..77f8bfcced9 100644 --- a/service/cognitoidentityprovider/doc.go +++ b/service/cognitoidentityprovider/doc.go @@ -3,12 +3,12 @@ // Package cognitoidentityprovider provides the client and types for making API // requests to Amazon Cognito Identity Provider. // -// Using the Amazon Cognito Your User Pools API, you can create a user pool -// to manage directories and users. You can authenticate a user to obtain tokens -// related to user identity and access policies. +// Using the Amazon Cognito User Pools API, you can create a user pool to manage +// directories and users. You can authenticate a user to obtain tokens related +// to user identity and access policies. // // This API reference provides information about user pools in Amazon Cognito -// Your User Pools. +// User Pools. // // For more information, see the Amazon Cognito Documentation. // diff --git a/service/cognitoidentityprovider/errors.go b/service/cognitoidentityprovider/errors.go index f1469377f23..cc9a5951b15 100644 --- a/service/cognitoidentityprovider/errors.go +++ b/service/cognitoidentityprovider/errors.go @@ -32,6 +32,13 @@ const ( // This exception is thrown if two or more modifications are happening concurrently. ErrCodeConcurrentModificationException = "ConcurrentModificationException" + // ErrCodeDuplicateProviderException for service response error code + // "DuplicateProviderException". + // + // This exception is thrown when the provider is already supported by the user + // pool. + ErrCodeDuplicateProviderException = "DuplicateProviderException" + // ErrCodeExpiredCodeException for service response error code // "ExpiredCodeException". // @@ -65,6 +72,12 @@ const ( // AWS Lambda response. ErrCodeInvalidLambdaResponseException = "InvalidLambdaResponseException" + // ErrCodeInvalidOAuthFlowException for service response error code + // "InvalidOAuthFlowException". + // + // This exception is thrown when the specified OAuth flow is invalid. + ErrCodeInvalidOAuthFlowException = "InvalidOAuthFlowException" + // ErrCodeInvalidParameterException for service response error code // "InvalidParameterException". // @@ -118,7 +131,7 @@ const ( // ErrCodeNotAuthorizedException for service response error code // "NotAuthorizedException". // - // This exception gets thrown when a user is not authorized. + // This exception is thrown when a user is not authorized. ErrCodeNotAuthorizedException = "NotAuthorizedException" // ErrCodePasswordResetRequiredException for service response error code @@ -140,27 +153,39 @@ const ( // requested resource. ErrCodeResourceNotFoundException = "ResourceNotFoundException" + // ErrCodeScopeDoesNotExistException for service response error code + // "ScopeDoesNotExistException". + // + // This exception is thrown when the specified scope does not exist. + ErrCodeScopeDoesNotExistException = "ScopeDoesNotExistException" + // ErrCodeTooManyFailedAttemptsException for service response error code // "TooManyFailedAttemptsException". // - // This exception gets thrown when the user has made too many failed attempts + // This exception is thrown when the user has made too many failed attempts // for a given action (e.g., sign in). ErrCodeTooManyFailedAttemptsException = "TooManyFailedAttemptsException" // ErrCodeTooManyRequestsException for service response error code // "TooManyRequestsException". // - // This exception gets thrown when the user has made too many requests for a - // given operation. + // This exception is thrown when the user has made too many requests for a given + // operation. ErrCodeTooManyRequestsException = "TooManyRequestsException" // ErrCodeUnexpectedLambdaException for service response error code // "UnexpectedLambdaException". // - // This exception gets thrown when the Amazon Cognito service encounters an - // unexpected exception with the AWS Lambda service. + // This exception is thrown when the Amazon Cognito service encounters an unexpected + // exception with the AWS Lambda service. ErrCodeUnexpectedLambdaException = "UnexpectedLambdaException" + // ErrCodeUnsupportedIdentityProviderException for service response error code + // "UnsupportedIdentityProviderException". + // + // This exception is thrown when the specified identifier is not supported. + ErrCodeUnsupportedIdentityProviderException = "UnsupportedIdentityProviderException" + // ErrCodeUnsupportedUserStateException for service response error code // "UnsupportedUserStateException". // @@ -177,7 +202,7 @@ const ( // ErrCodeUserLambdaValidationException for service response error code // "UserLambdaValidationException". // - // This exception gets thrown when the Amazon Cognito service encounters a user + // This exception is thrown when the Amazon Cognito service encounters a user // validation exception with the AWS Lambda service. ErrCodeUserLambdaValidationException = "UserLambdaValidationException" @@ -196,7 +221,7 @@ const ( // ErrCodeUserPoolTaggingException for service response error code // "UserPoolTaggingException". // - // This exception gets thrown when a user pool tag cannot be set or updated. + // This exception is thrown when a user pool tag cannot be set or updated. ErrCodeUserPoolTaggingException = "UserPoolTaggingException" // ErrCodeUsernameExistsException for service response error code diff --git a/service/cognitoidentityprovider/examples_test.go b/service/cognitoidentityprovider/examples_test.go index af0acce6beb..ce738281510 100644 --- a/service/cognitoidentityprovider/examples_test.go +++ b/service/cognitoidentityprovider/examples_test.go @@ -564,9 +564,9 @@ func ExampleCognitoIdentityProvider_ChangePassword() { svc := cognitoidentityprovider.New(sess) params := &cognitoidentityprovider.ChangePasswordInput{ - PreviousPassword: aws.String("PasswordType"), // Required - ProposedPassword: aws.String("PasswordType"), // Required - AccessToken: aws.String("TokenModelType"), + AccessToken: aws.String("TokenModelType"), // Required + PreviousPassword: aws.String("PasswordType"), // Required + ProposedPassword: aws.String("PasswordType"), // Required } resp, err := svc.ChangePassword(params) @@ -683,6 +683,41 @@ func ExampleCognitoIdentityProvider_CreateGroup() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_CreateIdentityProvider() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.CreateIdentityProviderInput{ + ProviderDetails: map[string]*string{ // Required + "Key": aws.String("StringType"), // Required + // More values... + }, + ProviderName: aws.String("ProviderNameType"), // Required + ProviderType: aws.String("IdentityProviderTypeType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + AttributeMapping: map[string]*string{ + "Key": aws.String("StringType"), // Required + // More values... + }, + IdpIdentifiers: []*string{ + aws.String("IdpIdentifierType"), // Required + // More values... + }, + } + resp, err := svc.CreateIdentityProvider(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -810,16 +845,38 @@ func ExampleCognitoIdentityProvider_CreateUserPoolClient() { params := &cognitoidentityprovider.CreateUserPoolClientInput{ ClientName: aws.String("ClientNameType"), // Required UserPoolId: aws.String("UserPoolIdType"), // Required + AllowedOAuthFlows: []*string{ + aws.String("OAuthFlowType"), // Required + // More values... + }, + AllowedOAuthFlowsUserPoolClient: aws.Bool(true), + AllowedOAuthScopes: []*string{ + aws.String("ScopeType"), // Required + // More values... + }, + CallbackURLs: []*string{ + aws.String("RedirectUrlType"), // Required + // More values... + }, + DefaultRedirectURI: aws.String("RedirectUrlType"), ExplicitAuthFlows: []*string{ aws.String("ExplicitAuthFlowsType"), // Required // More values... }, GenerateSecret: aws.Bool(true), + LogoutURLs: []*string{ + aws.String("RedirectUrlType"), // Required + // More values... + }, ReadAttributes: []*string{ aws.String("ClientPermissionType"), // Required // More values... }, RefreshTokenValidity: aws.Int64(1), + SupportedIdentityProviders: []*string{ + aws.String("ProviderNameType"), // Required + // More values... + }, WriteAttributes: []*string{ aws.String("ClientPermissionType"), // Required // More values... @@ -838,6 +895,28 @@ func ExampleCognitoIdentityProvider_CreateUserPoolClient() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_CreateUserPoolDomain() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.CreateUserPoolDomainInput{ + Domain: aws.String("DomainType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + } + resp, err := svc.CreateUserPoolDomain(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -860,13 +939,35 @@ func ExampleCognitoIdentityProvider_DeleteGroup() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_DeleteIdentityProvider() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.DeleteIdentityProviderInput{ + ProviderName: aws.String("ProviderNameType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + } + resp, err := svc.DeleteIdentityProvider(params) + + if err != nil { + // Print the error, cast err to awserr.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"), + AccessToken: aws.String("TokenModelType"), // Required } resp, err := svc.DeleteUser(params) @@ -887,11 +988,11 @@ func ExampleCognitoIdentityProvider_DeleteUserAttributes() { svc := cognitoidentityprovider.New(sess) params := &cognitoidentityprovider.DeleteUserAttributesInput{ + AccessToken: aws.String("TokenModelType"), // Required UserAttributeNames: []*string{ // Required aws.String("AttributeNameType"), // Required // More values... }, - AccessToken: aws.String("TokenModelType"), } resp, err := svc.DeleteUserAttributes(params) @@ -949,6 +1050,50 @@ func ExampleCognitoIdentityProvider_DeleteUserPoolClient() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_DeleteUserPoolDomain() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.DeleteUserPoolDomainInput{ + Domain: aws.String("DomainType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + } + resp, err := svc.DeleteUserPoolDomain(params) + + if err != nil { + // Print the error, cast err to awserr.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_DescribeIdentityProvider() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.DescribeIdentityProviderInput{ + ProviderName: aws.String("ProviderNameType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + } + resp, err := svc.DescribeIdentityProvider(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -1014,6 +1159,27 @@ func ExampleCognitoIdentityProvider_DescribeUserPoolClient() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_DescribeUserPoolDomain() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.DescribeUserPoolDomainInput{ + Domain: aws.String("DomainType"), // Required + } + resp, err := svc.DescribeUserPoolDomain(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -1124,13 +1290,35 @@ func ExampleCognitoIdentityProvider_GetGroup() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_GetIdentityProviderByIdentifier() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.GetIdentityProviderByIdentifierInput{ + IdpIdentifier: aws.String("IdpIdentifierType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + } + resp, err := svc.GetIdentityProviderByIdentifier(params) + + if err != nil { + // Print the error, cast err to awserr.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"), + AccessToken: aws.String("TokenModelType"), // Required } resp, err := svc.GetUser(params) @@ -1151,8 +1339,8 @@ func ExampleCognitoIdentityProvider_GetUserAttributeVerificationCode() { svc := cognitoidentityprovider.New(sess) params := &cognitoidentityprovider.GetUserAttributeVerificationCodeInput{ + AccessToken: aws.String("TokenModelType"), // Required AttributeName: aws.String("AttributeNameType"), // Required - AccessToken: aws.String("TokenModelType"), } resp, err := svc.GetUserAttributeVerificationCode(params) @@ -1173,7 +1361,7 @@ func ExampleCognitoIdentityProvider_GlobalSignOut() { svc := cognitoidentityprovider.New(sess) params := &cognitoidentityprovider.GlobalSignOutInput{ - AccessToken: aws.String("TokenModelType"), + AccessToken: aws.String("TokenModelType"), // Required } resp, err := svc.GlobalSignOut(params) @@ -1264,6 +1452,29 @@ func ExampleCognitoIdentityProvider_ListGroups() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_ListIdentityProviders() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.ListIdentityProvidersInput{ + UserPoolId: aws.String("UserPoolIdType"), // Required + MaxResults: aws.Int64(1), + NextToken: aws.String("PaginationKeyType"), + } + resp, err := svc.ListIdentityProviders(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -1592,12 +1803,47 @@ func ExampleCognitoIdentityProvider_UpdateGroup() { fmt.Println(resp) } +func ExampleCognitoIdentityProvider_UpdateIdentityProvider() { + sess := session.Must(session.NewSession()) + + svc := cognitoidentityprovider.New(sess) + + params := &cognitoidentityprovider.UpdateIdentityProviderInput{ + ProviderName: aws.String("ProviderNameType"), // Required + UserPoolId: aws.String("UserPoolIdType"), // Required + AttributeMapping: map[string]*string{ + "Key": aws.String("StringType"), // Required + // More values... + }, + IdpIdentifiers: []*string{ + aws.String("IdpIdentifierType"), // Required + // More values... + }, + ProviderDetails: map[string]*string{ + "Key": aws.String("StringType"), // Required + // More values... + }, + } + resp, err := svc.UpdateIdentityProvider(params) + + if err != nil { + // Print the error, cast err to awserr.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{ + AccessToken: aws.String("TokenModelType"), // Required UserAttributes: []*cognitoidentityprovider.AttributeType{ // Required { // Required Name: aws.String("AttributeNameType"), // Required @@ -1605,7 +1851,6 @@ func ExampleCognitoIdentityProvider_UpdateUserAttributes() { }, // More values... }, - AccessToken: aws.String("TokenModelType"), } resp, err := svc.UpdateUserAttributes(params) @@ -1702,16 +1947,38 @@ func ExampleCognitoIdentityProvider_UpdateUserPoolClient() { params := &cognitoidentityprovider.UpdateUserPoolClientInput{ ClientId: aws.String("ClientIdType"), // Required UserPoolId: aws.String("UserPoolIdType"), // Required - ClientName: aws.String("ClientNameType"), + AllowedOAuthFlows: []*string{ + aws.String("OAuthFlowType"), // Required + // More values... + }, + AllowedOAuthFlowsUserPoolClient: aws.Bool(true), + AllowedOAuthScopes: []*string{ + aws.String("ScopeType"), // Required + // More values... + }, + CallbackURLs: []*string{ + aws.String("RedirectUrlType"), // Required + // More values... + }, + ClientName: aws.String("ClientNameType"), + DefaultRedirectURI: aws.String("RedirectUrlType"), ExplicitAuthFlows: []*string{ aws.String("ExplicitAuthFlowsType"), // Required // More values... }, + LogoutURLs: []*string{ + aws.String("RedirectUrlType"), // Required + // More values... + }, ReadAttributes: []*string{ aws.String("ClientPermissionType"), // Required // More values... }, RefreshTokenValidity: aws.Int64(1), + SupportedIdentityProviders: []*string{ + aws.String("ProviderNameType"), // Required + // More values... + }, WriteAttributes: []*string{ aws.String("ClientPermissionType"), // Required // More values... @@ -1736,9 +2003,9 @@ func ExampleCognitoIdentityProvider_VerifyUserAttribute() { svc := cognitoidentityprovider.New(sess) params := &cognitoidentityprovider.VerifyUserAttributeInput{ + AccessToken: aws.String("TokenModelType"), // Required AttributeName: aws.String("AttributeNameType"), // Required Code: aws.String("ConfirmationCodeType"), // Required - AccessToken: aws.String("TokenModelType"), } resp, err := svc.VerifyUserAttribute(params) diff --git a/service/dynamodb/examples_test.go b/service/dynamodb/examples_test.go index a29286f10cf..a9a24af3d8e 100644 --- a/service/dynamodb/examples_test.go +++ b/service/dynamodb/examples_test.go @@ -8,1495 +8,670 @@ 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... - }, +// 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": { + Keys: []*map[string]dynamodb.AttributeValue{ + { + Artist: &dynamodb.AttributeValue{ + S: aws.String("No One You Know"), + }, + SongTitle: &dynamodb.AttributeValue{ + S: aws.String("Call Me Today"), + }, + }, + { + Artist: &dynamodb.AttributeValue{ + S: aws.String("Acme Band"), + }, + SongTitle: &dynamodb.AttributeValue{ + S: aws.String("Happy Day"), + }, + }, + { + Artist: &dynamodb.AttributeValue{ + S: aws.String("No One You Know"), + }, + SongTitle: &dynamodb.AttributeValue{ + S: aws.String("Scared of My Shadow"), }, - // 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"), + 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"), }, - // 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("Songs About Life"), + }, + "Artist": { + S: aws.String("Acme Band"), + }, + "SongTitle": { + S: aws.String("Happy Day"), + }, + }, + }, + }, + { + PutRequest: &dynamodb.PutRequest{ + 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.AttributeDefinition{ + { + 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.KeySchemaElement{ + { + 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) - - if err != nil { - // Print the error, cast err to awserr.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_DescribeLimits() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - var params *dynamodb.DescribeLimitsInput - resp, err := svc.DescribeLimits(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_DescribeTable() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DescribeTableInput{ - TableName: aws.String("TableName"), // Required - } - resp, err := svc.DescribeTable(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_DescribeTimeToLive() { - sess := session.Must(session.NewSession()) - - svc := dynamodb.New(sess) - - params := &dynamodb.DescribeTimeToLiveInput{ - 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.DescribeTimeToLive(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_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... - }, + ":v1": { + S: aws.String("No One You Know"), }, - // 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... - }, - }, - // 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... - }, - }, - // 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... - }, + ":a": { + S: aws.String("No One You Know"), }, - // More values... }, - Segment: aws.Int64(1), - Select: aws.String("Select"), - TotalSegments: aws.Int64(1), + FilterExpression: aws.String("Artist = :a"), + ProjectionExpression: aws.String("#ST, #AT"), + TableName: aws.String("Music"), } - resp, err := svc.Scan(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_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... - }, - } - 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 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/ec2/examples_test.go b/service/ec2/examples_test.go index 7a2133f4612..2b7c4a9e834 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{} - svc := ec2.New(sess) + 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 + } + + 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.NewDhcpConfiguration{ + { + 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.Tag{ + { + 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.Tag{ + { + 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()) +// 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 { + 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.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... +// 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.Filter{ + { + Name: aws.String("domain"), + Values: []*string{ + aws.String("vpc"), + }, + }, }, } - resp, err := svc.CreateVpcEndpoint(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_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-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.Filter{ + { + Name: aws.String("domain"), + Values: []*string{ + aws.String("standard"), + }, + }, + }, } - 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()) +// 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.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 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.CreateVpnConnection(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_CreateVpnConnectionRoute() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.CreateVpnConnectionRouteInput{ - DestinationCidrBlock: aws.String("String"), // Required - VpnConnectionId: aws.String("String"), // Required +// 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.CreateVpnConnectionRoute(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_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 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.CreateVpnGateway(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_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 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.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 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.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 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.Filter{ + { + Name: aws.String("attachment.vpc-id"), + Values: []*string{ + aws.String("vpc-a01106c2"), + }, + }, + }, } - resp, err := svc.DeleteEgressOnlyInternetGateway(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_DeleteFlowLogs() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteFlowLogsInput{ - FlowLogIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// 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.DeleteFlowLogs(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_DeleteInternetGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteInternetGatewayInput{ - InternetGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), - } - resp, err := svc.DeleteInternetGateway(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_DeleteKeyPair() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteKeyPairInput{ - KeyName: aws.String("String"), // Required - DryRun: aws.Bool(true), +// 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.Filter{ + { + Name: aws.String("vpc-id"), + Values: []*string{ + aws.String("vpc-1a2b3c4d"), + }, + }, + }, } - resp, err := svc.DeleteKeyPair(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_DeleteNatGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNatGatewayInput{ - NatGatewayId: aws.String("String"), // Required +// 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.DeleteNatGateway(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_DeleteNetworkAcl() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteNetworkAclInput{ - NetworkAclId: aws.String("String"), // 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.DeleteNetworkAcl(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_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 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.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 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.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 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.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()) +// To describe a network interface +// - svc := ec2.New(sess) - - params := &ec2.DeleteRouteInput{ - RouteTableId: aws.String("String"), // Required - DestinationCidrBlock: aws.String("String"), - DestinationIpv6CidrBlock: aws.String("String"), - 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.DeleteRoute(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_DeleteRouteTable() { - sess := session.Must(session.NewSession()) +// 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 { + 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.DeleteRouteTableInput{ - RouteTableId: aws.String("String"), // Required - 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.DeleteRouteTable(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_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"), +// 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: []*int64{ + aws.Int64(1), + }, + }, } - resp, err := svc.DeleteSecurityGroup(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_DeleteSnapshot() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSnapshotInput{ - SnapshotId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// 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.DeleteSnapshot(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_DeleteSpotDatafeedSubscription() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSpotDatafeedSubscriptionInput{ - 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.DeleteSpotDatafeedSubscription(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_DeleteSubnet() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteSubnetInput{ - SubnetId: 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.DeleteSubnet(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_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"), +// 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.Filter{ + { + Name: aws.String("status"), + Values: []*string{ + aws.String("pending"), + }, }, - // More values... + }, + OwnerIds: []*string{ + aws.String("012345678910"), }, } - resp, err := svc.DeleteTags(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_DeleteVolume() { - sess := session.Must(session.NewSession()) +// 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 { + 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.DeleteVolumeInput{ - VolumeId: 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.DeleteVolume(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_DeleteVpc() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcInput{ - VpcId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// 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.DeleteVpc(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_DeleteVpcEndpoints() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcEndpointsInput{ - VpcEndpointIds: []*string{ // Required - aws.String("String"), // Required - // More values... +// 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"), }, - DryRun: aws.Bool(true), } - resp, err := svc.DeleteVpcEndpoints(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_DeleteVpcPeeringConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpcPeeringConnectionInput{ - VpcPeeringConnectionId: 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.DeleteVpcPeeringConnection(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_DeleteVpnConnection() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpnConnectionInput{ - VpnConnectionId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// 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)"), + }, + StartTime: parseTime("2006-01-02T15:04:05Z", "2014-01-06T07:08:09"), } - resp, err := svc.DeleteVpnConnection(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_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 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.Filter{ + { + Name: aws.String("vpc-id"), + Values: []*string{ + aws.String("vpc-a01106c2"), + }, + }, + }, } - resp, err := svc.DeleteVpnConnectionRoute(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_DeleteVpnGateway() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DeleteVpnGatewayInput{ - VpnGatewayId: aws.String("String"), // Required - DryRun: aws.Bool(true), +// 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.Filter{ + { + Name: aws.String("resource-id"), + Values: []*string{ + aws.String("i-1234567890abcdef8"), + }, + }, + }, } - resp, err := svc.DeleteVpnGateway(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_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 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"), } - resp, err := svc.DeregisterImage(params) + result, err := svc.DescribeVolumeAttribute(input) if err != nil { - // Print the error, cast err to awserr.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 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"), }, - DryRun: aws.Bool(true), } - resp, err := svc.DescribeAccountAttributes(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_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), +// 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.Filter{ - { // Required - Name: aws.String("String"), + { + Name: aws.String("volume-status.status"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("impaired"), }, }, - // More values... - }, - PublicIps: []*string{ - aws.String("String"), // Required - // More values... }, } - resp, err := svc.DescribeAddresses(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_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"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - ZoneNames: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribeAvailabilityZones(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_DescribeBundleTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeBundleTasksInput{ - BundleIds: []*string{ - aws.String("String"), // Required - // More values... - }, - DryRun: aws.Bool(true), +// 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.Filter{ - { // Required - Name: aws.String("String"), + { + Name: aws.String("attachment.instance-id"), + Values: []*string{ + aws.String("i-1234567890abcdef0"), + }, + }, + { + Name: aws.String("attachment.delete-on-termination"), Values: []*string{ - aws.String("String"), // Required - // More values... + aws.String("true"), }, }, - // More values... }, } - resp, err := svc.DescribeBundleTasks(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_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"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // More values... - }, - InstanceIds: []*string{ - aws.String("String"), // Required - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// 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.DescribeClassicLinkInstances(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_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), +// 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.DescribeConversionTasks(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_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"), - Values: []*string{ - aws.String("String"), // Required - // More values... - }, - }, - // 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.DescribeCustomerGateways(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_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 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.DescribeDhcpOptions(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_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 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.DescribeEgressOnlyInternetGateways(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_DescribeExportTasks() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeExportTasksInput{ - ExportTaskIds: []*string{ - aws.String("String"), // Required - // More values... - }, +// 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.DescribeExportTasks(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_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 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.DescribeFlowLogs(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_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 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.DescribeHostReservationOfferings(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_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 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.DescribeHostReservations(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_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 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.DescribeHosts(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_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 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.DescribeIamInstanceProfileAssociations(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_DescribeIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeIdFormatInput{ - Resource: aws.String("String"), +// 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.DescribeIdFormat(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_DescribeIdentityIdFormat() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.DescribeIdentityIdFormatInput{ - PrincipalArn: aws.String("String"), // Required - Resource: aws.String("String"), +// 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), + }, + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DescribeIdentityIdFormat(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_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 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"), + }, + NetworkInterfaceId: aws.String("eni-686ea200"), } - resp, err := svc.DescribeImageAttribute(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_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 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.DescribeImages(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_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 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.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 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.DescribeImportSnapshotTasks(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_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 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.DescribeInstanceAttribute(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_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... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// 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.DescribeInstanceStatus(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_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... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), +// 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.DescribeInstances(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_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 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), }, + SubnetId: aws.String("subnet-1a2b3c4d"), } - resp, err := svc.DescribeInternetGateways(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_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 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.DescribeKeyPairs(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_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 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.DescribeMovingAddresses(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_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... - }, - NextToken: aws.String("String"), - } - resp, err := svc.DescribeNatGateways(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.DescribeNetworkAcls(params) - - if err != nil { - // Print the error, cast err to awserr.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_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), - } - resp, err := svc.DescribeNetworkInterfaceAttribute(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.DescribeNetworkInterfaces(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.DescribePlacementGroups(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - }, - // More values... - }, - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - PrefixListIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.DescribePrefixLists(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... +// 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.ReleaseHosts(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_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 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.ReplaceIamInstanceProfileAssociation(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_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 purchase a Scheduled Instance +// +// This example purchases a Scheduled Instance. +func ExampleEC2_PurchaseScheduledInstances_shared00() { + svc := ec2.New(session.New()) + input := &ec2.PurchaseScheduledInstancesInput{ + PurchaseRequests: []*ec2.PurchaseRequest{ + { + InstanceCount: aws.Int64(1), + PurchaseToken: aws.String("eyJ2IjoiMSIsInMiOjEsImMiOi..."), + }, + }, } - resp, err := svc.ReplaceNetworkAclAssociation(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_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"), - PortRange: &ec2.PortRange{ - From: aws.Int64(1), - To: aws.Int64(1), - }, +// 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"), } - resp, err := svc.ReplaceNetworkAclEntry(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_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"), +// 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.ReplaceRoute(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_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), +// 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.ReplaceRouteTableAssociation(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_ReportInstanceStatus() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.ReportInstanceStatusInput{ - Instances: []*string{ // Required - aws.String("String"), // Required - // More values... +// 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(53.000000), + To: aws.Int64(53.000000), }, - ReasonCodes: []*string{ // Required - aws.String("ReportInstanceReasonCodes"), // Required - // More values... + 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.SpotFleetLaunchSpecification{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), + SecurityGroups: []*ec2.GroupIdentifier{ + { + GroupId: aws.String("sg-1a2b3c4d"), + }, + }, + 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.SpotFleetLaunchSpecification{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), + SecurityGroups: []*ec2.GroupIdentifier{ + { + GroupId: aws.String("sg-1a2b3c4d"), + }, + }, + }, + }, + SpotPrice: aws.String("0.04"), + TargetCapacity: aws.Int64(2.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) + 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_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"), - }, - // 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), - }, +// 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.SpotFleetLaunchSpecification{ + { + ImageId: aws.String("ami-1a2b3c4d"), + InstanceType: aws.String("m3.medium"), + KeyName: aws.String("my-key-pair"), NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ - { // Required + { AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), + DeviceIndex: aws.Int64(0), Groups: []*string{ - aws.String("String"), // Required - // More values... + aws.String("sg-1a2b3c4d"), }, - 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... - }, - 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.SpotFleetLaunchSpecification{ + { + 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), - } - resp, err := svc.ResetSnapshotAttribute(params) - - if err != nil { - // Print the error, cast err to awserr.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_RestoreAddressToClassic() { - sess := session.Must(session.NewSession()) - - svc := ec2.New(sess) - - params := &ec2.RestoreAddressToClassicInput{ - PublicIp: aws.String("String"), // Required - DryRun: aws.Bool(true), + SpotPrice: aws.String("0.03"), + 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... - }, +// 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"), }, - // More values... + SubnetId: aws.String("subnet-1a2b3c4d"), }, - IpProtocol: aws.String("String"), - SourceSecurityGroupName: aws.String("String"), - SourceSecurityGroupOwnerId: aws.String("String"), - ToPort: aws.Int64(1), + SpotPrice: aws.String("0.050"), + Type: aws.String("one-time"), } - resp, err := svc.RevokeSecurityGroupEgress(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_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 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.RevokeSecurityGroupIngress(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_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"), - }, - // 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"), - }, - // More values... - }, - }, - // More values... - }, - UserData: aws.String("String"), +// 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.RunInstances(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_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 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{ - 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), + Name: aws.String("my-iam-role"), }, + ImageId: aws.String("ami-12345678"), + InstanceType: aws.String("c4.large"), + KeyName: aws.String("my-key-pair"), NetworkInterfaces: []*ec2.ScheduledInstancesNetworkInterface{ - { // Required + { AssociatePublicIpAddress: aws.Bool(true), - DeleteOnTermination: aws.Bool(true), - Description: aws.String("String"), - DeviceIndex: aws.Int64(1), + DeviceIndex: aws.Int64(0), 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... + aws.String("sg-12345678"), }, - SecondaryPrivateIpAddressCount: aws.Int64(1), - SubnetId: aws.String("String"), + SubnetId: aws.String("subnet-12345678"), }, - // More values... - }, - Placement: &ec2.ScheduledInstancesPlacement{ - AvailabilityZone: aws.String("String"), - GroupName: aws.String("String"), - }, - RamdiskId: aws.String("String"), - SecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... }, - 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 + ScheduledInstanceId: aws.String("sci-1234-1234-1234-1234-123456789012"), } - resp, err := svc.UnassignIpv6Addresses(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_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... +// 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{ + 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("us-west-2b"), + }, + SecurityGroupIds: []*string{ + aws.String("sg-12345678"), + }, }, + 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/ecs/examples_test.go b/service/ecs/examples_test.go index 19fae622f5d..62266e2c870 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.LoadBalancer{ + { + ContainerName: aws.String("simple-app"), + ContainerPort: aws.Int64(80), + 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) + 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_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) +// 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_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"), +// 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.ListAttributes(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_ListClusters() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.ListClustersInput{ - MaxResults: aws.Int64(1), - NextToken: aws.String("String"), - } - resp, err := svc.ListClusters(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_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) - - if err != nil { - // Print the error, cast err to awserr.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_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.ContainerDefinition{ + { 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.Int64(10), 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"), + Image: aws.String("busybox"), + Memory: aws.Int64(10), + Name: aws.String("sleep"), }, - // More values... - }, - TaskRoleArn: aws.String("String"), - Volumes: []*ecs.Volume{ - { // Required - Host: &ecs.HostVolumeProperties{ - SourcePath: aws.String("String"), - }, - Name: aws.String("String"), - }, - // More values... }, + Family: aws.String("sleep360"), + TaskRoleArn: aws.String(""), } - resp, err := svc.RegisterTaskDefinition(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_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"), +// 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.RunTask(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_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"), +// 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.StartTask(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_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"), - }, - // More values... - }, - Reason: aws.String("String"), - Status: aws.String("String"), - Task: aws.String("String"), - } - resp, err := svc.SubmitContainerStateChange(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.SubmitTaskStateChange(params) - - if err != nil { - // Print the error, cast err to awserr.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_UpdateContainerAgent() { - sess := session.Must(session.NewSession()) - - svc := ecs.New(sess) - - params := &ecs.UpdateContainerAgentInput{ - ContainerInstance: aws.String("String"), // Required - Cluster: aws.String("String"), - } - resp, err := svc.UpdateContainerAgent(params) - - if err != nil { - // Print the error, cast err to awserr.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_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/elasticache/examples_test.go b/service/elasticache/examples_test.go index c3da9c02656..159ecc6d22c 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.Tag{ + { + 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"), + 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.NodeGroupConfiguration{ - { // Required - PrimaryAvailabilityZone: aws.String("String"), + { + 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"), + 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.Int64(2), + 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.ParameterNameValue{ + { + 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/elb/examples_test.go b/service/elb/examples_test.go index 7a08f8052c5..b37b6bda2e6 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.Tag{ + { + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + Protocol: aws.String("HTTP"), + }, + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(443), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + Protocol: aws.String("HTTP"), + }, + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(443), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(80), + 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.Listener{ + { + InstancePort: aws.Int64(80), + InstanceProtocol: aws.String("HTTP"), + LoadBalancerPort: aws.Int64(443), + Protocol: aws.String("HTTPS"), + SSLCertificateId: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), + }, + }, + LoadBalancerName: aws.String("my-load-balancer"), + } + + 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 + } - svc := elb.New(sess) + fmt.Println(result) +} - params := &elb.DeleteLoadBalancerPolicyInput{ - LoadBalancerName: aws.String("AccessPointName"), // Required - PolicyName: aws.String("PolicyName"), // Required +// 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.PolicyAttribute{ + { + 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.PolicyAttribute{ + { + 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"), + } + + 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 + } - svc := elb.New(sess) + fmt.Println(result) +} - params := &elb.DeregisterInstancesFromLoadBalancerInput{ - Instances: []*elb.Instance{ // Required - { // Required - InstanceId: aws.String("InstanceId"), +// 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.PolicyAttribute{ + { + 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"), + } + + 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 + } - svc := elb.New(sess) + fmt.Println(result) +} - params := &elb.DescribeAccountLimitsInput{ - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), +// 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: []*int64{ + aws.Int64(80), + }, } - 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 +// 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.Instance{ - { // Required - InstanceId: aws.String("InstanceId"), + { + 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"), + } + + 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 + } - svc := elb.New(sess) + 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.Instance{ + { + 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.TagKeyOnly{ + { + 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/api.go b/service/elbv2/api.go index d5fadd720d7..e36e0f13f49 100644 --- a/service/elbv2/api.go +++ b/service/elbv2/api.go @@ -2272,6 +2272,12 @@ func (c *ELBV2) ModifyRuleRequest(input *ModifyRuleInput) (req *request.Request, // You've reached the limit on the number of times a target can be registered // with a load balancer. // +// * ErrCodeTooManyTargetsException "TooManyTargets" +// You've reached the limit on the number of targets. +// +// * ErrCodeTargetGroupNotFoundException "TargetGroupNotFound" +// The specified target group does not exist. +// // Please also see https://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancingv2-2015-12-01/ModifyRule func (c *ELBV2) ModifyRule(input *ModifyRuleInput) (*ModifyRuleOutput, error) { req, out := c.ModifyRuleRequest(input) @@ -4523,6 +4529,13 @@ type DescribeRulesInput struct { // The Amazon Resource Name (ARN) of the listener. ListenerArn *string `type:"string"` + // The marker for the next set of results. (You received this marker from a + // previous call.) + Marker *string `type:"string"` + + // The maximum number of results to return with this call. + PageSize *int64 `min:"1" type:"integer"` + // The Amazon Resource Names (ARN) of the rules. RuleArns []*string `type:"list"` } @@ -4537,12 +4550,37 @@ func (s DescribeRulesInput) GoString() string { return s.String() } +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeRulesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeRulesInput"} + if s.PageSize != nil && *s.PageSize < 1 { + invalidParams.Add(request.NewErrParamMinValue("PageSize", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + // SetListenerArn sets the ListenerArn field's value. func (s *DescribeRulesInput) SetListenerArn(v string) *DescribeRulesInput { s.ListenerArn = &v return s } +// SetMarker sets the Marker field's value. +func (s *DescribeRulesInput) SetMarker(v string) *DescribeRulesInput { + s.Marker = &v + return s +} + +// SetPageSize sets the PageSize field's value. +func (s *DescribeRulesInput) SetPageSize(v int64) *DescribeRulesInput { + s.PageSize = &v + return s +} + // SetRuleArns sets the RuleArns field's value. func (s *DescribeRulesInput) SetRuleArns(v []*string) *DescribeRulesInput { s.RuleArns = v @@ -4553,6 +4591,10 @@ func (s *DescribeRulesInput) SetRuleArns(v []*string) *DescribeRulesInput { type DescribeRulesOutput struct { _ struct{} `type:"structure"` + // The marker to use when requesting the next set of results. If there are no + // additional results, the string is empty. + NextMarker *string `type:"string"` + // Information about the rules. Rules []*Rule `type:"list"` } @@ -4567,6 +4609,12 @@ func (s DescribeRulesOutput) GoString() string { return s.String() } +// SetNextMarker sets the NextMarker field's value. +func (s *DescribeRulesOutput) SetNextMarker(v string) *DescribeRulesOutput { + s.NextMarker = &v + return s +} + // SetRules sets the Rules field's value. func (s *DescribeRulesOutput) SetRules(v []*Rule) *DescribeRulesOutput { s.Rules = v diff --git a/service/elbv2/examples_test.go b/service/elbv2/examples_test.go index b8e16c8db22..554afb6f2ed 100644 --- a/service/elbv2/examples_test.go +++ b/service/elbv2/examples_test.go @@ -8,872 +8,1473 @@ 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.Tag{ + { + 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()) - - svc := elbv2.New(sess) - - params := &elbv2.CreateListenerInput{ - DefaultActions: []*elbv2.Action{ // Required - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required - }, - // 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"), +// 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.Action{ + { + 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(80.000000), + Protocol: aws.String("HTTP"), } - 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... +// 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.Certificate{ + { + CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"), + }, }, - Tags: []*elbv2.Tag{ - { // Required - Key: aws.String("TagKey"), // Required - Value: aws.String("TagValue"), + DefaultActions: []*elbv2.Action{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Type: aws.String("forward"), }, - // More values... }, + 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.CreateLoadBalancer(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_CreateRule() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.CreateRuleInput{ - Actions: []*elbv2.Action{ // Required - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required - }, - // More values... - }, - Conditions: []*elbv2.RuleCondition{ // Required - { // Required - Field: aws.String("ConditionFieldName"), - Values: []*string{ - aws.String("StringValue"), // Required - // More values... - }, - }, - // 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"), }, - ListenerArn: aws.String("ListenerArn"), // Required - Priority: aws.Int64(1), // Required } - resp, err := svc.CreateRule(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_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 +// 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"), }, - UnhealthyThresholdCount: aws.Int64(1), } - resp, err := svc.CreateTargetGroup(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_DeleteListener() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteListenerInput{ - ListenerArn: aws.String("ListenerArn"), // 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.Action{ + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), + Type: aws.String("forward"), + }, + }, + Conditions: []*elbv2.RuleCondition{ + { + Field: aws.String("path-pattern"), + Values: []*string{ + aws.String("/img/*"), + }, + }, + }, + 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.DeleteListener(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_DeleteLoadBalancer() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteLoadBalancerInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required +// 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.DeleteLoadBalancer(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_DeleteRule() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteRuleInput{ - RuleArn: aws.String("RuleArn"), // 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.DeleteRule(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_DeleteTargetGroup() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DeleteTargetGroupInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // 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.DeleteTargetGroup(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_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), - }, - // More values... - }, +// 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.DeregisterTargets(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_DescribeAccountLimits() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeAccountLimitsInput{ - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), +// 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.DescribeAccountLimits(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_DescribeListeners() { - sess := session.Must(session.NewSession()) +// 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.TargetDescription{ + { + Id: aws.String("i-0f76fade"), + }, + }, + } + + result, err := svc.DeregisterTargets(input) + if err != nil { + 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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.DescribeListenersInput{ +// 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("ListenerArn"), // Required - // More values... + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), }, - LoadBalancerArn: aws.String("LoadBalancerArn"), - Marker: aws.String("Marker"), - PageSize: aws.Int64(1), } - resp, err := svc.DescribeListeners(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_DescribeLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeLoadBalancerAttributesInput{ - LoadBalancerArn: aws.String("LoadBalancerArn"), // Required +// 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"), } - resp, err := svc.DescribeLoadBalancerAttributes(params) + result, err := svc.DescribeLoadBalancerAttributes(input) if err != nil { - // Print the error, cast err to awserr.Error 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_DescribeLoadBalancers() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeLoadBalancersInput{ +// 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("LoadBalancerArn"), // Required - // More values... - }, - Marker: aws.String("Marker"), - Names: []*string{ - aws.String("LoadBalancerName"), // Required - // More values... + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), }, - 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 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_DescribeRules() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeRulesInput{ - ListenerArn: aws.String("ListenerArn"), +// 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("RuleArn"), // Required - // More values... + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee"), }, } - resp, err := svc.DescribeRules(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_DescribeSSLPolicies() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeSSLPoliciesInput{ - 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("SslPolicyName"), // Required - // More values... + aws.String("ELBSecurityPolicy-2015-05"), }, - PageSize: aws.Int64(1), } - resp, err := svc.DescribeSSLPolicies(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_DescribeTags() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeTagsInput{ - ResourceArns: []*string{ // Required - aws.String("ResourceArn"), // 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.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 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_DescribeTargetGroupAttributes() { - sess := session.Must(session.NewSession()) - - svc := elbv2.New(sess) - - params := &elbv2.DescribeTargetGroupAttributesInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required +// 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"), } - resp, err := svc.DescribeTargetGroupAttributes(params) + result, err := svc.DescribeTargetGroupAttributes(input) if err != nil { - // Print the error, cast err to awserr.Error 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_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), +// 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("TargetGroupArn"), // Required - // More values... + aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"), }, } - resp, err := svc.DescribeTargetGroups(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_DescribeTargetHealth() { - 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.DescribeTargetHealthInput{ - TargetGroupArn: aws.String("TargetGroupArn"), // Required +// 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.TargetDescription{ - { // Required - Id: aws.String("TargetId"), // Required - Port: aws.Int64(1), + { + Id: aws.String("i-0f76fade"), + Port: aws.Int64(80), }, - // More values... }, } - resp, err := svc.DescribeTargetHealth(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_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"), - }, - // More values... - }, +// 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.Action{ - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required + { + TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f"), + Type: aws.String("forward"), }, - // More values... }, - Port: aws.Int64(1), - Protocol: aws.String("ProtocolEnum"), - SslPolicy: aws.String("SslPolicyName"), + ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"), } - resp, err := svc.ModifyListener(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_ModifyLoadBalancerAttributes() { - sess := session.Must(session.NewSession()) +// 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.Certificate{ + { + 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"), + } + + result, err := svc.ModifyListener(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.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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.ModifyLoadBalancerAttributesInput{ - Attributes: []*elbv2.LoadBalancerAttribute{ // Required - { // Required - Key: aws.String("LoadBalancerAttributeKey"), - Value: aws.String("LoadBalancerAttributeValue"), +// 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.LoadBalancerAttribute{ + { + Key: aws.String("deletion_protection.enabled"), + Value: aws.String("true"), }, - // 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()) +// 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.LoadBalancerAttribute{ + { + Key: aws.String("idle_timeout.timeout_seconds"), + Value: aws.String("30"), + }, + }, + LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + } + + result, err := svc.ModifyLoadBalancerAttributes(input) + if err != nil { + 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 + } - svc := elbv2.New(sess) + fmt.Println(result) +} - params := &elbv2.ModifyRuleInput{ - RuleArn: aws.String("RuleArn"), // Required - Actions: []*elbv2.Action{ - { // Required - TargetGroupArn: aws.String("TargetGroupArn"), // Required - Type: aws.String("ActionTypeEnum"), // Required +// 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.LoadBalancerAttribute{ + { + 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("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"), + } + + result, err := svc.ModifyLoadBalancerAttributes(input) + if err != nil { + 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 + } + + fmt.Println(result) +} + +// 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.RuleCondition{ - { // Required - Field: aws.String("ConditionFieldName"), + { + 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()) + case elbv2.ErrCodeTooManyTargetsException: + fmt.Println(elbv2.ErrCodeTooManyTargetsException, 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_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.TargetGroupAttribute{ + { + 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.TargetDescription{ + { + 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.TargetDescription{ + { + Id: aws.String("i-80c8dd94"), + Port: aws.Int64(80), + }, + { + Id: aws.String("i-80c8dd94"), + Port: aws.Int64(766), + }, }, } - 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.RulePriorityPair{ + { + Priority: aws.Int64(5), + 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/glacier/examples_test.go b/service/glacier/examples_test.go index b629458c055..312dda5bc72 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"), + { + BytesPerHour: aws.Int64(10737418240), + 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/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/kinesisanalytics/api.go b/service/kinesisanalytics/api.go index fb9e18e44a2..5f49364fc5a 100644 --- a/service/kinesisanalytics/api.go +++ b/service/kinesisanalytics/api.go @@ -11,6 +11,99 @@ import ( "github.com/aws/aws-sdk-go/aws/request" ) +const opAddApplicationCloudWatchLoggingOption = "AddApplicationCloudWatchLoggingOption" + +// AddApplicationCloudWatchLoggingOptionRequest generates a "aws/request.Request" representing the +// client's request for the AddApplicationCloudWatchLoggingOption operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See AddApplicationCloudWatchLoggingOption for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the AddApplicationCloudWatchLoggingOption method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the AddApplicationCloudWatchLoggingOptionRequest method. +// req, resp := client.AddApplicationCloudWatchLoggingOptionRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOption +func (c *KinesisAnalytics) AddApplicationCloudWatchLoggingOptionRequest(input *AddApplicationCloudWatchLoggingOptionInput) (req *request.Request, output *AddApplicationCloudWatchLoggingOptionOutput) { + op := &request.Operation{ + Name: opAddApplicationCloudWatchLoggingOption, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AddApplicationCloudWatchLoggingOptionInput{} + } + + output = &AddApplicationCloudWatchLoggingOptionOutput{} + req = c.newRequest(op, input, output) + return +} + +// AddApplicationCloudWatchLoggingOption API operation for Amazon Kinesis Analytics. +// +// Adds a CloudWatch log stream to monitor application configuration errors. +// For more information about using CloudWatch log streams with Amazon Kinesis +// Analytics applications, see Monitoring Configuration Errors (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-monitor-configuration.html). +// +// 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. +// +// See the AWS API reference guide for Amazon Kinesis Analytics's +// API operation AddApplicationCloudWatchLoggingOption for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// Specified application can't be found. +// +// * ErrCodeResourceInUseException "ResourceInUseException" +// Application is not available for this operation. +// +// * ErrCodeInvalidArgumentException "InvalidArgumentException" +// Specified input parameter value is invalid. +// +// * ErrCodeConcurrentModificationException "ConcurrentModificationException" +// Exception thrown as a result of concurrent modification to an application. +// For example, two individuals attempting to edit the same application at the +// same time. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOption +func (c *KinesisAnalytics) AddApplicationCloudWatchLoggingOption(input *AddApplicationCloudWatchLoggingOptionInput) (*AddApplicationCloudWatchLoggingOptionOutput, error) { + req, out := c.AddApplicationCloudWatchLoggingOptionRequest(input) + return out, req.Send() +} + +// AddApplicationCloudWatchLoggingOptionWithContext is the same as AddApplicationCloudWatchLoggingOption with the addition of +// the ability to pass a context and additional request options. +// +// See AddApplicationCloudWatchLoggingOption for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *KinesisAnalytics) AddApplicationCloudWatchLoggingOptionWithContext(ctx aws.Context, input *AddApplicationCloudWatchLoggingOptionInput, opts ...request.Option) (*AddApplicationCloudWatchLoggingOptionOutput, error) { + req, out := c.AddApplicationCloudWatchLoggingOptionRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opAddApplicationInput = "AddApplicationInput" // AddApplicationInputRequest generates a "aws/request.Request" representing the @@ -386,8 +479,7 @@ func (c *KinesisAnalytics) CreateApplicationRequest(input *CreateApplicationInpu // In the input configuration, you map the streaming source to an in-application // stream, which you can think of as a constantly updating table. In the mapping, // you must provide a schema for the in-application stream and map each data -// column in the in-application stream to a data element in the streaming source, -// with the option of renaming, casting and dropping columns as desired. +// column in the in-application stream to a data element in the streaming source. // // Your application code is one or more SQL statements that read input data, // transform it, and generate output. Your application code can create one or @@ -541,6 +633,99 @@ func (c *KinesisAnalytics) DeleteApplicationWithContext(ctx aws.Context, input * return out, req.Send() } +const opDeleteApplicationCloudWatchLoggingOption = "DeleteApplicationCloudWatchLoggingOption" + +// DeleteApplicationCloudWatchLoggingOptionRequest generates a "aws/request.Request" representing the +// client's request for the DeleteApplicationCloudWatchLoggingOption operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DeleteApplicationCloudWatchLoggingOption for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DeleteApplicationCloudWatchLoggingOption method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DeleteApplicationCloudWatchLoggingOptionRequest method. +// req, resp := client.DeleteApplicationCloudWatchLoggingOptionRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOption +func (c *KinesisAnalytics) DeleteApplicationCloudWatchLoggingOptionRequest(input *DeleteApplicationCloudWatchLoggingOptionInput) (req *request.Request, output *DeleteApplicationCloudWatchLoggingOptionOutput) { + op := &request.Operation{ + Name: opDeleteApplicationCloudWatchLoggingOption, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteApplicationCloudWatchLoggingOptionInput{} + } + + output = &DeleteApplicationCloudWatchLoggingOptionOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteApplicationCloudWatchLoggingOption API operation for Amazon Kinesis Analytics. +// +// Deletes a CloudWatch log stream from an application. For more information +// about using CloudWatch log streams with Amazon Kinesis Analytics applications, +// see Monitoring Configuration Errors (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-monitor-configuration.html). +// +// 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. +// +// See the AWS API reference guide for Amazon Kinesis Analytics's +// API operation DeleteApplicationCloudWatchLoggingOption for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFoundException" +// Specified application can't be found. +// +// * ErrCodeResourceInUseException "ResourceInUseException" +// Application is not available for this operation. +// +// * ErrCodeInvalidArgumentException "InvalidArgumentException" +// Specified input parameter value is invalid. +// +// * ErrCodeConcurrentModificationException "ConcurrentModificationException" +// Exception thrown as a result of concurrent modification to an application. +// For example, two individuals attempting to edit the same application at the +// same time. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOption +func (c *KinesisAnalytics) DeleteApplicationCloudWatchLoggingOption(input *DeleteApplicationCloudWatchLoggingOptionInput) (*DeleteApplicationCloudWatchLoggingOptionOutput, error) { + req, out := c.DeleteApplicationCloudWatchLoggingOptionRequest(input) + return out, req.Send() +} + +// DeleteApplicationCloudWatchLoggingOptionWithContext is the same as DeleteApplicationCloudWatchLoggingOption with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteApplicationCloudWatchLoggingOption for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *KinesisAnalytics) DeleteApplicationCloudWatchLoggingOptionWithContext(ctx aws.Context, input *DeleteApplicationCloudWatchLoggingOptionInput, opts ...request.Option) (*DeleteApplicationCloudWatchLoggingOptionOutput, error) { + req, out := c.DeleteApplicationCloudWatchLoggingOptionRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDeleteApplicationOutput = "DeleteApplicationOutput" // DeleteApplicationOutputRequest generates a "aws/request.Request" representing the @@ -607,6 +792,9 @@ func (c *KinesisAnalytics) DeleteApplicationOutputRequest(input *DeleteApplicati // * ErrCodeResourceInUseException "ResourceInUseException" // Application is not available for this operation. // +// * ErrCodeInvalidArgumentException "InvalidArgumentException" +// Specified input parameter value is invalid. +// // * ErrCodeConcurrentModificationException "ConcurrentModificationException" // Exception thrown as a result of concurrent modification to an application. // For example, two individuals attempting to edit the same application at the @@ -892,12 +1080,14 @@ func (c *KinesisAnalytics) DiscoverInputSchemaRequest(input *DiscoverInputSchema // Specified input parameter value is invalid. // // * ErrCodeUnableToDetectSchemaException "UnableToDetectSchemaException" -// Data format is not valid, Kinesis Analytics is not able to detect schema -// for the given streaming source. +// Data format is not valid, Amazon Kinesis Analytics is not able to detect +// schema for the given streaming source. // // * ErrCodeResourceProvisionedThroughputExceededException "ResourceProvisionedThroughputExceededException" // Discovery failed to get a record from the streaming source because of the -// Kinesis Streams ProvisionedThroughputExceededException. +// Amazon Kinesis Streams ProvisionedThroughputExceededException. For more information, +// see GetRecords (http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetRecords.html) +// in the Amazon Kinesis Streams API Reference. // // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DiscoverInputSchema func (c *KinesisAnalytics) DiscoverInputSchema(input *DiscoverInputSchemaInput) (*DiscoverInputSchemaOutput, error) { @@ -1244,13 +1434,13 @@ func (c *KinesisAnalytics) UpdateApplicationRequest(input *UpdateApplicationInpu // UpdateApplication API operation for Amazon Kinesis Analytics. // -// Updates an existing Kinesis Analytics application. Using this API, you can -// update application code, input configuration, and output configuration. +// Updates an existing Amazon Kinesis Analytics application. Using this API, +// you can update application code, input configuration, and output configuration. // -// Note that Kinesis Analytics updates the CurrentApplicationVersionId each -// time you update your application. +// Note that Amazon Kinesis Analytics updates the CurrentApplicationVersionId +// each time you update your application. // -// This opeation requires permission for the kinesisanalytics:UpdateApplication +// This operation requires permission for the kinesisanalytics:UpdateApplication // action. // // Returns awserr.Error for service API and SDK errors. Use runtime type assertions @@ -1301,6 +1491,101 @@ func (c *KinesisAnalytics) UpdateApplicationWithContext(ctx aws.Context, input * return out, req.Send() } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOptionRequest +type AddApplicationCloudWatchLoggingOptionInput struct { + _ struct{} `type:"structure"` + + // The Amazon Kinesis Analytics application name. + // + // ApplicationName is a required field + ApplicationName *string `min:"1" type:"string" required:"true"` + + // Provide the CloudWatch log stream ARN and the IAM role ARN. Note: To write + // application messages to CloudWatch, the IAM role used must have the PutLogEvents + // policy action enabled. + // + // CloudWatchLoggingOption is a required field + CloudWatchLoggingOption *CloudWatchLoggingOption `type:"structure" required:"true"` + + // The version ID of the Amazon Kinesis Analytics application. + // + // CurrentApplicationVersionId is a required field + CurrentApplicationVersionId *int64 `min:"1" type:"long" required:"true"` +} + +// String returns the string representation +func (s AddApplicationCloudWatchLoggingOptionInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AddApplicationCloudWatchLoggingOptionInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AddApplicationCloudWatchLoggingOptionInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AddApplicationCloudWatchLoggingOptionInput"} + if s.ApplicationName == nil { + invalidParams.Add(request.NewErrParamRequired("ApplicationName")) + } + if s.ApplicationName != nil && len(*s.ApplicationName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ApplicationName", 1)) + } + if s.CloudWatchLoggingOption == nil { + invalidParams.Add(request.NewErrParamRequired("CloudWatchLoggingOption")) + } + if s.CurrentApplicationVersionId == nil { + invalidParams.Add(request.NewErrParamRequired("CurrentApplicationVersionId")) + } + if s.CurrentApplicationVersionId != nil && *s.CurrentApplicationVersionId < 1 { + invalidParams.Add(request.NewErrParamMinValue("CurrentApplicationVersionId", 1)) + } + if s.CloudWatchLoggingOption != nil { + if err := s.CloudWatchLoggingOption.Validate(); err != nil { + invalidParams.AddNested("CloudWatchLoggingOption", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetApplicationName sets the ApplicationName field's value. +func (s *AddApplicationCloudWatchLoggingOptionInput) SetApplicationName(v string) *AddApplicationCloudWatchLoggingOptionInput { + s.ApplicationName = &v + return s +} + +// SetCloudWatchLoggingOption sets the CloudWatchLoggingOption field's value. +func (s *AddApplicationCloudWatchLoggingOptionInput) SetCloudWatchLoggingOption(v *CloudWatchLoggingOption) *AddApplicationCloudWatchLoggingOptionInput { + s.CloudWatchLoggingOption = v + return s +} + +// SetCurrentApplicationVersionId sets the CurrentApplicationVersionId field's value. +func (s *AddApplicationCloudWatchLoggingOptionInput) SetCurrentApplicationVersionId(v int64) *AddApplicationCloudWatchLoggingOptionInput { + s.CurrentApplicationVersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOptionResponse +type AddApplicationCloudWatchLoggingOptionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s AddApplicationCloudWatchLoggingOptionOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AddApplicationCloudWatchLoggingOptionOutput) GoString() string { + return s.String() +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationInputRequest type AddApplicationInputInput struct { _ struct{} `type:"structure"` @@ -1631,6 +1916,11 @@ type ApplicationDetail struct { // ApplicationVersionId is a required field ApplicationVersionId *int64 `min:"1" type:"long" required:"true"` + // Describes the CloudWatch log streams configured to receive application messages. + // For more information about using CloudWatch log streams with Amazon Kinesis + // Analytics applications, see Monitoring Configuration Errors (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-monitor-configuration.html). + CloudWatchLoggingOptionDescriptions []*CloudWatchLoggingOptionDescription `type:"list"` + // Timestamp when the application version was created. CreateTimestamp *time.Time `type:"timestamp" timestampFormat:"unix"` @@ -1696,6 +1986,12 @@ func (s *ApplicationDetail) SetApplicationVersionId(v int64) *ApplicationDetail return s } +// SetCloudWatchLoggingOptionDescriptions sets the CloudWatchLoggingOptionDescriptions field's value. +func (s *ApplicationDetail) SetCloudWatchLoggingOptionDescriptions(v []*CloudWatchLoggingOptionDescription) *ApplicationDetail { + s.CloudWatchLoggingOptionDescriptions = v + return s +} + // SetCreateTimestamp sets the CreateTimestamp field's value. func (s *ApplicationDetail) SetCreateTimestamp(v time.Time) *ApplicationDetail { s.CreateTimestamp = &v @@ -1776,7 +2072,7 @@ func (s *ApplicationSummary) SetApplicationStatus(v string) *ApplicationSummary return s } -// Describes updates to apply to an existing Kinesis Analytics application. +// Describes updates to apply to an existing Amazon Kinesis Analytics application. // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ApplicationUpdate type ApplicationUpdate struct { _ struct{} `type:"structure"` @@ -1784,6 +2080,9 @@ type ApplicationUpdate struct { // Describes application code updates. ApplicationCodeUpdate *string `type:"string"` + // Describes application CloudWatch logging option updates. + CloudWatchLoggingOptionUpdates []*CloudWatchLoggingOptionUpdate `type:"list"` + // Describes application input configuration updates. InputUpdates []*InputUpdate `type:"list"` @@ -1807,6 +2106,16 @@ func (s ApplicationUpdate) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *ApplicationUpdate) Validate() error { invalidParams := request.ErrInvalidParams{Context: "ApplicationUpdate"} + if s.CloudWatchLoggingOptionUpdates != nil { + for i, v := range s.CloudWatchLoggingOptionUpdates { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "CloudWatchLoggingOptionUpdates", i), err.(request.ErrInvalidParams)) + } + } + } if s.InputUpdates != nil { for i, v := range s.InputUpdates { if v == nil { @@ -1850,6 +2159,12 @@ func (s *ApplicationUpdate) SetApplicationCodeUpdate(v string) *ApplicationUpdat return s } +// SetCloudWatchLoggingOptionUpdates sets the CloudWatchLoggingOptionUpdates field's value. +func (s *ApplicationUpdate) SetCloudWatchLoggingOptionUpdates(v []*CloudWatchLoggingOptionUpdate) *ApplicationUpdate { + s.CloudWatchLoggingOptionUpdates = v + return s +} + // SetInputUpdates sets the InputUpdates field's value. func (s *ApplicationUpdate) SetInputUpdates(v []*InputUpdate) *ApplicationUpdate { s.InputUpdates = v @@ -1884,12 +2199,12 @@ type CSVMappingParameters struct { // column delimiter. // // RecordColumnDelimiter is a required field - RecordColumnDelimiter *string `type:"string" required:"true"` + RecordColumnDelimiter *string `min:"1" type:"string" required:"true"` // Row delimiter. For example, in a CSV format, '\n' is the typical row delimiter. // // RecordRowDelimiter is a required field - RecordRowDelimiter *string `type:"string" required:"true"` + RecordRowDelimiter *string `min:"1" type:"string" required:"true"` } // String returns the string representation @@ -1908,9 +2223,15 @@ func (s *CSVMappingParameters) Validate() error { if s.RecordColumnDelimiter == nil { invalidParams.Add(request.NewErrParamRequired("RecordColumnDelimiter")) } + if s.RecordColumnDelimiter != nil && len(*s.RecordColumnDelimiter) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RecordColumnDelimiter", 1)) + } if s.RecordRowDelimiter == nil { invalidParams.Add(request.NewErrParamRequired("RecordRowDelimiter")) } + if s.RecordRowDelimiter != nil && len(*s.RecordRowDelimiter) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RecordRowDelimiter", 1)) + } if invalidParams.Len() > 0 { return invalidParams @@ -1930,18 +2251,202 @@ func (s *CSVMappingParameters) SetRecordRowDelimiter(v string) *CSVMappingParame return s } +// Provides a description of CloudWatch logging options, including the log stream +// ARN and the role ARN. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOption +type CloudWatchLoggingOption struct { + _ struct{} `type:"structure"` + + // ARN of the CloudWatch log to receive application messages. + // + // LogStreamARN is a required field + LogStreamARN *string `min:"1" type:"string" required:"true"` + + // IAM ARN of the role to use to send application messages. Note: To write application + // messages to CloudWatch, the IAM role used must have the PutLogEvents policy + // action enabled. + // + // RoleARN is a required field + RoleARN *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CloudWatchLoggingOption) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloudWatchLoggingOption) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CloudWatchLoggingOption) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CloudWatchLoggingOption"} + if s.LogStreamARN == nil { + invalidParams.Add(request.NewErrParamRequired("LogStreamARN")) + } + if s.LogStreamARN != nil && len(*s.LogStreamARN) < 1 { + invalidParams.Add(request.NewErrParamMinLen("LogStreamARN", 1)) + } + if s.RoleARN == nil { + invalidParams.Add(request.NewErrParamRequired("RoleARN")) + } + if s.RoleARN != nil && len(*s.RoleARN) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RoleARN", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLogStreamARN sets the LogStreamARN field's value. +func (s *CloudWatchLoggingOption) SetLogStreamARN(v string) *CloudWatchLoggingOption { + s.LogStreamARN = &v + return s +} + +// SetRoleARN sets the RoleARN field's value. +func (s *CloudWatchLoggingOption) SetRoleARN(v string) *CloudWatchLoggingOption { + s.RoleARN = &v + return s +} + +// Description of the CloudWatch logging option. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOptionDescription +type CloudWatchLoggingOptionDescription struct { + _ struct{} `type:"structure"` + + // ID of the CloudWatch logging option description. + CloudWatchLoggingOptionId *string `min:"1" type:"string"` + + // ARN of the CloudWatch log to receive application messages. + // + // LogStreamARN is a required field + LogStreamARN *string `min:"1" type:"string" required:"true"` + + // IAM ARN of the role to use to send application messages. Note: To write application + // messages to CloudWatch, the IAM role used must have the PutLogEvents policy + // action enabled. + // + // RoleARN is a required field + RoleARN *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CloudWatchLoggingOptionDescription) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloudWatchLoggingOptionDescription) GoString() string { + return s.String() +} + +// SetCloudWatchLoggingOptionId sets the CloudWatchLoggingOptionId field's value. +func (s *CloudWatchLoggingOptionDescription) SetCloudWatchLoggingOptionId(v string) *CloudWatchLoggingOptionDescription { + s.CloudWatchLoggingOptionId = &v + return s +} + +// SetLogStreamARN sets the LogStreamARN field's value. +func (s *CloudWatchLoggingOptionDescription) SetLogStreamARN(v string) *CloudWatchLoggingOptionDescription { + s.LogStreamARN = &v + return s +} + +// SetRoleARN sets the RoleARN field's value. +func (s *CloudWatchLoggingOptionDescription) SetRoleARN(v string) *CloudWatchLoggingOptionDescription { + s.RoleARN = &v + return s +} + +// Describes CloudWatch logging option updates. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOptionUpdate +type CloudWatchLoggingOptionUpdate struct { + _ struct{} `type:"structure"` + + // ID of the CloudWatch logging option to update + // + // CloudWatchLoggingOptionId is a required field + CloudWatchLoggingOptionId *string `min:"1" type:"string" required:"true"` + + // ARN of the CloudWatch log to receive application messages. + LogStreamARNUpdate *string `min:"1" type:"string"` + + // IAM ARN of the role to use to send application messages. Note: To write application + // messages to CloudWatch, the IAM role used must have the PutLogEvents policy + // action enabled. + RoleARNUpdate *string `min:"1" type:"string"` +} + +// String returns the string representation +func (s CloudWatchLoggingOptionUpdate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloudWatchLoggingOptionUpdate) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CloudWatchLoggingOptionUpdate) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CloudWatchLoggingOptionUpdate"} + if s.CloudWatchLoggingOptionId == nil { + invalidParams.Add(request.NewErrParamRequired("CloudWatchLoggingOptionId")) + } + if s.CloudWatchLoggingOptionId != nil && len(*s.CloudWatchLoggingOptionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CloudWatchLoggingOptionId", 1)) + } + if s.LogStreamARNUpdate != nil && len(*s.LogStreamARNUpdate) < 1 { + invalidParams.Add(request.NewErrParamMinLen("LogStreamARNUpdate", 1)) + } + if s.RoleARNUpdate != nil && len(*s.RoleARNUpdate) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RoleARNUpdate", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCloudWatchLoggingOptionId sets the CloudWatchLoggingOptionId field's value. +func (s *CloudWatchLoggingOptionUpdate) SetCloudWatchLoggingOptionId(v string) *CloudWatchLoggingOptionUpdate { + s.CloudWatchLoggingOptionId = &v + return s +} + +// SetLogStreamARNUpdate sets the LogStreamARNUpdate field's value. +func (s *CloudWatchLoggingOptionUpdate) SetLogStreamARNUpdate(v string) *CloudWatchLoggingOptionUpdate { + s.LogStreamARNUpdate = &v + return s +} + +// SetRoleARNUpdate sets the RoleARNUpdate field's value. +func (s *CloudWatchLoggingOptionUpdate) SetRoleARNUpdate(v string) *CloudWatchLoggingOptionUpdate { + s.RoleARNUpdate = &v + return s +} + // TBD // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CreateApplicationRequest type CreateApplicationInput struct { _ struct{} `type:"structure"` // One or more SQL statements that read input data, transform it, and generate - // output. For example, you can write a SQL statement that reads input data - // and generates a running average of the number of advertisement clicks by - // vendor. + // output. For example, you can write a SQL statement that reads data from one + // in-application stream, generates a running average of the number of advertisement + // clicks by vendor, and insert resulting rows in another in-application stream + // using pumps. For more inforamtion about the typical pattern, see Application + // Code (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-app-code.html). // - // You can also provide a series of SQL statements, where output of one statement - // can be used as the input for the next statement. + // You can provide such series of SQL statements, where output of one statement + // can be used as the input for the next statement. You store intermediate results + // by creating in-application streams and pumps. // // Note that the application code must create the streams with names specified // in the Outputs. For example, if your Outputs defines output streams named @@ -1957,6 +2462,11 @@ type CreateApplicationInput struct { // ApplicationName is a required field ApplicationName *string `min:"1" type:"string" required:"true"` + // Use this parameter to configure a CloudWatch log stream to monitor application + // configuration errors. For more information, see Monitoring Configuration + // Errors (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-monitor-configuration.html). + CloudWatchLoggingOptions []*CloudWatchLoggingOption `type:"list"` + // Use this parameter to configure the application input. // // You can configure your application to receive input from a single streaming @@ -2012,6 +2522,16 @@ func (s *CreateApplicationInput) Validate() error { if s.ApplicationName != nil && len(*s.ApplicationName) < 1 { invalidParams.Add(request.NewErrParamMinLen("ApplicationName", 1)) } + if s.CloudWatchLoggingOptions != nil { + for i, v := range s.CloudWatchLoggingOptions { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "CloudWatchLoggingOptions", i), err.(request.ErrInvalidParams)) + } + } + } if s.Inputs != nil { for i, v := range s.Inputs { if v == nil { @@ -2057,6 +2577,12 @@ func (s *CreateApplicationInput) SetApplicationName(v string) *CreateApplication return s } +// SetCloudWatchLoggingOptions sets the CloudWatchLoggingOptions field's value. +func (s *CreateApplicationInput) SetCloudWatchLoggingOptions(v []*CloudWatchLoggingOption) *CreateApplicationInput { + s.CloudWatchLoggingOptions = v + return s +} + // SetInputs sets the Inputs field's value. func (s *CreateApplicationInput) SetInputs(v []*Input) *CreateApplicationInput { s.Inputs = v @@ -2098,6 +2624,98 @@ func (s *CreateApplicationOutput) SetApplicationSummary(v *ApplicationSummary) * return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOptionRequest +type DeleteApplicationCloudWatchLoggingOptionInput struct { + _ struct{} `type:"structure"` + + // The Amazon Kinesis Analytics application name. + // + // ApplicationName is a required field + ApplicationName *string `min:"1" type:"string" required:"true"` + + // The CloudWatchLoggingOptionId of the CloudWatch logging option to delete. + // You can use the DescribeApplication operation to get the CloudWatchLoggingOptionId. + // + // CloudWatchLoggingOptionId is a required field + CloudWatchLoggingOptionId *string `min:"1" type:"string" required:"true"` + + // The version ID of the Amazon Kinesis Analytics application. + // + // CurrentApplicationVersionId is a required field + CurrentApplicationVersionId *int64 `min:"1" type:"long" required:"true"` +} + +// String returns the string representation +func (s DeleteApplicationCloudWatchLoggingOptionInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteApplicationCloudWatchLoggingOptionInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteApplicationCloudWatchLoggingOptionInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteApplicationCloudWatchLoggingOptionInput"} + if s.ApplicationName == nil { + invalidParams.Add(request.NewErrParamRequired("ApplicationName")) + } + if s.ApplicationName != nil && len(*s.ApplicationName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ApplicationName", 1)) + } + if s.CloudWatchLoggingOptionId == nil { + invalidParams.Add(request.NewErrParamRequired("CloudWatchLoggingOptionId")) + } + if s.CloudWatchLoggingOptionId != nil && len(*s.CloudWatchLoggingOptionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CloudWatchLoggingOptionId", 1)) + } + if s.CurrentApplicationVersionId == nil { + invalidParams.Add(request.NewErrParamRequired("CurrentApplicationVersionId")) + } + if s.CurrentApplicationVersionId != nil && *s.CurrentApplicationVersionId < 1 { + invalidParams.Add(request.NewErrParamMinValue("CurrentApplicationVersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetApplicationName sets the ApplicationName field's value. +func (s *DeleteApplicationCloudWatchLoggingOptionInput) SetApplicationName(v string) *DeleteApplicationCloudWatchLoggingOptionInput { + s.ApplicationName = &v + return s +} + +// SetCloudWatchLoggingOptionId sets the CloudWatchLoggingOptionId field's value. +func (s *DeleteApplicationCloudWatchLoggingOptionInput) SetCloudWatchLoggingOptionId(v string) *DeleteApplicationCloudWatchLoggingOptionInput { + s.CloudWatchLoggingOptionId = &v + return s +} + +// SetCurrentApplicationVersionId sets the CurrentApplicationVersionId field's value. +func (s *DeleteApplicationCloudWatchLoggingOptionInput) SetCurrentApplicationVersionId(v int64) *DeleteApplicationCloudWatchLoggingOptionInput { + s.CurrentApplicationVersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOptionResponse +type DeleteApplicationCloudWatchLoggingOptionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteApplicationCloudWatchLoggingOptionOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteApplicationCloudWatchLoggingOptionOutput) GoString() string { + return s.String() +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationRequest type DeleteApplicationInput struct { _ struct{} `type:"structure"` @@ -2613,8 +3231,8 @@ type Input struct { KinesisStreamsInput *KinesisStreamsInput `type:"structure"` // Name prefix to use when creating in-application stream. Suppose you specify - // a prefix "MyInApplicationStream". Kinesis Analytics will then create one - // or more (as per the InputParallelism count you specified) in-application + // a prefix "MyInApplicationStream". Amazon Kinesis Analytics will then create + // one or more (as per the InputParallelism count you specified) in-application // streams with names "MyInApplicationStream_001", "MyInApplicationStream_002" // and so on. // @@ -2859,7 +3477,7 @@ func (s *InputDescription) SetNamePrefix(v string) *InputDescription { } // Describes the number of in-application streams to create for a given streaming -// source. For information about parallellism, see Configuring Application Input +// source. For information about parallelism, see Configuring Application Input // (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html). // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputParallelism type InputParallelism struct { @@ -3018,7 +3636,8 @@ type InputStartingPositionConfiguration struct { // The starting position on the stream. // - // * LATEST - Start reading just after the most recent record in the stream. + // * NOW - Start reading just after the most recent record in the stream, + // start at the request timestamp that the customer issued. // // * TRIM_HORIZON - Start reading at the last untrimmed record in the stream, // which is the oldest record available in the stream. This option is not @@ -3056,8 +3675,8 @@ type InputUpdate struct { // InputId is a required field InputId *string `min:"1" type:"string" required:"true"` - // Describes the parallelism updates (the number in-application streams Kinesis - // Analytics creates for the specific streaming source). + // Describes the parallelism updates (the number in-application streams Amazon + // Kinesis Analytics creates for the specific streaming source). InputParallelismUpdate *InputParallelismUpdate `type:"structure"` // Describes the data format on the streaming source, and how record elements @@ -3074,8 +3693,8 @@ type InputUpdate struct { // an updated stream ARN and IAM role ARN. KinesisStreamsInputUpdate *KinesisStreamsInputUpdate `type:"structure"` - // Name prefix for in-application stream(s) that Kinesis Analytics creates for - // the specific streaming source. + // Name prefix for in-application streams that Amazon Kinesis Analytics creates + // for the specific streaming source. NamePrefixUpdate *string `min:"1" type:"string"` } @@ -3978,6 +4597,9 @@ func (s *MappingParameters) SetJSONMappingParameters(v *JSONMappingParameters) * // stream and a destination where you want the in-application stream data to // be written. The destination can be an Amazon Kinesis stream or an Amazon // Kinesis Firehose delivery stream. +// +// For limits on how many destinations an application can write and other limitations, +// see Limits (http://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html) // Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/Output type Output struct { _ struct{} `type:"structure"` @@ -5015,7 +5637,7 @@ func (s StopApplicationOutput) GoString() string { type UpdateApplicationInput struct { _ struct{} `type:"structure"` - // Name of the Kinesis Analytics application to update. + // Name of the Amazon Kinesis Analytics application to update. // // ApplicationName is a required field ApplicationName *string `min:"1" type:"string" required:"true"` diff --git a/service/kinesisanalytics/doc.go b/service/kinesisanalytics/doc.go index 5009a1b9fde..945f5d876da 100644 --- a/service/kinesisanalytics/doc.go +++ b/service/kinesisanalytics/doc.go @@ -48,7 +48,7 @@ // by the operation if the service models the API operation's errors. These // errors will also be available as const strings prefixed with "ErrCode". // -// result, err := svc.AddApplicationInput(params) +// result, err := svc.AddApplicationCloudWatchLoggingOption(params) // if err != nil { // // Cast err to awserr.Error to handle specific error codes. // aerr, ok := err.(awserr.Error) @@ -58,7 +58,7 @@ // return err // } // -// fmt.Println("AddApplicationInput result:") +// fmt.Println("AddApplicationCloudWatchLoggingOption result:") // fmt.Println(result) // // Using the Client with Context @@ -70,7 +70,7 @@ // // ctx := context.Background() // -// result, err := svc.AddApplicationInputWithContext(ctx, params) +// result, err := svc.AddApplicationCloudWatchLoggingOptionWithContext(ctx, params) // // See the request package documentation for more information on using Context pattern // with the SDK. diff --git a/service/kinesisanalytics/errors.go b/service/kinesisanalytics/errors.go index 985fe0017c7..3eb5d5f2544 100644 --- a/service/kinesisanalytics/errors.go +++ b/service/kinesisanalytics/errors.go @@ -53,13 +53,15 @@ const ( // "ResourceProvisionedThroughputExceededException". // // Discovery failed to get a record from the streaming source because of the - // Kinesis Streams ProvisionedThroughputExceededException. + // Amazon Kinesis Streams ProvisionedThroughputExceededException. For more information, + // see GetRecords (http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetRecords.html) + // in the Amazon Kinesis Streams API Reference. ErrCodeResourceProvisionedThroughputExceededException = "ResourceProvisionedThroughputExceededException" // ErrCodeUnableToDetectSchemaException for service response error code // "UnableToDetectSchemaException". // - // Data format is not valid, Kinesis Analytics is not able to detect schema - // for the given streaming source. + // Data format is not valid, Amazon Kinesis Analytics is not able to detect + // schema for the given streaming source. ErrCodeUnableToDetectSchemaException = "UnableToDetectSchemaException" ) diff --git a/service/kinesisanalytics/examples_test.go b/service/kinesisanalytics/examples_test.go index 70e74d5d5f1..9bf75fc1c58 100644 --- a/service/kinesisanalytics/examples_test.go +++ b/service/kinesisanalytics/examples_test.go @@ -15,6 +15,32 @@ import ( var _ time.Duration var _ bytes.Buffer +func ExampleKinesisAnalytics_AddApplicationCloudWatchLoggingOption() { + sess := session.Must(session.NewSession()) + + svc := kinesisanalytics.New(sess) + + params := &kinesisanalytics.AddApplicationCloudWatchLoggingOptionInput{ + ApplicationName: aws.String("ApplicationName"), // Required + CloudWatchLoggingOption: &kinesisanalytics.CloudWatchLoggingOption{ // Required + LogStreamARN: aws.String("LogStreamARN"), // Required + RoleARN: aws.String("RoleARN"), // Required + }, + CurrentApplicationVersionId: aws.Int64(1), // Required + } + resp, err := svc.AddApplicationCloudWatchLoggingOption(params) + + if err != nil { + // Print the error, cast err to awserr.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_AddApplicationInput() { sess := session.Must(session.NewSession()) @@ -172,6 +198,13 @@ func ExampleKinesisAnalytics_CreateApplication() { ApplicationName: aws.String("ApplicationName"), // Required ApplicationCode: aws.String("ApplicationCode"), ApplicationDescription: aws.String("ApplicationDescription"), + CloudWatchLoggingOptions: []*kinesisanalytics.CloudWatchLoggingOption{ + { // Required + LogStreamARN: aws.String("LogStreamARN"), // Required + RoleARN: aws.String("RoleARN"), // Required + }, + // More values... + }, Inputs: []*kinesisanalytics.Input{ { // Required InputSchema: &kinesisanalytics.SourceSchema{ // Required @@ -265,6 +298,29 @@ func ExampleKinesisAnalytics_DeleteApplication() { fmt.Println(resp) } +func ExampleKinesisAnalytics_DeleteApplicationCloudWatchLoggingOption() { + sess := session.Must(session.NewSession()) + + svc := kinesisanalytics.New(sess) + + params := &kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionInput{ + ApplicationName: aws.String("ApplicationName"), // Required + CloudWatchLoggingOptionId: aws.String("Id"), // Required + CurrentApplicationVersionId: aws.Int64(1), // Required + } + resp, err := svc.DeleteApplicationCloudWatchLoggingOption(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -439,6 +495,14 @@ func ExampleKinesisAnalytics_UpdateApplication() { ApplicationName: aws.String("ApplicationName"), // Required ApplicationUpdate: &kinesisanalytics.ApplicationUpdate{ // Required ApplicationCodeUpdate: aws.String("ApplicationCode"), + CloudWatchLoggingOptionUpdates: []*kinesisanalytics.CloudWatchLoggingOptionUpdate{ + { // Required + CloudWatchLoggingOptionId: aws.String("Id"), // Required + LogStreamARNUpdate: aws.String("LogStreamARN"), + RoleARNUpdate: aws.String("RoleARN"), + }, + // More values... + }, InputUpdates: []*kinesisanalytics.InputUpdate{ { // Required InputId: aws.String("Id"), // Required diff --git a/service/kinesisanalytics/kinesisanalyticsiface/interface.go b/service/kinesisanalytics/kinesisanalyticsiface/interface.go index 23c5a53b667..5928f2a48f9 100644 --- a/service/kinesisanalytics/kinesisanalyticsiface/interface.go +++ b/service/kinesisanalytics/kinesisanalyticsiface/interface.go @@ -26,7 +26,7 @@ import ( // // myFunc uses an SDK service client to make a request to // // Amazon Kinesis Analytics. // func myFunc(svc kinesisanalyticsiface.KinesisAnalyticsAPI) bool { -// // Make svc.AddApplicationInput request +// // Make svc.AddApplicationCloudWatchLoggingOption request // } // // func main() { @@ -42,7 +42,7 @@ import ( // type mockKinesisAnalyticsClient struct { // kinesisanalyticsiface.KinesisAnalyticsAPI // } -// func (m *mockKinesisAnalyticsClient) AddApplicationInput(input *kinesisanalytics.AddApplicationInputInput) (*kinesisanalytics.AddApplicationInputOutput, error) { +// func (m *mockKinesisAnalyticsClient) AddApplicationCloudWatchLoggingOption(input *kinesisanalytics.AddApplicationCloudWatchLoggingOptionInput) (*kinesisanalytics.AddApplicationCloudWatchLoggingOptionOutput, error) { // // mock response/functionality // } // @@ -60,6 +60,10 @@ import ( // and waiters. Its suggested to use the pattern above for testing, or using // tooling to generate mocks to satisfy the interfaces. type KinesisAnalyticsAPI interface { + AddApplicationCloudWatchLoggingOption(*kinesisanalytics.AddApplicationCloudWatchLoggingOptionInput) (*kinesisanalytics.AddApplicationCloudWatchLoggingOptionOutput, error) + AddApplicationCloudWatchLoggingOptionWithContext(aws.Context, *kinesisanalytics.AddApplicationCloudWatchLoggingOptionInput, ...request.Option) (*kinesisanalytics.AddApplicationCloudWatchLoggingOptionOutput, error) + AddApplicationCloudWatchLoggingOptionRequest(*kinesisanalytics.AddApplicationCloudWatchLoggingOptionInput) (*request.Request, *kinesisanalytics.AddApplicationCloudWatchLoggingOptionOutput) + AddApplicationInput(*kinesisanalytics.AddApplicationInputInput) (*kinesisanalytics.AddApplicationInputOutput, error) AddApplicationInputWithContext(aws.Context, *kinesisanalytics.AddApplicationInputInput, ...request.Option) (*kinesisanalytics.AddApplicationInputOutput, error) AddApplicationInputRequest(*kinesisanalytics.AddApplicationInputInput) (*request.Request, *kinesisanalytics.AddApplicationInputOutput) @@ -80,6 +84,10 @@ type KinesisAnalyticsAPI interface { DeleteApplicationWithContext(aws.Context, *kinesisanalytics.DeleteApplicationInput, ...request.Option) (*kinesisanalytics.DeleteApplicationOutput, error) DeleteApplicationRequest(*kinesisanalytics.DeleteApplicationInput) (*request.Request, *kinesisanalytics.DeleteApplicationOutput) + DeleteApplicationCloudWatchLoggingOption(*kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionInput) (*kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionOutput, error) + DeleteApplicationCloudWatchLoggingOptionWithContext(aws.Context, *kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionInput, ...request.Option) (*kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionOutput, error) + DeleteApplicationCloudWatchLoggingOptionRequest(*kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionInput) (*request.Request, *kinesisanalytics.DeleteApplicationCloudWatchLoggingOptionOutput) + DeleteApplicationOutput(*kinesisanalytics.DeleteApplicationOutputInput) (*kinesisanalytics.DeleteApplicationOutputOutput, error) DeleteApplicationOutputWithContext(aws.Context, *kinesisanalytics.DeleteApplicationOutputInput, ...request.Option) (*kinesisanalytics.DeleteApplicationOutputOutput, error) DeleteApplicationOutputRequest(*kinesisanalytics.DeleteApplicationOutputInput) (*request.Request, *kinesisanalytics.DeleteApplicationOutputOutput) diff --git a/service/lexmodelbuildingservice/api.go b/service/lexmodelbuildingservice/api.go index 9cb6b0854b9..05f9c318a7c 100644 --- a/service/lexmodelbuildingservice/api.go +++ b/service/lexmodelbuildingservice/api.go @@ -4526,7 +4526,7 @@ type CreateBotVersionOutput struct { // The version of the bot. Version *string `locationName:"version" min:"1" type:"string"` - // The Amazon Parrot voice ID that Amazon Lex uses for voice interactions with + // The Amazon Polly voice ID that Amazon Lex uses for voice interactions with // the user. VoiceId *string `locationName:"voiceId" type:"string"` } @@ -6243,7 +6243,8 @@ type GetBotChannelAssociationsInput struct { // Substring to match in channel association names. An association will be returned // if any part of its name matches the substring. For example, "xyz" matches - // both "xyzabc" and "abcxyz." + // both "xyzabc" and "abcxyz." To return all bot channel associations, use a + // hyphen ("-") as the nameContains parameter. NameContains *string `location:"querystring" locationName:"nameContains" min:"1" type:"string"` // A pagination token for fetching the next page of associations. If the response @@ -6490,7 +6491,7 @@ type GetBotOutput struct { // The version of the bot. For a new bot, the version is always $LATEST. Version *string `locationName:"version" min:"1" type:"string"` - // The Amazon Parrot voice ID that Amazon Lex uses for voice interaction with + // The Amazon Polly voice ID that Amazon Lex uses for voice interaction with // the user. For more information, see . VoiceId *string `locationName:"voiceId" type:"string"` } @@ -8521,7 +8522,7 @@ type PutBotInput struct { // If you don't specify this value, the default value is Save. ProcessBehavior *string `locationName:"processBehavior" type:"string" enum:"ProcessBehavior"` - // The Amazon Parrot voice ID that you want Amazon Lex to use for voice interactions + // The Amazon Polly voice ID that you want Amazon Lex to use for voice interactions // with the user. The locale configured for the voice must match the locale // of the bot. For more information, see Voice (http://docs.aws.amazon.com/polly/latest/dg/API_Voice.html) // in the Amazon Polly Developer Guide. @@ -8732,7 +8733,7 @@ type PutBotOutput struct { // The version of the bot. For a new bot, the version is always $LATEST. Version *string `locationName:"version" min:"1" type:"string"` - // The Amazon Parrot voice ID that Amazon Lex uses for voice interaction with + // The Amazon Polly voice ID that Amazon Lex uses for voice interaction with // the user. For more information, see . VoiceId *string `locationName:"voiceId" type:"string"` } diff --git a/service/rds/api.go b/service/rds/api.go index 786172c72bf..daa8723530d 100644 --- a/service/rds/api.go +++ b/service/rds/api.go @@ -9352,6 +9352,222 @@ func (c *RDS) RevokeDBSecurityGroupIngressWithContext(ctx aws.Context, input *Re return out, req.Send() } +const opStartDBInstance = "StartDBInstance" + +// StartDBInstanceRequest generates a "aws/request.Request" representing the +// client's request for the StartDBInstance operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See StartDBInstance for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the StartDBInstance method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the StartDBInstanceRequest method. +// req, resp := client.StartDBInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StartDBInstance +func (c *RDS) StartDBInstanceRequest(input *StartDBInstanceInput) (req *request.Request, output *StartDBInstanceOutput) { + op := &request.Operation{ + Name: opStartDBInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &StartDBInstanceInput{} + } + + output = &StartDBInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// StartDBInstance API operation for Amazon Relational Database Service. +// +// Starts a DB instance that was stopped using the AWS console, the stop-db-instance +// AWS CLI command, or the StopDBInstance action. For more information, see +// Stopping and Starting a DB instance in the AWS RDS user guide. +// +// 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. +// +// See the AWS API reference guide for Amazon Relational Database Service's +// API operation StartDBInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeDBInstanceNotFoundFault "DBInstanceNotFound" +// DBInstanceIdentifier does not refer to an existing DB instance. +// +// * ErrCodeInvalidDBInstanceStateFault "InvalidDBInstanceState" +// The specified DB instance is not in the available state. +// +// * ErrCodeInsufficientDBInstanceCapacityFault "InsufficientDBInstanceCapacity" +// Specified DB instance class is not available in the specified Availability +// Zone. +// +// * ErrCodeDBSubnetGroupNotFoundFault "DBSubnetGroupNotFoundFault" +// DBSubnetGroupName does not refer to an existing DB subnet group. +// +// * ErrCodeDBSubnetGroupDoesNotCoverEnoughAZs "DBSubnetGroupDoesNotCoverEnoughAZs" +// Subnets in the DB subnet group should cover at least two Availability Zones +// unless there is only one Availability Zone. +// +// * ErrCodeInvalidDBClusterStateFault "InvalidDBClusterStateFault" +// The DB cluster is not in a valid state. +// +// * ErrCodeInvalidSubnet "InvalidSubnet" +// The requested subnet is invalid, or multiple subnets were requested that +// are not all in a common VPC. +// +// * ErrCodeInvalidVPCNetworkStateFault "InvalidVPCNetworkStateFault" +// DB subnet group does not cover all Availability Zones after it is created +// because users' change. +// +// * ErrCodeDBClusterNotFoundFault "DBClusterNotFoundFault" +// DBClusterIdentifier does not refer to an existing DB cluster. +// +// * ErrCodeAuthorizationNotFoundFault "AuthorizationNotFound" +// Specified CIDRIP or EC2 security group is not authorized for the specified +// DB security group. +// +// RDS may not also be authorized via IAM to perform necessary actions on your +// behalf. +// +// * ErrCodeKMSKeyNotAccessibleFault "KMSKeyNotAccessibleFault" +// Error accessing KMS key. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StartDBInstance +func (c *RDS) StartDBInstance(input *StartDBInstanceInput) (*StartDBInstanceOutput, error) { + req, out := c.StartDBInstanceRequest(input) + return out, req.Send() +} + +// StartDBInstanceWithContext is the same as StartDBInstance with the addition of +// the ability to pass a context and additional request options. +// +// See StartDBInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *RDS) StartDBInstanceWithContext(ctx aws.Context, input *StartDBInstanceInput, opts ...request.Option) (*StartDBInstanceOutput, error) { + req, out := c.StartDBInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opStopDBInstance = "StopDBInstance" + +// StopDBInstanceRequest generates a "aws/request.Request" representing the +// client's request for the StopDBInstance operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See StopDBInstance for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the StopDBInstance method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the StopDBInstanceRequest method. +// req, resp := client.StopDBInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StopDBInstance +func (c *RDS) StopDBInstanceRequest(input *StopDBInstanceInput) (req *request.Request, output *StopDBInstanceOutput) { + op := &request.Operation{ + Name: opStopDBInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &StopDBInstanceInput{} + } + + output = &StopDBInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// StopDBInstance API operation for Amazon Relational Database Service. +// +// Stops a DB instance. When you stop a DB instance, Amazon RDS retains the +// DB instance's metadata, including its endpoint, DB parameter group, and option +// group membership. Amazon RDS also retains the transaction logs so you can +// do a point-in-time restore if necessary. For more information, see Stopping +// and Starting a DB instance in the AWS RDS user guide. +// +// 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. +// +// See the AWS API reference guide for Amazon Relational Database Service's +// API operation StopDBInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeDBInstanceNotFoundFault "DBInstanceNotFound" +// DBInstanceIdentifier does not refer to an existing DB instance. +// +// * ErrCodeInvalidDBInstanceStateFault "InvalidDBInstanceState" +// The specified DB instance is not in the available state. +// +// * ErrCodeDBSnapshotAlreadyExistsFault "DBSnapshotAlreadyExists" +// DBSnapshotIdentifier is already used by an existing snapshot. +// +// * ErrCodeSnapshotQuotaExceededFault "SnapshotQuotaExceeded" +// Request would result in user exceeding the allowed number of DB snapshots. +// +// * ErrCodeInvalidDBClusterStateFault "InvalidDBClusterStateFault" +// The DB cluster is not in a valid state. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StopDBInstance +func (c *RDS) StopDBInstance(input *StopDBInstanceInput) (*StopDBInstanceOutput, error) { + req, out := c.StopDBInstanceRequest(input) + return out, req.Send() +} + +// StopDBInstanceWithContext is the same as StopDBInstance with the addition of +// the ability to pass a context and additional request options. +// +// See StopDBInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *RDS) StopDBInstanceWithContext(ctx aws.Context, input *StopDBInstanceInput, opts ...request.Option) (*StopDBInstanceOutput, error) { + req, out := c.StopDBInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + // Describes a quota for an AWS account, for example, the number of DB instances // allowed. // Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/AccountQuota @@ -10873,7 +11089,7 @@ type CreateDBClusterInput struct { // Example: mySubnetgroup DBSubnetGroupName *string `type:"string"` - // The name for your database of up to 8 alpha-numeric characters. If you do + // The name for your database of up to 64 alpha-numeric characters. If you do // not provide a name, Amazon RDS will not create a database in the DB cluster // you are creating. DatabaseName *string `type:"string"` @@ -11628,7 +11844,9 @@ type CreateDBInstanceInput struct { // // Oracle // - // The Oracle System ID (SID) of the created DB instance. + // The Oracle System ID (SID) of the created DB instance. If you specify null, + // the default value ORCL is used. You can't specify the string NULL, or any + // other reserved word, for DBName. // // Default: ORCL // @@ -11795,6 +12013,9 @@ type CreateDBInstanceInput struct { // // Oracle 12c // + // * 12.1.0.2.v8 (supported for EE in all AWS regions, and SE2 in all AWS + // regions except us-gov-west-1) + // // * 12.1.0.2.v7 (supported for EE in all AWS regions, and SE2 in all AWS // regions except us-gov-west-1) // @@ -11818,6 +12039,8 @@ type CreateDBInstanceInput struct { // // Oracle 11g // + // * 11.2.0.4.v12 (supported for EE, SE1, and SE, in all AWS regions) + // // * 11.2.0.4.v11 (supported for EE, SE1, and SE, in all AWS regions) // // * 11.2.0.4.v10 (supported for EE, SE1, and SE, in all AWS regions) @@ -11840,14 +12063,13 @@ type CreateDBInstanceInput struct { // // PostgreSQL // - // * Version 9.6: 9.6.1 + // * Version 9.6.x: 9.6.1 | 9.6.2 // - // * Version 9.5:9.5.4 | 9.5.2 + // * Version 9.5.x:9.5.6 | 9.5.4 | 9.5.2 // - // * Version 9.4: 9.4.9 | 9.4.7 | 9.4.5 | 9.4.4 | 9.4.1 + // * Version 9.4.x:9.4.11 | 9.4.9 | 9.4.7 // - // * Version 9.3: 9.3.14 | 9.3.12 | 9.3.10 | 9.3.9 | 9.3.6 | 9.3.5 | 9.3.3 - // | 9.3.2 | 9.3.1 + // * Version 9.3.x:9.3.16 | 9.3.14 | 9.3.12 EngineVersion *string `type:"string"` // The amount of Provisioned IOPS (input/output operations per second) to be @@ -27085,6 +27307,158 @@ func (s *SourceRegion) SetStatus(v string) *SourceRegion { return s } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StartDBInstanceMessage +type StartDBInstanceInput struct { + _ struct{} `type:"structure"` + + // The user-supplied instance identifier. + // + // DBInstanceIdentifier is a required field + DBInstanceIdentifier *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s StartDBInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StartDBInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *StartDBInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "StartDBInstanceInput"} + if s.DBInstanceIdentifier == nil { + invalidParams.Add(request.NewErrParamRequired("DBInstanceIdentifier")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDBInstanceIdentifier sets the DBInstanceIdentifier field's value. +func (s *StartDBInstanceInput) SetDBInstanceIdentifier(v string) *StartDBInstanceInput { + s.DBInstanceIdentifier = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StartDBInstanceResult +type StartDBInstanceOutput struct { + _ struct{} `type:"structure"` + + // Contains the result of a successful invocation of the following actions: + // + // * CreateDBInstance + // + // * DeleteDBInstance + // + // * ModifyDBInstance + // + // This data type is used as a response element in the DescribeDBInstances action. + DBInstance *DBInstance `type:"structure"` +} + +// String returns the string representation +func (s StartDBInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StartDBInstanceOutput) GoString() string { + return s.String() +} + +// SetDBInstance sets the DBInstance field's value. +func (s *StartDBInstanceOutput) SetDBInstance(v *DBInstance) *StartDBInstanceOutput { + s.DBInstance = v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StopDBInstanceMessage +type StopDBInstanceInput struct { + _ struct{} `type:"structure"` + + // The user-supplied instance identifier. + // + // DBInstanceIdentifier is a required field + DBInstanceIdentifier *string `type:"string" required:"true"` + + // The user-supplied instance identifier of the DB Snapshot created immediately + // before the DB instance is stopped. + DBSnapshotIdentifier *string `type:"string"` +} + +// String returns the string representation +func (s StopDBInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StopDBInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *StopDBInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "StopDBInstanceInput"} + if s.DBInstanceIdentifier == nil { + invalidParams.Add(request.NewErrParamRequired("DBInstanceIdentifier")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDBInstanceIdentifier sets the DBInstanceIdentifier field's value. +func (s *StopDBInstanceInput) SetDBInstanceIdentifier(v string) *StopDBInstanceInput { + s.DBInstanceIdentifier = &v + return s +} + +// SetDBSnapshotIdentifier sets the DBSnapshotIdentifier field's value. +func (s *StopDBInstanceInput) SetDBSnapshotIdentifier(v string) *StopDBInstanceInput { + s.DBSnapshotIdentifier = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/StopDBInstanceResult +type StopDBInstanceOutput struct { + _ struct{} `type:"structure"` + + // Contains the result of a successful invocation of the following actions: + // + // * CreateDBInstance + // + // * DeleteDBInstance + // + // * ModifyDBInstance + // + // This data type is used as a response element in the DescribeDBInstances action. + DBInstance *DBInstance `type:"structure"` +} + +// String returns the string representation +func (s StopDBInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StopDBInstanceOutput) GoString() string { + return s.String() +} + +// SetDBInstance sets the DBInstance field's value. +func (s *StopDBInstanceOutput) SetDBInstance(v *DBInstance) *StopDBInstanceOutput { + s.DBInstance = v + return s +} + // This data type is used as a response element in the DescribeDBSubnetGroups // action. // Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/Subnet diff --git a/service/rds/examples_test.go b/service/rds/examples_test.go index df8dfcc4715..c0e6314ae81 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) - +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_AddSourceIdentifierToSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.AddSourceIdentifierToSubscriptionInput{ - SourceIdentifier: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required +// 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.AddSourceIdentifierToSubscription(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_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"), +// 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.Tag{ + { + Key: aws.String("Staging"), + Value: aws.String("LocationDB"), }, - // 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) + 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 - } - - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleRDS_CopyDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) + 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) +} - svc := rds.New(sess) - - params := &rds.CopyDBClusterParameterGroupInput{ - SourceDBClusterParameterGroupIdentifier: aws.String("String"), // Required - TargetDBClusterParameterGroupDescription: aws.String("String"), // Required - TargetDBClusterParameterGroupIdentifier: aws.String("String"), // Required +// 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.Tag{ - { // Required - Key: aws.String("String"), - Value: aws.String("String"), + { + Key: aws.String("mydbreadreplicakey"), + Value: aws.String("mydbreadreplicavalue"), }, - // 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... + 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"), }, + 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.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()) + + 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_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... - }, + +// 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.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()) + 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_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... - }, + +// 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.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()) + 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_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... - }, + +// 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.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()) + 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_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... - }, +// 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.CreateDBCluster(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_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... - }, +// 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.CreateDBClusterParameterGroup(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_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... - }, +// 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.CreateDBClusterSnapshot(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_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) +// 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_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... - }, +// 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.CreateDBInstanceReadReplica(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_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... - }, +// 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.CreateDBParameterGroup(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_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... - }, +// 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.CreateDBSecurityGroup(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_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... - }, +// 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.CreateDBSnapshot(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_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... - }, +// 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.CreateDBSubnetGroup(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_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... - }, +// 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.CreateEventSubscription(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_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... - }, +// 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.CreateOptionGroup(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_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), +// 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.DeleteDBCluster(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_DeleteDBClusterParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBClusterParameterGroupInput{ - DBClusterParameterGroupName: aws.String("String"), // Required +// 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.DeleteDBClusterParameterGroup(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_DeleteDBClusterSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBClusterSnapshotInput{ - DBClusterSnapshotIdentifier: aws.String("String"), // Required +// 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.DeleteDBClusterSnapshot(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_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), +// 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.DeleteDBInstance(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_DeleteDBParameterGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBParameterGroupInput{ - DBParameterGroupName: aws.String("String"), // Required +// 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.DeleteDBParameterGroup(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_DeleteDBSecurityGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSecurityGroupInput{ - DBSecurityGroupName: aws.String("String"), // Required +// 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.DeleteDBSecurityGroup(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_DeleteDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSnapshotInput{ - DBSnapshotIdentifier: aws.String("String"), // Required +// 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.DeleteDBSnapshot(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_DeleteDBSubnetGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteDBSubnetGroupInput{ - DBSubnetGroupName: aws.String("String"), // Required +// 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.DeleteDBSubnetGroup(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_DeleteEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteEventSubscriptionInput{ - SubscriptionName: aws.String("String"), // Required +// 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.DeleteEventSubscription(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_DeleteOptionGroup() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DeleteOptionGroupInput{ - OptionGroupName: aws.String("String"), // Required +// 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.DeleteOptionGroup(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_DescribeAccountAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - var params *rds.DescribeAccountAttributesInput - resp, err := svc.DescribeAccountAttributes(params) +// 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"), + } + 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_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), +// 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.DescribeCertificates(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_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... +// 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("backup"), }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), + SourceIdentifier: aws.String("mymysqlinstance"), + SourceType: aws.String("db-instance"), } - resp, err := svc.DescribeDBClusterParameterGroups(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_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"), +// 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.DescribeDBClusterParameters(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_DescribeDBClusterSnapshotAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBClusterSnapshotAttributesInput{ - DBClusterSnapshotIdentifier: aws.String("String"), // Required +// 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.DescribeDBClusterSnapshotAttributes(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_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"), +// 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.DescribeDBClusterSnapshots(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_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), +// 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.DescribeDBClusters(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_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), +// 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.DescribeDBEngineVersions(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_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), +// 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.DescribeDBInstances(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_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), - } - resp, err := svc.DescribeDBLogFiles(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_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 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.Parameter{ + { + ApplyMethod: aws.String("immediate"), + ParameterName: aws.String("time_zone"), + ParameterValue: aws.String("America/Phoenix"), }, - // More values... }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), } - resp, err := svc.DescribeDBParameterGroups(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_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 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"), + }, + 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.Parameter{ + { + ApplyMethod: aws.String("immediate"), + ParameterName: aws.String("time_zone"), + ParameterValue: aws.String("America/Phoenix"), }, - // More values... }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - Source: aws.String("String"), } - resp, err := svc.DescribeDBParameters(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_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... +// 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.OptionConfiguration{ + { + DBSecurityGroupMemberships: []*string{ + aws.String("default"), }, + OptionName: aws.String("MEMCACHED"), }, - // More values... }, - Marker: aws.String("String"), - MaxRecords: aws.Int64(1), - } - 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()) - return - } - - // Pretty-print the response data. - fmt.Println(resp) -} - -func ExampleRDS_DescribeDBSnapshotAttributes() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.DescribeDBSnapshotAttributesInput{ - DBSnapshotIdentifier: aws.String("String"), // Required } - resp, err := svc.DescribeDBSnapshotAttributes(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_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 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.DescribeDBSnapshots(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_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 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.DescribeDBSubnetGroups(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_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), - } - resp, err := svc.DescribeEngineDefaultClusterParameters(params) - - if err != nil { - // Print the error, cast err to awserr.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_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), - } - resp, err := svc.DescribeEngineDefaultParameters(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - 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 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) - - if err != nil { - // Print the error, cast err to awserr.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_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()), - } - 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 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), - } - resp, err := svc.DescribeOptionGroupOptions(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.DescribeOptionGroups(params) - - if err != nil { - // Print the error, cast err to awserr.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_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), - } - resp, err := svc.DescribeOrderableDBInstanceOptions(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.DescribePendingMaintenanceActions(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.DescribeReservedDBInstances(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.DescribeReservedDBInstancesOfferings(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.DescribeSourceRegions(params) - - if err != nil { - // Print the error, cast err to awserr.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_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), - } - resp, err := svc.DownloadDBLogFilePortion(params) - - if err != nil { - // Print the error, cast err to awserr.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_FailoverDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.FailoverDBClusterInput{ - DBClusterIdentifier: aws.String("String"), - TargetDBInstanceIdentifier: aws.String("String"), - } - resp, err := svc.FailoverDBCluster(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - 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 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... - }, - } - resp, err := svc.ModifyDBCluster(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.ModifyDBClusterParameterGroup(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.ModifyDBClusterSnapshotAttribute(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.ModifyDBInstance(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.ModifyDBParameterGroup(params) - - if err != nil { - // Print the error, cast err to awserr.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_ModifyDBSnapshot() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.ModifyDBSnapshotInput{ - DBSnapshotIdentifier: aws.String("String"), // Required - EngineVersion: aws.String("String"), - } - resp, err := svc.ModifyDBSnapshot(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.ModifyDBSnapshotAttribute(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - } - resp, err := svc.ModifyDBSubnetGroup(params) - - if err != nil { - // Print the error, cast err to awserr.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_ModifyEventSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.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 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... - }, - } - 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 - } - - // 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) - - if err != nil { - // Print the error, cast err to awserr.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_PromoteReadReplicaDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.PromoteReadReplicaDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - } - resp, err := svc.PromoteReadReplicaDBCluster(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.PurchaseReservedDBInstancesOffering(params) - - if err != nil { - // Print the error, cast err to awserr.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_RebootDBInstance() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RebootDBInstanceInput{ - DBInstanceIdentifier: aws.String("String"), // Required - ForceFailover: aws.Bool(true), - } - resp, err := svc.RebootDBInstance(params) - - if err != nil { - // Print the error, cast err to awserr.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_RemoveRoleFromDBCluster() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RemoveRoleFromDBClusterInput{ - DBClusterIdentifier: aws.String("String"), // Required - RoleArn: aws.String("String"), // Required - } - resp, err := svc.RemoveRoleFromDBCluster(params) - - if err != nil { - // Print the error, cast err to awserr.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_RemoveSourceIdentifierFromSubscription() { - sess := session.Must(session.NewSession()) - - svc := rds.New(sess) - - params := &rds.RemoveSourceIdentifierFromSubscriptionInput{ - SourceIdentifier: aws.String("String"), // Required - SubscriptionName: aws.String("String"), // Required - } - resp, err := svc.RemoveSourceIdentifierFromSubscription(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - 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 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) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - }, - // More values... - }, - ResetAllParameters: aws.Bool(true), - } - resp, err := svc.ResetDBParameterGroup(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - 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"), - }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RestoreDBClusterFromS3(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), - }, - // More values... - }, - VpcSecurityGroupIds: []*string{ - aws.String("String"), // Required - // More values... - }, - } - resp, err := svc.RestoreDBClusterFromSnapshot(params) - - if err != nil { - // Print the error, cast err to awserr.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_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... - }, - } - resp, err := svc.RestoreDBClusterToPointInTime(params) - - if err != nil { - // Print the error, cast err to awserr.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_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), - } - resp, err := svc.RestoreDBInstanceToPointInTime(params) - - if err != nil { - // Print the error, cast err to awserr.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_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/rds/rdsiface/interface.go b/service/rds/rdsiface/interface.go index 7b35112ff0b..0716dc815ba 100644 --- a/service/rds/rdsiface/interface.go +++ b/service/rds/rdsiface/interface.go @@ -459,6 +459,14 @@ type RDSAPI interface { RevokeDBSecurityGroupIngressWithContext(aws.Context, *rds.RevokeDBSecurityGroupIngressInput, ...request.Option) (*rds.RevokeDBSecurityGroupIngressOutput, error) RevokeDBSecurityGroupIngressRequest(*rds.RevokeDBSecurityGroupIngressInput) (*request.Request, *rds.RevokeDBSecurityGroupIngressOutput) + StartDBInstance(*rds.StartDBInstanceInput) (*rds.StartDBInstanceOutput, error) + StartDBInstanceWithContext(aws.Context, *rds.StartDBInstanceInput, ...request.Option) (*rds.StartDBInstanceOutput, error) + StartDBInstanceRequest(*rds.StartDBInstanceInput) (*request.Request, *rds.StartDBInstanceOutput) + + StopDBInstance(*rds.StopDBInstanceInput) (*rds.StopDBInstanceOutput, error) + StopDBInstanceWithContext(aws.Context, *rds.StopDBInstanceInput, ...request.Option) (*rds.StopDBInstanceOutput, error) + StopDBInstanceRequest(*rds.StopDBInstanceInput) (*request.Request, *rds.StopDBInstanceOutput) + WaitUntilDBInstanceAvailable(*rds.DescribeDBInstancesInput) error WaitUntilDBInstanceAvailableWithContext(aws.Context, *rds.DescribeDBInstancesInput, ...request.WaiterOption) error diff --git a/service/route53/examples_test.go b/service/route53/examples_test.go index a2b7aa75aa7..e1ef2176730 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Change{ + { + 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.Tag{ + { + 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/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/examples_test.go b/service/s3/examples_test.go index 4472990c234..71876f42114 100644 --- a/service/s3/examples_test.go +++ b/service/s3/examples_test.go @@ -8,2231 +8,2216 @@ 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"), + { + ETag: aws.String("\"d8c2eafd90c266e19ab9dcacc479f8af\""), PartNumber: aws.Int64(1), }, - // More values... + { + ETag: aws.String("\"d8c2eafd90c266e19ab9dcacc479f8af\""), + PartNumber: aws.Int64(2), + }, }, }, - 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.ObjectIdentifier{ + { + 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) - - if err != nil { - // Print the error, cast err to awserr.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_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) - + 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_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.ObjectIdentifier{ + { + 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 - } - - // 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"), +// 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"), } - 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.CORSRule{ + { + AllowedHeaders: []*string{ + aws.String("*"), + }, + AllowedMethods: []*string{ + aws.String("PUT"), + aws.String("POST"), + aws.String("DELETE"), }, - Permission: aws.String("Permission"), + AllowedOrigins: []*string{ + aws.String("http://www.example.com"), + }, + ExposeHeaders: []*string{ + aws.String("x-amz-server-side-encryption"), + }, + MaxAgeSeconds: aws.Int64(3000), + }, + { + AllowedHeaders: []*string{ + aws.String("Authorization"), + }, + AllowedMethods: []*string{ + aws.String("GET"), + }, + AllowedOrigins: []*string{ + aws.String("*"), + }, + MaxAgeSeconds: aws.Int64(3000), }, - // 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"), } - 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.LifecycleRule{ + { + ID: aws.String("TestOnly"), + Status: aws.String("Enabled"), + Transitions: []*s3.Transition{ + { + Days: aws.Int64(365), + 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.TargetGrant{ + { + 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.TopicConfiguration{ + { + 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.ReplicationRule{ + { + 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.Tag{ + { + 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"), + 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.Tag{ + { + 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/s3/s3manager/download.go b/service/s3/s3manager/download.go index 002df1c30eb..d50a61e807e 100644 --- a/service/s3/s3manager/download.go +++ b/service/s3/s3manager/download.go @@ -32,10 +32,14 @@ type Downloader struct { // The buffer size (in bytes) to use when buffering data into chunks and // sending them as parts to S3. The minimum allowed part size is 5MB, and // if this value is set to zero, the DefaultDownloadPartSize value will be used. + // + // PartSize is ignored if the Range input parameter is provided. PartSize int64 // The number of goroutines to spin up in parallel when sending parts. // If this is set to zero, the DefaultDownloadConcurrency value will be used. + // + // Concurrency is ignored if the Range input parameter is provided. Concurrency int // An S3 client to use when performing downloads. @@ -130,6 +134,10 @@ type maxRetrier interface { // // The w io.WriterAt can be satisfied by an os.File to do multipart concurrent // downloads, or in memory []byte wrapper using aws.WriteAtBuffer. +// +// If the GetObjectInput's Range value is provided that will cause the downloader +// to perform a single GetObjectInput request for that object's range. This will +// caused the part size, and concurrency configurations to be ignored. func (d Downloader) Download(w io.WriterAt, input *s3.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { return d.DownloadWithContext(aws.BackgroundContext(), w, input, options...) } @@ -153,6 +161,10 @@ func (d Downloader) Download(w io.WriterAt, input *s3.GetObjectInput, options .. // downloads, or in memory []byte wrapper using aws.WriteAtBuffer. // // It is safe to call this method concurrently across goroutines. +// +// If the GetObjectInput's Range value is provided that will cause the downloader +// to perform a single GetObjectInput request for that object's range. This will +// caused the part size, and concurrency configurations to be ignored. func (d Downloader) DownloadWithContext(ctx aws.Context, w io.WriterAt, input *s3.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { impl := downloader{w: w, in: input, cfg: d, ctx: ctx} @@ -199,6 +211,14 @@ type downloader struct { // download performs the implementation of the object download across ranged // GETs. func (d *downloader) download() (n int64, err error) { + // If range is specified fall back to single download of that range + // this enables the functionality of ranged gets with the downloader but + // at the cost of no multipart downloads. + if rng := aws.StringValue(d.in.Range); len(rng) > 0 { + d.downloadRange(rng) + return d.written, d.err + } + // Spin off first worker to check additional header information d.getChunk() @@ -285,14 +305,32 @@ func (d *downloader) getChunk() { } } -// downloadChunk downloads the chunk froom s3 +// downloadRange downloads an Object given the passed in Byte-Range value. +// The chunk used down download the range will be configured for that range. +func (d *downloader) downloadRange(rng string) { + if d.getErr() != nil { + return + } + + chunk := dlchunk{w: d.w, start: d.pos} + // Ranges specified will short circuit the multipart download + chunk.withRange = rng + + if err := d.downloadChunk(chunk); err != nil { + d.setErr(err) + } + + // Update the position based on the amount of data received. + d.pos = d.written +} + +// downloadChunk downloads the chunk from s3 func (d *downloader) downloadChunk(chunk dlchunk) error { in := &s3.GetObjectInput{} awsutil.Copy(in, d.in) // Get the next byte range of data - rng := fmt.Sprintf("bytes=%d-%d", chunk.start, chunk.start+chunk.size-1) - in.Range = &rng + in.Range = aws.String(chunk.ByteRange()) var n int64 var err error @@ -417,12 +455,18 @@ type dlchunk struct { start int64 size int64 cur int64 + + // specifies the byte range the chunk should be downloaded with. + withRange string } // Write wraps io.WriterAt for the dlchunk, writing from the dlchunk's start // position to its end (or EOF). +// +// If a range is specified on the dlchunk the size will be ignored when writing. +// as the total size may not of be known ahead of time. func (c *dlchunk) Write(p []byte) (n int, err error) { - if c.cur >= c.size { + if c.cur >= c.size && len(c.withRange) == 0 { return 0, io.EOF } @@ -431,3 +475,13 @@ func (c *dlchunk) Write(p []byte) (n int, err error) { return } + +// ByteRange returns a HTTP Byte-Range header value that should be used by the +// client to request the chunk's range. +func (c *dlchunk) ByteRange() string { + if len(c.withRange) != 0 { + return c.withRange + } + + return fmt.Sprintf("bytes=%d-%d", c.start, c.start+c.size-1) +} diff --git a/service/s3/s3manager/download_test.go b/service/s3/s3manager/download_test.go index f272c492096..32c81a442d3 100644 --- a/service/s3/s3manager/download_test.go +++ b/service/s3/s3manager/download_test.go @@ -6,6 +6,7 @@ import ( "io" "io/ioutil" "net/http" + "reflect" "regexp" "strconv" "strings" @@ -13,8 +14,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/request" @@ -199,16 +198,30 @@ func TestDownloadOrder(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(len(buf12MB)), n) - assert.Equal(t, []string{"GetObject", "GetObject", "GetObject"}, *names) - assert.Equal(t, []string{"bytes=0-5242879", "bytes=5242880-10485759", "bytes=10485760-15728639"}, *ranges) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(len(buf12MB)), n; e != a { + t.Errorf("expect %d buffer length, got %d", e, a) + } + + expectCalls := []string{"GetObject", "GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + + expectRngs := []string{"bytes=0-5242879", "bytes=5242880-10485759", "bytes=10485760-15728639"} + if e, a := expectRngs, *ranges; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v ranges, got %v", e, a) + } count := 0 for _, b := range w.Bytes() { count += int(b) } - assert.Equal(t, 0, count) + if count != 0 { + t.Errorf("expect 0 count, got %d", count) + } } func TestDownloadZero(t *testing.T) { @@ -221,10 +234,21 @@ func TestDownloadZero(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(0), n) - assert.Equal(t, []string{"GetObject"}, *names) - assert.Equal(t, []string{"bytes=0-5242879"}, *ranges) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if n != 0 { + t.Errorf("expect 0 bytes read, got %d", n) + } + expectCalls := []string{"GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + + expectRngs := []string{"bytes=0-5242879"} + if e, a := expectRngs, *ranges; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v ranges, got %v", e, a) + } } func TestDownloadSetPartSize(t *testing.T) { @@ -240,11 +264,24 @@ func TestDownloadSetPartSize(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(3), n) - assert.Equal(t, []string{"GetObject", "GetObject", "GetObject"}, *names) - assert.Equal(t, []string{"bytes=0-0", "bytes=1-1", "bytes=2-2"}, *ranges) - assert.Equal(t, []byte{1, 2, 3}, w.Bytes()) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(3), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject", "GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + expectRngs := []string{"bytes=0-0", "bytes=1-1", "bytes=2-2"} + if e, a := expectRngs, *ranges; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v ranges, got %v", e, a) + } + expectBytes := []byte{1, 2, 3} + if e, a := expectBytes, w.Bytes(); !reflect.DeepEqual(e, a) { + t.Errorf("expect %v bytes, got %v", e, a) + } } func TestDownloadError(t *testing.T) { @@ -269,10 +306,24 @@ func TestDownloadError(t *testing.T) { Key: aws.String("key"), }) - assert.NotNil(t, err) - assert.Equal(t, int64(1), n) - assert.Equal(t, []string{"GetObject", "GetObject"}, *names) - assert.Equal(t, []byte{1}, w.Bytes()) + if err == nil { + t.Fatalf("expect error, got none") + } + aerr := err.(awserr.Error) + if e, a := "BadRequest", aerr.Code(); e != a { + t.Errorf("expect %s error code, got %s", e, a) + } + if e, a := int64(1), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + expectBytes := []byte{1} + if e, a := expectBytes, w.Bytes(); !reflect.DeepEqual(e, a) { + t.Errorf("expect %v bytes, got %v", e, a) + } } func TestDownloadNonChunk(t *testing.T) { @@ -287,15 +338,24 @@ func TestDownloadNonChunk(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(len(buf2MB)), n) - assert.Equal(t, []string{"GetObject"}, *names) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(len(buf2MB)), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } count := 0 for _, b := range w.Bytes() { count += int(b) } - assert.Equal(t, 0, count) + if count != 0 { + t.Errorf("expect 0 count, got %d", count) + } } func TestDownloadNoContentRangeLength(t *testing.T) { @@ -310,15 +370,24 @@ func TestDownloadNoContentRangeLength(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(len(buf2MB)), n) - assert.Equal(t, []string{"GetObject", "GetObject"}, *names) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(len(buf2MB)), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } count := 0 for _, b := range w.Bytes() { count += int(b) } - assert.Equal(t, 0, count) + if count != 0 { + t.Errorf("expect 0 count, got %d", count) + } } func TestDownloadContentRangeTotalAny(t *testing.T) { @@ -333,15 +402,24 @@ func TestDownloadContentRangeTotalAny(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(len(buf2MB)), n) - assert.Equal(t, []string{"GetObject", "GetObject"}, *names) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(len(buf2MB)), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } count := 0 for _, b := range w.Bytes() { count += int(b) } - assert.Equal(t, 0, count) + if count != 0 { + t.Errorf("expect 0 count, got %d", count) + } } func TestDownloadPartBodyRetry_SuccessRetry(t *testing.T) { @@ -360,10 +438,19 @@ func TestDownloadPartBodyRetry_SuccessRetry(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(3), n) - assert.Equal(t, []string{"GetObject", "GetObject"}, *names) - assert.Equal(t, []byte("123"), w.Bytes()) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(3), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject", "GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + if e, a := "123", string(w.Bytes()); e != a { + t.Errorf("expect %q response, got %q", e, a) + } } func TestDownloadPartBodyRetry_SuccessNoRetry(t *testing.T) { @@ -381,10 +468,19 @@ func TestDownloadPartBodyRetry_SuccessNoRetry(t *testing.T) { Key: aws.String("key"), }) - assert.Nil(t, err) - assert.Equal(t, int64(3), n) - assert.Equal(t, []string{"GetObject"}, *names) - assert.Equal(t, []byte("abc"), w.Bytes()) + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(3), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + if e, a := "abc", string(w.Bytes()); e != a { + t.Errorf("expect %q response, got %q", e, a) + } } func TestDownloadPartBodyRetry_FailRetry(t *testing.T) { @@ -402,10 +498,22 @@ func TestDownloadPartBodyRetry_FailRetry(t *testing.T) { Key: aws.String("key"), }) - assert.Error(t, err) - assert.Equal(t, int64(2), n) - assert.Equal(t, []string{"GetObject"}, *names) - assert.Equal(t, []byte("ab"), w.Bytes()) + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "unexpected EOF", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %q error message to be in %q", e, a) + } + if e, a := int64(2), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + if e, a := "ab", string(w.Bytes()); e != a { + t.Errorf("expect %q response, got %q", e, a) + } } func TestDownloadWithContextCanceled(t *testing.T) { @@ -435,6 +543,41 @@ func TestDownloadWithContextCanceled(t *testing.T) { } } +func TestDownload_WithRange(t *testing.T) { + s, names, ranges := dlLoggingSvc([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) + + d := s3manager.NewDownloaderWithClient(s, func(d *s3manager.Downloader) { + d.Concurrency = 10 // should be ignored + d.PartSize = 1 // should be ignored + }) + + w := &aws.WriteAtBuffer{} + n, err := d.Download(w, &s3.GetObjectInput{ + Bucket: aws.String("bucket"), + Key: aws.String("key"), + Range: aws.String("bytes=2-6"), + }) + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + if e, a := int64(5), n; e != a { + t.Errorf("expect %d bytes read, got %d", e, a) + } + expectCalls := []string{"GetObject"} + if e, a := expectCalls, *names; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v API calls, got %v", e, a) + } + expectRngs := []string{"bytes=2-6"} + if e, a := expectRngs, *ranges; !reflect.DeepEqual(e, a) { + t.Errorf("expect %v ranges, got %v", e, a) + } + expectBytes := []byte{2, 3, 4, 5, 6} + if e, a := expectBytes, w.Bytes(); !reflect.DeepEqual(e, a) { + t.Errorf("expect %v bytes, got %v", e, a) + } +} + func TestDownload_WithFailure(t *testing.T) { svc := s3.New(unit.Session) svc.Handlers.Send.Clear() diff --git a/service/ses/examples_test.go b/service/ses/examples_test.go index 6210585f747..4794b7fa580 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 - }, +// 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.CreateConfigurationSet(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_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 +// 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("MyFilter"), }, } - resp, err := svc.CreateConfigurationSetEventDestination(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_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 - }, - Name: aws.String("ReceiptFilterName"), // Required - }, - } - resp, err := svc.CreateReceiptFilter(params) - - if err != nil { - // Print the error, cast err to awserr.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_CreateReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.CreateReceiptRuleInput{ - Rule: &ses.ReceiptRule{ // Required - Name: aws.String("ReceiptRuleName"), // Required +// 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.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... + {}, }, + 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 - } - - // 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) - - if err != nil { - // Print the error, cast err to awserr.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_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 +// 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"), } - resp, err := svc.DescribeReceiptRule(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_DescribeReceiptRuleSet() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.DescribeReceiptRuleSetInput{ - 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.DescribeReceiptRuleSet(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_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 - } - - // 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) - - if 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_ListVerifiedEmailAddresses() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - var params *ses.ListVerifiedEmailAddressesInput - resp, err := svc.ListVerifiedEmailAddresses(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_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) +// 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_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 - } - resp, err := svc.SetIdentityHeadersInNotificationsEnabled(params) - - if err != nil { - // Print the error, cast err to awserr.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_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"), +// 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.SetIdentityMailFromDomain(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_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"), +// 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.SetIdentityNotificationTopic(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_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"), +// 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.SetReceiptRulePosition(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_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 - }, - }, +// 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.UpdateConfigurationSetEventDestination(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_UpdateReceiptRule() { - sess := session.Must(session.NewSession()) - - svc := ses.New(sess) - - params := &ses.UpdateReceiptRuleInput{ - Rule: &ses.ReceiptRule{ // Required - Name: aws.String("ReceiptRuleName"), // Required +// 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.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... + {}, }, + 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/workdocs/api.go b/service/workdocs/api.go index e2bd2c66298..f82f6c88ded 100644 --- a/service/workdocs/api.go +++ b/service/workdocs/api.go @@ -62,7 +62,7 @@ func (c *WorkDocs) AbortDocumentVersionUploadRequest(input *AbortDocumentVersion // // Aborts the upload of the specified document version that was previously initiated // by InitiateDocumentVersionUpload. The client should make this call only when -// it no longer intends or fails to upload the document version. +// it no longer intends to upload the document version, or fails to do so. // // 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 @@ -300,6 +300,209 @@ func (c *WorkDocs) AddResourcePermissionsWithContext(ctx aws.Context, input *Add return out, req.Send() } +const opCreateComment = "CreateComment" + +// CreateCommentRequest generates a "aws/request.Request" representing the +// client's request for the CreateComment operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See CreateComment for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the CreateComment method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the CreateCommentRequest method. +// req, resp := client.CreateCommentRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateComment +func (c *WorkDocs) CreateCommentRequest(input *CreateCommentInput) (req *request.Request, output *CreateCommentOutput) { + op := &request.Operation{ + Name: opCreateComment, + HTTPMethod: "POST", + HTTPPath: "/api/v1/documents/{DocumentId}/versions/{VersionId}/comment", + } + + if input == nil { + input = &CreateCommentInput{} + } + + output = &CreateCommentOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateComment API operation for Amazon WorkDocs. +// +// Adds a new comment to the specified document version. +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation CreateComment for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeProhibitedStateException "ProhibitedStateException" +// The specified document version is not in the INITIALIZED state. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// * ErrCodeDocumentLockedForCommentsException "DocumentLockedForCommentsException" +// This exception is thrown when the document is locked for comments and user +// tries to create or delete a comment on that document. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateComment +func (c *WorkDocs) CreateComment(input *CreateCommentInput) (*CreateCommentOutput, error) { + req, out := c.CreateCommentRequest(input) + return out, req.Send() +} + +// CreateCommentWithContext is the same as CreateComment with the addition of +// the ability to pass a context and additional request options. +// +// See CreateComment for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) CreateCommentWithContext(ctx aws.Context, input *CreateCommentInput, opts ...request.Option) (*CreateCommentOutput, error) { + req, out := c.CreateCommentRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateCustomMetadata = "CreateCustomMetadata" + +// CreateCustomMetadataRequest generates a "aws/request.Request" representing the +// client's request for the CreateCustomMetadata operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See CreateCustomMetadata for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the CreateCustomMetadata method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the CreateCustomMetadataRequest method. +// req, resp := client.CreateCustomMetadataRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCustomMetadata +func (c *WorkDocs) CreateCustomMetadataRequest(input *CreateCustomMetadataInput) (req *request.Request, output *CreateCustomMetadataOutput) { + op := &request.Operation{ + Name: opCreateCustomMetadata, + HTTPMethod: "PUT", + HTTPPath: "/api/v1/resources/{ResourceId}/customMetadata", + } + + if input == nil { + input = &CreateCustomMetadataInput{} + } + + output = &CreateCustomMetadataOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateCustomMetadata API operation for Amazon WorkDocs. +// +// Adds one or more custom properties to the specified resource (a folder, document, +// or version). +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation CreateCustomMetadata for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeProhibitedStateException "ProhibitedStateException" +// The specified document version is not in the INITIALIZED state. +// +// * ErrCodeCustomMetadataLimitExceededException "CustomMetadataLimitExceededException" +// The limit has been reached on the number of custom properties for the specified +// resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCustomMetadata +func (c *WorkDocs) CreateCustomMetadata(input *CreateCustomMetadataInput) (*CreateCustomMetadataOutput, error) { + req, out := c.CreateCustomMetadataRequest(input) + return out, req.Send() +} + +// CreateCustomMetadataWithContext is the same as CreateCustomMetadata with the addition of +// the ability to pass a context and additional request options. +// +// See CreateCustomMetadata for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) CreateCustomMetadataWithContext(ctx aws.Context, input *CreateCustomMetadataInput, opts ...request.Option) (*CreateCustomMetadataOutput, error) { + req, out := c.CreateCustomMetadataRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opCreateFolder = "CreateFolder" // CreateFolderRequest generates a "aws/request.Request" representing the @@ -365,7 +568,7 @@ func (c *WorkDocs) CreateFolderRequest(input *CreateFolderInput) (req *request.R // The specified document version is not in the INITIALIZED state. // // * ErrCodeLimitExceededException "LimitExceededException" -// You've exceeded the maximum of 100,000 folders under the parent folder. +// The maximum of 100,000 folders under the parent folder has been exceeded. // // * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" // The operation is not permitted. @@ -403,6 +606,103 @@ func (c *WorkDocs) CreateFolderWithContext(ctx aws.Context, input *CreateFolderI return out, req.Send() } +const opCreateLabels = "CreateLabels" + +// CreateLabelsRequest generates a "aws/request.Request" representing the +// client's request for the CreateLabels operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See CreateLabels for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the CreateLabels method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the CreateLabelsRequest method. +// req, resp := client.CreateLabelsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateLabels +func (c *WorkDocs) CreateLabelsRequest(input *CreateLabelsInput) (req *request.Request, output *CreateLabelsOutput) { + op := &request.Operation{ + Name: opCreateLabels, + HTTPMethod: "PUT", + HTTPPath: "/api/v1/resources/{ResourceId}/labels", + } + + if input == nil { + input = &CreateLabelsInput{} + } + + output = &CreateLabelsOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateLabels API operation for Amazon WorkDocs. +// +// Adds the specified list of labels to the given resource (a document or folder) +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation CreateLabels for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// * ErrCodeTooManyLabelsException "TooManyLabelsException" +// The limit has been reached on the number of labels for the specified resource. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateLabels +func (c *WorkDocs) CreateLabels(input *CreateLabelsInput) (*CreateLabelsOutput, error) { + req, out := c.CreateLabelsRequest(input) + return out, req.Send() +} + +// CreateLabelsWithContext is the same as CreateLabels with the addition of +// the ability to pass a context and additional request options. +// +// See CreateLabels for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) CreateLabelsWithContext(ctx aws.Context, input *CreateLabelsInput, opts ...request.Option) (*CreateLabelsOutput, error) { + req, out := c.CreateLabelsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opCreateNotificationSubscription = "CreateNotificationSubscription" // CreateNotificationSubscriptionRequest generates a "aws/request.Request" representing the @@ -686,61 +986,61 @@ func (c *WorkDocs) DeactivateUserWithContext(ctx aws.Context, input *DeactivateU return out, req.Send() } -const opDeleteDocument = "DeleteDocument" +const opDeleteComment = "DeleteComment" -// DeleteDocumentRequest generates a "aws/request.Request" representing the -// client's request for the DeleteDocument operation. The "output" return +// DeleteCommentRequest generates a "aws/request.Request" representing the +// client's request for the DeleteComment operation. The "output" return // value can be used to capture response data after the request's "Send" method // is called. // -// See DeleteDocument for usage and error information. +// See DeleteComment for usage and error information. // // Creating a request object using this method should be used when you want to inject // custom logic into the request's lifecycle using a custom handler, or if you want to // access properties on the request object before or after sending the request. If -// you just want the service response, call the DeleteDocument method directly +// you just want the service response, call the DeleteComment method directly // instead. // // Note: You must call the "Send" method on the returned request object in order // to execute the request. // -// // Example sending a request using the DeleteDocumentRequest method. -// req, resp := client.DeleteDocumentRequest(params) +// // Example sending a request using the DeleteCommentRequest method. +// req, resp := client.DeleteCommentRequest(params) // // err := req.Send() // if err == nil { // resp is now filled // fmt.Println(resp) // } // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteDocument -func (c *WorkDocs) DeleteDocumentRequest(input *DeleteDocumentInput) (req *request.Request, output *DeleteDocumentOutput) { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteComment +func (c *WorkDocs) DeleteCommentRequest(input *DeleteCommentInput) (req *request.Request, output *DeleteCommentOutput) { op := &request.Operation{ - Name: opDeleteDocument, + Name: opDeleteComment, HTTPMethod: "DELETE", - HTTPPath: "/api/v1/documents/{DocumentId}", + HTTPPath: "/api/v1/documents/{DocumentId}/versions/{VersionId}/comment/{CommentId}", } if input == nil { - input = &DeleteDocumentInput{} + input = &DeleteCommentInput{} } - output = &DeleteDocumentOutput{} + output = &DeleteCommentOutput{} req = c.newRequest(op, input, output) req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return } -// DeleteDocument API operation for Amazon WorkDocs. +// DeleteComment API operation for Amazon WorkDocs. // -// Permanently deletes the specified document and its associated metadata. +// Deletes the specified comment from the document version. // // 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. // // See the AWS API reference guide for Amazon WorkDocs's -// API operation DeleteDocument for usage and error information. +// API operation DeleteComment for usage and error information. // // Returned Error Codes: // * ErrCodeEntityNotExistsException "EntityNotExistsException" @@ -749,9 +1049,6 @@ func (c *WorkDocs) DeleteDocumentRequest(input *DeleteDocumentInput) (req *reque // * ErrCodeProhibitedStateException "ProhibitedStateException" // The specified document version is not in the INITIALIZED state. // -// * ErrCodeConcurrentModificationException "ConcurrentModificationException" -// The resource hierarchy is changing. -// // * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" // The operation is not permitted. // @@ -766,56 +1063,259 @@ func (c *WorkDocs) DeleteDocumentRequest(input *DeleteDocumentInput) (req *reque // * ErrCodeServiceUnavailableException "ServiceUnavailableException" // One or more of the dependencies is unavailable. // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteDocument -func (c *WorkDocs) DeleteDocument(input *DeleteDocumentInput) (*DeleteDocumentOutput, error) { - req, out := c.DeleteDocumentRequest(input) +// * ErrCodeDocumentLockedForCommentsException "DocumentLockedForCommentsException" +// This exception is thrown when the document is locked for comments and user +// tries to create or delete a comment on that document. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteComment +func (c *WorkDocs) DeleteComment(input *DeleteCommentInput) (*DeleteCommentOutput, error) { + req, out := c.DeleteCommentRequest(input) return out, req.Send() } -// DeleteDocumentWithContext is the same as DeleteDocument with the addition of +// DeleteCommentWithContext is the same as DeleteComment with the addition of // the ability to pass a context and additional request options. // -// See DeleteDocument for details on how to use this API operation. +// See DeleteComment for details on how to use this API operation. // // The context must be non-nil and will be used for request cancellation. If // the context is nil a panic will occur. In the future the SDK may create // sub-contexts for http.Requests. See https://golang.org/pkg/context/ // for more information on using Contexts. -func (c *WorkDocs) DeleteDocumentWithContext(ctx aws.Context, input *DeleteDocumentInput, opts ...request.Option) (*DeleteDocumentOutput, error) { - req, out := c.DeleteDocumentRequest(input) +func (c *WorkDocs) DeleteCommentWithContext(ctx aws.Context, input *DeleteCommentInput, opts ...request.Option) (*DeleteCommentOutput, error) { + req, out := c.DeleteCommentRequest(input) req.SetContext(ctx) req.ApplyOptions(opts...) return out, req.Send() } -const opDeleteFolder = "DeleteFolder" +const opDeleteCustomMetadata = "DeleteCustomMetadata" -// DeleteFolderRequest generates a "aws/request.Request" representing the -// client's request for the DeleteFolder operation. The "output" return +// DeleteCustomMetadataRequest generates a "aws/request.Request" representing the +// client's request for the DeleteCustomMetadata operation. The "output" return // value can be used to capture response data after the request's "Send" method // is called. // -// See DeleteFolder for usage and error information. +// See DeleteCustomMetadata for usage and error information. // // Creating a request object using this method should be used when you want to inject // custom logic into the request's lifecycle using a custom handler, or if you want to // access properties on the request object before or after sending the request. If -// you just want the service response, call the DeleteFolder method directly +// you just want the service response, call the DeleteCustomMetadata method directly // instead. // // Note: You must call the "Send" method on the returned request object in order // to execute the request. // -// // Example sending a request using the DeleteFolderRequest method. -// req, resp := client.DeleteFolderRequest(params) +// // Example sending a request using the DeleteCustomMetadataRequest method. +// req, resp := client.DeleteCustomMetadataRequest(params) // // err := req.Send() // if err == nil { // resp is now filled // fmt.Println(resp) // } // -// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteFolder -func (c *WorkDocs) DeleteFolderRequest(input *DeleteFolderInput) (req *request.Request, output *DeleteFolderOutput) { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCustomMetadata +func (c *WorkDocs) DeleteCustomMetadataRequest(input *DeleteCustomMetadataInput) (req *request.Request, output *DeleteCustomMetadataOutput) { + op := &request.Operation{ + Name: opDeleteCustomMetadata, + HTTPMethod: "DELETE", + HTTPPath: "/api/v1/resources/{ResourceId}/customMetadata", + } + + if input == nil { + input = &DeleteCustomMetadataInput{} + } + + output = &DeleteCustomMetadataOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteCustomMetadata API operation for Amazon WorkDocs. +// +// Deletes custom metadata from the specified resource. +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation DeleteCustomMetadata for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeProhibitedStateException "ProhibitedStateException" +// The specified document version is not in the INITIALIZED state. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCustomMetadata +func (c *WorkDocs) DeleteCustomMetadata(input *DeleteCustomMetadataInput) (*DeleteCustomMetadataOutput, error) { + req, out := c.DeleteCustomMetadataRequest(input) + return out, req.Send() +} + +// DeleteCustomMetadataWithContext is the same as DeleteCustomMetadata with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteCustomMetadata for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) DeleteCustomMetadataWithContext(ctx aws.Context, input *DeleteCustomMetadataInput, opts ...request.Option) (*DeleteCustomMetadataOutput, error) { + req, out := c.DeleteCustomMetadataRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteDocument = "DeleteDocument" + +// DeleteDocumentRequest generates a "aws/request.Request" representing the +// client's request for the DeleteDocument operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DeleteDocument for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DeleteDocument method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DeleteDocumentRequest method. +// req, resp := client.DeleteDocumentRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteDocument +func (c *WorkDocs) DeleteDocumentRequest(input *DeleteDocumentInput) (req *request.Request, output *DeleteDocumentOutput) { + op := &request.Operation{ + Name: opDeleteDocument, + HTTPMethod: "DELETE", + HTTPPath: "/api/v1/documents/{DocumentId}", + } + + if input == nil { + input = &DeleteDocumentInput{} + } + + output = &DeleteDocumentOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler) + req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeleteDocument API operation for Amazon WorkDocs. +// +// Permanently deletes the specified document and its associated metadata. +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation DeleteDocument for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeProhibitedStateException "ProhibitedStateException" +// The specified document version is not in the INITIALIZED state. +// +// * ErrCodeConcurrentModificationException "ConcurrentModificationException" +// The resource hierarchy is changing. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteDocument +func (c *WorkDocs) DeleteDocument(input *DeleteDocumentInput) (*DeleteDocumentOutput, error) { + req, out := c.DeleteDocumentRequest(input) + return out, req.Send() +} + +// DeleteDocumentWithContext is the same as DeleteDocument with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteDocument for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) DeleteDocumentWithContext(ctx aws.Context, input *DeleteDocumentInput, opts ...request.Option) (*DeleteDocumentOutput, error) { + req, out := c.DeleteDocumentRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteFolder = "DeleteFolder" + +// DeleteFolderRequest generates a "aws/request.Request" representing the +// client's request for the DeleteFolder operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DeleteFolder for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DeleteFolder method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DeleteFolderRequest method. +// req, resp := client.DeleteFolderRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteFolder +func (c *WorkDocs) DeleteFolderRequest(input *DeleteFolderInput) (req *request.Request, output *DeleteFolderOutput) { op := &request.Operation{ Name: opDeleteFolder, HTTPMethod: "DELETE", @@ -986,6 +1486,100 @@ func (c *WorkDocs) DeleteFolderContentsWithContext(ctx aws.Context, input *Delet return out, req.Send() } +const opDeleteLabels = "DeleteLabels" + +// DeleteLabelsRequest generates a "aws/request.Request" representing the +// client's request for the DeleteLabels operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DeleteLabels for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DeleteLabels method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DeleteLabelsRequest method. +// req, resp := client.DeleteLabelsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteLabels +func (c *WorkDocs) DeleteLabelsRequest(input *DeleteLabelsInput) (req *request.Request, output *DeleteLabelsOutput) { + op := &request.Operation{ + Name: opDeleteLabels, + HTTPMethod: "DELETE", + HTTPPath: "/api/v1/resources/{ResourceId}/labels", + } + + if input == nil { + input = &DeleteLabelsInput{} + } + + output = &DeleteLabelsOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteLabels API operation for Amazon WorkDocs. +// +// Deletes the specified list of labels from a resource. +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation DeleteLabels for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteLabels +func (c *WorkDocs) DeleteLabels(input *DeleteLabelsInput) (*DeleteLabelsOutput, error) { + req, out := c.DeleteLabelsRequest(input) + return out, req.Send() +} + +// DeleteLabelsWithContext is the same as DeleteLabels with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteLabels for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) DeleteLabelsWithContext(ctx aws.Context, input *DeleteLabelsInput, opts ...request.Option) (*DeleteLabelsOutput, error) { + req, out := c.DeleteLabelsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDeleteNotificationSubscription = "DeleteNotificationSubscription" // DeleteNotificationSubscriptionRequest generates a "aws/request.Request" representing the @@ -1173,6 +1767,103 @@ func (c *WorkDocs) DeleteUserWithContext(ctx aws.Context, input *DeleteUserInput return out, req.Send() } +const opDescribeComments = "DescribeComments" + +// DescribeCommentsRequest generates a "aws/request.Request" representing the +// client's request for the DescribeComments operation. The "output" return +// value can be used to capture response data after the request's "Send" method +// is called. +// +// See DescribeComments for usage and error information. +// +// Creating a request object using this method should be used when you want to inject +// custom logic into the request's lifecycle using a custom handler, or if you want to +// access properties on the request object before or after sending the request. If +// you just want the service response, call the DescribeComments method directly +// instead. +// +// Note: You must call the "Send" method on the returned request object in order +// to execute the request. +// +// // Example sending a request using the DescribeCommentsRequest method. +// req, resp := client.DescribeCommentsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DescribeComments +func (c *WorkDocs) DescribeCommentsRequest(input *DescribeCommentsInput) (req *request.Request, output *DescribeCommentsOutput) { + op := &request.Operation{ + Name: opDescribeComments, + HTTPMethod: "GET", + HTTPPath: "/api/v1/documents/{DocumentId}/versions/{VersionId}/comments", + } + + if input == nil { + input = &DescribeCommentsInput{} + } + + output = &DescribeCommentsOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeComments API operation for Amazon WorkDocs. +// +// List all the comments for the specified document version. +// +// 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. +// +// See the AWS API reference guide for Amazon WorkDocs's +// API operation DescribeComments for usage and error information. +// +// Returned Error Codes: +// * ErrCodeEntityNotExistsException "EntityNotExistsException" +// The resource does not exist. +// +// * ErrCodeProhibitedStateException "ProhibitedStateException" +// The specified document version is not in the INITIALIZED state. +// +// * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" +// The operation is not permitted. +// +// * ErrCodeUnauthorizedResourceAccessException "UnauthorizedResourceAccessException" +// The caller does not have access to perform the action on the resource. +// +// * ErrCodeFailedDependencyException "FailedDependencyException" +// The AWS Directory Service cannot reach an on-premises instance. Or a dependency +// under the control of the organization is failing, such as a connected active +// directory. +// +// * ErrCodeServiceUnavailableException "ServiceUnavailableException" +// One or more of the dependencies is unavailable. +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DescribeComments +func (c *WorkDocs) DescribeComments(input *DescribeCommentsInput) (*DescribeCommentsOutput, error) { + req, out := c.DescribeCommentsRequest(input) + return out, req.Send() +} + +// DescribeCommentsWithContext is the same as DescribeComments with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeComments for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *WorkDocs) DescribeCommentsWithContext(ctx aws.Context, input *DescribeCommentsInput, opts ...request.Option) (*DescribeCommentsOutput, error) { + req, out := c.DescribeCommentsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDescribeDocumentVersions = "DescribeDocumentVersions" // DescribeDocumentVersionsRequest generates a "aws/request.Request" representing the @@ -1383,7 +2074,7 @@ func (c *WorkDocs) DescribeFolderContentsRequest(input *DescribeFolderContentsIn // DescribeFolderContents API operation for Amazon WorkDocs. // // Describes the contents of the specified folder, including its documents and -// sub-folders. +// subfolders. // // By default, Amazon WorkDocs returns the first 100 active document and folder // metadata items. If there are more results, the response includes a marker @@ -1867,7 +2558,7 @@ func (c *WorkDocs) GetDocumentRequest(input *GetDocumentInput) (req *request.Req // GetDocument API operation for Amazon WorkDocs. // -// Retrieves the specified document object. +// Retrieves details of a document. // // 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 @@ -2407,6 +3098,12 @@ func (c *WorkDocs) InitiateDocumentVersionUploadRequest(input *InitiateDocumentV // * ErrCodeServiceUnavailableException "ServiceUnavailableException" // One or more of the dependencies is unavailable. // +// * ErrCodeDraftUploadOutOfSyncException "DraftUploadOutOfSyncException" +// This exception is thrown when a valid checkout ID is not presented on document +// version upload calls for a document that has been checked out from Web client. +// +// * ErrCodeResourceAlreadyCheckedOutException "ResourceAlreadyCheckedOutException" +// // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/InitiateDocumentVersionUpload func (c *WorkDocs) InitiateDocumentVersionUpload(input *InitiateDocumentVersionUploadInput) (*InitiateDocumentVersionUploadOutput, error) { req, out := c.InitiateDocumentVersionUploadRequest(input) @@ -2662,8 +3359,8 @@ func (c *WorkDocs) UpdateDocumentRequest(input *UpdateDocumentInput) (req *reque // UpdateDocument API operation for Amazon WorkDocs. // -// Updates the specified attributes of the specified document. The user must -// have access to both the document and its parent folder, if applicable. +// Updates the specified attributes of a document. The user must have access +// to both the document and its parent folder, if applicable. // // 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 @@ -2680,7 +3377,7 @@ func (c *WorkDocs) UpdateDocumentRequest(input *UpdateDocumentInput) (req *reque // The resource already exists. // // * ErrCodeLimitExceededException "LimitExceededException" -// You've exceeded the maximum of 100,000 folders under the parent folder. +// The maximum of 100,000 folders under the parent folder has been exceeded. // // * ErrCodeProhibitedStateException "ProhibitedStateException" // The specified document version is not in the INITIALIZED state. @@ -2904,7 +3601,7 @@ func (c *WorkDocs) UpdateFolderRequest(input *UpdateFolderInput) (req *request.R // The resource hierarchy is changing. // // * ErrCodeLimitExceededException "LimitExceededException" -// You've exceeded the maximum of 100,000 folders under the parent folder. +// The maximum of 100,000 folders under the parent folder has been exceeded. // // * ErrCodeUnauthorizedOperationException "UnauthorizedOperationException" // The operation is not permitted. @@ -3047,6 +3744,10 @@ func (c *WorkDocs) UpdateUserWithContext(ctx aws.Context, input *UpdateUserInput type AbortDocumentVersionUploadInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -3071,6 +3772,9 @@ func (s AbortDocumentVersionUploadInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *AbortDocumentVersionUploadInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "AbortDocumentVersionUploadInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -3090,6 +3794,12 @@ func (s *AbortDocumentVersionUploadInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *AbortDocumentVersionUploadInput) SetAuthenticationToken(v string) *AbortDocumentVersionUploadInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *AbortDocumentVersionUploadInput) SetDocumentId(v string) *AbortDocumentVersionUploadInput { s.DocumentId = &v @@ -3121,6 +3831,10 @@ func (s AbortDocumentVersionUploadOutput) GoString() string { type ActivateUserInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the user. // // UserId is a required field @@ -3140,6 +3854,9 @@ func (s ActivateUserInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *ActivateUserInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "ActivateUserInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.UserId == nil { invalidParams.Add(request.NewErrParamRequired("UserId")) } @@ -3153,6 +3870,12 @@ func (s *ActivateUserInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *ActivateUserInput) SetAuthenticationToken(v string) *ActivateUserInput { + s.AuthenticationToken = &v + return s +} + // SetUserId sets the UserId field's value. func (s *ActivateUserInput) SetUserId(v string) *ActivateUserInput { s.UserId = &v @@ -3187,6 +3910,10 @@ func (s *ActivateUserOutput) SetUser(v *User) *ActivateUserOutput { type AddResourcePermissionsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The users, groups, or organization being granted permission. // // Principals is a required field @@ -3211,6 +3938,9 @@ func (s AddResourcePermissionsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *AddResourcePermissionsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "AddResourcePermissionsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.Principals == nil { invalidParams.Add(request.NewErrParamRequired("Principals")) } @@ -3237,6 +3967,12 @@ func (s *AddResourcePermissionsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *AddResourcePermissionsInput) SetAuthenticationToken(v string) *AddResourcePermissionsInput { + s.AuthenticationToken = &v + return s +} + // SetPrincipals sets the Principals field's value. func (s *AddResourcePermissionsInput) SetPrincipals(v []*SharePrincipal) *AddResourcePermissionsInput { s.Principals = v @@ -3273,10 +4009,374 @@ func (s *AddResourcePermissionsOutput) SetShareResults(v []*ShareResult) *AddRes return s } +// Describes a comment. +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/Comment +type Comment struct { + _ struct{} `type:"structure"` + + // The ID of the comment. + // + // CommentId is a required field + CommentId *string `min:"1" type:"string" required:"true"` + + // The details of the user who made the comment. + Contributor *User `type:"structure"` + + // The time that the comment was created. + CreatedTimestamp *time.Time `type:"timestamp" timestampFormat:"unix"` + + // The ID of the parent comment. + ParentId *string `min:"1" type:"string"` + + // If the comment is a reply to another user's comment, this field contains + // the user ID of the user being replied to. + RecipientId *string `min:"1" type:"string"` + + // The status of the comment. + Status *string `type:"string" enum:"CommentStatusType"` + + // The text of the comment. + Text *string `min:"1" type:"string"` + + // The ID of the root comment in the thread. + ThreadId *string `min:"1" type:"string"` + + // The visibility of the comment. Options are either PRIVATE, where the comment + // is visible only to the comment author and document owner and co-owners, or + // PUBLIC, where the comment is visible to document owners, co-owners, and contributors. + Visibility *string `type:"string" enum:"CommentVisibilityType"` +} + +// String returns the string representation +func (s Comment) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Comment) GoString() string { + return s.String() +} + +// SetCommentId sets the CommentId field's value. +func (s *Comment) SetCommentId(v string) *Comment { + s.CommentId = &v + return s +} + +// SetContributor sets the Contributor field's value. +func (s *Comment) SetContributor(v *User) *Comment { + s.Contributor = v + return s +} + +// SetCreatedTimestamp sets the CreatedTimestamp field's value. +func (s *Comment) SetCreatedTimestamp(v time.Time) *Comment { + s.CreatedTimestamp = &v + return s +} + +// SetParentId sets the ParentId field's value. +func (s *Comment) SetParentId(v string) *Comment { + s.ParentId = &v + return s +} + +// SetRecipientId sets the RecipientId field's value. +func (s *Comment) SetRecipientId(v string) *Comment { + s.RecipientId = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *Comment) SetStatus(v string) *Comment { + s.Status = &v + return s +} + +// SetText sets the Text field's value. +func (s *Comment) SetText(v string) *Comment { + s.Text = &v + return s +} + +// SetThreadId sets the ThreadId field's value. +func (s *Comment) SetThreadId(v string) *Comment { + s.ThreadId = &v + return s +} + +// SetVisibility sets the Visibility field's value. +func (s *Comment) SetVisibility(v string) *Comment { + s.Visibility = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCommentRequest +type CreateCommentInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // The ID of the document. + // + // DocumentId is a required field + DocumentId *string `location:"uri" locationName:"DocumentId" min:"1" type:"string" required:"true"` + + // Set this parameter to TRUE to send an email out to the document collaborators + // after the comment is created. + NotifyCollaborators *bool `type:"boolean"` + + // The ID of the parent comment. + ParentId *string `min:"1" type:"string"` + + // The text of the comment. + // + // Text is a required field + Text *string `min:"1" type:"string" required:"true"` + + // The ID of the root comment in the thread. + ThreadId *string `min:"1" type:"string"` + + // The ID of the document version. + // + // VersionId is a required field + VersionId *string `location:"uri" locationName:"VersionId" min:"1" type:"string" required:"true"` + + // The visibility of the comment. Options are either PRIVATE, where the comment + // is visible only to the comment author and document owner and co-owners, or + // PUBLIC, where the comment is visible to document owners, co-owners, and contributors. + Visibility *string `type:"string" enum:"CommentVisibilityType"` +} + +// String returns the string representation +func (s CreateCommentInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateCommentInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateCommentInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateCommentInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.DocumentId == nil { + invalidParams.Add(request.NewErrParamRequired("DocumentId")) + } + if s.DocumentId != nil && len(*s.DocumentId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("DocumentId", 1)) + } + if s.ParentId != nil && len(*s.ParentId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ParentId", 1)) + } + if s.Text == nil { + invalidParams.Add(request.NewErrParamRequired("Text")) + } + if s.Text != nil && len(*s.Text) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Text", 1)) + } + if s.ThreadId != nil && len(*s.ThreadId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ThreadId", 1)) + } + if s.VersionId == nil { + invalidParams.Add(request.NewErrParamRequired("VersionId")) + } + if s.VersionId != nil && len(*s.VersionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *CreateCommentInput) SetAuthenticationToken(v string) *CreateCommentInput { + s.AuthenticationToken = &v + return s +} + +// SetDocumentId sets the DocumentId field's value. +func (s *CreateCommentInput) SetDocumentId(v string) *CreateCommentInput { + s.DocumentId = &v + return s +} + +// SetNotifyCollaborators sets the NotifyCollaborators field's value. +func (s *CreateCommentInput) SetNotifyCollaborators(v bool) *CreateCommentInput { + s.NotifyCollaborators = &v + return s +} + +// SetParentId sets the ParentId field's value. +func (s *CreateCommentInput) SetParentId(v string) *CreateCommentInput { + s.ParentId = &v + return s +} + +// SetText sets the Text field's value. +func (s *CreateCommentInput) SetText(v string) *CreateCommentInput { + s.Text = &v + return s +} + +// SetThreadId sets the ThreadId field's value. +func (s *CreateCommentInput) SetThreadId(v string) *CreateCommentInput { + s.ThreadId = &v + return s +} + +// SetVersionId sets the VersionId field's value. +func (s *CreateCommentInput) SetVersionId(v string) *CreateCommentInput { + s.VersionId = &v + return s +} + +// SetVisibility sets the Visibility field's value. +func (s *CreateCommentInput) SetVisibility(v string) *CreateCommentInput { + s.Visibility = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCommentResponse +type CreateCommentOutput struct { + _ struct{} `type:"structure"` + + // The comment that has been created. + Comment *Comment `type:"structure"` +} + +// String returns the string representation +func (s CreateCommentOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateCommentOutput) GoString() string { + return s.String() +} + +// SetComment sets the Comment field's value. +func (s *CreateCommentOutput) SetComment(v *Comment) *CreateCommentOutput { + s.Comment = v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCustomMetadataRequest +type CreateCustomMetadataInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // Custom metadata in the form of name-value pairs. + // + // CustomMetadata is a required field + CustomMetadata map[string]*string `min:"1" type:"map" required:"true"` + + // The ID of the resource. + // + // ResourceId is a required field + ResourceId *string `location:"uri" locationName:"ResourceId" min:"1" type:"string" required:"true"` + + // The ID of the version, if the custom metadata is being added to a document + // version. + VersionId *string `location:"querystring" locationName:"versionid" min:"1" type:"string"` +} + +// String returns the string representation +func (s CreateCustomMetadataInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateCustomMetadataInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateCustomMetadataInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateCustomMetadataInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.CustomMetadata == nil { + invalidParams.Add(request.NewErrParamRequired("CustomMetadata")) + } + if s.CustomMetadata != nil && len(s.CustomMetadata) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CustomMetadata", 1)) + } + if s.ResourceId == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceId")) + } + if s.ResourceId != nil && len(*s.ResourceId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceId", 1)) + } + if s.VersionId != nil && len(*s.VersionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *CreateCustomMetadataInput) SetAuthenticationToken(v string) *CreateCustomMetadataInput { + s.AuthenticationToken = &v + return s +} + +// SetCustomMetadata sets the CustomMetadata field's value. +func (s *CreateCustomMetadataInput) SetCustomMetadata(v map[string]*string) *CreateCustomMetadataInput { + s.CustomMetadata = v + return s +} + +// SetResourceId sets the ResourceId field's value. +func (s *CreateCustomMetadataInput) SetResourceId(v string) *CreateCustomMetadataInput { + s.ResourceId = &v + return s +} + +// SetVersionId sets the VersionId field's value. +func (s *CreateCustomMetadataInput) SetVersionId(v string) *CreateCustomMetadataInput { + s.VersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateCustomMetadataResponse +type CreateCustomMetadataOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s CreateCustomMetadataOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateCustomMetadataOutput) GoString() string { + return s.String() +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateFolderRequest type CreateFolderInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The name of the new folder. Name *string `min:"1" type:"string"` @@ -3299,6 +4399,9 @@ func (s CreateFolderInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *CreateFolderInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "CreateFolderInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.Name != nil && len(*s.Name) < 1 { invalidParams.Add(request.NewErrParamMinLen("Name", 1)) } @@ -3315,6 +4418,12 @@ func (s *CreateFolderInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *CreateFolderInput) SetAuthenticationToken(v string) *CreateFolderInput { + s.AuthenticationToken = &v + return s +} + // SetName sets the Name field's value. func (s *CreateFolderInput) SetName(v string) *CreateFolderInput { s.Name = &v @@ -3327,30 +4436,114 @@ func (s *CreateFolderInput) SetParentFolderId(v string) *CreateFolderInput { return s } -// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateFolderResponse -type CreateFolderOutput struct { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateFolderResponse +type CreateFolderOutput struct { + _ struct{} `type:"structure"` + + // The metadata of the folder. + Metadata *FolderMetadata `type:"structure"` +} + +// String returns the string representation +func (s CreateFolderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateFolderOutput) GoString() string { + return s.String() +} + +// SetMetadata sets the Metadata field's value. +func (s *CreateFolderOutput) SetMetadata(v *FolderMetadata) *CreateFolderOutput { + s.Metadata = v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateLabelsRequest +type CreateLabelsInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // List of labels to add to the resource. + // + // Labels is a required field + Labels []*string `type:"list" required:"true"` + + // The ID of the resource. + // + // ResourceId is a required field + ResourceId *string `location:"uri" locationName:"ResourceId" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateLabelsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateLabelsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateLabelsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateLabelsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.Labels == nil { + invalidParams.Add(request.NewErrParamRequired("Labels")) + } + if s.ResourceId == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceId")) + } + if s.ResourceId != nil && len(*s.ResourceId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *CreateLabelsInput) SetAuthenticationToken(v string) *CreateLabelsInput { + s.AuthenticationToken = &v + return s +} + +// SetLabels sets the Labels field's value. +func (s *CreateLabelsInput) SetLabels(v []*string) *CreateLabelsInput { + s.Labels = v + return s +} + +// SetResourceId sets the ResourceId field's value. +func (s *CreateLabelsInput) SetResourceId(v string) *CreateLabelsInput { + s.ResourceId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateLabelsResponse +type CreateLabelsOutput struct { _ struct{} `type:"structure"` - - // The metadata of the folder. - Metadata *FolderMetadata `type:"structure"` } // String returns the string representation -func (s CreateFolderOutput) String() string { +func (s CreateLabelsOutput) String() string { return awsutil.Prettify(s) } // GoString returns the string representation -func (s CreateFolderOutput) GoString() string { +func (s CreateLabelsOutput) GoString() string { return s.String() } -// SetMetadata sets the Metadata field's value. -func (s *CreateFolderOutput) SetMetadata(v *FolderMetadata) *CreateFolderOutput { - s.Metadata = v - return s -} - // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/CreateNotificationSubscriptionRequest type CreateNotificationSubscriptionInput struct { _ struct{} `type:"structure"` @@ -3468,6 +4661,13 @@ func (s *CreateNotificationSubscriptionOutput) SetSubscription(v *Subscription) type CreateUserInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // The email address of the user. + EmailAddress *string `min:"1" type:"string"` + // The given name of the user. // // GivenName is a required field @@ -3511,6 +4711,12 @@ func (s CreateUserInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *CreateUserInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "CreateUserInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.EmailAddress != nil && len(*s.EmailAddress) < 1 { + invalidParams.Add(request.NewErrParamMinLen("EmailAddress", 1)) + } if s.GivenName == nil { invalidParams.Add(request.NewErrParamRequired("GivenName")) } @@ -3548,6 +4754,18 @@ func (s *CreateUserInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *CreateUserInput) SetAuthenticationToken(v string) *CreateUserInput { + s.AuthenticationToken = &v + return s +} + +// SetEmailAddress sets the EmailAddress field's value. +func (s *CreateUserInput) SetEmailAddress(v string) *CreateUserInput { + s.EmailAddress = &v + return s +} + // SetGivenName sets the GivenName field's value. func (s *CreateUserInput) SetGivenName(v string) *CreateUserInput { s.GivenName = &v @@ -3618,6 +4836,10 @@ func (s *CreateUserOutput) SetUser(v *User) *CreateUserOutput { type DeactivateUserInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the user. // // UserId is a required field @@ -3637,6 +4859,9 @@ func (s DeactivateUserInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeactivateUserInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeactivateUserInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.UserId == nil { invalidParams.Add(request.NewErrParamRequired("UserId")) } @@ -3650,6 +4875,12 @@ func (s *DeactivateUserInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeactivateUserInput) SetAuthenticationToken(v string) *DeactivateUserInput { + s.AuthenticationToken = &v + return s +} + // SetUserId sets the UserId field's value. func (s *DeactivateUserInput) SetUserId(v string) *DeactivateUserInput { s.UserId = &v @@ -3671,10 +4902,220 @@ func (s DeactivateUserOutput) GoString() string { return s.String() } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCommentRequest +type DeleteCommentInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // The ID of the comment. + // + // CommentId is a required field + CommentId *string `location:"uri" locationName:"CommentId" min:"1" type:"string" required:"true"` + + // The ID of the document. + // + // DocumentId is a required field + DocumentId *string `location:"uri" locationName:"DocumentId" min:"1" type:"string" required:"true"` + + // The ID of the document version. + // + // VersionId is a required field + VersionId *string `location:"uri" locationName:"VersionId" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteCommentInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteCommentInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteCommentInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteCommentInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.CommentId == nil { + invalidParams.Add(request.NewErrParamRequired("CommentId")) + } + if s.CommentId != nil && len(*s.CommentId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CommentId", 1)) + } + if s.DocumentId == nil { + invalidParams.Add(request.NewErrParamRequired("DocumentId")) + } + if s.DocumentId != nil && len(*s.DocumentId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("DocumentId", 1)) + } + if s.VersionId == nil { + invalidParams.Add(request.NewErrParamRequired("VersionId")) + } + if s.VersionId != nil && len(*s.VersionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteCommentInput) SetAuthenticationToken(v string) *DeleteCommentInput { + s.AuthenticationToken = &v + return s +} + +// SetCommentId sets the CommentId field's value. +func (s *DeleteCommentInput) SetCommentId(v string) *DeleteCommentInput { + s.CommentId = &v + return s +} + +// SetDocumentId sets the DocumentId field's value. +func (s *DeleteCommentInput) SetDocumentId(v string) *DeleteCommentInput { + s.DocumentId = &v + return s +} + +// SetVersionId sets the VersionId field's value. +func (s *DeleteCommentInput) SetVersionId(v string) *DeleteCommentInput { + s.VersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCommentOutput +type DeleteCommentOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteCommentOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteCommentOutput) GoString() string { + return s.String() +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCustomMetadataRequest +type DeleteCustomMetadataInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // Flag to indicate removal of all custom metadata properties from the specified + // resource. + DeleteAll *bool `location:"querystring" locationName:"deleteAll" type:"boolean"` + + // List of properties to remove. + Keys []*string `location:"querystring" locationName:"keys" type:"list"` + + // The ID of the resource, either a document or folder. + // + // ResourceId is a required field + ResourceId *string `location:"uri" locationName:"ResourceId" min:"1" type:"string" required:"true"` + + // The ID of the version, if the custom metadata is being deleted from a document + // version. + VersionId *string `location:"querystring" locationName:"versionId" min:"1" type:"string"` +} + +// String returns the string representation +func (s DeleteCustomMetadataInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteCustomMetadataInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteCustomMetadataInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteCustomMetadataInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.ResourceId == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceId")) + } + if s.ResourceId != nil && len(*s.ResourceId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceId", 1)) + } + if s.VersionId != nil && len(*s.VersionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteCustomMetadataInput) SetAuthenticationToken(v string) *DeleteCustomMetadataInput { + s.AuthenticationToken = &v + return s +} + +// SetDeleteAll sets the DeleteAll field's value. +func (s *DeleteCustomMetadataInput) SetDeleteAll(v bool) *DeleteCustomMetadataInput { + s.DeleteAll = &v + return s +} + +// SetKeys sets the Keys field's value. +func (s *DeleteCustomMetadataInput) SetKeys(v []*string) *DeleteCustomMetadataInput { + s.Keys = v + return s +} + +// SetResourceId sets the ResourceId field's value. +func (s *DeleteCustomMetadataInput) SetResourceId(v string) *DeleteCustomMetadataInput { + s.ResourceId = &v + return s +} + +// SetVersionId sets the VersionId field's value. +func (s *DeleteCustomMetadataInput) SetVersionId(v string) *DeleteCustomMetadataInput { + s.VersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteCustomMetadataResponse +type DeleteCustomMetadataOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteCustomMetadataOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteCustomMetadataOutput) GoString() string { + return s.String() +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteDocumentRequest type DeleteDocumentInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -3694,6 +5135,9 @@ func (s DeleteDocumentInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeleteDocumentInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeleteDocumentInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -3707,6 +5151,12 @@ func (s *DeleteDocumentInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteDocumentInput) SetAuthenticationToken(v string) *DeleteDocumentInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *DeleteDocumentInput) SetDocumentId(v string) *DeleteDocumentInput { s.DocumentId = &v @@ -3732,6 +5182,10 @@ func (s DeleteDocumentOutput) GoString() string { type DeleteFolderContentsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the folder. // // FolderId is a required field @@ -3751,6 +5205,9 @@ func (s DeleteFolderContentsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeleteFolderContentsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeleteFolderContentsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.FolderId == nil { invalidParams.Add(request.NewErrParamRequired("FolderId")) } @@ -3764,6 +5221,12 @@ func (s *DeleteFolderContentsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteFolderContentsInput) SetAuthenticationToken(v string) *DeleteFolderContentsInput { + s.AuthenticationToken = &v + return s +} + // SetFolderId sets the FolderId field's value. func (s *DeleteFolderContentsInput) SetFolderId(v string) *DeleteFolderContentsInput { s.FolderId = &v @@ -3789,6 +5252,10 @@ func (s DeleteFolderContentsOutput) GoString() string { type DeleteFolderInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the folder. // // FolderId is a required field @@ -3808,6 +5275,9 @@ func (s DeleteFolderInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeleteFolderInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeleteFolderInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.FolderId == nil { invalidParams.Add(request.NewErrParamRequired("FolderId")) } @@ -3815,30 +5285,124 @@ func (s *DeleteFolderInput) Validate() error { invalidParams.Add(request.NewErrParamMinLen("FolderId", 1)) } - if invalidParams.Len() > 0 { - return invalidParams - } - return nil + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteFolderInput) SetAuthenticationToken(v string) *DeleteFolderInput { + s.AuthenticationToken = &v + return s +} + +// SetFolderId sets the FolderId field's value. +func (s *DeleteFolderInput) SetFolderId(v string) *DeleteFolderInput { + s.FolderId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteFolderOutput +type DeleteFolderOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteFolderOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteFolderOutput) GoString() string { + return s.String() +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteLabelsRequest +type DeleteLabelsInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // Flag to request removal of all labels from the specified resource. + DeleteAll *bool `location:"querystring" locationName:"deleteAll" type:"boolean"` + + // List of labels to delete from the resource. + Labels []*string `location:"querystring" locationName:"labels" type:"list"` + + // The ID of the resource. + // + // ResourceId is a required field + ResourceId *string `location:"uri" locationName:"ResourceId" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteLabelsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteLabelsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteLabelsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteLabelsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.ResourceId == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceId")) + } + if s.ResourceId != nil && len(*s.ResourceId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteLabelsInput) SetAuthenticationToken(v string) *DeleteLabelsInput { + s.AuthenticationToken = &v + return s +} + +// SetDeleteAll sets the DeleteAll field's value. +func (s *DeleteLabelsInput) SetDeleteAll(v bool) *DeleteLabelsInput { + s.DeleteAll = &v + return s +} + +// SetLabels sets the Labels field's value. +func (s *DeleteLabelsInput) SetLabels(v []*string) *DeleteLabelsInput { + s.Labels = v + return s } -// SetFolderId sets the FolderId field's value. -func (s *DeleteFolderInput) SetFolderId(v string) *DeleteFolderInput { - s.FolderId = &v +// SetResourceId sets the ResourceId field's value. +func (s *DeleteLabelsInput) SetResourceId(v string) *DeleteLabelsInput { + s.ResourceId = &v return s } -// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteFolderOutput -type DeleteFolderOutput struct { +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DeleteLabelsResponse +type DeleteLabelsOutput struct { _ struct{} `type:"structure"` } // String returns the string representation -func (s DeleteFolderOutput) String() string { +func (s DeleteLabelsOutput) String() string { return awsutil.Prettify(s) } // GoString returns the string representation -func (s DeleteFolderOutput) GoString() string { +func (s DeleteLabelsOutput) GoString() string { return s.String() } @@ -3920,6 +5484,10 @@ func (s DeleteNotificationSubscriptionOutput) GoString() string { type DeleteUserInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the user. // // UserId is a required field @@ -3939,6 +5507,9 @@ func (s DeleteUserInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DeleteUserInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DeleteUserInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.UserId == nil { invalidParams.Add(request.NewErrParamRequired("UserId")) } @@ -3952,6 +5523,12 @@ func (s *DeleteUserInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DeleteUserInput) SetAuthenticationToken(v string) *DeleteUserInput { + s.AuthenticationToken = &v + return s +} + // SetUserId sets the UserId field's value. func (s *DeleteUserInput) SetUserId(v string) *DeleteUserInput { s.UserId = &v @@ -3973,10 +5550,145 @@ func (s DeleteUserOutput) GoString() string { return s.String() } +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DescribeCommentsRequest +type DescribeCommentsInput struct { + _ struct{} `type:"structure"` + + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // The ID of the document. + // + // DocumentId is a required field + DocumentId *string `location:"uri" locationName:"DocumentId" min:"1" type:"string" required:"true"` + + // The maximum number of items to return. + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + // The marker for the next set of results. This marker was received from a previous + // call. + Marker *string `location:"querystring" locationName:"marker" min:"1" type:"string"` + + // The ID of the document version. + // + // VersionId is a required field + VersionId *string `location:"uri" locationName:"VersionId" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeCommentsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeCommentsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeCommentsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeCommentsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } + if s.DocumentId == nil { + invalidParams.Add(request.NewErrParamRequired("DocumentId")) + } + if s.DocumentId != nil && len(*s.DocumentId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("DocumentId", 1)) + } + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.Marker != nil && len(*s.Marker) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Marker", 1)) + } + if s.VersionId == nil { + invalidParams.Add(request.NewErrParamRequired("VersionId")) + } + if s.VersionId != nil && len(*s.VersionId) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VersionId", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DescribeCommentsInput) SetAuthenticationToken(v string) *DescribeCommentsInput { + s.AuthenticationToken = &v + return s +} + +// SetDocumentId sets the DocumentId field's value. +func (s *DescribeCommentsInput) SetDocumentId(v string) *DescribeCommentsInput { + s.DocumentId = &v + return s +} + +// SetLimit sets the Limit field's value. +func (s *DescribeCommentsInput) SetLimit(v int64) *DescribeCommentsInput { + s.Limit = &v + return s +} + +// SetMarker sets the Marker field's value. +func (s *DescribeCommentsInput) SetMarker(v string) *DescribeCommentsInput { + s.Marker = &v + return s +} + +// SetVersionId sets the VersionId field's value. +func (s *DescribeCommentsInput) SetVersionId(v string) *DescribeCommentsInput { + s.VersionId = &v + return s +} + +// Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DescribeCommentsResponse +type DescribeCommentsOutput struct { + _ struct{} `type:"structure"` + + // The list of comments for the specified document version. + Comments []*Comment `type:"list"` + + // The marker for the next set of results. This marker was received from a previous + // call. + Marker *string `min:"1" type:"string"` +} + +// String returns the string representation +func (s DescribeCommentsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeCommentsOutput) GoString() string { + return s.String() +} + +// SetComments sets the Comments field's value. +func (s *DescribeCommentsOutput) SetComments(v []*Comment) *DescribeCommentsOutput { + s.Comments = v + return s +} + +// SetMarker sets the Marker field's value. +func (s *DescribeCommentsOutput) SetMarker(v string) *DescribeCommentsOutput { + s.Marker = &v + return s +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/DescribeDocumentVersionsRequest type DescribeDocumentVersionsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -4011,6 +5723,9 @@ func (s DescribeDocumentVersionsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DescribeDocumentVersionsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DescribeDocumentVersionsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -4036,6 +5751,12 @@ func (s *DescribeDocumentVersionsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DescribeDocumentVersionsInput) SetAuthenticationToken(v string) *DescribeDocumentVersionsInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *DescribeDocumentVersionsInput) SetDocumentId(v string) *DescribeDocumentVersionsInput { s.DocumentId = &v @@ -4104,6 +5825,10 @@ func (s *DescribeDocumentVersionsOutput) SetMarker(v string) *DescribeDocumentVe type DescribeFolderContentsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the folder. // // FolderId is a required field @@ -4115,8 +5840,8 @@ type DescribeFolderContentsInput struct { // The maximum number of items to return with this call. Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` - // The marker for the next set of results. (You received this marker from a - // previous call.) + // The marker for the next set of results. This marker was received from a previous + // call. Marker *string `location:"querystring" locationName:"marker" min:"1" type:"string"` // The order for the contents of the folder. @@ -4142,6 +5867,9 @@ func (s DescribeFolderContentsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DescribeFolderContentsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DescribeFolderContentsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.FolderId == nil { invalidParams.Add(request.NewErrParamRequired("FolderId")) } @@ -4164,6 +5892,12 @@ func (s *DescribeFolderContentsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DescribeFolderContentsInput) SetAuthenticationToken(v string) *DescribeFolderContentsInput { + s.AuthenticationToken = &v + return s +} + // SetFolderId sets the FolderId field's value. func (s *DescribeFolderContentsInput) SetFolderId(v string) *DescribeFolderContentsInput { s.FolderId = &v @@ -4213,7 +5947,7 @@ type DescribeFolderContentsOutput struct { // The documents in the specified folder. Documents []*DocumentMetadata `type:"list"` - // The sub-folders in the specified folder. + // The subfolders in the specified folder. Folders []*FolderMetadata `type:"list"` // The marker to use when requesting the next set of results. If there are no @@ -4354,6 +6088,10 @@ func (s *DescribeNotificationSubscriptionsOutput) SetSubscriptions(v []*Subscrip type DescribeResourcePermissionsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The maximum number of items to return with this call. Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` @@ -4380,6 +6118,9 @@ func (s DescribeResourcePermissionsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DescribeResourcePermissionsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DescribeResourcePermissionsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.Limit != nil && *s.Limit < 1 { invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) } @@ -4399,6 +6140,12 @@ func (s *DescribeResourcePermissionsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DescribeResourcePermissionsInput) SetAuthenticationToken(v string) *DescribeResourcePermissionsInput { + s.AuthenticationToken = &v + return s +} + // SetLimit sets the Limit field's value. func (s *DescribeResourcePermissionsInput) SetLimit(v int64) *DescribeResourcePermissionsInput { s.Limit = &v @@ -4455,6 +6202,10 @@ func (s *DescribeResourcePermissionsOutput) SetPrincipals(v []*Principal) *Descr type DescribeUsersInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // A comma-separated list of values. Specify "STORAGE_METADATA" to include the // user storage quota and utilization information. Fields *string `location:"querystring" locationName:"fields" min:"1" type:"string"` @@ -4498,6 +6249,9 @@ func (s DescribeUsersInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *DescribeUsersInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "DescribeUsersInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.Fields != nil && len(*s.Fields) < 1 { invalidParams.Add(request.NewErrParamMinLen("Fields", 1)) } @@ -4523,6 +6277,12 @@ func (s *DescribeUsersInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *DescribeUsersInput) SetAuthenticationToken(v string) *DescribeUsersInput { + s.AuthenticationToken = &v + return s +} + // SetFields sets the Fields field's value. func (s *DescribeUsersInput) SetFields(v string) *DescribeUsersInput { s.Fields = &v @@ -4634,6 +6394,9 @@ type DocumentMetadata struct { // The ID of the document. Id *string `min:"1" type:"string"` + // List of labels on the document. + Labels []*string `type:"list"` + // The latest version of the document. LatestVersionMetadata *DocumentVersionMetadata `type:"structure"` @@ -4675,6 +6438,12 @@ func (s *DocumentMetadata) SetId(v string) *DocumentMetadata { return s } +// SetLabels sets the Labels field's value. +func (s *DocumentMetadata) SetLabels(v []*string) *DocumentMetadata { + s.Labels = v + return s +} + // SetLatestVersionMetadata sets the LatestVersionMetadata field's value. func (s *DocumentMetadata) SetLatestVersionMetadata(v *DocumentVersionMetadata) *DocumentMetadata { s.LatestVersionMetadata = v @@ -4846,6 +6615,11 @@ type FolderMetadata struct { // The ID of the folder. Id *string `min:"1" type:"string"` + // List of labels on the folder. + Labels []*string `type:"list"` + + LatestVersionSize *int64 `type:"long"` + // The time when the folder was updated. ModifiedTimestamp *time.Time `type:"timestamp" timestampFormat:"unix"` @@ -4860,6 +6634,8 @@ type FolderMetadata struct { // The unique identifier created from the subfolders and documents of the folder. Signature *string `type:"string"` + + Size *int64 `type:"long"` } // String returns the string representation @@ -4890,6 +6666,18 @@ func (s *FolderMetadata) SetId(v string) *FolderMetadata { return s } +// SetLabels sets the Labels field's value. +func (s *FolderMetadata) SetLabels(v []*string) *FolderMetadata { + s.Labels = v + return s +} + +// SetLatestVersionSize sets the LatestVersionSize field's value. +func (s *FolderMetadata) SetLatestVersionSize(v int64) *FolderMetadata { + s.LatestVersionSize = &v + return s +} + // SetModifiedTimestamp sets the ModifiedTimestamp field's value. func (s *FolderMetadata) SetModifiedTimestamp(v time.Time) *FolderMetadata { s.ModifiedTimestamp = &v @@ -4920,14 +6708,27 @@ func (s *FolderMetadata) SetSignature(v string) *FolderMetadata { return s } +// SetSize sets the Size field's value. +func (s *FolderMetadata) SetSize(v int64) *FolderMetadata { + s.Size = &v + return s +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/GetDocumentRequest type GetDocumentInput struct { _ struct{} `type:"structure"` - // The ID of the document object. + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + + // The ID of the document. // // DocumentId is a required field DocumentId *string `location:"uri" locationName:"DocumentId" min:"1" type:"string" required:"true"` + + // Set this to TRUE to include custom metadata in the response. + IncludeCustomMetadata *bool `location:"querystring" locationName:"includeCustomMetadata" type:"boolean"` } // String returns the string representation @@ -4943,6 +6744,9 @@ func (s GetDocumentInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetDocumentInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetDocumentInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -4956,17 +6760,32 @@ func (s *GetDocumentInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *GetDocumentInput) SetAuthenticationToken(v string) *GetDocumentInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *GetDocumentInput) SetDocumentId(v string) *GetDocumentInput { s.DocumentId = &v return s } +// SetIncludeCustomMetadata sets the IncludeCustomMetadata field's value. +func (s *GetDocumentInput) SetIncludeCustomMetadata(v bool) *GetDocumentInput { + s.IncludeCustomMetadata = &v + return s +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/GetDocumentResponse type GetDocumentOutput struct { _ struct{} `type:"structure"` - // The document object. + // The custom metadata on the document. + CustomMetadata map[string]*string `min:"1" type:"map"` + + // The metadata details of the document. Metadata *DocumentMetadata `type:"structure"` } @@ -4980,6 +6799,12 @@ func (s GetDocumentOutput) GoString() string { return s.String() } +// SetCustomMetadata sets the CustomMetadata field's value. +func (s *GetDocumentOutput) SetCustomMetadata(v map[string]*string) *GetDocumentOutput { + s.CustomMetadata = v + return s +} + // SetMetadata sets the Metadata field's value. func (s *GetDocumentOutput) SetMetadata(v *DocumentMetadata) *GetDocumentOutput { s.Metadata = v @@ -4990,13 +6815,17 @@ func (s *GetDocumentOutput) SetMetadata(v *DocumentMetadata) *GetDocumentOutput type GetDocumentPathInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field DocumentId *string `location:"uri" locationName:"DocumentId" min:"1" type:"string" required:"true"` - // A comma-separated list of values. Specify "NAME" to include the names of - // the parent folders. + // A comma-separated list of values. Specify NAME to include the names of the + // parent folders. Fields *string `location:"querystring" locationName:"fields" min:"1" type:"string"` // The maximum number of levels in the hierarchy to return. @@ -5019,6 +6848,9 @@ func (s GetDocumentPathInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetDocumentPathInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetDocumentPathInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -5041,6 +6873,12 @@ func (s *GetDocumentPathInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *GetDocumentPathInput) SetAuthenticationToken(v string) *GetDocumentPathInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *GetDocumentPathInput) SetDocumentId(v string) *GetDocumentPathInput { s.DocumentId = &v @@ -5093,6 +6931,10 @@ func (s *GetDocumentPathOutput) SetPath(v *ResourcePath) *GetDocumentPathOutput type GetDocumentVersionInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -5102,6 +6944,9 @@ type GetDocumentVersionInput struct { // source document. Fields *string `location:"querystring" locationName:"fields" min:"1" type:"string"` + // Set this to TRUE to include custom metadata in the response. + IncludeCustomMetadata *bool `location:"querystring" locationName:"includeCustomMetadata" type:"boolean"` + // The version ID of the document. // // VersionId is a required field @@ -5121,6 +6966,9 @@ func (s GetDocumentVersionInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetDocumentVersionInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetDocumentVersionInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -5143,6 +6991,12 @@ func (s *GetDocumentVersionInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *GetDocumentVersionInput) SetAuthenticationToken(v string) *GetDocumentVersionInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *GetDocumentVersionInput) SetDocumentId(v string) *GetDocumentVersionInput { s.DocumentId = &v @@ -5155,6 +7009,12 @@ func (s *GetDocumentVersionInput) SetFields(v string) *GetDocumentVersionInput { return s } +// SetIncludeCustomMetadata sets the IncludeCustomMetadata field's value. +func (s *GetDocumentVersionInput) SetIncludeCustomMetadata(v bool) *GetDocumentVersionInput { + s.IncludeCustomMetadata = &v + return s +} + // SetVersionId sets the VersionId field's value. func (s *GetDocumentVersionInput) SetVersionId(v string) *GetDocumentVersionInput { s.VersionId = &v @@ -5165,6 +7025,9 @@ func (s *GetDocumentVersionInput) SetVersionId(v string) *GetDocumentVersionInpu type GetDocumentVersionOutput struct { _ struct{} `type:"structure"` + // The custom metadata on the document version. + CustomMetadata map[string]*string `min:"1" type:"map"` + // The version metadata. Metadata *DocumentVersionMetadata `type:"structure"` } @@ -5179,6 +7042,12 @@ func (s GetDocumentVersionOutput) GoString() string { return s.String() } +// SetCustomMetadata sets the CustomMetadata field's value. +func (s *GetDocumentVersionOutput) SetCustomMetadata(v map[string]*string) *GetDocumentVersionOutput { + s.CustomMetadata = v + return s +} + // SetMetadata sets the Metadata field's value. func (s *GetDocumentVersionOutput) SetMetadata(v *DocumentVersionMetadata) *GetDocumentVersionOutput { s.Metadata = v @@ -5189,10 +7058,17 @@ func (s *GetDocumentVersionOutput) SetMetadata(v *DocumentVersionMetadata) *GetD type GetFolderInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the folder. // // FolderId is a required field FolderId *string `location:"uri" locationName:"FolderId" min:"1" type:"string" required:"true"` + + // Set to TRUE to include custom metadata in the response. + IncludeCustomMetadata *bool `location:"querystring" locationName:"includeCustomMetadata" type:"boolean"` } // String returns the string representation @@ -5208,6 +7084,9 @@ func (s GetFolderInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetFolderInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetFolderInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.FolderId == nil { invalidParams.Add(request.NewErrParamRequired("FolderId")) } @@ -5221,16 +7100,31 @@ func (s *GetFolderInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *GetFolderInput) SetAuthenticationToken(v string) *GetFolderInput { + s.AuthenticationToken = &v + return s +} + // SetFolderId sets the FolderId field's value. func (s *GetFolderInput) SetFolderId(v string) *GetFolderInput { s.FolderId = &v return s } +// SetIncludeCustomMetadata sets the IncludeCustomMetadata field's value. +func (s *GetFolderInput) SetIncludeCustomMetadata(v bool) *GetFolderInput { + s.IncludeCustomMetadata = &v + return s +} + // Please also see https://docs.aws.amazon.com/goto/WebAPI/workdocs-2016-05-01/GetFolderResponse type GetFolderOutput struct { _ struct{} `type:"structure"` + // The custom metadata on the folder. + CustomMetadata map[string]*string `min:"1" type:"map"` + // The metadata of the folder. Metadata *FolderMetadata `type:"structure"` } @@ -5245,6 +7139,12 @@ func (s GetFolderOutput) GoString() string { return s.String() } +// SetCustomMetadata sets the CustomMetadata field's value. +func (s *GetFolderOutput) SetCustomMetadata(v map[string]*string) *GetFolderOutput { + s.CustomMetadata = v + return s +} + // SetMetadata sets the Metadata field's value. func (s *GetFolderOutput) SetMetadata(v *FolderMetadata) *GetFolderOutput { s.Metadata = v @@ -5255,6 +7155,10 @@ func (s *GetFolderOutput) SetMetadata(v *FolderMetadata) *GetFolderOutput { type GetFolderPathInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // A comma-separated list of values. Specify "NAME" to include the names of // the parent folders. Fields *string `location:"querystring" locationName:"fields" min:"1" type:"string"` @@ -5284,6 +7188,9 @@ func (s GetFolderPathInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *GetFolderPathInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "GetFolderPathInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.Fields != nil && len(*s.Fields) < 1 { invalidParams.Add(request.NewErrParamMinLen("Fields", 1)) } @@ -5306,6 +7213,12 @@ func (s *GetFolderPathInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *GetFolderPathInput) SetAuthenticationToken(v string) *GetFolderPathInput { + s.AuthenticationToken = &v + return s +} + // SetFields sets the Fields field's value. func (s *GetFolderPathInput) SetFields(v string) *GetFolderPathInput { s.Fields = &v @@ -5358,6 +7271,10 @@ func (s *GetFolderPathOutput) SetPath(v *ResourcePath) *GetFolderPathOutput { type InitiateDocumentVersionUploadInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The time stamp when the content of the document was originally created. ContentCreatedTimestamp *time.Time `type:"timestamp" timestampFormat:"unix"` @@ -5395,6 +7312,9 @@ func (s InitiateDocumentVersionUploadInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *InitiateDocumentVersionUploadInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "InitiateDocumentVersionUploadInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.ContentType != nil && len(*s.ContentType) < 1 { invalidParams.Add(request.NewErrParamMinLen("ContentType", 1)) } @@ -5417,6 +7337,12 @@ func (s *InitiateDocumentVersionUploadInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *InitiateDocumentVersionUploadInput) SetAuthenticationToken(v string) *InitiateDocumentVersionUploadInput { + s.AuthenticationToken = &v + return s +} + // SetContentCreatedTimestamp sets the ContentCreatedTimestamp field's value. func (s *InitiateDocumentVersionUploadInput) SetContentCreatedTimestamp(v time.Time) *InitiateDocumentVersionUploadInput { s.ContentCreatedTimestamp = &v @@ -5573,6 +7499,10 @@ func (s *Principal) SetType(v string) *Principal { type RemoveAllResourcePermissionsInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the resource. // // ResourceId is a required field @@ -5592,6 +7522,9 @@ func (s RemoveAllResourcePermissionsInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *RemoveAllResourcePermissionsInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "RemoveAllResourcePermissionsInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.ResourceId == nil { invalidParams.Add(request.NewErrParamRequired("ResourceId")) } @@ -5605,6 +7538,12 @@ func (s *RemoveAllResourcePermissionsInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *RemoveAllResourcePermissionsInput) SetAuthenticationToken(v string) *RemoveAllResourcePermissionsInput { + s.AuthenticationToken = &v + return s +} + // SetResourceId sets the ResourceId field's value. func (s *RemoveAllResourcePermissionsInput) SetResourceId(v string) *RemoveAllResourcePermissionsInput { s.ResourceId = &v @@ -5630,6 +7569,10 @@ func (s RemoveAllResourcePermissionsOutput) GoString() string { type RemoveResourcePermissionInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The principal ID of the resource. // // PrincipalId is a required field @@ -5657,6 +7600,9 @@ func (s RemoveResourcePermissionInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *RemoveResourcePermissionInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "RemoveResourcePermissionInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.PrincipalId == nil { invalidParams.Add(request.NewErrParamRequired("PrincipalId")) } @@ -5676,6 +7622,12 @@ func (s *RemoveResourcePermissionInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *RemoveResourcePermissionInput) SetAuthenticationToken(v string) *RemoveResourcePermissionInput { + s.AuthenticationToken = &v + return s +} + // SetPrincipalId sets the PrincipalId field's value. func (s *RemoveResourcePermissionInput) SetPrincipalId(v string) *RemoveResourcePermissionInput { s.PrincipalId = &v @@ -5981,6 +7933,10 @@ func (s *Subscription) SetSubscriptionId(v string) *Subscription { type UpdateDocumentInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -6010,6 +7966,9 @@ func (s UpdateDocumentInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *UpdateDocumentInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "UpdateDocumentInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -6029,6 +7988,12 @@ func (s *UpdateDocumentInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *UpdateDocumentInput) SetAuthenticationToken(v string) *UpdateDocumentInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *UpdateDocumentInput) SetDocumentId(v string) *UpdateDocumentInput { s.DocumentId = &v @@ -6072,6 +8037,10 @@ func (s UpdateDocumentOutput) GoString() string { type UpdateDocumentVersionInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the document. // // DocumentId is a required field @@ -6099,6 +8068,9 @@ func (s UpdateDocumentVersionInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *UpdateDocumentVersionInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "UpdateDocumentVersionInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.DocumentId == nil { invalidParams.Add(request.NewErrParamRequired("DocumentId")) } @@ -6118,6 +8090,12 @@ func (s *UpdateDocumentVersionInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *UpdateDocumentVersionInput) SetAuthenticationToken(v string) *UpdateDocumentVersionInput { + s.AuthenticationToken = &v + return s +} + // SetDocumentId sets the DocumentId field's value. func (s *UpdateDocumentVersionInput) SetDocumentId(v string) *UpdateDocumentVersionInput { s.DocumentId = &v @@ -6155,6 +8133,10 @@ func (s UpdateDocumentVersionOutput) GoString() string { type UpdateFolderInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The ID of the folder. // // FolderId is a required field @@ -6184,6 +8166,9 @@ func (s UpdateFolderInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *UpdateFolderInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "UpdateFolderInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.FolderId == nil { invalidParams.Add(request.NewErrParamRequired("FolderId")) } @@ -6203,6 +8188,12 @@ func (s *UpdateFolderInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *UpdateFolderInput) SetAuthenticationToken(v string) *UpdateFolderInput { + s.AuthenticationToken = &v + return s +} + // SetFolderId sets the FolderId field's value. func (s *UpdateFolderInput) SetFolderId(v string) *UpdateFolderInput { s.FolderId = &v @@ -6246,6 +8237,10 @@ func (s UpdateFolderOutput) GoString() string { type UpdateUserInput struct { _ struct{} `type:"structure"` + // Amazon WorkDocs authentication token. This field should not be set when using + // administrative API actions, as in accessing the API using AWS credentials. + AuthenticationToken *string `location:"header" locationName:"Authentication" min:"1" type:"string"` + // The given name of the user. GivenName *string `min:"1" type:"string"` @@ -6283,6 +8278,9 @@ func (s UpdateUserInput) GoString() string { // Validate inspects the fields of the type to determine if they are valid. func (s *UpdateUserInput) Validate() error { invalidParams := request.ErrInvalidParams{Context: "UpdateUserInput"} + if s.AuthenticationToken != nil && len(*s.AuthenticationToken) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AuthenticationToken", 1)) + } if s.GivenName != nil && len(*s.GivenName) < 1 { invalidParams.Add(request.NewErrParamMinLen("GivenName", 1)) } @@ -6305,6 +8303,12 @@ func (s *UpdateUserInput) Validate() error { return nil } +// SetAuthenticationToken sets the AuthenticationToken field's value. +func (s *UpdateUserInput) SetAuthenticationToken(v string) *UpdateUserInput { + s.AuthenticationToken = &v + return s +} + // SetGivenName sets the GivenName field's value. func (s *UpdateUserInput) SetGivenName(v string) *UpdateUserInput { s.GivenName = &v @@ -6590,6 +8594,25 @@ func (s *UserStorageMetadata) SetStorageUtilizedInBytes(v int64) *UserStorageMet return s } +const ( + // CommentStatusTypeDraft is a CommentStatusType enum value + CommentStatusTypeDraft = "DRAFT" + + // CommentStatusTypePublished is a CommentStatusType enum value + CommentStatusTypePublished = "PUBLISHED" + + // CommentStatusTypeDeleted is a CommentStatusType enum value + CommentStatusTypeDeleted = "DELETED" +) + +const ( + // CommentVisibilityTypePublic is a CommentVisibilityType enum value + CommentVisibilityTypePublic = "PUBLIC" + + // CommentVisibilityTypePrivate is a CommentVisibilityType enum value + CommentVisibilityTypePrivate = "PRIVATE" +) + const ( // DocumentSourceTypeOriginal is a DocumentSourceType enum value DocumentSourceTypeOriginal = "ORIGINAL" diff --git a/service/workdocs/errors.go b/service/workdocs/errors.go index d7917c299fd..f3cab8b2a55 100644 --- a/service/workdocs/errors.go +++ b/service/workdocs/errors.go @@ -10,12 +10,33 @@ const ( // The resource hierarchy is changing. ErrCodeConcurrentModificationException = "ConcurrentModificationException" + // ErrCodeCustomMetadataLimitExceededException for service response error code + // "CustomMetadataLimitExceededException". + // + // The limit has been reached on the number of custom properties for the specified + // resource. + ErrCodeCustomMetadataLimitExceededException = "CustomMetadataLimitExceededException" + // ErrCodeDeactivatingLastSystemUserException for service response error code // "DeactivatingLastSystemUserException". // // The last user in the organization is being deactivated. ErrCodeDeactivatingLastSystemUserException = "DeactivatingLastSystemUserException" + // ErrCodeDocumentLockedForCommentsException for service response error code + // "DocumentLockedForCommentsException". + // + // This exception is thrown when the document is locked for comments and user + // tries to create or delete a comment on that document. + ErrCodeDocumentLockedForCommentsException = "DocumentLockedForCommentsException" + + // ErrCodeDraftUploadOutOfSyncException for service response error code + // "DraftUploadOutOfSyncException". + // + // This exception is thrown when a valid checkout ID is not presented on document + // version upload calls for a document that has been checked out from Web client. + ErrCodeDraftUploadOutOfSyncException = "DraftUploadOutOfSyncException" + // ErrCodeEntityAlreadyExistsException for service response error code // "EntityAlreadyExistsException". // @@ -57,7 +78,7 @@ const ( // ErrCodeLimitExceededException for service response error code // "LimitExceededException". // - // You've exceeded the maximum of 100,000 folders under the parent folder. + // The maximum of 100,000 folders under the parent folder has been exceeded. ErrCodeLimitExceededException = "LimitExceededException" // ErrCodeProhibitedStateException for service response error code @@ -66,6 +87,10 @@ const ( // The specified document version is not in the INITIALIZED state. ErrCodeProhibitedStateException = "ProhibitedStateException" + // ErrCodeResourceAlreadyCheckedOutException for service response error code + // "ResourceAlreadyCheckedOutException". + ErrCodeResourceAlreadyCheckedOutException = "ResourceAlreadyCheckedOutException" + // ErrCodeServiceUnavailableException for service response error code // "ServiceUnavailableException". // @@ -84,6 +109,12 @@ const ( // The storage limit will be exceeded. ErrCodeStorageLimitWillExceedException = "StorageLimitWillExceedException" + // ErrCodeTooManyLabelsException for service response error code + // "TooManyLabelsException". + // + // The limit has been reached on the number of labels for the specified resource. + ErrCodeTooManyLabelsException = "TooManyLabelsException" + // ErrCodeTooManySubscriptionsException for service response error code // "TooManySubscriptionsException". // diff --git a/service/workdocs/examples_test.go b/service/workdocs/examples_test.go index 7f3a4a9cd79..453a5b1f88c 100644 --- a/service/workdocs/examples_test.go +++ b/service/workdocs/examples_test.go @@ -21,8 +21,9 @@ func ExampleWorkDocs_AbortDocumentVersionUpload() { svc := workdocs.New(sess) params := &workdocs.AbortDocumentVersionUploadInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required + DocumentId: aws.String("ResourceIdType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.AbortDocumentVersionUpload(params) @@ -43,7 +44,8 @@ func ExampleWorkDocs_ActivateUser() { svc := workdocs.New(sess) params := &workdocs.ActivateUserInput{ - UserId: aws.String("IdType"), // Required + UserId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.ActivateUser(params) @@ -72,7 +74,8 @@ func ExampleWorkDocs_AddResourcePermissions() { }, // More values... }, - ResourceId: aws.String("ResourceIdType"), // Required + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.AddResourcePermissions(params) @@ -87,14 +90,70 @@ func ExampleWorkDocs_AddResourcePermissions() { fmt.Println(resp) } +func ExampleWorkDocs_CreateComment() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.CreateCommentInput{ + DocumentId: aws.String("ResourceIdType"), // Required + Text: aws.String("CommentTextType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + NotifyCollaborators: aws.Bool(true), + ParentId: aws.String("CommentIdType"), + ThreadId: aws.String("CommentIdType"), + Visibility: aws.String("CommentVisibilityType"), + } + resp, err := svc.CreateComment(params) + + if err != nil { + // Print the error, cast err to awserr.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_CreateCustomMetadata() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.CreateCustomMetadataInput{ + CustomMetadata: map[string]*string{ // Required + "Key": aws.String("CustomMetadataValueType"), // Required + // More values... + }, + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + VersionId: aws.String("DocumentVersionIdType"), + } + resp, err := svc.CreateCustomMetadata(params) + + if err != nil { + // Print the error, cast err to awserr.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"), + ParentFolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Name: aws.String("ResourceNameType"), } resp, err := svc.CreateFolder(params) @@ -109,6 +168,32 @@ func ExampleWorkDocs_CreateFolder() { fmt.Println(resp) } +func ExampleWorkDocs_CreateLabels() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.CreateLabelsInput{ + Labels: []*string{ // Required + aws.String("Label"), // Required + // More values... + }, + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + } + resp, err := svc.CreateLabels(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -139,11 +224,13 @@ func ExampleWorkDocs_CreateUser() { 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"), + GivenName: aws.String("UserAttributeValueType"), // Required + Password: aws.String("PasswordType"), // Required + Surname: aws.String("UserAttributeValueType"), // Required + Username: aws.String("UsernameType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + EmailAddress: aws.String("EmailAddressType"), + OrganizationId: aws.String("IdType"), StorageRule: &workdocs.StorageRuleType{ StorageAllocatedInBytes: aws.Int64(1), StorageType: aws.String("StorageType"), @@ -169,7 +256,8 @@ func ExampleWorkDocs_DeactivateUser() { svc := workdocs.New(sess) params := &workdocs.DeactivateUserInput{ - UserId: aws.String("IdType"), // Required + UserId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.DeactivateUser(params) @@ -184,13 +272,66 @@ func ExampleWorkDocs_DeactivateUser() { fmt.Println(resp) } +func ExampleWorkDocs_DeleteComment() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.DeleteCommentInput{ + CommentId: aws.String("CommentIdType"), // Required + DocumentId: aws.String("ResourceIdType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + } + resp, err := svc.DeleteComment(params) + + if err != nil { + // Print the error, cast err to awserr.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_DeleteCustomMetadata() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.DeleteCustomMetadataInput{ + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + DeleteAll: aws.Bool(true), + Keys: []*string{ + aws.String("CustomMetadataKeyType"), // Required + // More values... + }, + VersionId: aws.String("DocumentVersionIdType"), + } + resp, err := svc.DeleteCustomMetadata(params) + + if err != nil { + // Print the error, cast err to awserr.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 + DocumentId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.DeleteDocument(params) @@ -211,7 +352,8 @@ func ExampleWorkDocs_DeleteFolder() { svc := workdocs.New(sess) params := &workdocs.DeleteFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required + FolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.DeleteFolder(params) @@ -232,7 +374,8 @@ func ExampleWorkDocs_DeleteFolderContents() { svc := workdocs.New(sess) params := &workdocs.DeleteFolderContentsInput{ - FolderId: aws.String("ResourceIdType"), // Required + FolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.DeleteFolderContents(params) @@ -247,6 +390,33 @@ func ExampleWorkDocs_DeleteFolderContents() { fmt.Println(resp) } +func ExampleWorkDocs_DeleteLabels() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.DeleteLabelsInput{ + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + DeleteAll: aws.Bool(true), + Labels: []*string{ + aws.String("Label"), // Required + // More values... + }, + } + resp, err := svc.DeleteLabels(params) + + if err != nil { + // Print the error, cast err to awserr.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()) @@ -275,7 +445,8 @@ func ExampleWorkDocs_DeleteUser() { svc := workdocs.New(sess) params := &workdocs.DeleteUserInput{ - UserId: aws.String("IdType"), // Required + UserId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.DeleteUser(params) @@ -290,17 +461,43 @@ func ExampleWorkDocs_DeleteUser() { fmt.Println(resp) } +func ExampleWorkDocs_DescribeComments() { + sess := session.Must(session.NewSession()) + + svc := workdocs.New(sess) + + params := &workdocs.DescribeCommentsInput{ + DocumentId: aws.String("ResourceIdType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Limit: aws.Int64(1), + Marker: aws.String("MarkerType"), + } + resp, err := svc.DescribeComments(params) + + if err != nil { + // Print the error, cast err to awserr.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"), + DocumentId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Fields: aws.String("FieldNamesType"), + Include: aws.String("FieldNamesType"), + Limit: aws.Int64(1), + Marker: aws.String("PageMarkerType"), } resp, err := svc.DescribeDocumentVersions(params) @@ -321,13 +518,14 @@ func ExampleWorkDocs_DescribeFolderContents() { 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"), + FolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + 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) @@ -371,9 +569,10 @@ func ExampleWorkDocs_DescribeResourcePermissions() { svc := workdocs.New(sess) params := &workdocs.DescribeResourcePermissionsInput{ - ResourceId: aws.String("ResourceIdType"), // Required - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Limit: aws.Int64(1), + Marker: aws.String("PageMarkerType"), } resp, err := svc.DescribeResourcePermissions(params) @@ -394,15 +593,16 @@ func ExampleWorkDocs_DescribeUsers() { 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"), + AuthenticationToken: aws.String("AuthenticationHeaderType"), + 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) @@ -423,7 +623,9 @@ func ExampleWorkDocs_GetDocument() { svc := workdocs.New(sess) params := &workdocs.GetDocumentInput{ - DocumentId: aws.String("ResourceIdType"), // Required + DocumentId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + IncludeCustomMetadata: aws.Bool(true), } resp, err := svc.GetDocument(params) @@ -444,10 +646,11 @@ func ExampleWorkDocs_GetDocumentPath() { svc := workdocs.New(sess) params := &workdocs.GetDocumentPathInput{ - DocumentId: aws.String("IdType"), // Required - Fields: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), + DocumentId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Fields: aws.String("FieldNamesType"), + Limit: aws.Int64(1), + Marker: aws.String("PageMarkerType"), } resp, err := svc.GetDocumentPath(params) @@ -468,9 +671,11 @@ func ExampleWorkDocs_GetDocumentVersion() { svc := workdocs.New(sess) params := &workdocs.GetDocumentVersionInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required - Fields: aws.String("FieldNamesType"), + DocumentId: aws.String("ResourceIdType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Fields: aws.String("FieldNamesType"), + IncludeCustomMetadata: aws.Bool(true), } resp, err := svc.GetDocumentVersion(params) @@ -491,7 +696,9 @@ func ExampleWorkDocs_GetFolder() { svc := workdocs.New(sess) params := &workdocs.GetFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required + FolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + IncludeCustomMetadata: aws.Bool(true), } resp, err := svc.GetFolder(params) @@ -512,10 +719,11 @@ func ExampleWorkDocs_GetFolderPath() { svc := workdocs.New(sess) params := &workdocs.GetFolderPathInput{ - FolderId: aws.String("IdType"), // Required - Fields: aws.String("FieldNamesType"), - Limit: aws.Int64(1), - Marker: aws.String("PageMarkerType"), + FolderId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Fields: aws.String("FieldNamesType"), + Limit: aws.Int64(1), + Marker: aws.String("PageMarkerType"), } resp, err := svc.GetFolderPath(params) @@ -537,6 +745,7 @@ func ExampleWorkDocs_InitiateDocumentVersionUpload() { params := &workdocs.InitiateDocumentVersionUploadInput{ ParentFolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), ContentCreatedTimestamp: aws.Time(time.Now()), ContentModifiedTimestamp: aws.Time(time.Now()), ContentType: aws.String("DocumentContentType"), @@ -563,7 +772,8 @@ func ExampleWorkDocs_RemoveAllResourcePermissions() { svc := workdocs.New(sess) params := &workdocs.RemoveAllResourcePermissionsInput{ - ResourceId: aws.String("ResourceIdType"), // Required + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), } resp, err := svc.RemoveAllResourcePermissions(params) @@ -584,9 +794,10 @@ func ExampleWorkDocs_RemoveResourcePermission() { svc := workdocs.New(sess) params := &workdocs.RemoveResourcePermissionInput{ - PrincipalId: aws.String("IdType"), // Required - ResourceId: aws.String("ResourceIdType"), // Required - PrincipalType: aws.String("PrincipalType"), + PrincipalId: aws.String("IdType"), // Required + ResourceId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + PrincipalType: aws.String("PrincipalType"), } resp, err := svc.RemoveResourcePermission(params) @@ -607,10 +818,11 @@ func ExampleWorkDocs_UpdateDocument() { svc := workdocs.New(sess) params := &workdocs.UpdateDocumentInput{ - DocumentId: aws.String("ResourceIdType"), // Required - Name: aws.String("ResourceNameType"), - ParentFolderId: aws.String("ResourceIdType"), - ResourceState: aws.String("ResourceStateType"), + DocumentId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Name: aws.String("ResourceNameType"), + ParentFolderId: aws.String("ResourceIdType"), + ResourceState: aws.String("ResourceStateType"), } resp, err := svc.UpdateDocument(params) @@ -631,9 +843,10 @@ func ExampleWorkDocs_UpdateDocumentVersion() { svc := workdocs.New(sess) params := &workdocs.UpdateDocumentVersionInput{ - DocumentId: aws.String("ResourceIdType"), // Required - VersionId: aws.String("DocumentVersionIdType"), // Required - VersionStatus: aws.String("DocumentVersionStatus"), + DocumentId: aws.String("ResourceIdType"), // Required + VersionId: aws.String("DocumentVersionIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + VersionStatus: aws.String("DocumentVersionStatus"), } resp, err := svc.UpdateDocumentVersion(params) @@ -654,10 +867,11 @@ func ExampleWorkDocs_UpdateFolder() { svc := workdocs.New(sess) params := &workdocs.UpdateFolderInput{ - FolderId: aws.String("ResourceIdType"), // Required - Name: aws.String("ResourceNameType"), - ParentFolderId: aws.String("ResourceIdType"), - ResourceState: aws.String("ResourceStateType"), + FolderId: aws.String("ResourceIdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + Name: aws.String("ResourceNameType"), + ParentFolderId: aws.String("ResourceIdType"), + ResourceState: aws.String("ResourceStateType"), } resp, err := svc.UpdateFolder(params) @@ -678,9 +892,10 @@ func ExampleWorkDocs_UpdateUser() { svc := workdocs.New(sess) params := &workdocs.UpdateUserInput{ - UserId: aws.String("IdType"), // Required - GivenName: aws.String("UserAttributeValueType"), - Locale: aws.String("LocaleType"), + UserId: aws.String("IdType"), // Required + AuthenticationToken: aws.String("AuthenticationHeaderType"), + GivenName: aws.String("UserAttributeValueType"), + Locale: aws.String("LocaleType"), StorageRule: &workdocs.StorageRuleType{ StorageAllocatedInBytes: aws.Int64(1), StorageType: aws.String("StorageType"), diff --git a/service/workdocs/workdocsiface/interface.go b/service/workdocs/workdocsiface/interface.go index cf729c45687..543f7b43b91 100644 --- a/service/workdocs/workdocsiface/interface.go +++ b/service/workdocs/workdocsiface/interface.go @@ -72,10 +72,22 @@ type WorkDocsAPI interface { AddResourcePermissionsWithContext(aws.Context, *workdocs.AddResourcePermissionsInput, ...request.Option) (*workdocs.AddResourcePermissionsOutput, error) AddResourcePermissionsRequest(*workdocs.AddResourcePermissionsInput) (*request.Request, *workdocs.AddResourcePermissionsOutput) + CreateComment(*workdocs.CreateCommentInput) (*workdocs.CreateCommentOutput, error) + CreateCommentWithContext(aws.Context, *workdocs.CreateCommentInput, ...request.Option) (*workdocs.CreateCommentOutput, error) + CreateCommentRequest(*workdocs.CreateCommentInput) (*request.Request, *workdocs.CreateCommentOutput) + + CreateCustomMetadata(*workdocs.CreateCustomMetadataInput) (*workdocs.CreateCustomMetadataOutput, error) + CreateCustomMetadataWithContext(aws.Context, *workdocs.CreateCustomMetadataInput, ...request.Option) (*workdocs.CreateCustomMetadataOutput, error) + CreateCustomMetadataRequest(*workdocs.CreateCustomMetadataInput) (*request.Request, *workdocs.CreateCustomMetadataOutput) + CreateFolder(*workdocs.CreateFolderInput) (*workdocs.CreateFolderOutput, error) CreateFolderWithContext(aws.Context, *workdocs.CreateFolderInput, ...request.Option) (*workdocs.CreateFolderOutput, error) CreateFolderRequest(*workdocs.CreateFolderInput) (*request.Request, *workdocs.CreateFolderOutput) + CreateLabels(*workdocs.CreateLabelsInput) (*workdocs.CreateLabelsOutput, error) + CreateLabelsWithContext(aws.Context, *workdocs.CreateLabelsInput, ...request.Option) (*workdocs.CreateLabelsOutput, error) + CreateLabelsRequest(*workdocs.CreateLabelsInput) (*request.Request, *workdocs.CreateLabelsOutput) + CreateNotificationSubscription(*workdocs.CreateNotificationSubscriptionInput) (*workdocs.CreateNotificationSubscriptionOutput, error) CreateNotificationSubscriptionWithContext(aws.Context, *workdocs.CreateNotificationSubscriptionInput, ...request.Option) (*workdocs.CreateNotificationSubscriptionOutput, error) CreateNotificationSubscriptionRequest(*workdocs.CreateNotificationSubscriptionInput) (*request.Request, *workdocs.CreateNotificationSubscriptionOutput) @@ -88,6 +100,14 @@ type WorkDocsAPI interface { DeactivateUserWithContext(aws.Context, *workdocs.DeactivateUserInput, ...request.Option) (*workdocs.DeactivateUserOutput, error) DeactivateUserRequest(*workdocs.DeactivateUserInput) (*request.Request, *workdocs.DeactivateUserOutput) + DeleteComment(*workdocs.DeleteCommentInput) (*workdocs.DeleteCommentOutput, error) + DeleteCommentWithContext(aws.Context, *workdocs.DeleteCommentInput, ...request.Option) (*workdocs.DeleteCommentOutput, error) + DeleteCommentRequest(*workdocs.DeleteCommentInput) (*request.Request, *workdocs.DeleteCommentOutput) + + DeleteCustomMetadata(*workdocs.DeleteCustomMetadataInput) (*workdocs.DeleteCustomMetadataOutput, error) + DeleteCustomMetadataWithContext(aws.Context, *workdocs.DeleteCustomMetadataInput, ...request.Option) (*workdocs.DeleteCustomMetadataOutput, error) + DeleteCustomMetadataRequest(*workdocs.DeleteCustomMetadataInput) (*request.Request, *workdocs.DeleteCustomMetadataOutput) + DeleteDocument(*workdocs.DeleteDocumentInput) (*workdocs.DeleteDocumentOutput, error) DeleteDocumentWithContext(aws.Context, *workdocs.DeleteDocumentInput, ...request.Option) (*workdocs.DeleteDocumentOutput, error) DeleteDocumentRequest(*workdocs.DeleteDocumentInput) (*request.Request, *workdocs.DeleteDocumentOutput) @@ -100,6 +120,10 @@ type WorkDocsAPI interface { DeleteFolderContentsWithContext(aws.Context, *workdocs.DeleteFolderContentsInput, ...request.Option) (*workdocs.DeleteFolderContentsOutput, error) DeleteFolderContentsRequest(*workdocs.DeleteFolderContentsInput) (*request.Request, *workdocs.DeleteFolderContentsOutput) + DeleteLabels(*workdocs.DeleteLabelsInput) (*workdocs.DeleteLabelsOutput, error) + DeleteLabelsWithContext(aws.Context, *workdocs.DeleteLabelsInput, ...request.Option) (*workdocs.DeleteLabelsOutput, error) + DeleteLabelsRequest(*workdocs.DeleteLabelsInput) (*request.Request, *workdocs.DeleteLabelsOutput) + DeleteNotificationSubscription(*workdocs.DeleteNotificationSubscriptionInput) (*workdocs.DeleteNotificationSubscriptionOutput, error) DeleteNotificationSubscriptionWithContext(aws.Context, *workdocs.DeleteNotificationSubscriptionInput, ...request.Option) (*workdocs.DeleteNotificationSubscriptionOutput, error) DeleteNotificationSubscriptionRequest(*workdocs.DeleteNotificationSubscriptionInput) (*request.Request, *workdocs.DeleteNotificationSubscriptionOutput) @@ -108,6 +132,10 @@ type WorkDocsAPI interface { DeleteUserWithContext(aws.Context, *workdocs.DeleteUserInput, ...request.Option) (*workdocs.DeleteUserOutput, error) DeleteUserRequest(*workdocs.DeleteUserInput) (*request.Request, *workdocs.DeleteUserOutput) + DescribeComments(*workdocs.DescribeCommentsInput) (*workdocs.DescribeCommentsOutput, error) + DescribeCommentsWithContext(aws.Context, *workdocs.DescribeCommentsInput, ...request.Option) (*workdocs.DescribeCommentsOutput, error) + DescribeCommentsRequest(*workdocs.DescribeCommentsInput) (*request.Request, *workdocs.DescribeCommentsOutput) + DescribeDocumentVersions(*workdocs.DescribeDocumentVersionsInput) (*workdocs.DescribeDocumentVersionsOutput, error) DescribeDocumentVersionsWithContext(aws.Context, *workdocs.DescribeDocumentVersionsInput, ...request.Option) (*workdocs.DescribeDocumentVersionsOutput, error) DescribeDocumentVersionsRequest(*workdocs.DescribeDocumentVersionsInput) (*request.Request, *workdocs.DescribeDocumentVersionsOutput)