diff --git a/clients/cmd/docker-driver/config.go b/clients/cmd/docker-driver/config.go index c6b19375cebf..c204618a6c42 100644 --- a/clients/cmd/docker-driver/config.go +++ b/clients/cmd/docker-driver/config.go @@ -10,10 +10,10 @@ import ( "strings" "time" - cortex_util "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/docker/docker/daemon/logger" "github.com/docker/docker/daemon/logger/templates" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" @@ -71,7 +71,7 @@ var ( defaultClientConfig = client.Config{ BatchWait: client.BatchWait, BatchSize: client.BatchSize, - BackoffConfig: cortex_util.BackoffConfig{ + BackoffConfig: backoff.Config{ MinBackoff: client.MinBackoff, MaxBackoff: client.MaxBackoff, MaxRetries: client.MaxRetries, diff --git a/clients/cmd/fluent-bit/config_test.go b/clients/cmd/fluent-bit/config_test.go index 1c7df9220227..27fc1be6ac9a 100644 --- a/clients/cmd/fluent-bit/config_test.go +++ b/clients/cmd/fluent-bit/config_test.go @@ -8,10 +8,9 @@ import ( "testing" "time" - "github.com/prometheus/common/model" - - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/grafana/dskit/backoff" + "github.com/prometheus/common/model" "github.com/weaveworks/common/logging" "github.com/grafana/loki/clients/pkg/promtail/client" @@ -77,7 +76,7 @@ func Test_parseConfig(t *testing.T) { BatchWait: mustParseDuration("30s"), Timeout: mustParseDuration("1s"), ExternalLabels: lokiflag.LabelSet{LabelSet: model.LabelSet{"app": "foo"}}, - BackoffConfig: util.BackoffConfig{MinBackoff: mustParseDuration("1ms"), MaxBackoff: mustParseDuration("5m"), MaxRetries: 10}, + BackoffConfig: backoff.Config{MinBackoff: mustParseDuration("1ms"), MaxBackoff: mustParseDuration("5m"), MaxRetries: 10}, }, logLevel: mustParseLogLevel("warn"), labelKeys: []string{"foo", "bar"}, @@ -111,7 +110,7 @@ func Test_parseConfig(t *testing.T) { BatchWait: mustParseDuration("30s"), Timeout: mustParseDuration("1s"), ExternalLabels: lokiflag.LabelSet{LabelSet: model.LabelSet{"app": "foo"}}, - BackoffConfig: util.BackoffConfig{MinBackoff: mustParseDuration("1ms"), MaxBackoff: mustParseDuration("5m"), MaxRetries: 10}, + BackoffConfig: backoff.Config{MinBackoff: mustParseDuration("1ms"), MaxBackoff: mustParseDuration("5m"), MaxRetries: 10}, }, logLevel: mustParseLogLevel("warn"), labelKeys: nil, diff --git a/clients/pkg/promtail/client/client.go b/clients/pkg/promtail/client/client.go index 714a87465203..a3e3a57a717a 100644 --- a/clients/pkg/promtail/client/client.go +++ b/clients/pkg/promtail/client/client.go @@ -14,12 +14,12 @@ import ( "github.com/prometheus/prometheus/promql/parser" + "github.com/grafana/dskit/backoff" "github.com/grafana/loki/clients/pkg/logentry/metric" "github.com/grafana/loki/clients/pkg/promtail/api" lokiutil "github.com/grafana/loki/pkg/util" - "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" @@ -301,7 +301,7 @@ func (c *client) sendBatch(tenantID string, batch *batch) { bufBytes := float64(len(buf)) c.metrics.encodedBytes.WithLabelValues(c.cfg.URL.Host).Add(bufBytes) - backoff := util.NewBackoff(c.ctx, c.cfg.BackoffConfig) + backoff := backoff.New(c.ctx, c.cfg.BackoffConfig) var status int for { start := time.Now() diff --git a/clients/pkg/promtail/client/client_test.go b/clients/pkg/promtail/client/client_test.go index 2b236417270f..bcfacb2aca0c 100644 --- a/clients/pkg/promtail/client/client_test.go +++ b/clients/pkg/promtail/client/client_test.go @@ -16,6 +16,7 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/grafana/dskit/backoff" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" "github.com/prometheus/common/config" @@ -260,7 +261,7 @@ func TestClient_Handle(t *testing.T) { BatchWait: testData.clientBatchWait, BatchSize: testData.clientBatchSize, Client: config.HTTPClientConfig{}, - BackoffConfig: util.BackoffConfig{MinBackoff: 1 * time.Millisecond, MaxBackoff: 2 * time.Millisecond, MaxRetries: testData.clientMaxRetries}, + BackoffConfig: backoff.Config{MinBackoff: 1 * time.Millisecond, MaxBackoff: 2 * time.Millisecond, MaxRetries: testData.clientMaxRetries}, ExternalLabels: lokiflag.LabelSet{}, Timeout: 1 * time.Second, TenantID: testData.clientTenantID, @@ -392,7 +393,7 @@ func TestClient_StopNow(t *testing.T) { BatchWait: c.clientBatchWait, BatchSize: c.clientBatchSize, Client: config.HTTPClientConfig{}, - BackoffConfig: util.BackoffConfig{MinBackoff: 5 * time.Second, MaxBackoff: 10 * time.Second, MaxRetries: c.clientMaxRetries}, + BackoffConfig: backoff.Config{MinBackoff: 5 * time.Second, MaxBackoff: 10 * time.Second, MaxRetries: c.clientMaxRetries}, ExternalLabels: lokiflag.LabelSet{}, Timeout: 1 * time.Second, TenantID: c.clientTenantID, diff --git a/clients/pkg/promtail/client/config.go b/clients/pkg/promtail/client/config.go index e12e53d7cf4e..c8d364f3b21b 100644 --- a/clients/pkg/promtail/client/config.go +++ b/clients/pkg/promtail/client/config.go @@ -4,8 +4,8 @@ import ( "flag" "time" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/grafana/dskit/backoff" "github.com/prometheus/common/config" lokiflag "github.com/grafana/loki/pkg/util/flagext" @@ -29,7 +29,7 @@ type Config struct { Client config.HTTPClientConfig `yaml:",inline"` - BackoffConfig util.BackoffConfig `yaml:"backoff_config"` + BackoffConfig backoff.Config `yaml:"backoff_config"` // The labels to add to any time series or alerts when communicating with loki ExternalLabels lokiflag.LabelSet `yaml:"external_labels,omitempty"` Timeout time.Duration `yaml:"timeout"` @@ -70,7 +70,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { } else { // force sane defaults. cfg = raw{ - BackoffConfig: util.BackoffConfig{ + BackoffConfig: backoff.Config{ MaxBackoff: MaxBackoff, MaxRetries: MaxRetries, MinBackoff: MinBackoff, diff --git a/clients/pkg/promtail/client/config_test.go b/clients/pkg/promtail/client/config_test.go index 4ed25170557d..94b98c6d2deb 100644 --- a/clients/pkg/promtail/client/config_test.go +++ b/clients/pkg/promtail/client/config_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/grafana/dskit/backoff" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" @@ -43,7 +43,7 @@ func Test_Config(t *testing.T) { URL: flagext.URLValue{ URL: u, }, - BackoffConfig: util.BackoffConfig{ + BackoffConfig: backoff.Config{ MaxBackoff: MaxBackoff, MaxRetries: MaxRetries, MinBackoff: MinBackoff, @@ -59,7 +59,7 @@ func Test_Config(t *testing.T) { URL: flagext.URLValue{ URL: u, }, - BackoffConfig: util.BackoffConfig{ + BackoffConfig: backoff.Config{ MaxBackoff: 1 * time.Minute, MaxRetries: 20, MinBackoff: 5 * time.Second, diff --git a/clients/pkg/promtail/client/multi_test.go b/clients/pkg/promtail/client/multi_test.go index 36a1bc6e6197..6cbad18c5acf 100644 --- a/clients/pkg/promtail/client/multi_test.go +++ b/clients/pkg/promtail/client/multi_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/go-kit/kit/log" @@ -14,6 +13,7 @@ import ( "github.com/prometheus/common/model" "github.com/stretchr/testify/require" + "github.com/grafana/dskit/backoff" "github.com/grafana/loki/clients/pkg/promtail/api" "github.com/grafana/loki/pkg/logproto" @@ -123,9 +123,9 @@ func TestMultiClient_Handle(t *testing.T) { func TestMultiClient_Handle_Race(t *testing.T) { u := flagext.URLValue{} require.NoError(t, u.Set("http://localhost")) - c1, err := New(nil, Config{URL: u, BackoffConfig: util.BackoffConfig{MaxRetries: 1}, Timeout: time.Microsecond}, log.NewNopLogger()) + c1, err := New(nil, Config{URL: u, BackoffConfig: backoff.Config{MaxRetries: 1}, Timeout: time.Microsecond}, log.NewNopLogger()) require.NoError(t, err) - c2, err := New(nil, Config{URL: u, BackoffConfig: util.BackoffConfig{MaxRetries: 1}, Timeout: time.Microsecond}, log.NewNopLogger()) + c2, err := New(nil, Config{URL: u, BackoffConfig: backoff.Config{MaxRetries: 1}, Timeout: time.Microsecond}, log.NewNopLogger()) require.NoError(t, err) clients := []Client{c1, c2} m := &MultiClient{ diff --git a/clients/pkg/promtail/targets/syslog/syslogtarget.go b/clients/pkg/promtail/targets/syslog/syslogtarget.go index 77b4bb2fb055..21e36bc312b0 100644 --- a/clients/pkg/promtail/targets/syslog/syslogtarget.go +++ b/clients/pkg/promtail/targets/syslog/syslogtarget.go @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/influxdata/go-syslog/v3" "github.com/influxdata/go-syslog/v3/rfc5424" "github.com/mwitkow/go-conntrack" @@ -105,7 +105,7 @@ func (t *SyslogTarget) acceptConnections() { l := log.With(t.logger, "address", t.listener.Addr().String()) - backoff := util.NewBackoff(t.ctx, util.BackoffConfig{ + backoff := backoff.New(t.ctx, backoff.Config{ MinBackoff: 5 * time.Millisecond, MaxBackoff: 1 * time.Second, }) diff --git a/go.mod b/go.mod index 0eac1957ed8c..b02b00e83b8f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/Workiva/go-datastructures v1.0.53 github.com/alicebob/miniredis/v2 v2.14.3 github.com/aws/aws-lambda-go v1.17.0 - github.com/aws/aws-sdk-go v1.38.60 + github.com/aws/aws-sdk-go v1.38.68 github.com/bmatcuk/doublestar v1.2.2 github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b github.com/buger/jsonparser v1.1.1 @@ -21,7 +21,7 @@ require ( github.com/cespare/xxhash v1.1.0 github.com/cespare/xxhash/v2 v2.1.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf - github.com/cortexproject/cortex v1.9.1-0.20210726155107-a4bf10354786 + github.com/cortexproject/cortex v1.10.1-0.20210818115638-df9af3a99954 github.com/davecgh/go-spew v1.1.1 github.com/docker/docker v20.10.7+incompatible github.com/docker/go-plugins-helpers v0.0.0-20181025120712-1e6269c305b8 @@ -32,7 +32,7 @@ require ( github.com/felixge/fgprof v0.9.1 github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c github.com/fsouza/fake-gcs-server v1.7.0 - github.com/go-kit/kit v0.10.0 + github.com/go-kit/kit v0.11.0 github.com/go-logfmt/logfmt v0.5.0 github.com/go-redis/redis/v8 v8.9.0 github.com/gocql/gocql v0.0.0-20200526081602-cd04bd7f22a7 @@ -44,6 +44,7 @@ require ( github.com/google/go-cmp v0.5.6 github.com/gorilla/mux v1.7.3 github.com/gorilla/websocket v1.4.2 + github.com/grafana/dskit v0.0.0-20210817085554-1b69d2de136f github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20191002090509-6af20e3a5340 // indirect github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 @@ -56,7 +57,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 github.com/joncrlsn/dque v2.2.1-0.20200515025108-956d14155fa2+incompatible github.com/json-iterator/go v1.1.11 - github.com/klauspost/compress v1.11.13 + github.com/klauspost/compress v1.13.1 github.com/klauspost/pgzip v1.2.5 github.com/minio/minio-go/v7 v7.0.10 github.com/mitchellh/mapstructure v1.4.1 @@ -79,13 +80,13 @@ require ( github.com/sony/gobreaker v0.4.1 github.com/spf13/afero v1.2.2 github.com/stretchr/testify v1.7.0 - github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2 + github.com/thanos-io/thanos v0.19.1-0.20210729154440-aa148f8fdb28 github.com/tonistiigi/fifo v0.0.0-20190226154929-a9fb20d87448 github.com/uber/jaeger-client-go v2.29.1+incompatible github.com/ugorji/go v1.1.7 // indirect github.com/weaveworks/common v0.0.0-20210506120931-f2676019da11 go.etcd.io/bbolt v1.3.5 - go.uber.org/atomic v1.8.0 + go.uber.org/atomic v1.9.0 go.uber.org/goleak v1.1.10 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e golang.org/x/net v0.0.0-20210610132358-84b48f89b13b diff --git a/go.sum b/go.sum index 99ffc71bc28e..f55c48b1a31a 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,7 @@ github.com/Azure/go-autorest/autorest v0.11.4/go.mod h1:JFgpikqFJ/MleTTxwepExTKn github.com/Azure/go-autorest/autorest v0.11.10/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest v0.11.11/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= +github.com/Azure/go-autorest/autorest v0.11.17/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= github.com/Azure/go-autorest/autorest v0.11.19 h1:7/IqD2fEYVha1EPeaiytVKhzmPV223pfkRIQUGOK2IE= github.com/Azure/go-autorest/autorest v0.11.19/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= @@ -99,11 +100,16 @@ github.com/Azure/go-autorest/autorest/adal v0.8.3/go.mod h1:ZjhuQClTqx435SRJ2iMl github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= github.com/Azure/go-autorest/autorest/adal v0.9.2/go.mod h1:/3SMAM86bP6wC9Ev35peQDUeqFZBMH07vvUOmg4z/fE= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= +github.com/Azure/go-autorest/autorest/adal v0.9.11/go.mod h1:nBKAnTomx8gDtl+3ZCJv2v0KACFHWTB2drffI1B68Pk= github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/adal v0.9.14 h1:G8hexQdV5D4khOXrWG2YuLCFKhWYmWD8bHYaXN5ophk= github.com/Azure/go-autorest/autorest/adal v0.9.14/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= +github.com/Azure/go-autorest/autorest/azure/auth v0.5.8 h1:TzPg6B6fTZ0G1zBf3T54aI7p3cAT6u//TOXGPmFMOXg= +github.com/Azure/go-autorest/autorest/azure/auth v0.5.8/go.mod h1:kxyKZTSfKh8OVFWPAgOgQ/frrJgeYQJPyR5fLFmXko4= github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 h1:dMOmEJfkLKW/7JsokJqkyoYSgmR08hi9KrhjZb+JALY= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.2/go.mod h1:7qkJkT+j6b+hIpzMOwPChJhTqS8VbsqqgULzMNRugoM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= @@ -129,7 +135,6 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -279,9 +284,14 @@ github.com/aws/aws-sdk-go v1.35.5/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+ github.com/aws/aws-sdk-go v1.35.31/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.37.8/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.38.60 h1:MgyEsX0IMwivwth1VwEnesBpH0vxbjp5a0w1lurMOXY= +github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.38.60/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go v1.38.68 h1:aOG8geU4SohNp659eKBHRBgbqSrZ6jNZlfimIuJAwL8= +github.com/aws/aws-sdk-go v1.38.68/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/aws/aws-sdk-go-v2 v1.7.0/go.mod h1:tb9wi5s61kTDA5qCkcDbt3KRVV74GGslQkl/DRdX/P4= +github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.5.0/go.mod h1:acH3+MQoiMzozT/ivU+DbRg7Ooo2298RdRaWcOv+4vM= +github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= @@ -301,7 +311,10 @@ github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngE github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= +github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bmatcuk/doublestar v1.2.2 h1:oC24CykoSAB8zd7XgruHo33E0cHJf/WhQA/7BeXj+x0= github.com/bmatcuk/doublestar v1.2.2/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= @@ -322,6 +335,7 @@ github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee/go.mod h1:S/7n9cop github.com/cactus/go-statsd-client/statsd v0.0.0-20191106001114-12b4e2b38748/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI= github.com/caio/go-tdigest v2.3.0+incompatible/go.mod h1:sHQM/ubZStBUmF1WbB8FAm8q9GjDajLC5T7ydxE3JHI= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/casbin/casbin/v2 v2.31.6/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v0.0.0-20181003080854-62661b46c409/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff v1.0.0/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -476,8 +490,9 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -491,8 +506,8 @@ github.com/cortexproject/cortex v1.6.1-0.20210215155036-dfededd9f331/go.mod h1:8 github.com/cortexproject/cortex v1.7.1-0.20210224085859-66d6fb5b0d42/go.mod h1:u2dxcHInYbe45wxhLoWVdlFJyDhXewsMcxtnbq/QbH4= github.com/cortexproject/cortex v1.7.1-0.20210316085356-3fedc1108a49/go.mod h1:/DBOW8TzYBTE/U+O7Whs7i7E2eeeZl1iRVDtIqxn5kg= github.com/cortexproject/cortex v1.8.1-0.20210422151339-cf1c444e0905/go.mod h1:xxm4/CLvTmDxwE7yXwtClR4dIvkG4S09o5DygPOgc1U= -github.com/cortexproject/cortex v1.9.1-0.20210726155107-a4bf10354786 h1:AIwk+TdXdOKD8KVkDAo4txZ3ozHmmnbe7wJoiT3USPU= -github.com/cortexproject/cortex v1.9.1-0.20210726155107-a4bf10354786/go.mod h1:vMkymug9co7+mIu0d5eTkzP8i5v8xOGKke2kUM2Sj08= +github.com/cortexproject/cortex v1.10.1-0.20210818115638-df9af3a99954 h1:sFN9N6RMYDQuRNKMtsc27rq18Voo2d8fBDdLzDxt1Mc= +github.com/cortexproject/cortex v1.10.1-0.20210818115638-df9af3a99954/go.mod h1:FH37S/x4jCA66OL9Gn6MDESb9lVjgfRMYr1diA112IE= github.com/couchbase/go-couchbase v0.0.0-20180501122049-16db1f1fe037/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U= github.com/couchbase/gomemcached v0.0.0-20180502221210-0da75df14530/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c= github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs= @@ -551,9 +566,12 @@ github.com/digitalocean/godo v1.46.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2x github.com/digitalocean/godo v1.52.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/digitalocean/godo v1.57.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/digitalocean/godo v1.58.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= +github.com/digitalocean/godo v1.60.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/digitalocean/godo v1.62.0 h1:7Gw2KFsWkxl36qJa0s50tgXaE0Cgm51JdRP+MFQvNnM= github.com/digitalocean/godo v1.62.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= +github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= +github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= @@ -568,6 +586,7 @@ github.com/docker/docker v17.12.0-ce-rc1.0.20200706150819-a40b877fbb9e+incompati github.com/docker/docker v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.7+incompatible h1:Z6O9Nhsjv+ayUEeI1IojKbYcsGdgYSNqxe1s2MYzUhQ= github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= @@ -602,6 +621,8 @@ github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7j github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20 h1:kM/ALyvAnTrwSB+nlKqoKaDnZbInp1YImZvW+gtHwc8= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20/go.mod h1:ZV0utlglOczUWv3ih2AbqPSoLoFzdplUYxwV62eZi6Q= github.com/elastic/go-sysinfo v1.0.1/go.mod h1:O/D5m1VpYLwGjCYzEt63g3Z1uO3jXfwyzzjiW90t8cY= github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= @@ -673,8 +694,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/kit v0.11.0 h1:IGmIEl7aHTYh6E2HlT+ptILBotjo4xl8PMDl852etiI= +github.com/go-kit/kit v0.11.0/go.mod h1:73/6Ixaufkvb5Osvkls8C79vuQ49Ba1rUEUYNSf+FUw= github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= @@ -858,6 +880,7 @@ github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblf github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc= github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v2.1.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= @@ -982,6 +1005,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210208152844-1612e9be7af6/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210323184331-8eee2492667d/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210504235042-3a04a4d88a10/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9 h1:2tft2559dNwKl2znYB58oVTql0grRB+Ml3LWIBbc4WM= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= @@ -1017,6 +1041,7 @@ github.com/gophercloud/gophercloud v0.13.0/go.mod h1:VX0Ibx85B60B5XOrZr6kaNwrmPU github.com/gophercloud/gophercloud v0.14.0/go.mod h1:VX0Ibx85B60B5XOrZr6kaNwrmPUzcmMpwxvQ1WQIIWM= github.com/gophercloud/gophercloud v0.15.0/go.mod h1:VX0Ibx85B60B5XOrZr6kaNwrmPUzcmMpwxvQ1WQIIWM= github.com/gophercloud/gophercloud v0.16.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4= +github.com/gophercloud/gophercloud v0.17.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4= github.com/gophercloud/gophercloud v0.18.0 h1:V6hcuMPmjXg+js9flU8T3RIHDCjV7F5CG5GD0MRhP/w= github.com/gophercloud/gophercloud v0.18.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4= github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -1035,6 +1060,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/grafana/dskit v0.0.0-20210817085554-1b69d2de136f h1:zCEH60Ej/qD5nISoB2DMwONGQUTZzrSwprY41RX/NqM= +github.com/grafana/dskit v0.0.0-20210817085554-1b69d2de136f/go.mod h1:QaNAQaCSFOtG/NHf6Jd/zh67H25kkrVCq36U61Y2Mhw= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85/go.mod h1:crI9WX6p0IhrqB+DqIUHulRW853PaNFf7o4UprV//3I= github.com/grafana/tail v0.0.0-20201004203643-7aa4e4a91f03 h1:fGgFrAraMB0BaPfYumu+iulfDXwHm+GFyHA4xEtBqI8= @@ -1166,6 +1193,7 @@ github.com/hetznercloud/hcloud-go v1.21.1/go.mod h1:xng8lbDUg+xM1dgc0yGHX5EeqbwI github.com/hetznercloud/hcloud-go v1.22.0/go.mod h1:xng8lbDUg+xM1dgc0yGHX5EeqbwIq7UYlMWMTx3SQVg= github.com/hetznercloud/hcloud-go v1.23.1/go.mod h1:xng8lbDUg+xM1dgc0yGHX5EeqbwIq7UYlMWMTx3SQVg= github.com/hetznercloud/hcloud-go v1.24.0/go.mod h1:3YmyK8yaZZ48syie6xpm3dt26rtB6s65AisBHylXYFA= +github.com/hetznercloud/hcloud-go v1.25.0/go.mod h1:2C5uMtBiMoFr3m7lBFPf7wXTdh33CevmZpQIIDPGYJI= github.com/hetznercloud/hcloud-go v1.26.2 h1:fI8BXAGJI4EFeCDd2a/I4EhqyK32cDdxGeWfYMGUi50= github.com/hetznercloud/hcloud-go v1.26.2/go.mod h1:2C5uMtBiMoFr3m7lBFPf7wXTdh33CevmZpQIIDPGYJI= github.com/hodgesds/perf-utils v0.0.8/go.mod h1:F6TfvsbtrF88i++hou29dTXlI2sfsJv+gRZDtmTJkAs= @@ -1196,8 +1224,10 @@ github.com/influxdata/influxdb v1.8.1/go.mod h1:SIzcnsjaHRFpmlxpJ4S3NT64qtEKYweN github.com/influxdata/influxdb v1.8.2/go.mod h1:SIzcnsjaHRFpmlxpJ4S3NT64qtEKYweNTUMb/vh0OMQ= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= github.com/influxdata/influxdb v1.8.4/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= +github.com/influxdata/influxdb v1.8.5/go.mod h1:oFH+pbEyDln/1TKwa98oJzVrkZwdjrJOwIDGYZj7Ma0= github.com/influxdata/influxdb v1.9.2/go.mod h1:UEe3MeD9AaP5rlPIes102IhYua3FhIWZuOXNHxDjSrI= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/influxql v1.1.0/go.mod h1:KpVI7okXjK6PRi3Z5B+mtKZli+R1DnZgb3N+tzevNgo= github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= github.com/influxdata/influxql v1.1.1-0.20210223160523-b6ab99450c93/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= @@ -1286,8 +1316,10 @@ github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.13 h1:eSvu8Tmq6j2psUJqJrLcWH6K3w5Dwc+qipbaA6eVEN4= +github.com/klauspost/compress v1.11.12/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.1 h1:wXr2uRxZTJXHLly6qhJabee5JqIhTRoLBhDOA74hDEQ= +github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s= @@ -1406,6 +1438,7 @@ github.com/miekg/dns v1.1.42/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0 github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/mileusna/useragent v0.0.0-20190129205925-3e331f0949a5/go.mod h1:JWhYAp2EXqUtsxTKdeGlY8Wp44M7VxThC9FEoNGi2IE= +github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/minio-go/v6 v6.0.44/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= @@ -1478,11 +1511,17 @@ github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86w github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= +github.com/nats-io/jwt/v2 v2.0.2/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= github.com/nats-io/nats-server/v2 v2.1.4/go.mod h1:Jw1Z28soD/QasIA2uWjXyM9El1jly3YwyFOuR8tH1rg= +github.com/nats-io/nats-server/v2 v2.2.6/go.mod h1:sEnFaxqe09cDmfMgACxZbziXnhQFhwk+aKkZjBBRYrI= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nats.go v1.11.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= +github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/ncw/swift v1.0.50/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= @@ -1574,6 +1613,7 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/openzipkin/zipkin-go-opentracing v0.3.4/go.mod h1:js2AbwmHW0YD9DwIw2JhQWmbfFi/UnWyYwdVhqbCDOE= github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= @@ -1622,8 +1662,8 @@ github.com/prometheus/alertmanager v0.21.1-0.20201106142418-c39b78780054/go.mod github.com/prometheus/alertmanager v0.21.1-0.20210310093010-0f9cab6991e6/go.mod h1:MTqVn+vIupE0dzdgo+sMcNCp37SCAi8vPrvKTTnTz9g= github.com/prometheus/alertmanager v0.21.1-0.20210422101724-8176f78a70e1/go.mod h1:gsEqwD5BHHW9RNKvCuPOrrTMiP5I+faJUyLXvnivHik= github.com/prometheus/alertmanager v0.22.2/go.mod h1:rYinOWxFuCnNssc3iOjn2oMTlhLaPcUuqV5yk5JKUAE= -github.com/prometheus/alertmanager v0.22.3-0.20210628111558-8491f816296b h1:Ug/6s8FVHfsuSGFNUTAhvp3ZXkeAVk2TvHeolesN/wk= -github.com/prometheus/alertmanager v0.22.3-0.20210628111558-8491f816296b/go.mod h1:ntrorfzWQ1I9mhJK7AO71w4xMUgM4SxmwbtyQgAWZz0= +github.com/prometheus/alertmanager v0.22.3-0.20210726110322-3d86bd709df8 h1:EH5EZxZcmazowe8c86MnhO77Kn/7ni9C5SdmdDK38UE= +github.com/prometheus/alertmanager v0.22.3-0.20210726110322-3d86bd709df8/go.mod h1:BBhEP06PwDGsIKsQzOeTNe2jU6tU19SzhJ41C2ib4XE= github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.0.0-20180328130430-f504d69affe1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -1677,12 +1717,14 @@ github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.20.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.21.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.23.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= -github.com/prometheus/common v0.24.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0 h1:3jqPBvKT4OHAbje2Ql7KeaaSicDBCxMYwEJU1zRJceE= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= +github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.5.0/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= +github.com/prometheus/exporter-toolkit v0.6.0 h1:rGoS9gIqj3sXaw+frvo0ozCs1CxBRqpOCGsbixC52UI= github.com/prometheus/exporter-toolkit v0.6.0/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= github.com/prometheus/node_exporter v1.0.0-rc.0.0.20200428091818-01054558c289 h1:dTUS1vaLWq+Y6XKOTnrFpoVsQKLCbCp1OLj24TDi7oM= github.com/prometheus/node_exporter v1.0.0-rc.0.0.20200428091818-01054558c289/go.mod h1:FGbBv5OPKjch+jNUJmEQpMZytIdyW0NdBtWFcfSKusc= @@ -1722,7 +1764,7 @@ github.com/prometheus/prometheus v1.8.2-0.20201119181812-c8f810083d3f/go.mod h1: github.com/prometheus/prometheus v1.8.2-0.20210215121130-6f488061dfb4/go.mod h1:NAYujktP0dmSSpeV155mtnwX2pndLpVVK/Ps68R01TA= github.com/prometheus/prometheus v1.8.2-0.20210315220929-1cba1741828b/go.mod h1:MS/bpdil77lPbfQeKk6OqVQ9OLnpN3Rszd0hka0EOWE= github.com/prometheus/prometheus v1.8.2-0.20210324152458-c7a62b95cea0/go.mod h1:sf7j/iAbhZahjeC0s3wwMmp5dksrJ/Za1UKdR+j6Hmw= -github.com/prometheus/prometheus v1.8.2-0.20210421143221-52df5ef7a3be/go.mod h1:WbIKsp4vWCoPHis5qQfd0QimLOR7qe79roXN5O8U8bs= +github.com/prometheus/prometheus v1.8.2-0.20210519120135-d95b0972505f/go.mod h1:yUzDYX0hIYu5YVHmpj/JXLOclB6QcLNDgmagD3FUnSU= github.com/prometheus/prometheus v1.8.2-0.20210720123808-b1ed4a0a663d h1:UnqZFF2qXa+ctCfbss/J4yn9rTVoTiuawjrokqwt4Hg= github.com/prometheus/prometheus v1.8.2-0.20210720123808-b1ed4a0a663d/go.mod h1:o6V+A4iPEWjLG0rSEKeev3OzfBZwP+ay+4iS4dkfLI4= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -1797,8 +1839,9 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= @@ -1843,7 +1886,9 @@ github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8/go.mod h1:1WNBiOZtZQLpVAyu0iTduoJL9hEsMloAK5XWrtW0xdY= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -1877,8 +1922,8 @@ github.com/thanos-io/thanos v0.13.1-0.20210204123931-82545cdd16fe/go.mod h1:ZLDG github.com/thanos-io/thanos v0.13.1-0.20210224074000-659446cab117/go.mod h1:kdqFpzdkveIKpNNECVJd75RPvgsAifQgJymwCdfev1w= github.com/thanos-io/thanos v0.13.1-0.20210226164558-03dace0a1aa1/go.mod h1:gMCy4oCteKTT7VuXVvXLTPGzzjovX1VPE5p+HgL1hyU= github.com/thanos-io/thanos v0.13.1-0.20210401085038-d7dff0c84d17/go.mod h1:zU8KqE+6A+HksK4wiep8e/3UvCZLm+Wrw9AqZGaAm9k= -github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2 h1:L6U4VYeIConcO4GaFOAaZW4Gwr+lIVfBprW9a0+py/k= -github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2/go.mod h1:zvSf4uKtey4KjSVcalV/5oUuGthaTzI8kVDrO42I8II= +github.com/thanos-io/thanos v0.19.1-0.20210729154440-aa148f8fdb28 h1:rppxzAPi+uFTCzaEgYuo/9JPmhPWcxL9UHat4UfA/SM= +github.com/thanos-io/thanos v0.19.1-0.20210729154440-aa148f8fdb28/go.mod h1:Xskx78e0CYL6w0yDNOZHGdvwQMlsuzPsePmPtbp9Xuk= github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab h1:7ZR3hmisBWw77ZpO1/o86g+JV3VKlk3d48jopJxzTjU= github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab/go.mod h1:eheTFp954zcWZXCU8d0AT76ftsQOTo4DTqkN/h3k1MY= github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= @@ -1999,13 +2044,18 @@ go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mI go.etcd.io/etcd v0.5.0-alpha.5.0.20200520232829-54ba9589114f/go.mod h1:skWido08r9w6Lq/w70DO5XYIKMu4QFu1+4VsqLQuJy8= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= -go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 h1:+e5nrluATIy3GP53znpkHMFzPTHGYyzvJGFCbuI6ZLc= go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= -go.etcd.io/etcd/client/v2 v2.305.0-alpha.0 h1:jZepGpOeJATxsbMNBZczDS2jHdK/QVHM1iPe9jURJ8o= +go.etcd.io/etcd/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/6PU= +go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0-alpha.0/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= +go.etcd.io/etcd/client/v2 v2.305.0 h1:ftQ0nOOHMcbMS3KIaDQ0g5Qcd6bhaBrQT6b89DfwLTs= +go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= -go.etcd.io/etcd/client/v3 v3.5.0-alpha.0.0.20210225194612-fa82d11a958a h1:GZLxiPIaZ/U1Mez9rw3BqUHKt3y3+CK4HWtGAG0Pfx0= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0.0.20210225194612-fa82d11a958a/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= +go.etcd.io/etcd/client/v3 v3.5.0 h1:62Eh0XOro+rDwkrypAGDfgmNh5Joq+z+W9HZdlXMzek= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0 h1:3yLUEC0nFCxw/RArImOyRUI4OAFbg4PFpBbAhSNzKNY= go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0 h1:DvYJotxV9q1Lkn7pknzAbFO/CLtCVidCr2K9qRLJ8pA= @@ -2052,26 +2102,29 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.8.0 h1:CUhrE4N1rqSE6FM9ecihEjRkLQu8cDfgDyoOs83mEY4= go.uber.org/atomic v1.8.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.2.0/go.mod h1:YfO3fm683kQpzETxlTGZhGIVmXAhaw3gxeBADbpZtnU= +go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q= go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= -go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go4.org/intern v0.0.0-20210108033219-3eb7198706b2 h1:VFTf+jjIgsldaz/Mr00VaCSswHJrI2hIjQygE/W4IMg= go4.org/intern v0.0.0-20210108033219-3eb7198706b2/go.mod h1:vLqJ+12kCw61iCWsPto0EOHhBS+o4rO5VIucbc9g2Cc= go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222175341-b30ae309168e/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= @@ -2104,6 +2157,7 @@ golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200422194213-44a606286825/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -2114,7 +2168,9 @@ golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2234,6 +2290,7 @@ golang.org/x/net v0.0.0-20210324051636-2c4c8ecb7826/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210505214959-0714010a04ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -2253,6 +2310,7 @@ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2279,6 +2337,7 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190102155601-82a175fd1598/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2389,8 +2448,11 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2565,6 +2627,7 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.42.0/go.mod h1:+Oj4s6ch2SEGtPjGqfUfZonBH0GjQH89gTeKKAEGZKI= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.46.0/go.mod h1:ceL4oozhkAiTID8XMmJBsIxID/9wMXJVVFXPg4ylg3I= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0 h1:RDAPWfNFY06dffEXfn7hZF5Fr1ZbnChzfQZAPyBd1+I= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= @@ -2637,6 +2700,7 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210312152112-fc591d9ea70f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 h1:pc16UedxnxXXtGxHCSUhafAoVHQZ0yXl8ZelMH4EETc= @@ -2689,8 +2753,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -2771,7 +2836,6 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= inet.af/netaddr v0.0.0-20210707202901-70468d781e6c h1:ZNUX2CiFwNbN1VFaD4MQFmC8o5Rxc7BQW1P1K8kMpbE= diff --git a/pkg/canary/reader/reader.go b/pkg/canary/reader/reader.go index 1ef1b43ddd95..d1ca3d4266ee 100644 --- a/pkg/canary/reader/reader.go +++ b/pkg/canary/reader/reader.go @@ -15,8 +15,8 @@ import ( "sync" "time" - "github.com/cortexproject/cortex/pkg/util" "github.com/gorilla/websocket" + "github.com/grafana/dskit/backoff" json "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -59,7 +59,7 @@ type Reader struct { sValue string lName string lVal string - backoff *util.Backoff + backoff *backoff.Backoff nextQuery time.Time backoffMtx sync.RWMutex interval time.Duration @@ -92,12 +92,12 @@ func NewReader(writer io.Writer, } next := time.Now() - bkcfg := util.BackoffConfig{ + bkcfg := backoff.Config{ MinBackoff: 1 * time.Second, MaxBackoff: 10 * time.Minute, MaxRetries: 0, } - bkoff := util.NewBackoff(context.Background(), bkcfg) + bkoff := backoff.New(context.Background(), bkcfg) rd := Reader{ header: h, @@ -438,7 +438,7 @@ func parseResponse(entry *loghttp.Entry) (*time.Time, error) { return &t, nil } -func nextBackoff(w io.Writer, statusCode int, backoff *util.Backoff) time.Time { +func nextBackoff(w io.Writer, statusCode int, backoff *backoff.Backoff) time.Time { // Be way more conservative with an http 429 and wait 5 minutes before trying again. var next time.Time if statusCode == http.StatusTooManyRequests { diff --git a/pkg/ingester/transfer.go b/pkg/ingester/transfer.go index ecc9a76543e1..679b61bb1b86 100644 --- a/pkg/ingester/transfer.go +++ b/pkg/ingester/transfer.go @@ -7,9 +7,9 @@ import ( "time" "github.com/cortexproject/cortex/pkg/ring" - "github.com/cortexproject/cortex/pkg/util" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -186,7 +186,7 @@ func (i *Ingester) TransferOut(ctx context.Context) error { return ring.ErrTransferDisabled } - backoff := util.NewBackoff(ctx, util.BackoffConfig{ + backoff := backoff.New(ctx, backoff.Config{ MinBackoff: 100 * time.Millisecond, MaxBackoff: 5 * time.Second, MaxRetries: i.cfg.MaxTransferRetries, diff --git a/pkg/loki/loki.go b/pkg/loki/loki.go index 19978e63449b..f1e33cdfe8b9 100644 --- a/pkg/loki/loki.go +++ b/pkg/loki/loki.go @@ -371,7 +371,7 @@ func (t *Loki) readyHandler(sm *services.Manager) http.HandlerFunc { } func (t *Loki) setupModuleManager() error { - mm := modules.NewManager() + mm := modules.NewManager(util_log.Logger) mm.RegisterModule(Server, t.initServer) mm.RegisterModule(RuntimeConfig, t.initRuntimeConfig) diff --git a/pkg/storage/chunk/aws/dynamodb_storage_client.go b/pkg/storage/chunk/aws/dynamodb_storage_client.go index ab4687dc823e..449bd1669d5b 100644 --- a/pkg/storage/chunk/aws/dynamodb_storage_client.go +++ b/pkg/storage/chunk/aws/dynamodb_storage_client.go @@ -10,11 +10,6 @@ import ( "strings" "time" - "github.com/go-kit/kit/log/level" - ot "github.com/opentracing/opentracing-go" - otlog "github.com/opentracing/opentracing-go/log" - "golang.org/x/time/rate" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/client" @@ -22,10 +17,15 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" + "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" + ot "github.com/opentracing/opentracing-go" + otlog "github.com/opentracing/opentracing-go/log" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" awscommon "github.com/weaveworks/common/aws" "github.com/weaveworks/common/instrument" + "golang.org/x/time/rate" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" @@ -61,7 +61,7 @@ type DynamoDBConfig struct { Metrics MetricsAutoScalingConfig `yaml:"metrics"` ChunkGangSize int `yaml:"chunk_gang_size"` ChunkGetMaxParallelism int `yaml:"chunk_get_max_parallelism"` - BackoffConfig util.BackoffConfig `yaml:"backoff_config"` + BackoffConfig backoff.Config `yaml:"backoff_config"` } // RegisterFlags adds the flags required to config this to the given FlagSet @@ -178,7 +178,7 @@ func (a dynamoDBStorageClient) BatchWrite(ctx context.Context, input chunk.Write outstanding := input.(dynamoDBWriteBatch) unprocessed := dynamoDBWriteBatch{} - backoff := util.NewBackoff(ctx, a.cfg.BackoffConfig) + backoff := backoff.New(ctx, a.cfg.BackoffConfig) for outstanding.Len()+unprocessed.Len() > 0 && backoff.Ongoing() { requests := dynamoDBWriteBatch{} @@ -434,7 +434,7 @@ func (a dynamoDBStorageClient) getDynamoDBChunks(ctx context.Context, chunks []c result := []chunk.Chunk{} unprocessed := dynamoDBReadRequest{} - backoff := util.NewBackoff(ctx, a.cfg.BackoffConfig) + backoff := backoff.New(ctx, a.cfg.BackoffConfig) for outstanding.Len()+unprocessed.Len() > 0 && backoff.Ongoing() { requests := dynamoDBReadRequest{} diff --git a/pkg/storage/chunk/aws/dynamodb_table_client.go b/pkg/storage/chunk/aws/dynamodb_table_client.go index 4fde3fca9539..54f56bf6ed5c 100644 --- a/pkg/storage/chunk/aws/dynamodb_table_client.go +++ b/pkg/storage/chunk/aws/dynamodb_table_client.go @@ -8,15 +8,14 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" + "github.com/cortexproject/cortex/pkg/util/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/weaveworks/common/instrument" "golang.org/x/time/rate" - "github.com/cortexproject/cortex/pkg/util" - "github.com/cortexproject/cortex/pkg/util/log" - "github.com/grafana/loki/pkg/storage/chunk" ) @@ -31,7 +30,7 @@ type autoscale interface { type callManager struct { limiter *rate.Limiter - backoffConfig util.BackoffConfig + backoffConfig backoff.Config } type dynamoTableClient struct { @@ -81,7 +80,7 @@ func (d callManager) backoffAndRetry(ctx context.Context, fn func(context.Contex _ = d.limiter.Wait(ctx) } - backoff := util.NewBackoff(ctx, d.backoffConfig) + backoff := backoff.New(ctx, d.backoffConfig) for backoff.Ongoing() { if err := fn(ctx); err != nil { if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ThrottlingException" { diff --git a/pkg/storage/chunk/aws/fixtures.go b/pkg/storage/chunk/aws/fixtures.go index 7d1e27c04620..36aa4eefe395 100644 --- a/pkg/storage/chunk/aws/fixtures.go +++ b/pkg/storage/chunk/aws/fixtures.go @@ -5,10 +5,9 @@ import ( "io" "time" + "github.com/grafana/dskit/backoff" "golang.org/x/time/rate" - "github.com/cortexproject/cortex/pkg/util" - "github.com/grafana/loki/pkg/storage/chunk" "github.com/grafana/loki/pkg/storage/chunk/objectclient" "github.com/grafana/loki/pkg/storage/chunk/testutils" @@ -75,7 +74,7 @@ func dynamoDBFixture(provisionedErr, gangsize, maxParallelism int) testutils.Fix cfg: DynamoDBConfig{ ChunkGangSize: gangsize, ChunkGetMaxParallelism: maxParallelism, - BackoffConfig: util.BackoffConfig{ + BackoffConfig: backoff.Config{ MinBackoff: 1 * time.Millisecond, MaxBackoff: 5 * time.Millisecond, MaxRetries: 20, diff --git a/pkg/storage/chunk/aws/retryer.go b/pkg/storage/chunk/aws/retryer.go index 94ac71f90570..5e3b7a2710b2 100644 --- a/pkg/storage/chunk/aws/retryer.go +++ b/pkg/storage/chunk/aws/retryer.go @@ -5,23 +5,22 @@ import ( "time" "github.com/aws/aws-sdk-go/aws/request" + "github.com/grafana/dskit/backoff" ot "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" - - "github.com/cortexproject/cortex/pkg/util" ) // Map Cortex Backoff into AWS Retryer interface type retryer struct { - *util.Backoff + *backoff.Backoff maxRetries int } var _ request.Retryer = &retryer{} -func newRetryer(ctx context.Context, cfg util.BackoffConfig) *retryer { +func newRetryer(ctx context.Context, cfg backoff.Config) *retryer { return &retryer{ - Backoff: util.NewBackoff(ctx, cfg), + Backoff: backoff.New(ctx, cfg), maxRetries: cfg.MaxRetries, } } diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/auth/LICENSE b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/LICENSE new file mode 100644 index 000000000000..b9d6a27ea92e --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015 Microsoft Corporation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/auth/auth.go b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/auth.go new file mode 100644 index 000000000000..85acf1c9bc98 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/auth.go @@ -0,0 +1,757 @@ +package auth + +// Copyright 2017 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "bytes" + "encoding/binary" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "log" + "os" + "strings" + "unicode/utf16" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/adal" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/azure/cli" + "github.com/Azure/go-autorest/logger" + "github.com/dimchansky/utfbom" +) + +// The possible keys in the Values map. +const ( + SubscriptionID = "AZURE_SUBSCRIPTION_ID" + TenantID = "AZURE_TENANT_ID" + AuxiliaryTenantIDs = "AZURE_AUXILIARY_TENANT_IDS" + ClientID = "AZURE_CLIENT_ID" + ClientSecret = "AZURE_CLIENT_SECRET" + CertificatePath = "AZURE_CERTIFICATE_PATH" + CertificatePassword = "AZURE_CERTIFICATE_PASSWORD" + Username = "AZURE_USERNAME" + Password = "AZURE_PASSWORD" + EnvironmentName = "AZURE_ENVIRONMENT" + Resource = "AZURE_AD_RESOURCE" + ActiveDirectoryEndpoint = "ActiveDirectoryEndpoint" + ResourceManagerEndpoint = "ResourceManagerEndpoint" + GraphResourceID = "GraphResourceID" + SQLManagementEndpoint = "SQLManagementEndpoint" + GalleryEndpoint = "GalleryEndpoint" + ManagementEndpoint = "ManagementEndpoint" +) + +// NewAuthorizerFromEnvironment creates an Authorizer configured from environment variables in the order: +// 1. Client credentials +// 2. Client certificate +// 3. Username password +// 4. MSI +func NewAuthorizerFromEnvironment() (autorest.Authorizer, error) { + logger.Instance.Writeln(logger.LogInfo, "NewAuthorizerFromEnvironment() determining authentication mechanism") + settings, err := GetSettingsFromEnvironment() + if err != nil { + return nil, err + } + return settings.GetAuthorizer() +} + +// NewAuthorizerFromEnvironmentWithResource creates an Authorizer configured from environment variables in the order: +// 1. Client credentials +// 2. Client certificate +// 3. Username password +// 4. MSI +func NewAuthorizerFromEnvironmentWithResource(resource string) (autorest.Authorizer, error) { + logger.Instance.Writeln(logger.LogInfo, "NewAuthorizerFromEnvironmentWithResource() determining authentication mechanism") + settings, err := GetSettingsFromEnvironment() + if err != nil { + return nil, err + } + settings.Values[Resource] = resource + return settings.GetAuthorizer() +} + +// EnvironmentSettings contains the available authentication settings. +type EnvironmentSettings struct { + Values map[string]string + Environment azure.Environment +} + +// GetSettingsFromEnvironment returns the available authentication settings from the environment. +func GetSettingsFromEnvironment() (s EnvironmentSettings, err error) { + s = EnvironmentSettings{ + Values: map[string]string{}, + } + s.setValue(SubscriptionID) + s.setValue(TenantID) + s.setValue(AuxiliaryTenantIDs) + s.setValue(ClientID) + s.setValue(ClientSecret) + s.setValue(CertificatePath) + s.setValue(CertificatePassword) + s.setValue(Username) + s.setValue(Password) + s.setValue(EnvironmentName) + s.setValue(Resource) + if v := s.Values[EnvironmentName]; v == "" { + s.Environment = azure.PublicCloud + } else { + s.Environment, err = azure.EnvironmentFromName(v) + } + if s.Values[Resource] == "" { + s.Values[Resource] = s.Environment.ResourceManagerEndpoint + } + return +} + +// GetSubscriptionID returns the available subscription ID or an empty string. +func (settings EnvironmentSettings) GetSubscriptionID() string { + return settings.Values[SubscriptionID] +} + +// adds the specified environment variable value to the Values map if it exists +func (settings EnvironmentSettings) setValue(key string) { + if v := os.Getenv(key); v != "" { + logger.Instance.Writef(logger.LogInfo, "GetSettingsFromEnvironment() found environment var %s\n", key) + settings.Values[key] = v + } +} + +// helper to return client and tenant IDs +func (settings EnvironmentSettings) getClientAndTenant() (string, string) { + clientID := settings.Values[ClientID] + tenantID := settings.Values[TenantID] + return clientID, tenantID +} + +// GetClientCredentials creates a config object from the available client credentials. +// An error is returned if no client credentials are available. +func (settings EnvironmentSettings) GetClientCredentials() (ClientCredentialsConfig, error) { + secret := settings.Values[ClientSecret] + if secret == "" { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetClientCredentials() missing client secret") + return ClientCredentialsConfig{}, errors.New("missing client secret") + } + clientID, tenantID := settings.getClientAndTenant() + config := NewClientCredentialsConfig(clientID, secret, tenantID) + config.AADEndpoint = settings.Environment.ActiveDirectoryEndpoint + config.Resource = settings.Values[Resource] + if auxTenants, ok := settings.Values[AuxiliaryTenantIDs]; ok { + config.AuxTenants = strings.Split(auxTenants, ";") + for i := range config.AuxTenants { + config.AuxTenants[i] = strings.TrimSpace(config.AuxTenants[i]) + } + } + return config, nil +} + +// GetClientCertificate creates a config object from the available certificate credentials. +// An error is returned if no certificate credentials are available. +func (settings EnvironmentSettings) GetClientCertificate() (ClientCertificateConfig, error) { + certPath := settings.Values[CertificatePath] + if certPath == "" { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetClientCertificate() missing certificate path") + return ClientCertificateConfig{}, errors.New("missing certificate path") + } + certPwd := settings.Values[CertificatePassword] + clientID, tenantID := settings.getClientAndTenant() + config := NewClientCertificateConfig(certPath, certPwd, clientID, tenantID) + config.AADEndpoint = settings.Environment.ActiveDirectoryEndpoint + config.Resource = settings.Values[Resource] + return config, nil +} + +// GetUsernamePassword creates a config object from the available username/password credentials. +// An error is returned if no username/password credentials are available. +func (settings EnvironmentSettings) GetUsernamePassword() (UsernamePasswordConfig, error) { + username := settings.Values[Username] + password := settings.Values[Password] + if username == "" || password == "" { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetUsernamePassword() missing username and/or password") + return UsernamePasswordConfig{}, errors.New("missing username/password") + } + clientID, tenantID := settings.getClientAndTenant() + config := NewUsernamePasswordConfig(username, password, clientID, tenantID) + config.AADEndpoint = settings.Environment.ActiveDirectoryEndpoint + config.Resource = settings.Values[Resource] + return config, nil +} + +// GetMSI creates a MSI config object from the available client ID. +func (settings EnvironmentSettings) GetMSI() MSIConfig { + config := NewMSIConfig() + config.Resource = settings.Values[Resource] + config.ClientID = settings.Values[ClientID] + return config +} + +// GetDeviceFlow creates a device-flow config object from the available client and tenant IDs. +func (settings EnvironmentSettings) GetDeviceFlow() DeviceFlowConfig { + clientID, tenantID := settings.getClientAndTenant() + config := NewDeviceFlowConfig(clientID, tenantID) + config.AADEndpoint = settings.Environment.ActiveDirectoryEndpoint + config.Resource = settings.Values[Resource] + return config +} + +// GetAuthorizer creates an Authorizer configured from environment variables in the order: +// 1. Client credentials +// 2. Client certificate +// 3. Username password +// 4. MSI +func (settings EnvironmentSettings) GetAuthorizer() (autorest.Authorizer, error) { + //1.Client Credentials + if c, e := settings.GetClientCredentials(); e == nil { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetAuthorizer() using client secret credentials") + return c.Authorizer() + } + + //2. Client Certificate + if c, e := settings.GetClientCertificate(); e == nil { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetAuthorizer() using client certificate credentials") + return c.Authorizer() + } + + //3. Username Password + if c, e := settings.GetUsernamePassword(); e == nil { + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetAuthorizer() using user name/password credentials") + return c.Authorizer() + } + + // 4. MSI + logger.Instance.Writeln(logger.LogInfo, "EnvironmentSettings.GetAuthorizer() using MSI authentication") + return settings.GetMSI().Authorizer() +} + +// NewAuthorizerFromFile creates an Authorizer configured from a configuration file in the following order. +// 1. Client credentials +// 2. Client certificate +// The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable. +// resourceBaseURI - used to determine the resource type +func NewAuthorizerFromFile(resourceBaseURI string) (autorest.Authorizer, error) { + settings, err := GetSettingsFromFile() + if err != nil { + return nil, err + } + if a, err := settings.ClientCredentialsAuthorizer(resourceBaseURI); err == nil { + return a, err + } + if a, err := settings.ClientCertificateAuthorizer(resourceBaseURI); err == nil { + return a, err + } + return nil, errors.New("auth file missing client and certificate credentials") +} + +// NewAuthorizerFromFileWithResource creates an Authorizer configured from a configuration file in the following order. +// 1. Client credentials +// 2. Client certificate +// The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable. +func NewAuthorizerFromFileWithResource(resource string) (autorest.Authorizer, error) { + s, err := GetSettingsFromFile() + if err != nil { + return nil, err + } + if a, err := s.ClientCredentialsAuthorizerWithResource(resource); err == nil { + return a, err + } + if a, err := s.ClientCertificateAuthorizerWithResource(resource); err == nil { + return a, err + } + return nil, errors.New("auth file missing client and certificate credentials") +} + +// NewAuthorizerFromCLI creates an Authorizer configured from Azure CLI 2.0 for local development scenarios. +func NewAuthorizerFromCLI() (autorest.Authorizer, error) { + settings, err := GetSettingsFromEnvironment() + if err != nil { + return nil, err + } + + if settings.Values[Resource] == "" { + settings.Values[Resource] = settings.Environment.ResourceManagerEndpoint + } + + return NewAuthorizerFromCLIWithResource(settings.Values[Resource]) +} + +// NewAuthorizerFromCLIWithResource creates an Authorizer configured from Azure CLI 2.0 for local development scenarios. +func NewAuthorizerFromCLIWithResource(resource string) (autorest.Authorizer, error) { + token, err := cli.GetTokenFromCLI(resource) + if err != nil { + return nil, err + } + + adalToken, err := token.ToADALToken() + if err != nil { + return nil, err + } + + return autorest.NewBearerAuthorizer(&adalToken), nil +} + +// GetSettingsFromFile returns the available authentication settings from an Azure CLI authentication file. +func GetSettingsFromFile() (FileSettings, error) { + s := FileSettings{} + fileLocation := os.Getenv("AZURE_AUTH_LOCATION") + if fileLocation == "" { + return s, errors.New("environment variable AZURE_AUTH_LOCATION is not set") + } + + contents, err := ioutil.ReadFile(fileLocation) + if err != nil { + return s, err + } + + // Auth file might be encoded + decoded, err := decode(contents) + if err != nil { + return s, err + } + + authFile := map[string]interface{}{} + err = json.Unmarshal(decoded, &authFile) + if err != nil { + return s, err + } + + s.Values = map[string]string{} + s.setKeyValue(ClientID, authFile["clientId"]) + s.setKeyValue(ClientSecret, authFile["clientSecret"]) + s.setKeyValue(CertificatePath, authFile["clientCertificate"]) + s.setKeyValue(CertificatePassword, authFile["clientCertificatePassword"]) + s.setKeyValue(SubscriptionID, authFile["subscriptionId"]) + s.setKeyValue(TenantID, authFile["tenantId"]) + s.setKeyValue(ActiveDirectoryEndpoint, authFile["activeDirectoryEndpointUrl"]) + s.setKeyValue(ResourceManagerEndpoint, authFile["resourceManagerEndpointUrl"]) + s.setKeyValue(GraphResourceID, authFile["activeDirectoryGraphResourceId"]) + s.setKeyValue(SQLManagementEndpoint, authFile["sqlManagementEndpointUrl"]) + s.setKeyValue(GalleryEndpoint, authFile["galleryEndpointUrl"]) + s.setKeyValue(ManagementEndpoint, authFile["managementEndpointUrl"]) + return s, nil +} + +// FileSettings contains the available authentication settings. +type FileSettings struct { + Values map[string]string +} + +// GetSubscriptionID returns the available subscription ID or an empty string. +func (settings FileSettings) GetSubscriptionID() string { + return settings.Values[SubscriptionID] +} + +// adds the specified value to the Values map if it isn't nil +func (settings FileSettings) setKeyValue(key string, val interface{}) { + if val != nil { + settings.Values[key] = val.(string) + } +} + +// returns the specified AAD endpoint or the public cloud endpoint if unspecified +func (settings FileSettings) getAADEndpoint() string { + if v, ok := settings.Values[ActiveDirectoryEndpoint]; ok { + return v + } + return azure.PublicCloud.ActiveDirectoryEndpoint +} + +// ServicePrincipalTokenFromClientCredentials creates a ServicePrincipalToken from the available client credentials. +func (settings FileSettings) ServicePrincipalTokenFromClientCredentials(baseURI string) (*adal.ServicePrincipalToken, error) { + resource, err := settings.getResourceForToken(baseURI) + if err != nil { + return nil, err + } + return settings.ServicePrincipalTokenFromClientCredentialsWithResource(resource) +} + +// ClientCredentialsAuthorizer creates an authorizer from the available client credentials. +func (settings FileSettings) ClientCredentialsAuthorizer(baseURI string) (autorest.Authorizer, error) { + resource, err := settings.getResourceForToken(baseURI) + if err != nil { + return nil, err + } + return settings.ClientCredentialsAuthorizerWithResource(resource) +} + +// ServicePrincipalTokenFromClientCredentialsWithResource creates a ServicePrincipalToken +// from the available client credentials and the specified resource. +func (settings FileSettings) ServicePrincipalTokenFromClientCredentialsWithResource(resource string) (*adal.ServicePrincipalToken, error) { + if _, ok := settings.Values[ClientSecret]; !ok { + return nil, errors.New("missing client secret") + } + config, err := adal.NewOAuthConfig(settings.getAADEndpoint(), settings.Values[TenantID]) + if err != nil { + return nil, err + } + return adal.NewServicePrincipalToken(*config, settings.Values[ClientID], settings.Values[ClientSecret], resource) +} + +func (settings FileSettings) clientCertificateConfigWithResource(resource string) (ClientCertificateConfig, error) { + if _, ok := settings.Values[CertificatePath]; !ok { + return ClientCertificateConfig{}, errors.New("missing certificate path") + } + cfg := NewClientCertificateConfig(settings.Values[CertificatePath], settings.Values[CertificatePassword], settings.Values[ClientID], settings.Values[TenantID]) + cfg.AADEndpoint = settings.getAADEndpoint() + cfg.Resource = resource + return cfg, nil +} + +// ClientCredentialsAuthorizerWithResource creates an authorizer from the available client credentials and the specified resource. +func (settings FileSettings) ClientCredentialsAuthorizerWithResource(resource string) (autorest.Authorizer, error) { + spToken, err := settings.ServicePrincipalTokenFromClientCredentialsWithResource(resource) + if err != nil { + return nil, err + } + return autorest.NewBearerAuthorizer(spToken), nil +} + +// ServicePrincipalTokenFromClientCertificate creates a ServicePrincipalToken from the available certificate credentials. +func (settings FileSettings) ServicePrincipalTokenFromClientCertificate(baseURI string) (*adal.ServicePrincipalToken, error) { + resource, err := settings.getResourceForToken(baseURI) + if err != nil { + return nil, err + } + return settings.ServicePrincipalTokenFromClientCertificateWithResource(resource) +} + +// ClientCertificateAuthorizer creates an authorizer from the available certificate credentials. +func (settings FileSettings) ClientCertificateAuthorizer(baseURI string) (autorest.Authorizer, error) { + resource, err := settings.getResourceForToken(baseURI) + if err != nil { + return nil, err + } + return settings.ClientCertificateAuthorizerWithResource(resource) +} + +// ServicePrincipalTokenFromClientCertificateWithResource creates a ServicePrincipalToken from the available certificate credentials. +func (settings FileSettings) ServicePrincipalTokenFromClientCertificateWithResource(resource string) (*adal.ServicePrincipalToken, error) { + cfg, err := settings.clientCertificateConfigWithResource(resource) + if err != nil { + return nil, err + } + return cfg.ServicePrincipalToken() +} + +// ClientCertificateAuthorizerWithResource creates an authorizer from the available certificate credentials and the specified resource. +func (settings FileSettings) ClientCertificateAuthorizerWithResource(resource string) (autorest.Authorizer, error) { + cfg, err := settings.clientCertificateConfigWithResource(resource) + if err != nil { + return nil, err + } + return cfg.Authorizer() +} + +func decode(b []byte) ([]byte, error) { + reader, enc := utfbom.Skip(bytes.NewReader(b)) + + switch enc { + case utfbom.UTF16LittleEndian: + u16 := make([]uint16, (len(b)/2)-1) + err := binary.Read(reader, binary.LittleEndian, &u16) + if err != nil { + return nil, err + } + return []byte(string(utf16.Decode(u16))), nil + case utfbom.UTF16BigEndian: + u16 := make([]uint16, (len(b)/2)-1) + err := binary.Read(reader, binary.BigEndian, &u16) + if err != nil { + return nil, err + } + return []byte(string(utf16.Decode(u16))), nil + } + return ioutil.ReadAll(reader) +} + +func (settings FileSettings) getResourceForToken(baseURI string) (string, error) { + // Compare default base URI from the SDK to the endpoints from the public cloud + // Base URI and token resource are the same string. This func finds the authentication + // file field that matches the SDK base URI. The SDK defines the public cloud + // endpoint as its default base URI + if !strings.HasSuffix(baseURI, "/") { + baseURI += "/" + } + switch baseURI { + case azure.PublicCloud.ServiceManagementEndpoint: + return settings.Values[ManagementEndpoint], nil + case azure.PublicCloud.ResourceManagerEndpoint: + return settings.Values[ResourceManagerEndpoint], nil + case azure.PublicCloud.ActiveDirectoryEndpoint: + return settings.Values[ActiveDirectoryEndpoint], nil + case azure.PublicCloud.GalleryEndpoint: + return settings.Values[GalleryEndpoint], nil + case azure.PublicCloud.GraphEndpoint: + return settings.Values[GraphResourceID], nil + } + return "", fmt.Errorf("auth: base URI not found in endpoints") +} + +// NewClientCredentialsConfig creates an AuthorizerConfig object configured to obtain an Authorizer through Client Credentials. +// Defaults to Public Cloud and Resource Manager Endpoint. +func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string) ClientCredentialsConfig { + return ClientCredentialsConfig{ + ClientID: clientID, + ClientSecret: clientSecret, + TenantID: tenantID, + Resource: azure.PublicCloud.ResourceManagerEndpoint, + AADEndpoint: azure.PublicCloud.ActiveDirectoryEndpoint, + } +} + +// NewClientCertificateConfig creates a ClientCertificateConfig object configured to obtain an Authorizer through client certificate. +// Defaults to Public Cloud and Resource Manager Endpoint. +func NewClientCertificateConfig(certificatePath string, certificatePassword string, clientID string, tenantID string) ClientCertificateConfig { + return ClientCertificateConfig{ + CertificatePath: certificatePath, + CertificatePassword: certificatePassword, + ClientID: clientID, + TenantID: tenantID, + Resource: azure.PublicCloud.ResourceManagerEndpoint, + AADEndpoint: azure.PublicCloud.ActiveDirectoryEndpoint, + } +} + +// NewUsernamePasswordConfig creates an UsernamePasswordConfig object configured to obtain an Authorizer through username and password. +// Defaults to Public Cloud and Resource Manager Endpoint. +func NewUsernamePasswordConfig(username string, password string, clientID string, tenantID string) UsernamePasswordConfig { + return UsernamePasswordConfig{ + Username: username, + Password: password, + ClientID: clientID, + TenantID: tenantID, + Resource: azure.PublicCloud.ResourceManagerEndpoint, + AADEndpoint: azure.PublicCloud.ActiveDirectoryEndpoint, + } +} + +// NewMSIConfig creates an MSIConfig object configured to obtain an Authorizer through MSI. +func NewMSIConfig() MSIConfig { + return MSIConfig{ + Resource: azure.PublicCloud.ResourceManagerEndpoint, + } +} + +// NewDeviceFlowConfig creates a DeviceFlowConfig object configured to obtain an Authorizer through device flow. +// Defaults to Public Cloud and Resource Manager Endpoint. +func NewDeviceFlowConfig(clientID string, tenantID string) DeviceFlowConfig { + return DeviceFlowConfig{ + ClientID: clientID, + TenantID: tenantID, + Resource: azure.PublicCloud.ResourceManagerEndpoint, + AADEndpoint: azure.PublicCloud.ActiveDirectoryEndpoint, + } +} + +//AuthorizerConfig provides an authorizer from the configuration provided. +type AuthorizerConfig interface { + Authorizer() (autorest.Authorizer, error) +} + +// ClientCredentialsConfig provides the options to get a bearer authorizer from client credentials. +type ClientCredentialsConfig struct { + ClientID string + ClientSecret string + TenantID string + AuxTenants []string + AADEndpoint string + Resource string +} + +// ServicePrincipalToken creates a ServicePrincipalToken from client credentials. +func (ccc ClientCredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error) { + oauthConfig, err := adal.NewOAuthConfig(ccc.AADEndpoint, ccc.TenantID) + if err != nil { + return nil, err + } + return adal.NewServicePrincipalToken(*oauthConfig, ccc.ClientID, ccc.ClientSecret, ccc.Resource) +} + +// MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client credentials. +func (ccc ClientCredentialsConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error) { + oauthConfig, err := adal.NewMultiTenantOAuthConfig(ccc.AADEndpoint, ccc.TenantID, ccc.AuxTenants, adal.OAuthOptions{}) + if err != nil { + return nil, err + } + return adal.NewMultiTenantServicePrincipalToken(oauthConfig, ccc.ClientID, ccc.ClientSecret, ccc.Resource) +} + +// Authorizer gets the authorizer from client credentials. +func (ccc ClientCredentialsConfig) Authorizer() (autorest.Authorizer, error) { + if len(ccc.AuxTenants) == 0 { + spToken, err := ccc.ServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get SPT from client credentials: %v", err) + } + return autorest.NewBearerAuthorizer(spToken), nil + } + mtSPT, err := ccc.MultiTenantServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get multitenant SPT from client credentials: %v", err) + } + return autorest.NewMultiTenantServicePrincipalTokenAuthorizer(mtSPT), nil +} + +// ClientCertificateConfig provides the options to get a bearer authorizer from a client certificate. +type ClientCertificateConfig struct { + ClientID string + CertificatePath string + CertificatePassword string + TenantID string + AuxTenants []string + AADEndpoint string + Resource string +} + +// ServicePrincipalToken creates a ServicePrincipalToken from client certificate. +func (ccc ClientCertificateConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error) { + oauthConfig, err := adal.NewOAuthConfig(ccc.AADEndpoint, ccc.TenantID) + if err != nil { + return nil, err + } + certData, err := ioutil.ReadFile(ccc.CertificatePath) + if err != nil { + return nil, fmt.Errorf("failed to read the certificate file (%s): %v", ccc.CertificatePath, err) + } + certificate, rsaPrivateKey, err := adal.DecodePfxCertificateData(certData, ccc.CertificatePassword) + if err != nil { + return nil, fmt.Errorf("failed to decode pkcs12 certificate while creating spt: %v", err) + } + return adal.NewServicePrincipalTokenFromCertificate(*oauthConfig, ccc.ClientID, certificate, rsaPrivateKey, ccc.Resource) +} + +// MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client certificate. +func (ccc ClientCertificateConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error) { + oauthConfig, err := adal.NewMultiTenantOAuthConfig(ccc.AADEndpoint, ccc.TenantID, ccc.AuxTenants, adal.OAuthOptions{}) + if err != nil { + return nil, err + } + certData, err := ioutil.ReadFile(ccc.CertificatePath) + if err != nil { + return nil, fmt.Errorf("failed to read the certificate file (%s): %v", ccc.CertificatePath, err) + } + certificate, rsaPrivateKey, err := adal.DecodePfxCertificateData(certData, ccc.CertificatePassword) + if err != nil { + return nil, fmt.Errorf("failed to decode pkcs12 certificate while creating spt: %v", err) + } + return adal.NewMultiTenantServicePrincipalTokenFromCertificate(oauthConfig, ccc.ClientID, certificate, rsaPrivateKey, ccc.Resource) +} + +// Authorizer gets an authorizer object from client certificate. +func (ccc ClientCertificateConfig) Authorizer() (autorest.Authorizer, error) { + if len(ccc.AuxTenants) == 0 { + spToken, err := ccc.ServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get oauth token from certificate auth: %v", err) + } + return autorest.NewBearerAuthorizer(spToken), nil + } + mtSPT, err := ccc.MultiTenantServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get multitenant SPT from certificate auth: %v", err) + } + return autorest.NewMultiTenantServicePrincipalTokenAuthorizer(mtSPT), nil +} + +// DeviceFlowConfig provides the options to get a bearer authorizer using device flow authentication. +type DeviceFlowConfig struct { + ClientID string + TenantID string + AADEndpoint string + Resource string +} + +// Authorizer gets the authorizer from device flow. +func (dfc DeviceFlowConfig) Authorizer() (autorest.Authorizer, error) { + spToken, err := dfc.ServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get oauth token from device flow: %v", err) + } + return autorest.NewBearerAuthorizer(spToken), nil +} + +// ServicePrincipalToken gets the service principal token from device flow. +func (dfc DeviceFlowConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error) { + oauthConfig, err := adal.NewOAuthConfig(dfc.AADEndpoint, dfc.TenantID) + if err != nil { + return nil, err + } + oauthClient := &autorest.Client{} + deviceCode, err := adal.InitiateDeviceAuth(oauthClient, *oauthConfig, dfc.ClientID, dfc.Resource) + if err != nil { + return nil, fmt.Errorf("failed to start device auth flow: %s", err) + } + log.Println(*deviceCode.Message) + token, err := adal.WaitForUserCompletion(oauthClient, deviceCode) + if err != nil { + return nil, fmt.Errorf("failed to finish device auth flow: %s", err) + } + return adal.NewServicePrincipalTokenFromManualToken(*oauthConfig, dfc.ClientID, dfc.Resource, *token) +} + +// UsernamePasswordConfig provides the options to get a bearer authorizer from a username and a password. +type UsernamePasswordConfig struct { + ClientID string + Username string + Password string + TenantID string + AADEndpoint string + Resource string +} + +// ServicePrincipalToken creates a ServicePrincipalToken from username and password. +func (ups UsernamePasswordConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error) { + oauthConfig, err := adal.NewOAuthConfig(ups.AADEndpoint, ups.TenantID) + if err != nil { + return nil, err + } + return adal.NewServicePrincipalTokenFromUsernamePassword(*oauthConfig, ups.ClientID, ups.Username, ups.Password, ups.Resource) +} + +// Authorizer gets the authorizer from a username and a password. +func (ups UsernamePasswordConfig) Authorizer() (autorest.Authorizer, error) { + spToken, err := ups.ServicePrincipalToken() + if err != nil { + return nil, fmt.Errorf("failed to get oauth token from username and password auth: %v", err) + } + return autorest.NewBearerAuthorizer(spToken), nil +} + +// MSIConfig provides the options to get a bearer authorizer through MSI. +type MSIConfig struct { + Resource string + ClientID string +} + +// ServicePrincipalToken creates a ServicePrincipalToken from MSI. +func (mc MSIConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error) { + spToken, err := adal.NewServicePrincipalTokenFromManagedIdentity(mc.Resource, &adal.ManagedIdentityOptions{ + ClientID: mc.ClientID, + }) + if err != nil { + return nil, fmt.Errorf("failed to get oauth token from MSI: %v", err) + } + return spToken, nil +} + +// Authorizer gets the authorizer from MSI. +func (mc MSIConfig) Authorizer() (autorest.Authorizer, error) { + spToken, err := mc.ServicePrincipalToken() + if err != nil { + return nil, err + } + + return autorest.NewBearerAuthorizer(spToken), nil +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.mod b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.mod new file mode 100644 index 000000000000..7a894fabaa9c --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/go-autorest/autorest/azure/auth + +go 1.12 + +require ( + github.com/Azure/go-autorest v14.2.0+incompatible + github.com/Azure/go-autorest/autorest v0.11.17 + github.com/Azure/go-autorest/autorest/adal v0.9.11 + github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 + github.com/Azure/go-autorest/logger v0.2.0 + github.com/dimchansky/utfbom v1.1.1 + golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect +) diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.sum b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.sum new file mode 100644 index 000000000000..ab1094597074 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= +github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Azure/go-autorest/autorest v0.11.17 h1:2zCdHwNgRH+St1J+ZMf66xI8aLr/5KMy+wWLH97zwYM= +github.com/Azure/go-autorest/autorest v0.11.17/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= +github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= +github.com/Azure/go-autorest/autorest/adal v0.9.11 h1:L4/pmq7poLdsy41Bj1FayKvBhayuWRYkx9HU5i4Ybl0= +github.com/Azure/go-autorest/autorest/adal v0.9.11/go.mod h1:nBKAnTomx8gDtl+3ZCJv2v0KACFHWTB2drffI1B68Pk= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 h1:dMOmEJfkLKW/7JsokJqkyoYSgmR08hi9KrhjZb+JALY= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.2/go.mod h1:7qkJkT+j6b+hIpzMOwPChJhTqS8VbsqqgULzMNRugoM= +github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= +github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= +github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= +github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= +github.com/Azure/go-autorest/logger v0.2.0 h1:e4RVHVZKC5p6UANLJHkM4OfR1UKZPj8Wt8Pcx+3oqrE= +github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= +github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= +github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= +github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= +github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go_mod_tidy_hack.go b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go_mod_tidy_hack.go new file mode 100644 index 000000000000..38e4900ad0fb --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/auth/go_mod_tidy_hack.go @@ -0,0 +1,24 @@ +// +build modhack + +package auth + +// Copyright 2017 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file, and the github.com/Azure/go-autorest import, won't actually become part of +// the resultant binary. + +// Necessary for safely adding multi-module repo. +// See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/go-autorest" diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/LICENSE b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/LICENSE new file mode 100644 index 000000000000..b9d6a27ea92e --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015 Microsoft Corporation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.mod b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.mod new file mode 100644 index 000000000000..7e06a8bb7248 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/go-autorest/autorest/azure/cli + +go 1.12 + +require ( + github.com/Azure/go-autorest v14.2.0+incompatible + github.com/Azure/go-autorest/autorest/adal v0.9.5 + github.com/Azure/go-autorest/autorest/date v0.3.0 + github.com/dimchansky/utfbom v1.1.0 + github.com/mitchellh/go-homedir v1.1.0 +) diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.sum b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.sum new file mode 100644 index 000000000000..f2f970684df3 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go.sum @@ -0,0 +1,24 @@ +github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= +github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Azure/go-autorest/autorest/adal v0.9.5 h1:Y3bBUV4rTuxenJJs41HU3qmqsb+auo+a3Lz+PlJPpL0= +github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= +github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= +github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= +github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= +github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= +github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= +github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= +github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go_mod_tidy_hack.go b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go_mod_tidy_hack.go new file mode 100644 index 000000000000..861ce2984e64 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/go_mod_tidy_hack.go @@ -0,0 +1,24 @@ +// +build modhack + +package cli + +// Copyright 2017 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file, and the github.com/Azure/go-autorest import, won't actually become part of +// the resultant binary. + +// Necessary for safely adding multi-module repo. +// See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/go-autorest" diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go new file mode 100644 index 000000000000..f45c3a516d9f --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go @@ -0,0 +1,83 @@ +package cli + +// Copyright 2017 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "os" + "path/filepath" + + "github.com/dimchansky/utfbom" + "github.com/mitchellh/go-homedir" +) + +// Profile represents a Profile from the Azure CLI +type Profile struct { + InstallationID string `json:"installationId"` + Subscriptions []Subscription `json:"subscriptions"` +} + +// Subscription represents a Subscription from the Azure CLI +type Subscription struct { + EnvironmentName string `json:"environmentName"` + ID string `json:"id"` + IsDefault bool `json:"isDefault"` + Name string `json:"name"` + State string `json:"state"` + TenantID string `json:"tenantId"` + User *User `json:"user"` +} + +// User represents a User from the Azure CLI +type User struct { + Name string `json:"name"` + Type string `json:"type"` +} + +const azureProfileJSON = "azureProfile.json" + +func configDir() string { + return os.Getenv("AZURE_CONFIG_DIR") +} + +// ProfilePath returns the path where the Azure Profile is stored from the Azure CLI +func ProfilePath() (string, error) { + if cfgDir := configDir(); cfgDir != "" { + return filepath.Join(cfgDir, azureProfileJSON), nil + } + return homedir.Expand("~/.azure/" + azureProfileJSON) +} + +// LoadProfile restores a Profile object from a file located at 'path'. +func LoadProfile(path string) (result Profile, err error) { + var contents []byte + contents, err = ioutil.ReadFile(path) + if err != nil { + err = fmt.Errorf("failed to open file (%s) while loading token: %v", path, err) + return + } + reader := utfbom.SkipOnly(bytes.NewReader(contents)) + + dec := json.NewDecoder(reader) + if err = dec.Decode(&result); err != nil { + err = fmt.Errorf("failed to decode contents of file (%s) into a Profile representation: %v", path, err) + return + } + + return +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go new file mode 100644 index 000000000000..44ff446f6697 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go @@ -0,0 +1,175 @@ +package cli + +// Copyright 2017 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strconv" + "time" + + "github.com/Azure/go-autorest/autorest/adal" + "github.com/Azure/go-autorest/autorest/date" + "github.com/mitchellh/go-homedir" +) + +// Token represents an AccessToken from the Azure CLI +type Token struct { + AccessToken string `json:"accessToken"` + Authority string `json:"_authority"` + ClientID string `json:"_clientId"` + ExpiresOn string `json:"expiresOn"` + IdentityProvider string `json:"identityProvider"` + IsMRRT bool `json:"isMRRT"` + RefreshToken string `json:"refreshToken"` + Resource string `json:"resource"` + TokenType string `json:"tokenType"` + UserID string `json:"userId"` +} + +const accessTokensJSON = "accessTokens.json" + +// ToADALToken converts an Azure CLI `Token`` to an `adal.Token`` +func (t Token) ToADALToken() (converted adal.Token, err error) { + tokenExpirationDate, err := ParseExpirationDate(t.ExpiresOn) + if err != nil { + err = fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err) + return + } + + difference := tokenExpirationDate.Sub(date.UnixEpoch()) + + converted = adal.Token{ + AccessToken: t.AccessToken, + Type: t.TokenType, + ExpiresIn: "3600", + ExpiresOn: json.Number(strconv.Itoa(int(difference.Seconds()))), + RefreshToken: t.RefreshToken, + Resource: t.Resource, + } + return +} + +// AccessTokensPath returns the path where access tokens are stored from the Azure CLI +// TODO(#199): add unit test. +func AccessTokensPath() (string, error) { + // Azure-CLI allows user to customize the path of access tokens through environment variable. + if accessTokenPath := os.Getenv("AZURE_ACCESS_TOKEN_FILE"); accessTokenPath != "" { + return accessTokenPath, nil + } + + // Azure-CLI allows user to customize the path to Azure config directory through environment variable. + if cfgDir := configDir(); cfgDir != "" { + return filepath.Join(cfgDir, accessTokensJSON), nil + } + + // Fallback logic to default path on non-cloud-shell environment. + // TODO(#200): remove the dependency on hard-coding path. + return homedir.Expand("~/.azure/" + accessTokensJSON) +} + +// ParseExpirationDate parses either a Azure CLI or CloudShell date into a time object +func ParseExpirationDate(input string) (*time.Time, error) { + // CloudShell (and potentially the Azure CLI in future) + expirationDate, cloudShellErr := time.Parse(time.RFC3339, input) + if cloudShellErr != nil { + // Azure CLI (Python) e.g. 2017-08-31 19:48:57.998857 (plus the local timezone) + const cliFormat = "2006-01-02 15:04:05.999999" + expirationDate, cliErr := time.ParseInLocation(cliFormat, input, time.Local) + if cliErr == nil { + return &expirationDate, nil + } + + return nil, fmt.Errorf("Error parsing expiration date %q.\n\nCloudShell Error: \n%+v\n\nCLI Error:\n%+v", input, cloudShellErr, cliErr) + } + + return &expirationDate, nil +} + +// LoadTokens restores a set of Token objects from a file located at 'path'. +func LoadTokens(path string) ([]Token, error) { + file, err := os.Open(path) + if err != nil { + return nil, fmt.Errorf("failed to open file (%s) while loading token: %v", path, err) + } + defer file.Close() + + var tokens []Token + + dec := json.NewDecoder(file) + if err = dec.Decode(&tokens); err != nil { + return nil, fmt.Errorf("failed to decode contents of file (%s) into a `cli.Token` representation: %v", path, err) + } + + return tokens, nil +} + +// GetTokenFromCLI gets a token using Azure CLI 2.0 for local development scenarios. +func GetTokenFromCLI(resource string) (*Token, error) { + // This is the path that a developer can set to tell this class what the install path for Azure CLI is. + const azureCLIPath = "AzureCLIPath" + + // The default install paths are used to find Azure CLI. This is for security, so that any path in the calling program's Path environment is not used to execute Azure CLI. + azureCLIDefaultPathWindows := fmt.Sprintf("%s\\Microsoft SDKs\\Azure\\CLI2\\wbin; %s\\Microsoft SDKs\\Azure\\CLI2\\wbin", os.Getenv("ProgramFiles(x86)"), os.Getenv("ProgramFiles")) + + // Default path for non-Windows. + const azureCLIDefaultPath = "/bin:/sbin:/usr/bin:/usr/local/bin" + + // Validate resource, since it gets sent as a command line argument to Azure CLI + const invalidResourceErrorTemplate = "Resource %s is not in expected format. Only alphanumeric characters, [dot], [colon], [hyphen], and [forward slash] are allowed." + match, err := regexp.MatchString("^[0-9a-zA-Z-.:/]+$", resource) + if err != nil { + return nil, err + } + if !match { + return nil, fmt.Errorf(invalidResourceErrorTemplate, resource) + } + + // Execute Azure CLI to get token + var cliCmd *exec.Cmd + if runtime.GOOS == "windows" { + cliCmd = exec.Command(fmt.Sprintf("%s\\system32\\cmd.exe", os.Getenv("windir"))) + cliCmd.Env = os.Environ() + cliCmd.Env = append(cliCmd.Env, fmt.Sprintf("PATH=%s;%s", os.Getenv(azureCLIPath), azureCLIDefaultPathWindows)) + cliCmd.Args = append(cliCmd.Args, "/c", "az") + } else { + cliCmd = exec.Command("az") + cliCmd.Env = os.Environ() + cliCmd.Env = append(cliCmd.Env, fmt.Sprintf("PATH=%s:%s", os.Getenv(azureCLIPath), azureCLIDefaultPath)) + } + cliCmd.Args = append(cliCmd.Args, "account", "get-access-token", "-o", "json", "--resource", resource) + + var stderr bytes.Buffer + cliCmd.Stderr = &stderr + + output, err := cliCmd.Output() + if err != nil { + return nil, fmt.Errorf("Invoking Azure CLI failed with the following error: %s", stderr.String()) + } + + tokenResponse := Token{} + err = json.Unmarshal(output, &tokenResponse) + if err != nil { + return nil, err + } + + return &tokenResponse, err +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go index 8f35b3464ba1..df63bade1048 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go @@ -13,7 +13,6 @@ package ec2metadata import ( "bytes" - "errors" "io" "net/http" "net/url" @@ -234,7 +233,8 @@ func unmarshalError(r *request.Request) { // Response body format is not consistent between metadata endpoints. // Grab the error message as a string and include that as the source error - r.Error = awserr.NewRequestFailure(awserr.New("EC2MetadataError", "failed to make EC2Metadata request", errors.New(b.String())), + r.Error = awserr.NewRequestFailure( + awserr.New("EC2MetadataError", "failed to make EC2Metadata request\n"+b.String(), nil), r.HTTPResponse.StatusCode, r.RequestID) } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go index a07649e9063b..887c21dcb1ca 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go @@ -4891,6 +4891,7 @@ var awsPartition = partition{ "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, + "ap-northeast-3": endpoint{}, "ap-south-1": endpoint{}, "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, @@ -5137,6 +5138,7 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "eu-central-1": endpoint{}, "eu-west-1": endpoint{}, + "eu-west-2": endpoint{}, "fips-us-east-1": endpoint{ Hostname: "qldb-fips.us-east-1.amazonaws.com", CredentialScope: credentialScope{ @@ -6299,6 +6301,7 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "eu-central-1": endpoint{}, "eu-west-1": endpoint{}, + "eu-west-2": endpoint{}, "fips-us-east-1": endpoint{ Hostname: "session.qldb-fips.us-east-1.amazonaws.com", CredentialScope: credentialScope{ @@ -9623,6 +9626,25 @@ var awsusgovPartition = partition{ "us-gov-west-1": endpoint{}, }, }, + "mq": service{ + + Endpoints: endpoints{ + "fips-us-gov-east-1": endpoint{ + Hostname: "mq-fips.us-gov-east-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-gov-east-1", + }, + }, + "fips-us-gov-west-1": endpoint{ + Hostname: "mq-fips.us-gov-west-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-gov-west-1", + }, + }, + "us-gov-east-1": endpoint{}, + "us-gov-west-1": endpoint{}, + }, + }, "neptune": service{ Endpoints: endpoints{ diff --git a/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go b/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go index 07ea799fbd37..716e6181f54b 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go @@ -34,23 +34,23 @@ func (m mapRule) IsValid(value string) bool { return ok } -// whitelist is a generic rule for whitelisting -type whitelist struct { +// allowList is a generic rule for allow listing +type allowList struct { rule } -// IsValid for whitelist checks if the value is within the whitelist -func (w whitelist) IsValid(value string) bool { +// IsValid for allow list checks if the value is within the allow list +func (w allowList) IsValid(value string) bool { return w.rule.IsValid(value) } -// blacklist is a generic rule for blacklisting -type blacklist struct { +// excludeList is a generic rule for blacklisting +type excludeList struct { rule } -// IsValid for whitelist checks if the value is within the whitelist -func (b blacklist) IsValid(value string) bool { +// IsValid for allow list checks if the value is within the allow list +func (b excludeList) IsValid(value string) bool { return !b.rule.IsValid(value) } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go b/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go index 1737c2686de4..c1949859ad52 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go @@ -90,7 +90,7 @@ const ( ) var ignoredHeaders = rules{ - blacklist{ + excludeList{ mapRule{ authorizationHeader: struct{}{}, "User-Agent": struct{}{}, @@ -99,9 +99,9 @@ var ignoredHeaders = rules{ }, } -// requiredSignedHeaders is a whitelist for build canonical headers. +// requiredSignedHeaders is a allow list for build canonical headers. var requiredSignedHeaders = rules{ - whitelist{ + allowList{ mapRule{ "Cache-Control": struct{}{}, "Content-Disposition": struct{}{}, @@ -145,12 +145,13 @@ var requiredSignedHeaders = rules{ }, }, patterns{"X-Amz-Meta-"}, + patterns{"X-Amz-Object-Lock-"}, } -// allowedHoisting is a whitelist for build query headers. The boolean value +// allowedHoisting is a allow list for build query headers. The boolean value // represents whether or not it is a pattern. var allowedQueryHoisting = inclusiveRules{ - blacklist{requiredSignedHeaders}, + excludeList{requiredSignedHeaders}, patterns{"X-Amz-"}, } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index 938fdfd135a8..db6522049807 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.38.60" +const SDKVersion = "1.38.68" diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go index 1301b149d35e..fb35fee5fe73 100644 --- a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go @@ -98,7 +98,7 @@ func buildLocationElements(r *request.Request, v reflect.Value, buildGETQuery bo // Support the ability to customize values to be marshaled as a // blob even though they were modeled as a string. Required for S3 - // API operations like SSECustomerKey is modeled as stirng but + // API operations like SSECustomerKey is modeled as string but // required to be base64 encoded in request. if field.Tag.Get("marshal-as") == "blob" { m = m.Convert(byteSliceType) diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go index 98f4caed91cc..d486a4c2a0dc 100644 --- a/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go @@ -1,6 +1,8 @@ package protocol import ( + "bytes" + "fmt" "math" "strconv" "time" @@ -19,7 +21,9 @@ const ( // Output time is intended to not contain decimals const ( // RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT - RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT" + RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT" + rfc822TimeFormatSingleDigitDay = "Mon, _2 Jan 2006 15:04:05 GMT" + rfc822TimeFormatSingleDigitDayTwoDigitYear = "Mon, _2 Jan 06 15:04:05 GMT" // This format is used for output time without seconds precision RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT" @@ -67,10 +71,20 @@ func FormatTime(name string, t time.Time) string { // the time if it was able to be parsed, and fails otherwise. func ParseTime(formatName, value string) (time.Time, error) { switch formatName { - case RFC822TimeFormatName: - return time.Parse(RFC822TimeFormat, value) - case ISO8601TimeFormatName: - return time.Parse(ISO8601TimeFormat, value) + case RFC822TimeFormatName: // Smithy HTTPDate format + return tryParse(value, + RFC822TimeFormat, + rfc822TimeFormatSingleDigitDay, + rfc822TimeFormatSingleDigitDayTwoDigitYear, + time.RFC850, + time.ANSIC, + ) + case ISO8601TimeFormatName: // Smithy DateTime format + return tryParse(value, + ISO8601TimeFormat, + time.RFC3339Nano, + time.RFC3339, + ) case UnixTimeFormatName: v, err := strconv.ParseFloat(value, 64) _, dec := math.Modf(v) @@ -83,3 +97,36 @@ func ParseTime(formatName, value string) (time.Time, error) { panic("unknown timestamp format name, " + formatName) } } + +func tryParse(v string, formats ...string) (time.Time, error) { + var errs parseErrors + for _, f := range formats { + t, err := time.Parse(f, v) + if err != nil { + errs = append(errs, parseError{ + Format: f, + Err: err, + }) + continue + } + return t, nil + } + + return time.Time{}, fmt.Errorf("unable to parse time string, %v", errs) +} + +type parseErrors []parseError + +func (es parseErrors) Error() string { + var s bytes.Buffer + for _, e := range es { + fmt.Fprintf(&s, "\n * %q: %v", e.Format, e.Err) + } + + return "parse errors:" + s.String() +} + +type parseError struct { + Format string + Err error +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go index 20a8eee3fd05..42c06eba4468 100644 --- a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go +++ b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go @@ -515,19 +515,20 @@ func (c *EC2) AdvertiseByoipCidrRequest(input *AdvertiseByoipCidrInput) (req *re // AdvertiseByoipCidr API operation for Amazon Elastic Compute Cloud. // // Advertises an IPv4 or IPv6 address range that is provisioned for use with -// your AWS resources through bring your own IP addresses (BYOIP). +// your Amazon Web Services resources through bring your own IP addresses (BYOIP). // // You can perform this operation at most once every 10 seconds, even if you // specify different address ranges each time. // // We recommend that you stop advertising the BYOIP CIDR from other locations -// when you advertise it from AWS. To minimize down time, you can configure -// your AWS resources to use an address from a BYOIP CIDR before it is advertised, -// and then simultaneously stop advertising it from the current location and -// start advertising it through AWS. +// when you advertise it from Amazon Web Services. To minimize down time, you +// can configure your Amazon Web Services resources to use an address from a +// BYOIP CIDR before it is advertised, and then simultaneously stop advertising +// it from the current location and start advertising it through Amazon Web +// Services. // // It can take a few minutes before traffic to the specified addresses starts -// routing to AWS because of BGP propagation delays. +// routing to Amazon Web Services because of BGP propagation delays. // // To stop advertising the BYOIP CIDR, use WithdrawByoipCidr. // @@ -603,22 +604,22 @@ func (c *EC2) AllocateAddressRequest(input *AllocateAddressInput) (req *request. // AllocateAddress API operation for Amazon Elastic Compute Cloud. // -// Allocates an Elastic IP address to your AWS account. After you allocate the -// Elastic IP address you can associate it with an instance or network interface. -// After you release an Elastic IP address, it is released to the IP address -// pool and can be allocated to a different AWS account. +// Allocates an Elastic IP address to your account. After you allocate the Elastic +// IP address you can associate it with an instance or network interface. After +// you release an Elastic IP address, it is released to the IP address pool +// and can be allocated to a different account. // -// You can allocate an Elastic IP address from an address pool owned by AWS -// or from an address pool created from a public IPv4 address range that you -// have brought to AWS for use with your AWS resources using bring your own -// IP addresses (BYOIP). For more information, see Bring Your Own IP Addresses -// (BYOIP) (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html) +// You can allocate an Elastic IP address from an address pool owned by Amazon +// Web Services or from an address pool created from a public IPv4 address range +// that you have brought to Amazon Web Services for use with your Amazon Web +// Services resources using bring your own IP addresses (BYOIP). For more information, +// see Bring Your Own IP Addresses (BYOIP) (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html) // in the Amazon Elastic Compute Cloud User Guide. // // [EC2-VPC] If you release an Elastic IP address, you might be able to recover // it. You cannot recover an Elastic IP address that you released after it is -// allocated to another AWS account. You cannot recover an Elastic IP address -// for EC2-Classic. To attempt to recover an Elastic IP address that you released, +// allocated to another account. You cannot recover an Elastic IP address for +// EC2-Classic. To attempt to recover an Elastic IP address that you released, // specify it in this operation. // // An Elastic IP address is for use either in the EC2-Classic platform or in @@ -1743,6 +1744,88 @@ func (c *EC2) AssociateTransitGatewayRouteTableWithContext(ctx aws.Context, inpu return out, req.Send() } +const opAssociateTrunkInterface = "AssociateTrunkInterface" + +// AssociateTrunkInterfaceRequest generates a "aws/request.Request" representing the +// client's request for the AssociateTrunkInterface operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AssociateTrunkInterface for more information on using the AssociateTrunkInterface +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AssociateTrunkInterfaceRequest method. +// req, resp := client.AssociateTrunkInterfaceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/AssociateTrunkInterface +func (c *EC2) AssociateTrunkInterfaceRequest(input *AssociateTrunkInterfaceInput) (req *request.Request, output *AssociateTrunkInterfaceOutput) { + op := &request.Operation{ + Name: opAssociateTrunkInterface, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AssociateTrunkInterfaceInput{} + } + + output = &AssociateTrunkInterfaceOutput{} + req = c.newRequest(op, input, output) + return +} + +// AssociateTrunkInterface API operation for Amazon Elastic Compute Cloud. +// +// Associates a branch network interface with a trunk network interface. +// +// Before you create the association, run the create-network-interface (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateNetworkInterface.html) +// command and set --interface-type to trunk. You must also create a network +// interface for each branch network interface that you want to associate with +// the trunk network interface. +// +// For more information, see Network interface trunking (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/eni-trunking.html) +// in the Amazon Elastic Compute Cloud 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 Elastic Compute Cloud's +// API operation AssociateTrunkInterface for usage and error information. +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/AssociateTrunkInterface +func (c *EC2) AssociateTrunkInterface(input *AssociateTrunkInterfaceInput) (*AssociateTrunkInterfaceOutput, error) { + req, out := c.AssociateTrunkInterfaceRequest(input) + return out, req.Send() +} + +// AssociateTrunkInterfaceWithContext is the same as AssociateTrunkInterface with the addition of +// the ability to pass a context and additional request options. +// +// See AssociateTrunkInterface 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 *EC2) AssociateTrunkInterfaceWithContext(ctx aws.Context, input *AssociateTrunkInterfaceInput, opts ...request.Option) (*AssociateTrunkInterfaceOutput, error) { + req, out := c.AssociateTrunkInterfaceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opAssociateVpcCidrBlock = "AssociateVpcCidrBlock" // AssociateVpcCidrBlockRequest generates a "aws/request.Request" representing the @@ -5751,11 +5834,11 @@ func (c *EC2) CreateNetworkInterfacePermissionRequest(input *CreateNetworkInterf // CreateNetworkInterfacePermission API operation for Amazon Elastic Compute Cloud. // -// Grants an AWS-authorized account permission to attach the specified network -// interface to an instance in their account. +// Grants an Amazon Web Services-authorized account permission to attach the +// specified network interface to an instance in their account. // -// You can grant permission to a single AWS account only, and only one account -// at a time. +// You can grant permission to a single account only, and only one account at +// a time. // // 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 @@ -12972,8 +13055,8 @@ func (c *EC2) DeprovisionByoipCidrRequest(input *DeprovisionByoipCidrInput) (req // DeprovisionByoipCidr API operation for Amazon Elastic Compute Cloud. // // Releases the specified address range that you provisioned for use with your -// AWS resources through bring your own IP addresses (BYOIP) and deletes the -// corresponding address pool. +// Amazon Web Services resources through bring your own IP addresses (BYOIP) +// and deletes the corresponding address pool. // // Before you can release an address range, you must stop advertising it using // WithdrawByoipCidr and you must not have any IP addresses allocated from its @@ -20147,7 +20230,8 @@ func (c *EC2) DescribeManagedPrefixListsRequest(input *DescribeManagedPrefixList // DescribeManagedPrefixLists API operation for Amazon Elastic Compute Cloud. // -// Describes your managed prefix lists and any AWS-managed prefix lists. +// Describes your managed prefix lists and any Amazon Web Services-managed prefix +// lists. // // To view the entries for your prefix list, use GetManagedPrefixListEntries. // @@ -21361,9 +21445,9 @@ func (c *EC2) DescribePrefixListsRequest(input *DescribePrefixListsInput) (req * // DescribePrefixLists API operation for Amazon Elastic Compute Cloud. // -// Describes available AWS services in a prefix list format, which includes -// the prefix list name and prefix list ID of the service and the IP address -// range for the service. +// Describes available Amazon Web Services services in a prefix list format, +// which includes the prefix list name and prefix list ID of the service and +// the IP address range for the service. // // We recommend that you use DescribeManagedPrefixLists instead. // @@ -25941,6 +26025,80 @@ func (c *EC2) DescribeTransitGatewaysPagesWithContext(ctx aws.Context, input *De return p.Err() } +const opDescribeTrunkInterfaceAssociations = "DescribeTrunkInterfaceAssociations" + +// DescribeTrunkInterfaceAssociationsRequest generates a "aws/request.Request" representing the +// client's request for the DescribeTrunkInterfaceAssociations operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeTrunkInterfaceAssociations for more information on using the DescribeTrunkInterfaceAssociations +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeTrunkInterfaceAssociationsRequest method. +// req, resp := client.DescribeTrunkInterfaceAssociationsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DescribeTrunkInterfaceAssociations +func (c *EC2) DescribeTrunkInterfaceAssociationsRequest(input *DescribeTrunkInterfaceAssociationsInput) (req *request.Request, output *DescribeTrunkInterfaceAssociationsOutput) { + op := &request.Operation{ + Name: opDescribeTrunkInterfaceAssociations, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeTrunkInterfaceAssociationsInput{} + } + + output = &DescribeTrunkInterfaceAssociationsOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeTrunkInterfaceAssociations API operation for Amazon Elastic Compute Cloud. +// +// Describes one or more network interface trunk associations. +// +// 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 Elastic Compute Cloud's +// API operation DescribeTrunkInterfaceAssociations for usage and error information. +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DescribeTrunkInterfaceAssociations +func (c *EC2) DescribeTrunkInterfaceAssociations(input *DescribeTrunkInterfaceAssociationsInput) (*DescribeTrunkInterfaceAssociationsOutput, error) { + req, out := c.DescribeTrunkInterfaceAssociationsRequest(input) + return out, req.Send() +} + +// DescribeTrunkInterfaceAssociationsWithContext is the same as DescribeTrunkInterfaceAssociations with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeTrunkInterfaceAssociations 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 *EC2) DescribeTrunkInterfaceAssociationsWithContext(ctx aws.Context, input *DescribeTrunkInterfaceAssociationsInput, opts ...request.Option) (*DescribeTrunkInterfaceAssociationsOutput, error) { + req, out := c.DescribeTrunkInterfaceAssociationsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDescribeVolumeAttribute = "DescribeVolumeAttribute" // DescribeVolumeAttributeRequest generates a "aws/request.Request" representing the @@ -29563,6 +29721,81 @@ func (c *EC2) DisassociateTransitGatewayRouteTableWithContext(ctx aws.Context, i return out, req.Send() } +const opDisassociateTrunkInterface = "DisassociateTrunkInterface" + +// DisassociateTrunkInterfaceRequest generates a "aws/request.Request" representing the +// client's request for the DisassociateTrunkInterface operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DisassociateTrunkInterface for more information on using the DisassociateTrunkInterface +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DisassociateTrunkInterfaceRequest method. +// req, resp := client.DisassociateTrunkInterfaceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DisassociateTrunkInterface +func (c *EC2) DisassociateTrunkInterfaceRequest(input *DisassociateTrunkInterfaceInput) (req *request.Request, output *DisassociateTrunkInterfaceOutput) { + op := &request.Operation{ + Name: opDisassociateTrunkInterface, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DisassociateTrunkInterfaceInput{} + } + + output = &DisassociateTrunkInterfaceOutput{} + req = c.newRequest(op, input, output) + return +} + +// DisassociateTrunkInterface API operation for Amazon Elastic Compute Cloud. +// +// Removes an association between a branch network interface with a trunk network +// interface. +// +// 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 Elastic Compute Cloud's +// API operation DisassociateTrunkInterface for usage and error information. +// See also, https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DisassociateTrunkInterface +func (c *EC2) DisassociateTrunkInterface(input *DisassociateTrunkInterfaceInput) (*DisassociateTrunkInterfaceOutput, error) { + req, out := c.DisassociateTrunkInterfaceRequest(input) + return out, req.Send() +} + +// DisassociateTrunkInterfaceWithContext is the same as DisassociateTrunkInterface with the addition of +// the ability to pass a context and additional request options. +// +// See DisassociateTrunkInterface 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 *EC2) DisassociateTrunkInterfaceWithContext(ctx aws.Context, input *DisassociateTrunkInterfaceInput, opts ...request.Option) (*DisassociateTrunkInterfaceOutput, error) { + req, out := c.DisassociateTrunkInterfaceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + const opDisassociateVpcCidrBlock = "DisassociateVpcCidrBlock" // DisassociateVpcCidrBlockRequest generates a "aws/request.Request" representing the @@ -37332,16 +37565,16 @@ func (c *EC2) ProvisionByoipCidrRequest(input *ProvisionByoipCidrInput) (req *re // ProvisionByoipCidr API operation for Amazon Elastic Compute Cloud. // -// Provisions an IPv4 or IPv6 address range for use with your AWS resources -// through bring your own IP addresses (BYOIP) and creates a corresponding address -// pool. After the address range is provisioned, it is ready to be advertised +// Provisions an IPv4 or IPv6 address range for use with your Amazon Web Services +// resources through bring your own IP addresses (BYOIP) and creates a corresponding +// address pool. After the address range is provisioned, it is ready to be advertised // using AdvertiseByoipCidr. // -// AWS verifies that you own the address range and are authorized to advertise -// it. You must ensure that the address range is registered to you and that -// you created an RPKI ROA to authorize Amazon ASNs 16509 and 14618 to advertise -// the address range. For more information, see Bring Your Own IP Addresses -// (BYOIP) (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html) +// Amazon Web Services verifies that you own the address range and are authorized +// to advertise it. You must ensure that the address range is registered to +// you and that you created an RPKI ROA to authorize Amazon ASNs 16509 and 14618 +// to advertise the address range. For more information, see Bring your own +// IP addresses (BYOIP) (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html) // in the Amazon Elastic Compute Cloud User Guide. // // Provisioning an address range is an asynchronous operation, so the call returns @@ -38514,7 +38747,7 @@ func (c *EC2) ReleaseAddressRequest(input *ReleaseAddressInput) (req *request.Re // Be sure to update your DNS records and any servers or devices that communicate // with the address. If you attempt to release an Elastic IP address that you // already released, you'll get an AuthFailure error if the address is already -// allocated to another AWS account. +// allocated to another account. // // [EC2-VPC] After you release an Elastic IP address for use in a VPC, you might // be able to recover it. For more information, see AllocateAddress. @@ -41936,7 +42169,7 @@ func (c *EC2) WithdrawByoipCidrRequest(input *WithdrawByoipCidrInput) (req *requ // specify different address ranges each time. // // It can take a few minutes before traffic to the specified addresses stops -// routing to AWS because of BGP propagation delays. +// routing to Amazon Web Services because of BGP propagation delays. // // 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 @@ -42626,7 +42859,7 @@ type Address struct { // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string"` - // The ID of the AWS account that owns the network interface. + // The ID of the account that owns the network interface. NetworkInterfaceOwnerId *string `locationName:"networkInterfaceOwnerId" type:"string"` // The private IP address associated with the Elastic IP address. @@ -42962,8 +43195,8 @@ func (s *AllocateAddressInput) SetTagSpecifications(v []*TagSpecification) *Allo type AllocateAddressOutput struct { _ struct{} `type:"structure"` - // [EC2-VPC] The ID that AWS assigns to represent the allocation of the Elastic - // IP address for use with instances in a VPC. + // [EC2-VPC] The ID that Amazon Web Services assigns to represent the allocation + // of the Elastic IP address for use with instances in a VPC. AllocationId *string `locationName:"allocationId" type:"string"` // The carrier IP address. This option is only available for network interfaces @@ -44859,6 +45092,132 @@ func (s *AssociateTransitGatewayRouteTableOutput) SetAssociation(v *TransitGatew return s } +type AssociateTrunkInterfaceInput struct { + _ struct{} `type:"structure"` + + // The ID of the branch network interface. + // + // BranchInterfaceId is a required field + BranchInterfaceId *string `type:"string" required:"true"` + + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see How to Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + ClientToken *string `type:"string" idempotencyToken:"true"` + + // Checks whether you have the required permissions for the action, without + // actually making the request, and provides an error response. If you have + // the required permissions, the error response is DryRunOperation. Otherwise, + // it is UnauthorizedOperation. + DryRun *bool `type:"boolean"` + + // The application key. This applies to the GRE protocol. + GreKey *int64 `type:"integer"` + + // The ID of the trunk network interface. + // + // TrunkInterfaceId is a required field + TrunkInterfaceId *string `type:"string" required:"true"` + + // The ID of the VLAN. This applies to the VLAN protocol. + VlanId *int64 `type:"integer"` +} + +// String returns the string representation +func (s AssociateTrunkInterfaceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AssociateTrunkInterfaceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AssociateTrunkInterfaceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AssociateTrunkInterfaceInput"} + if s.BranchInterfaceId == nil { + invalidParams.Add(request.NewErrParamRequired("BranchInterfaceId")) + } + if s.TrunkInterfaceId == nil { + invalidParams.Add(request.NewErrParamRequired("TrunkInterfaceId")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetBranchInterfaceId sets the BranchInterfaceId field's value. +func (s *AssociateTrunkInterfaceInput) SetBranchInterfaceId(v string) *AssociateTrunkInterfaceInput { + s.BranchInterfaceId = &v + return s +} + +// SetClientToken sets the ClientToken field's value. +func (s *AssociateTrunkInterfaceInput) SetClientToken(v string) *AssociateTrunkInterfaceInput { + s.ClientToken = &v + return s +} + +// SetDryRun sets the DryRun field's value. +func (s *AssociateTrunkInterfaceInput) SetDryRun(v bool) *AssociateTrunkInterfaceInput { + s.DryRun = &v + return s +} + +// SetGreKey sets the GreKey field's value. +func (s *AssociateTrunkInterfaceInput) SetGreKey(v int64) *AssociateTrunkInterfaceInput { + s.GreKey = &v + return s +} + +// SetTrunkInterfaceId sets the TrunkInterfaceId field's value. +func (s *AssociateTrunkInterfaceInput) SetTrunkInterfaceId(v string) *AssociateTrunkInterfaceInput { + s.TrunkInterfaceId = &v + return s +} + +// SetVlanId sets the VlanId field's value. +func (s *AssociateTrunkInterfaceInput) SetVlanId(v int64) *AssociateTrunkInterfaceInput { + s.VlanId = &v + return s +} + +type AssociateTrunkInterfaceOutput struct { + _ struct{} `type:"structure"` + + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see How to Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + ClientToken *string `locationName:"clientToken" type:"string"` + + // Information about the association between the trunk network interface and + // branch network interface. + InterfaceAssociation *TrunkInterfaceAssociation `locationName:"interfaceAssociation" type:"structure"` +} + +// String returns the string representation +func (s AssociateTrunkInterfaceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AssociateTrunkInterfaceOutput) GoString() string { + return s.String() +} + +// SetClientToken sets the ClientToken field's value. +func (s *AssociateTrunkInterfaceOutput) SetClientToken(v string) *AssociateTrunkInterfaceOutput { + s.ClientToken = &v + return s +} + +// SetInterfaceAssociation sets the InterfaceAssociation field's value. +func (s *AssociateTrunkInterfaceOutput) SetInterfaceAssociation(v *TrunkInterfaceAssociation) *AssociateTrunkInterfaceOutput { + s.InterfaceAssociation = v + return s +} + type AssociateVpcCidrBlockInput struct { _ struct{} `type:"structure"` @@ -46684,7 +47043,7 @@ func (s *BundleTaskError) SetMessage(v string) *BundleTaskError { } // Information about an address range that is provisioned for use with your -// AWS resources through bring your own IP addresses (BYOIP). +// Amazon Web Services resources through bring your own IP addresses (BYOIP). type ByoipCidr struct { _ struct{} `type:"structure"` @@ -48117,9 +48476,8 @@ func (s *CertificateAuthenticationRequest) SetClientRootCertificateChainArn(v st } // Provides authorization for Amazon to bring a specific IP address range to -// a specific AWS account using bring your own IP addresses (BYOIP). For more -// information, see Prepare to Bring Your Address Range to Your AWS Account -// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html#prepare-for-byoip) +// a specific account using bring your own IP addresses (BYOIP). For more information, +// see Configuring your BYOIP address range (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html#prepare-for-byoip) // in the Amazon Elastic Compute Cloud User Guide. type CidrAuthorizationContext struct { _ struct{} `type:"structure"` @@ -53779,7 +54137,10 @@ type CreateNetworkInterfaceInput struct { // Indicates the type of network interface. To create an Elastic Fabric Adapter // (EFA), specify efa. For more information, see Elastic Fabric Adapter (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html) - // in the Amazon Elastic Compute Cloud User Guide. + // in the Amazon Elastic Compute Cloud User Guide. To create a trunk network + // interface, specify efa. For more information, see Network interface trunking + // (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/eni-trunking.html) in + // the Amazon Elastic Compute Cloud User Guide. InterfaceType *string `type:"string" enum:"NetworkInterfaceCreationType"` // The number of IPv6 addresses to assign to a network interface. Amazon EC2 @@ -53956,10 +54317,10 @@ func (s *CreateNetworkInterfaceOutput) SetNetworkInterface(v *NetworkInterface) type CreateNetworkInterfacePermissionInput struct { _ struct{} `type:"structure"` - // The AWS account ID. + // The account ID. AwsAccountId *string `type:"string"` - // The AWS service. Currently not supported. + // The Amazon Web Service. Currently not supported. AwsService *string `type:"string"` // Checks whether you have the required permissions for the action, without @@ -63382,12 +63743,12 @@ type DescribeAddressesInput struct { // if any. // // * network-border-group - A unique set of Availability Zones, Local Zones, - // or Wavelength Zones from where AWS advertises IP addresses. + // or Wavelength Zones from where Amazon Web Services advertises IP addresses. // // * network-interface-id - [EC2-VPC] The ID of the network interface that // the address is associated with, if any. // - // * network-interface-owner-id - The AWS account ID of the owner. + // * network-interface-owner-id - The account ID of the owner. // // * private-ip-address - [EC2-VPC] The private IP address associated with // the Elastic IP address. @@ -71407,9 +71768,9 @@ type DescribeNetworkInterfacePermissionsInput struct { // * network-interface-permission.network-interface-id - The ID of the network // interface. // - // * network-interface-permission.aws-account-id - The AWS account ID. + // * network-interface-permission.aws-account-id - The account ID. // - // * network-interface-permission.aws-service - The AWS service. + // * network-interface-permission.aws-service - The Amazon Web Service. // // * network-interface-permission.permission - The type of permission (INSTANCE-ATTACH // | EIP-ASSOCIATE). @@ -71582,19 +71943,19 @@ type DescribeNetworkInterfacesInput struct { // // * network-interface-id - The ID of the network interface. // - // * owner-id - The AWS account ID of the network interface owner. + // * owner-id - The account ID of the network interface owner. // // * private-ip-address - The private IPv4 address or addresses of the network // interface. // // * private-dns-name - The private DNS name of the network interface (IPv4). // - // * requester-id - The alias or AWS account ID of the principal or service - // that created the network interface. + // * requester-id - The alias or account ID of the principal or service that + // created the network interface. // // * requester-managed - Indicates whether the network interface is being - // managed by an AWS service (for example, AWS Management Console, Auto Scaling, - // and so on). + // managed by an Amazon Web Service (for example, Management Console, Auto + // Scaling, and so on). // // * source-dest-check - Indicates whether the network interface performs // source/destination checking. A value of true means checking is enabled, @@ -76533,6 +76894,120 @@ func (s *DescribeTransitGatewaysOutput) SetTransitGateways(v []*TransitGateway) return s } +type DescribeTrunkInterfaceAssociationsInput struct { + _ struct{} `type:"structure"` + + // The IDs of the associations. + AssociationIds []*string `locationName:"AssociationId" locationNameList:"item" type:"list"` + + // Checks whether you have the required permissions for the action, without + // actually making the request, and provides an error response. If you have + // the required permissions, the error response is DryRunOperation. Otherwise, + // it is UnauthorizedOperation. + DryRun *bool `type:"boolean"` + + // One or more filters. + // + // * gre-key - The ID of a trunk interface association. + // + // * interface-protocol - The interface protocol. Valid values are VLAN and + // GRE. + Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` + + // The maximum number of results to return with a single call. To retrieve the + // remaining results, make another call with the returned nextToken value. + MaxResults *int64 `min:"5" type:"integer"` + + // The token for the next page of results. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s DescribeTrunkInterfaceAssociationsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeTrunkInterfaceAssociationsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeTrunkInterfaceAssociationsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeTrunkInterfaceAssociationsInput"} + if s.MaxResults != nil && *s.MaxResults < 5 { + invalidParams.Add(request.NewErrParamMinValue("MaxResults", 5)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAssociationIds sets the AssociationIds field's value. +func (s *DescribeTrunkInterfaceAssociationsInput) SetAssociationIds(v []*string) *DescribeTrunkInterfaceAssociationsInput { + s.AssociationIds = v + return s +} + +// SetDryRun sets the DryRun field's value. +func (s *DescribeTrunkInterfaceAssociationsInput) SetDryRun(v bool) *DescribeTrunkInterfaceAssociationsInput { + s.DryRun = &v + return s +} + +// SetFilters sets the Filters field's value. +func (s *DescribeTrunkInterfaceAssociationsInput) SetFilters(v []*Filter) *DescribeTrunkInterfaceAssociationsInput { + s.Filters = v + return s +} + +// SetMaxResults sets the MaxResults field's value. +func (s *DescribeTrunkInterfaceAssociationsInput) SetMaxResults(v int64) *DescribeTrunkInterfaceAssociationsInput { + s.MaxResults = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *DescribeTrunkInterfaceAssociationsInput) SetNextToken(v string) *DescribeTrunkInterfaceAssociationsInput { + s.NextToken = &v + return s +} + +type DescribeTrunkInterfaceAssociationsOutput struct { + _ struct{} `type:"structure"` + + // Information about the trunk associations. + InterfaceAssociations []*TrunkInterfaceAssociation `locationName:"interfaceAssociationSet" locationNameList:"item" type:"list"` + + // The token to use to retrieve the next page of results. This value is null + // when there are no more results to return. + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s DescribeTrunkInterfaceAssociationsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeTrunkInterfaceAssociationsOutput) GoString() string { + return s.String() +} + +// SetInterfaceAssociations sets the InterfaceAssociations field's value. +func (s *DescribeTrunkInterfaceAssociationsOutput) SetInterfaceAssociations(v []*TrunkInterfaceAssociation) *DescribeTrunkInterfaceAssociationsOutput { + s.InterfaceAssociations = v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *DescribeTrunkInterfaceAssociationsOutput) SetNextToken(v string) *DescribeTrunkInterfaceAssociationsOutput { + s.NextToken = &v + return s +} + type DescribeVolumeAttributeInput struct { _ struct{} `type:"structure"` @@ -80459,6 +80934,99 @@ func (s *DisassociateTransitGatewayRouteTableOutput) SetAssociation(v *TransitGa return s } +type DisassociateTrunkInterfaceInput struct { + _ struct{} `type:"structure"` + + // The ID ofthe association + // + // AssociationId is a required field + AssociationId *string `type:"string" required:"true"` + + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see How to Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + ClientToken *string `type:"string" idempotencyToken:"true"` + + // Checks whether you have the required permissions for the action, without + // actually making the request, and provides an error response. If you have + // the required permissions, the error response is DryRunOperation. Otherwise, + // it is UnauthorizedOperation. + DryRun *bool `type:"boolean"` +} + +// String returns the string representation +func (s DisassociateTrunkInterfaceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DisassociateTrunkInterfaceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DisassociateTrunkInterfaceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DisassociateTrunkInterfaceInput"} + if s.AssociationId == nil { + invalidParams.Add(request.NewErrParamRequired("AssociationId")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAssociationId sets the AssociationId field's value. +func (s *DisassociateTrunkInterfaceInput) SetAssociationId(v string) *DisassociateTrunkInterfaceInput { + s.AssociationId = &v + return s +} + +// SetClientToken sets the ClientToken field's value. +func (s *DisassociateTrunkInterfaceInput) SetClientToken(v string) *DisassociateTrunkInterfaceInput { + s.ClientToken = &v + return s +} + +// SetDryRun sets the DryRun field's value. +func (s *DisassociateTrunkInterfaceInput) SetDryRun(v bool) *DisassociateTrunkInterfaceInput { + s.DryRun = &v + return s +} + +type DisassociateTrunkInterfaceOutput struct { + _ struct{} `type:"structure"` + + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see How to Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + ClientToken *string `locationName:"clientToken" type:"string"` + + // Returns true if the request succeeds; otherwise, it returns an error. + Return *bool `locationName:"return" type:"boolean"` +} + +// String returns the string representation +func (s DisassociateTrunkInterfaceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DisassociateTrunkInterfaceOutput) GoString() string { + return s.String() +} + +// SetClientToken sets the ClientToken field's value. +func (s *DisassociateTrunkInterfaceOutput) SetClientToken(v string) *DisassociateTrunkInterfaceOutput { + s.ClientToken = &v + return s +} + +// SetReturn sets the Return field's value. +func (s *DisassociateTrunkInterfaceOutput) SetReturn(v bool) *DisassociateTrunkInterfaceOutput { + s.Return = &v + return s +} + type DisassociateVpcCidrBlockInput struct { _ struct{} `type:"structure"` @@ -91773,7 +92341,7 @@ type InstanceNetworkInterface struct { // Describes the type of network interface. // - // Valid values: interface | efa + // Valid values: interface | efa | trunk InterfaceType *string `locationName:"interfaceType" type:"string"` // One or more IPv6 addresses associated with the network interface. @@ -91785,7 +92353,7 @@ type InstanceNetworkInterface struct { // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string"` - // The ID of the AWS account that created the network interface. + // The ID of the account that created the network interface. OwnerId *string `locationName:"ownerId" type:"string"` // The private DNS name. @@ -92044,7 +92612,8 @@ type InstanceNetworkInterfaceSpecification struct { // // You can only assign a carrier IP address to a network interface that is in // a subnet in a Wavelength Zone. For more information about carrier IP addresses, - // see Carrier IP addresses in the AWS Wavelength Developer Guide. + // see Carrier IP addresses in the Amazon Web Services Wavelength Developer + // Guide. AssociateCarrierIpAddress *bool `type:"boolean"` // Indicates whether to assign a public IPv4 address to an instance you launch @@ -92080,8 +92649,6 @@ type InstanceNetworkInterfaceSpecification struct { // see Elastic Fabric Adapter (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html) // in the Amazon Elastic Compute Cloud User Guide. // - // If you are not creating an EFA, specify interface or omit this parameter. - // // Valid values: interface | efa InterfaceType *string `type:"string"` @@ -103209,7 +103776,7 @@ type NetworkInterface struct { // The Amazon Resource Name (ARN) of the Outpost. OutpostArn *string `locationName:"outpostArn" type:"string"` - // The AWS account ID of the owner of the network interface. + // The account ID of the owner of the network interface. OwnerId *string `locationName:"ownerId" type:"string"` // The private DNS name. @@ -103221,11 +103788,11 @@ type NetworkInterface struct { // The private IPv4 addresses associated with the network interface. PrivateIpAddresses []*NetworkInterfacePrivateIpAddress `locationName:"privateIpAddressesSet" locationNameList:"item" type:"list"` - // The alias or AWS account ID of the principal or service that created the - // network interface. + // The alias or account ID of the principal or service that created the network + // interface. RequesterId *string `locationName:"requesterId" type:"string"` - // Indicates whether the network interface is being managed by AWS. + // Indicates whether the network interface is being managed by Amazon Web Services. RequesterManaged *bool `locationName:"requesterManaged" type:"boolean"` // Indicates whether source/destination checking is enabled. @@ -103482,7 +104049,7 @@ type NetworkInterfaceAttachment struct { // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string"` - // The AWS account ID of the owner of the instance. + // The account ID of the owner of the instance. InstanceOwnerId *string `locationName:"instanceOwnerId" type:"string"` // The index of the network card. @@ -103611,10 +104178,10 @@ func (s *NetworkInterfaceIpv6Address) SetIpv6Address(v string) *NetworkInterface type NetworkInterfacePermission struct { _ struct{} `type:"structure"` - // The AWS account ID. + // The account ID. AwsAccountId *string `locationName:"awsAccountId" type:"string"` - // The AWS service. + // The Amazon Web Service. AwsService *string `locationName:"awsService" type:"string"` // The ID of the network interface. @@ -104859,11 +105426,11 @@ func (s *PortRange) SetTo(v int64) *PortRange { return s } -// Describes prefixes for AWS services. +// Describes prefixes for Amazon Web Services services. type PrefixList struct { _ struct{} `type:"structure"` - // The IP address range of the AWS service. + // The IP address range of the Amazon Web Service. Cidrs []*string `locationName:"cidrSet" locationNameList:"item" type:"list"` // The ID of the prefix. @@ -105407,6 +105974,9 @@ type ProvisionByoipCidrInput struct { // it is UnauthorizedOperation. DryRun *bool `type:"boolean"` + // Reserved. + MultiRegion *bool `type:"boolean"` + // The tags to apply to the address pool. PoolTagSpecifications []*TagSpecification `locationName:"PoolTagSpecification" locationNameList:"item" type:"list"` @@ -105469,6 +106039,12 @@ func (s *ProvisionByoipCidrInput) SetDryRun(v bool) *ProvisionByoipCidrInput { return s } +// SetMultiRegion sets the MultiRegion field's value. +func (s *ProvisionByoipCidrInput) SetMultiRegion(v bool) *ProvisionByoipCidrInput { + s.MultiRegion = &v + return s +} + // SetPoolTagSpecifications sets the PoolTagSpecifications field's value. func (s *ProvisionByoipCidrInput) SetPoolTagSpecifications(v []*TagSpecification) *ProvisionByoipCidrInput { s.PoolTagSpecifications = v @@ -105627,7 +106203,7 @@ type PublicIpv4Pool struct { // The name of the location from which the address pool is advertised. A network // border group is a unique set of Availability Zones or Local Zones from where - // AWS advertises public IP addresses. + // Amazon Web Services advertises public IP addresses. NetworkBorderGroup *string `locationName:"networkBorderGroup" type:"string"` // The address ranges. @@ -121013,6 +121589,85 @@ func (s *TransitGatewayVpcAttachmentOptions) SetIpv6Support(v string) *TransitGa return s } +// Information about an association between a branch network interface with +// a trunk network interface. +type TrunkInterfaceAssociation struct { + _ struct{} `type:"structure"` + + // The ID of the association. + AssociationId *string `locationName:"associationId" type:"string"` + + // The ID of the branch network interface. + BranchInterfaceId *string `locationName:"branchInterfaceId" type:"string"` + + // The application key when you use the GRE protocol. + GreKey *int64 `locationName:"greKey" type:"integer"` + + // The interface protocol. Valid values are VLAN and GRE. + InterfaceProtocol *string `locationName:"interfaceProtocol" type:"string" enum:"InterfaceProtocolType"` + + // The tags. + Tags []*Tag `locationName:"tagSet" locationNameList:"item" type:"list"` + + // The ID of the trunk network interface. + TrunkInterfaceId *string `locationName:"trunkInterfaceId" type:"string"` + + // The ID of the VLAN when you use the VLAN protocol. + VlanId *int64 `locationName:"vlanId" type:"integer"` +} + +// String returns the string representation +func (s TrunkInterfaceAssociation) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TrunkInterfaceAssociation) GoString() string { + return s.String() +} + +// SetAssociationId sets the AssociationId field's value. +func (s *TrunkInterfaceAssociation) SetAssociationId(v string) *TrunkInterfaceAssociation { + s.AssociationId = &v + return s +} + +// SetBranchInterfaceId sets the BranchInterfaceId field's value. +func (s *TrunkInterfaceAssociation) SetBranchInterfaceId(v string) *TrunkInterfaceAssociation { + s.BranchInterfaceId = &v + return s +} + +// SetGreKey sets the GreKey field's value. +func (s *TrunkInterfaceAssociation) SetGreKey(v int64) *TrunkInterfaceAssociation { + s.GreKey = &v + return s +} + +// SetInterfaceProtocol sets the InterfaceProtocol field's value. +func (s *TrunkInterfaceAssociation) SetInterfaceProtocol(v string) *TrunkInterfaceAssociation { + s.InterfaceProtocol = &v + return s +} + +// SetTags sets the Tags field's value. +func (s *TrunkInterfaceAssociation) SetTags(v []*Tag) *TrunkInterfaceAssociation { + s.Tags = v + return s +} + +// SetTrunkInterfaceId sets the TrunkInterfaceId field's value. +func (s *TrunkInterfaceAssociation) SetTrunkInterfaceId(v string) *TrunkInterfaceAssociation { + s.TrunkInterfaceId = &v + return s +} + +// SetVlanId sets the VlanId field's value. +func (s *TrunkInterfaceAssociation) SetVlanId(v int64) *TrunkInterfaceAssociation { + s.VlanId = &v + return s +} + // The VPN tunnel options. type TunnelOption struct { _ struct{} `type:"structure"` @@ -127596,6 +128251,9 @@ const ( // InstanceTypeM5dn24xlarge is a InstanceType enum value InstanceTypeM5dn24xlarge = "m5dn.24xlarge" + // InstanceTypeM5dnMetal is a InstanceType enum value + InstanceTypeM5dnMetal = "m5dn.metal" + // InstanceTypeM5nLarge is a InstanceType enum value InstanceTypeM5nLarge = "m5n.large" @@ -127620,6 +128278,9 @@ const ( // InstanceTypeM5n24xlarge is a InstanceType enum value InstanceTypeM5n24xlarge = "m5n.24xlarge" + // InstanceTypeM5nMetal is a InstanceType enum value + InstanceTypeM5nMetal = "m5n.metal" + // InstanceTypeR5dnLarge is a InstanceType enum value InstanceTypeR5dnLarge = "r5dn.large" @@ -127644,6 +128305,9 @@ const ( // InstanceTypeR5dn24xlarge is a InstanceType enum value InstanceTypeR5dn24xlarge = "r5dn.24xlarge" + // InstanceTypeR5dnMetal is a InstanceType enum value + InstanceTypeR5dnMetal = "r5dn.metal" + // InstanceTypeR5nLarge is a InstanceType enum value InstanceTypeR5nLarge = "r5n.large" @@ -127668,6 +128332,9 @@ const ( // InstanceTypeR5n24xlarge is a InstanceType enum value InstanceTypeR5n24xlarge = "r5n.24xlarge" + // InstanceTypeR5nMetal is a InstanceType enum value + InstanceTypeR5nMetal = "r5n.metal" + // InstanceTypeInf1Xlarge is a InstanceType enum value InstanceTypeInf1Xlarge = "inf1.xlarge" @@ -128114,6 +128781,7 @@ func InstanceType_Values() []string { InstanceTypeM5dn12xlarge, InstanceTypeM5dn16xlarge, InstanceTypeM5dn24xlarge, + InstanceTypeM5dnMetal, InstanceTypeM5nLarge, InstanceTypeM5nXlarge, InstanceTypeM5n2xlarge, @@ -128122,6 +128790,7 @@ func InstanceType_Values() []string { InstanceTypeM5n12xlarge, InstanceTypeM5n16xlarge, InstanceTypeM5n24xlarge, + InstanceTypeM5nMetal, InstanceTypeR5dnLarge, InstanceTypeR5dnXlarge, InstanceTypeR5dn2xlarge, @@ -128130,6 +128799,7 @@ func InstanceType_Values() []string { InstanceTypeR5dn12xlarge, InstanceTypeR5dn16xlarge, InstanceTypeR5dn24xlarge, + InstanceTypeR5dnMetal, InstanceTypeR5nLarge, InstanceTypeR5nXlarge, InstanceTypeR5n2xlarge, @@ -128138,6 +128808,7 @@ func InstanceType_Values() []string { InstanceTypeR5n12xlarge, InstanceTypeR5n16xlarge, InstanceTypeR5n24xlarge, + InstanceTypeR5nMetal, InstanceTypeInf1Xlarge, InstanceTypeInf12xlarge, InstanceTypeInf16xlarge, @@ -128205,6 +128876,22 @@ func InterfacePermissionType_Values() []string { } } +const ( + // InterfaceProtocolTypeVlan is a InterfaceProtocolType enum value + InterfaceProtocolTypeVlan = "VLAN" + + // InterfaceProtocolTypeGre is a InterfaceProtocolType enum value + InterfaceProtocolTypeGre = "GRE" +) + +// InterfaceProtocolType_Values returns all elements of the InterfaceProtocolType enum +func InterfaceProtocolType_Values() []string { + return []string{ + InterfaceProtocolTypeVlan, + InterfaceProtocolTypeGre, + } +} + const ( // Ipv6SupportValueEnable is a Ipv6SupportValue enum value Ipv6SupportValueEnable = "enable" @@ -128584,12 +129271,20 @@ func NetworkInterfaceAttribute_Values() []string { const ( // NetworkInterfaceCreationTypeEfa is a NetworkInterfaceCreationType enum value NetworkInterfaceCreationTypeEfa = "efa" + + // NetworkInterfaceCreationTypeBranch is a NetworkInterfaceCreationType enum value + NetworkInterfaceCreationTypeBranch = "branch" + + // NetworkInterfaceCreationTypeTrunk is a NetworkInterfaceCreationType enum value + NetworkInterfaceCreationTypeTrunk = "trunk" ) // NetworkInterfaceCreationType_Values returns all elements of the NetworkInterfaceCreationType enum func NetworkInterfaceCreationType_Values() []string { return []string{ NetworkInterfaceCreationTypeEfa, + NetworkInterfaceCreationTypeBranch, + NetworkInterfaceCreationTypeTrunk, } } @@ -128654,6 +129349,9 @@ const ( // NetworkInterfaceTypeEfa is a NetworkInterfaceType enum value NetworkInterfaceTypeEfa = "efa" + + // NetworkInterfaceTypeTrunk is a NetworkInterfaceType enum value + NetworkInterfaceTypeTrunk = "trunk" ) // NetworkInterfaceType_Values returns all elements of the NetworkInterfaceType enum @@ -128662,6 +129360,7 @@ func NetworkInterfaceType_Values() []string { NetworkInterfaceTypeInterface, NetworkInterfaceTypeNatGateway, NetworkInterfaceTypeEfa, + NetworkInterfaceTypeTrunk, } } diff --git a/vendor/github.com/aws/aws-sdk-go/service/sns/api.go b/vendor/github.com/aws/aws-sdk-go/service/sns/api.go new file mode 100644 index 000000000000..30204862b2a8 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sns/api.go @@ -0,0 +1,8082 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package sns + +import ( + "fmt" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol" + "github.com/aws/aws-sdk-go/private/protocol/query" +) + +const opAddPermission = "AddPermission" + +// AddPermissionRequest generates a "aws/request.Request" representing the +// client's request for the AddPermission operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AddPermission for more information on using the AddPermission +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AddPermissionRequest method. +// req, resp := client.AddPermissionRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/AddPermission +func (c *SNS) AddPermissionRequest(input *AddPermissionInput) (req *request.Request, output *AddPermissionOutput) { + op := &request.Operation{ + Name: opAddPermission, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AddPermissionInput{} + } + + output = &AddPermissionOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// AddPermission API operation for Amazon Simple Notification Service. +// +// Adds a statement to a topic's access control policy, granting access for +// the specified AWS accounts to the specified actions. +// +// 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 Simple Notification Service's +// API operation AddPermission for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/AddPermission +func (c *SNS) AddPermission(input *AddPermissionInput) (*AddPermissionOutput, error) { + req, out := c.AddPermissionRequest(input) + return out, req.Send() +} + +// AddPermissionWithContext is the same as AddPermission with the addition of +// the ability to pass a context and additional request options. +// +// See AddPermission 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 *SNS) AddPermissionWithContext(ctx aws.Context, input *AddPermissionInput, opts ...request.Option) (*AddPermissionOutput, error) { + req, out := c.AddPermissionRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCheckIfPhoneNumberIsOptedOut = "CheckIfPhoneNumberIsOptedOut" + +// CheckIfPhoneNumberIsOptedOutRequest generates a "aws/request.Request" representing the +// client's request for the CheckIfPhoneNumberIsOptedOut operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CheckIfPhoneNumberIsOptedOut for more information on using the CheckIfPhoneNumberIsOptedOut +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CheckIfPhoneNumberIsOptedOutRequest method. +// req, resp := client.CheckIfPhoneNumberIsOptedOutRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CheckIfPhoneNumberIsOptedOut +func (c *SNS) CheckIfPhoneNumberIsOptedOutRequest(input *CheckIfPhoneNumberIsOptedOutInput) (req *request.Request, output *CheckIfPhoneNumberIsOptedOutOutput) { + op := &request.Operation{ + Name: opCheckIfPhoneNumberIsOptedOut, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CheckIfPhoneNumberIsOptedOutInput{} + } + + output = &CheckIfPhoneNumberIsOptedOutOutput{} + req = c.newRequest(op, input, output) + return +} + +// CheckIfPhoneNumberIsOptedOut API operation for Amazon Simple Notification Service. +// +// Accepts a phone number and indicates whether the phone holder has opted out +// of receiving SMS messages from your account. You cannot send SMS messages +// to a number that is opted out. +// +// To resume sending messages, you can opt in the number by using the OptInPhoneNumber +// action. +// +// 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 Simple Notification Service's +// API operation CheckIfPhoneNumberIsOptedOut for usage and error information. +// +// Returned Error Codes: +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CheckIfPhoneNumberIsOptedOut +func (c *SNS) CheckIfPhoneNumberIsOptedOut(input *CheckIfPhoneNumberIsOptedOutInput) (*CheckIfPhoneNumberIsOptedOutOutput, error) { + req, out := c.CheckIfPhoneNumberIsOptedOutRequest(input) + return out, req.Send() +} + +// CheckIfPhoneNumberIsOptedOutWithContext is the same as CheckIfPhoneNumberIsOptedOut with the addition of +// the ability to pass a context and additional request options. +// +// See CheckIfPhoneNumberIsOptedOut 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 *SNS) CheckIfPhoneNumberIsOptedOutWithContext(ctx aws.Context, input *CheckIfPhoneNumberIsOptedOutInput, opts ...request.Option) (*CheckIfPhoneNumberIsOptedOutOutput, error) { + req, out := c.CheckIfPhoneNumberIsOptedOutRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opConfirmSubscription = "ConfirmSubscription" + +// ConfirmSubscriptionRequest generates a "aws/request.Request" representing the +// client's request for the ConfirmSubscription operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ConfirmSubscription for more information on using the ConfirmSubscription +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ConfirmSubscriptionRequest method. +// req, resp := client.ConfirmSubscriptionRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ConfirmSubscription +func (c *SNS) ConfirmSubscriptionRequest(input *ConfirmSubscriptionInput) (req *request.Request, output *ConfirmSubscriptionOutput) { + op := &request.Operation{ + Name: opConfirmSubscription, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ConfirmSubscriptionInput{} + } + + output = &ConfirmSubscriptionOutput{} + req = c.newRequest(op, input, output) + return +} + +// ConfirmSubscription API operation for Amazon Simple Notification Service. +// +// Verifies an endpoint owner's intent to receive messages by validating the +// token sent to the endpoint by an earlier Subscribe action. If the token is +// valid, the action creates a new subscription and returns its Amazon Resource +// Name (ARN). This call requires an AWS signature only when the AuthenticateOnUnsubscribe +// flag is set to "true". +// +// 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 Simple Notification Service's +// API operation ConfirmSubscription for usage and error information. +// +// Returned Error Codes: +// * ErrCodeSubscriptionLimitExceededException "SubscriptionLimitExceeded" +// Indicates that the customer already owns the maximum allowed number of subscriptions. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeFilterPolicyLimitExceededException "FilterPolicyLimitExceeded" +// Indicates that the number of filter polices in your AWS account exceeds the +// limit. To add more filter polices, submit an SNS Limit Increase case in the +// AWS Support Center. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ConfirmSubscription +func (c *SNS) ConfirmSubscription(input *ConfirmSubscriptionInput) (*ConfirmSubscriptionOutput, error) { + req, out := c.ConfirmSubscriptionRequest(input) + return out, req.Send() +} + +// ConfirmSubscriptionWithContext is the same as ConfirmSubscription with the addition of +// the ability to pass a context and additional request options. +// +// See ConfirmSubscription 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 *SNS) ConfirmSubscriptionWithContext(ctx aws.Context, input *ConfirmSubscriptionInput, opts ...request.Option) (*ConfirmSubscriptionOutput, error) { + req, out := c.ConfirmSubscriptionRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreatePlatformApplication = "CreatePlatformApplication" + +// CreatePlatformApplicationRequest generates a "aws/request.Request" representing the +// client's request for the CreatePlatformApplication operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreatePlatformApplication for more information on using the CreatePlatformApplication +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreatePlatformApplicationRequest method. +// req, resp := client.CreatePlatformApplicationRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformApplication +func (c *SNS) CreatePlatformApplicationRequest(input *CreatePlatformApplicationInput) (req *request.Request, output *CreatePlatformApplicationOutput) { + op := &request.Operation{ + Name: opCreatePlatformApplication, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreatePlatformApplicationInput{} + } + + output = &CreatePlatformApplicationOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreatePlatformApplication API operation for Amazon Simple Notification Service. +// +// Creates a platform application object for one of the supported push notification +// services, such as APNS and GCM (Firebase Cloud Messaging), to which devices +// and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential +// attributes when using the CreatePlatformApplication action. +// +// PlatformPrincipal and PlatformCredential are received from the notification +// service. +// +// * For ADM, PlatformPrincipal is client id and PlatformCredential is client +// secret. +// +// * For Baidu, PlatformPrincipal is API key and PlatformCredential is secret +// key. +// +// * For APNS and APNS_SANDBOX, PlatformPrincipal is SSL certificate and +// PlatformCredential is private key. +// +// * For GCM (Firebase Cloud Messaging), there is no PlatformPrincipal and +// the PlatformCredential is API key. +// +// * For MPNS, PlatformPrincipal is TLS certificate and PlatformCredential +// is private key. +// +// * For WNS, PlatformPrincipal is Package Security Identifier and PlatformCredential +// is secret key. +// +// You can use the returned PlatformApplicationArn as an attribute for the CreatePlatformEndpoint +// action. +// +// 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 Simple Notification Service's +// API operation CreatePlatformApplication for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformApplication +func (c *SNS) CreatePlatformApplication(input *CreatePlatformApplicationInput) (*CreatePlatformApplicationOutput, error) { + req, out := c.CreatePlatformApplicationRequest(input) + return out, req.Send() +} + +// CreatePlatformApplicationWithContext is the same as CreatePlatformApplication with the addition of +// the ability to pass a context and additional request options. +// +// See CreatePlatformApplication 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 *SNS) CreatePlatformApplicationWithContext(ctx aws.Context, input *CreatePlatformApplicationInput, opts ...request.Option) (*CreatePlatformApplicationOutput, error) { + req, out := c.CreatePlatformApplicationRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreatePlatformEndpoint = "CreatePlatformEndpoint" + +// CreatePlatformEndpointRequest generates a "aws/request.Request" representing the +// client's request for the CreatePlatformEndpoint operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreatePlatformEndpoint for more information on using the CreatePlatformEndpoint +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreatePlatformEndpointRequest method. +// req, resp := client.CreatePlatformEndpointRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformEndpoint +func (c *SNS) CreatePlatformEndpointRequest(input *CreatePlatformEndpointInput) (req *request.Request, output *CreatePlatformEndpointOutput) { + op := &request.Operation{ + Name: opCreatePlatformEndpoint, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreatePlatformEndpointInput{} + } + + output = &CreatePlatformEndpointOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreatePlatformEndpoint API operation for Amazon Simple Notification Service. +// +// Creates an endpoint for a device and mobile app on one of the supported push +// notification services, such as GCM (Firebase Cloud Messaging) and APNS. CreatePlatformEndpoint +// requires the PlatformApplicationArn that is returned from CreatePlatformApplication. +// You can use the returned EndpointArn to send a message to a mobile app or +// by the Subscribe action for subscription to a topic. The CreatePlatformEndpoint +// action is idempotent, so if the requester already owns an endpoint with the +// same device token and attributes, that endpoint's ARN is returned without +// creating a new endpoint. For more information, see Using Amazon SNS Mobile +// Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html). +// +// When using CreatePlatformEndpoint with Baidu, two attributes must be provided: +// ChannelId and UserId. The token field must also contain the ChannelId. For +// more information, see Creating an Amazon SNS Endpoint for Baidu (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePushBaiduEndpoint.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 Simple Notification Service's +// API operation CreatePlatformEndpoint for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformEndpoint +func (c *SNS) CreatePlatformEndpoint(input *CreatePlatformEndpointInput) (*CreatePlatformEndpointOutput, error) { + req, out := c.CreatePlatformEndpointRequest(input) + return out, req.Send() +} + +// CreatePlatformEndpointWithContext is the same as CreatePlatformEndpoint with the addition of +// the ability to pass a context and additional request options. +// +// See CreatePlatformEndpoint 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 *SNS) CreatePlatformEndpointWithContext(ctx aws.Context, input *CreatePlatformEndpointInput, opts ...request.Option) (*CreatePlatformEndpointOutput, error) { + req, out := c.CreatePlatformEndpointRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateSMSSandboxPhoneNumber = "CreateSMSSandboxPhoneNumber" + +// CreateSMSSandboxPhoneNumberRequest generates a "aws/request.Request" representing the +// client's request for the CreateSMSSandboxPhoneNumber operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateSMSSandboxPhoneNumber for more information on using the CreateSMSSandboxPhoneNumber +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateSMSSandboxPhoneNumberRequest method. +// req, resp := client.CreateSMSSandboxPhoneNumberRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreateSMSSandboxPhoneNumber +func (c *SNS) CreateSMSSandboxPhoneNumberRequest(input *CreateSMSSandboxPhoneNumberInput) (req *request.Request, output *CreateSMSSandboxPhoneNumberOutput) { + op := &request.Operation{ + Name: opCreateSMSSandboxPhoneNumber, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateSMSSandboxPhoneNumberInput{} + } + + output = &CreateSMSSandboxPhoneNumberOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// CreateSMSSandboxPhoneNumber API operation for Amazon Simple Notification Service. +// +// Adds a destination phone number to an AWS account in the SMS sandbox and +// sends a one-time password (OTP) to that phone number. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation CreateSMSSandboxPhoneNumber for usage and error information. +// +// Returned Error Codes: +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeOptedOutException "OptedOut" +// Indicates that the specified phone number opted out of receiving SMS messages +// from your AWS account. You can't send SMS messages to phone numbers that +// opt out. +// +// * ErrCodeUserErrorException "UserError" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreateSMSSandboxPhoneNumber +func (c *SNS) CreateSMSSandboxPhoneNumber(input *CreateSMSSandboxPhoneNumberInput) (*CreateSMSSandboxPhoneNumberOutput, error) { + req, out := c.CreateSMSSandboxPhoneNumberRequest(input) + return out, req.Send() +} + +// CreateSMSSandboxPhoneNumberWithContext is the same as CreateSMSSandboxPhoneNumber with the addition of +// the ability to pass a context and additional request options. +// +// See CreateSMSSandboxPhoneNumber 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 *SNS) CreateSMSSandboxPhoneNumberWithContext(ctx aws.Context, input *CreateSMSSandboxPhoneNumberInput, opts ...request.Option) (*CreateSMSSandboxPhoneNumberOutput, error) { + req, out := c.CreateSMSSandboxPhoneNumberRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateTopic = "CreateTopic" + +// CreateTopicRequest generates a "aws/request.Request" representing the +// client's request for the CreateTopic operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateTopic for more information on using the CreateTopic +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateTopicRequest method. +// req, resp := client.CreateTopicRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreateTopic +func (c *SNS) CreateTopicRequest(input *CreateTopicInput) (req *request.Request, output *CreateTopicOutput) { + op := &request.Operation{ + Name: opCreateTopic, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateTopicInput{} + } + + output = &CreateTopicOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateTopic API operation for Amazon Simple Notification Service. +// +// Creates a topic to which notifications can be published. Users can create +// at most 100,000 standard topics (at most 1,000 FIFO topics). For more information, +// see https://aws.amazon.com/sns (http://aws.amazon.com/sns/). This action +// is idempotent, so if the requester already owns a topic with the specified +// name, that topic's ARN is returned without creating a new topic. +// +// 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 Simple Notification Service's +// API operation CreateTopic for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeTopicLimitExceededException "TopicLimitExceeded" +// Indicates that the customer already owns the maximum allowed number of topics. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// * ErrCodeTagLimitExceededException "TagLimitExceeded" +// Can't add more than 50 tags to a topic. +// +// * ErrCodeStaleTagException "StaleTag" +// A tag has been added to a resource with the same ARN as a deleted resource. +// Wait a short while and then retry the operation. +// +// * ErrCodeTagPolicyException "TagPolicy" +// The request doesn't comply with the IAM tag policy. Correct your request +// and then retry it. +// +// * ErrCodeConcurrentAccessException "ConcurrentAccess" +// Can't perform multiple operations on a tag simultaneously. Perform the operations +// sequentially. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreateTopic +func (c *SNS) CreateTopic(input *CreateTopicInput) (*CreateTopicOutput, error) { + req, out := c.CreateTopicRequest(input) + return out, req.Send() +} + +// CreateTopicWithContext is the same as CreateTopic with the addition of +// the ability to pass a context and additional request options. +// +// See CreateTopic 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 *SNS) CreateTopicWithContext(ctx aws.Context, input *CreateTopicInput, opts ...request.Option) (*CreateTopicOutput, error) { + req, out := c.CreateTopicRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteEndpoint = "DeleteEndpoint" + +// DeleteEndpointRequest generates a "aws/request.Request" representing the +// client's request for the DeleteEndpoint operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteEndpoint for more information on using the DeleteEndpoint +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteEndpointRequest method. +// req, resp := client.DeleteEndpointRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteEndpoint +func (c *SNS) DeleteEndpointRequest(input *DeleteEndpointInput) (req *request.Request, output *DeleteEndpointOutput) { + op := &request.Operation{ + Name: opDeleteEndpoint, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteEndpointInput{} + } + + output = &DeleteEndpointOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeleteEndpoint API operation for Amazon Simple Notification Service. +// +// Deletes the endpoint for a device and mobile app from Amazon SNS. This action +// is idempotent. For more information, see Using Amazon SNS Mobile Push Notifications +// (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html). +// +// When you delete an endpoint that is also subscribed to a topic, then you +// must also unsubscribe the endpoint from the topic. +// +// 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 Simple Notification Service's +// API operation DeleteEndpoint for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteEndpoint +func (c *SNS) DeleteEndpoint(input *DeleteEndpointInput) (*DeleteEndpointOutput, error) { + req, out := c.DeleteEndpointRequest(input) + return out, req.Send() +} + +// DeleteEndpointWithContext is the same as DeleteEndpoint with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteEndpoint 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 *SNS) DeleteEndpointWithContext(ctx aws.Context, input *DeleteEndpointInput, opts ...request.Option) (*DeleteEndpointOutput, error) { + req, out := c.DeleteEndpointRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeletePlatformApplication = "DeletePlatformApplication" + +// DeletePlatformApplicationRequest generates a "aws/request.Request" representing the +// client's request for the DeletePlatformApplication operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeletePlatformApplication for more information on using the DeletePlatformApplication +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeletePlatformApplicationRequest method. +// req, resp := client.DeletePlatformApplicationRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeletePlatformApplication +func (c *SNS) DeletePlatformApplicationRequest(input *DeletePlatformApplicationInput) (req *request.Request, output *DeletePlatformApplicationOutput) { + op := &request.Operation{ + Name: opDeletePlatformApplication, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeletePlatformApplicationInput{} + } + + output = &DeletePlatformApplicationOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeletePlatformApplication API operation for Amazon Simple Notification Service. +// +// Deletes a platform application object for one of the supported push notification +// services, such as APNS and GCM (Firebase Cloud Messaging). For more information, +// see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.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 Simple Notification Service's +// API operation DeletePlatformApplication for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeletePlatformApplication +func (c *SNS) DeletePlatformApplication(input *DeletePlatformApplicationInput) (*DeletePlatformApplicationOutput, error) { + req, out := c.DeletePlatformApplicationRequest(input) + return out, req.Send() +} + +// DeletePlatformApplicationWithContext is the same as DeletePlatformApplication with the addition of +// the ability to pass a context and additional request options. +// +// See DeletePlatformApplication 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 *SNS) DeletePlatformApplicationWithContext(ctx aws.Context, input *DeletePlatformApplicationInput, opts ...request.Option) (*DeletePlatformApplicationOutput, error) { + req, out := c.DeletePlatformApplicationRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteSMSSandboxPhoneNumber = "DeleteSMSSandboxPhoneNumber" + +// DeleteSMSSandboxPhoneNumberRequest generates a "aws/request.Request" representing the +// client's request for the DeleteSMSSandboxPhoneNumber operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteSMSSandboxPhoneNumber for more information on using the DeleteSMSSandboxPhoneNumber +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteSMSSandboxPhoneNumberRequest method. +// req, resp := client.DeleteSMSSandboxPhoneNumberRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteSMSSandboxPhoneNumber +func (c *SNS) DeleteSMSSandboxPhoneNumberRequest(input *DeleteSMSSandboxPhoneNumberInput) (req *request.Request, output *DeleteSMSSandboxPhoneNumberOutput) { + op := &request.Operation{ + Name: opDeleteSMSSandboxPhoneNumber, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteSMSSandboxPhoneNumberInput{} + } + + output = &DeleteSMSSandboxPhoneNumberOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeleteSMSSandboxPhoneNumber API operation for Amazon Simple Notification Service. +// +// Deletes an AWS account's verified or pending phone number from the SMS sandbox. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation DeleteSMSSandboxPhoneNumber for usage and error information. +// +// Returned Error Codes: +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeUserErrorException "UserError" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteSMSSandboxPhoneNumber +func (c *SNS) DeleteSMSSandboxPhoneNumber(input *DeleteSMSSandboxPhoneNumberInput) (*DeleteSMSSandboxPhoneNumberOutput, error) { + req, out := c.DeleteSMSSandboxPhoneNumberRequest(input) + return out, req.Send() +} + +// DeleteSMSSandboxPhoneNumberWithContext is the same as DeleteSMSSandboxPhoneNumber with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteSMSSandboxPhoneNumber 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 *SNS) DeleteSMSSandboxPhoneNumberWithContext(ctx aws.Context, input *DeleteSMSSandboxPhoneNumberInput, opts ...request.Option) (*DeleteSMSSandboxPhoneNumberOutput, error) { + req, out := c.DeleteSMSSandboxPhoneNumberRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteTopic = "DeleteTopic" + +// DeleteTopicRequest generates a "aws/request.Request" representing the +// client's request for the DeleteTopic operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteTopic for more information on using the DeleteTopic +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteTopicRequest method. +// req, resp := client.DeleteTopicRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteTopic +func (c *SNS) DeleteTopicRequest(input *DeleteTopicInput) (req *request.Request, output *DeleteTopicOutput) { + op := &request.Operation{ + Name: opDeleteTopic, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteTopicInput{} + } + + output = &DeleteTopicOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// DeleteTopic API operation for Amazon Simple Notification Service. +// +// Deletes a topic and all its subscriptions. Deleting a topic might prevent +// some messages previously sent to the topic from being delivered to subscribers. +// This action is idempotent, so deleting a topic that does not exist does not +// result in an error. +// +// 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 Simple Notification Service's +// API operation DeleteTopic for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeStaleTagException "StaleTag" +// A tag has been added to a resource with the same ARN as a deleted resource. +// Wait a short while and then retry the operation. +// +// * ErrCodeTagPolicyException "TagPolicy" +// The request doesn't comply with the IAM tag policy. Correct your request +// and then retry it. +// +// * ErrCodeConcurrentAccessException "ConcurrentAccess" +// Can't perform multiple operations on a tag simultaneously. Perform the operations +// sequentially. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteTopic +func (c *SNS) DeleteTopic(input *DeleteTopicInput) (*DeleteTopicOutput, error) { + req, out := c.DeleteTopicRequest(input) + return out, req.Send() +} + +// DeleteTopicWithContext is the same as DeleteTopic with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteTopic 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 *SNS) DeleteTopicWithContext(ctx aws.Context, input *DeleteTopicInput, opts ...request.Option) (*DeleteTopicOutput, error) { + req, out := c.DeleteTopicRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetEndpointAttributes = "GetEndpointAttributes" + +// GetEndpointAttributesRequest generates a "aws/request.Request" representing the +// client's request for the GetEndpointAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetEndpointAttributes for more information on using the GetEndpointAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetEndpointAttributesRequest method. +// req, resp := client.GetEndpointAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetEndpointAttributes +func (c *SNS) GetEndpointAttributesRequest(input *GetEndpointAttributesInput) (req *request.Request, output *GetEndpointAttributesOutput) { + op := &request.Operation{ + Name: opGetEndpointAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetEndpointAttributesInput{} + } + + output = &GetEndpointAttributesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetEndpointAttributes API operation for Amazon Simple Notification Service. +// +// Retrieves the endpoint attributes for a device on one of the supported push +// notification services, such as GCM (Firebase Cloud Messaging) and APNS. For +// more information, see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.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 Simple Notification Service's +// API operation GetEndpointAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetEndpointAttributes +func (c *SNS) GetEndpointAttributes(input *GetEndpointAttributesInput) (*GetEndpointAttributesOutput, error) { + req, out := c.GetEndpointAttributesRequest(input) + return out, req.Send() +} + +// GetEndpointAttributesWithContext is the same as GetEndpointAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See GetEndpointAttributes 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 *SNS) GetEndpointAttributesWithContext(ctx aws.Context, input *GetEndpointAttributesInput, opts ...request.Option) (*GetEndpointAttributesOutput, error) { + req, out := c.GetEndpointAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetPlatformApplicationAttributes = "GetPlatformApplicationAttributes" + +// GetPlatformApplicationAttributesRequest generates a "aws/request.Request" representing the +// client's request for the GetPlatformApplicationAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetPlatformApplicationAttributes for more information on using the GetPlatformApplicationAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetPlatformApplicationAttributesRequest method. +// req, resp := client.GetPlatformApplicationAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetPlatformApplicationAttributes +func (c *SNS) GetPlatformApplicationAttributesRequest(input *GetPlatformApplicationAttributesInput) (req *request.Request, output *GetPlatformApplicationAttributesOutput) { + op := &request.Operation{ + Name: opGetPlatformApplicationAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetPlatformApplicationAttributesInput{} + } + + output = &GetPlatformApplicationAttributesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetPlatformApplicationAttributes API operation for Amazon Simple Notification Service. +// +// Retrieves the attributes of the platform application object for the supported +// push notification services, such as APNS and GCM (Firebase Cloud Messaging). +// For more information, see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.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 Simple Notification Service's +// API operation GetPlatformApplicationAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetPlatformApplicationAttributes +func (c *SNS) GetPlatformApplicationAttributes(input *GetPlatformApplicationAttributesInput) (*GetPlatformApplicationAttributesOutput, error) { + req, out := c.GetPlatformApplicationAttributesRequest(input) + return out, req.Send() +} + +// GetPlatformApplicationAttributesWithContext is the same as GetPlatformApplicationAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See GetPlatformApplicationAttributes 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 *SNS) GetPlatformApplicationAttributesWithContext(ctx aws.Context, input *GetPlatformApplicationAttributesInput, opts ...request.Option) (*GetPlatformApplicationAttributesOutput, error) { + req, out := c.GetPlatformApplicationAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetSMSAttributes = "GetSMSAttributes" + +// GetSMSAttributesRequest generates a "aws/request.Request" representing the +// client's request for the GetSMSAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetSMSAttributes for more information on using the GetSMSAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetSMSAttributesRequest method. +// req, resp := client.GetSMSAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSMSAttributes +func (c *SNS) GetSMSAttributesRequest(input *GetSMSAttributesInput) (req *request.Request, output *GetSMSAttributesOutput) { + op := &request.Operation{ + Name: opGetSMSAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetSMSAttributesInput{} + } + + output = &GetSMSAttributesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetSMSAttributes API operation for Amazon Simple Notification Service. +// +// Returns the settings for sending SMS messages from your account. +// +// These settings are set with the SetSMSAttributes action. +// +// 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 Simple Notification Service's +// API operation GetSMSAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSMSAttributes +func (c *SNS) GetSMSAttributes(input *GetSMSAttributesInput) (*GetSMSAttributesOutput, error) { + req, out := c.GetSMSAttributesRequest(input) + return out, req.Send() +} + +// GetSMSAttributesWithContext is the same as GetSMSAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See GetSMSAttributes 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 *SNS) GetSMSAttributesWithContext(ctx aws.Context, input *GetSMSAttributesInput, opts ...request.Option) (*GetSMSAttributesOutput, error) { + req, out := c.GetSMSAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetSMSSandboxAccountStatus = "GetSMSSandboxAccountStatus" + +// GetSMSSandboxAccountStatusRequest generates a "aws/request.Request" representing the +// client's request for the GetSMSSandboxAccountStatus operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetSMSSandboxAccountStatus for more information on using the GetSMSSandboxAccountStatus +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetSMSSandboxAccountStatusRequest method. +// req, resp := client.GetSMSSandboxAccountStatusRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSMSSandboxAccountStatus +func (c *SNS) GetSMSSandboxAccountStatusRequest(input *GetSMSSandboxAccountStatusInput) (req *request.Request, output *GetSMSSandboxAccountStatusOutput) { + op := &request.Operation{ + Name: opGetSMSSandboxAccountStatus, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetSMSSandboxAccountStatusInput{} + } + + output = &GetSMSSandboxAccountStatusOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetSMSSandboxAccountStatus API operation for Amazon Simple Notification Service. +// +// Retrieves the SMS sandbox status for the calling AWS account in the target +// AWS Region. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation GetSMSSandboxAccountStatus for usage and error information. +// +// Returned Error Codes: +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSMSSandboxAccountStatus +func (c *SNS) GetSMSSandboxAccountStatus(input *GetSMSSandboxAccountStatusInput) (*GetSMSSandboxAccountStatusOutput, error) { + req, out := c.GetSMSSandboxAccountStatusRequest(input) + return out, req.Send() +} + +// GetSMSSandboxAccountStatusWithContext is the same as GetSMSSandboxAccountStatus with the addition of +// the ability to pass a context and additional request options. +// +// See GetSMSSandboxAccountStatus 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 *SNS) GetSMSSandboxAccountStatusWithContext(ctx aws.Context, input *GetSMSSandboxAccountStatusInput, opts ...request.Option) (*GetSMSSandboxAccountStatusOutput, error) { + req, out := c.GetSMSSandboxAccountStatusRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetSubscriptionAttributes = "GetSubscriptionAttributes" + +// GetSubscriptionAttributesRequest generates a "aws/request.Request" representing the +// client's request for the GetSubscriptionAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetSubscriptionAttributes for more information on using the GetSubscriptionAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetSubscriptionAttributesRequest method. +// req, resp := client.GetSubscriptionAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSubscriptionAttributes +func (c *SNS) GetSubscriptionAttributesRequest(input *GetSubscriptionAttributesInput) (req *request.Request, output *GetSubscriptionAttributesOutput) { + op := &request.Operation{ + Name: opGetSubscriptionAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetSubscriptionAttributesInput{} + } + + output = &GetSubscriptionAttributesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetSubscriptionAttributes API operation for Amazon Simple Notification Service. +// +// Returns all of the properties of a subscription. +// +// 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 Simple Notification Service's +// API operation GetSubscriptionAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSubscriptionAttributes +func (c *SNS) GetSubscriptionAttributes(input *GetSubscriptionAttributesInput) (*GetSubscriptionAttributesOutput, error) { + req, out := c.GetSubscriptionAttributesRequest(input) + return out, req.Send() +} + +// GetSubscriptionAttributesWithContext is the same as GetSubscriptionAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See GetSubscriptionAttributes 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 *SNS) GetSubscriptionAttributesWithContext(ctx aws.Context, input *GetSubscriptionAttributesInput, opts ...request.Option) (*GetSubscriptionAttributesOutput, error) { + req, out := c.GetSubscriptionAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetTopicAttributes = "GetTopicAttributes" + +// GetTopicAttributesRequest generates a "aws/request.Request" representing the +// client's request for the GetTopicAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetTopicAttributes for more information on using the GetTopicAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetTopicAttributesRequest method. +// req, resp := client.GetTopicAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetTopicAttributes +func (c *SNS) GetTopicAttributesRequest(input *GetTopicAttributesInput) (req *request.Request, output *GetTopicAttributesOutput) { + op := &request.Operation{ + Name: opGetTopicAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetTopicAttributesInput{} + } + + output = &GetTopicAttributesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetTopicAttributes API operation for Amazon Simple Notification Service. +// +// Returns all of the properties of a topic. Topic properties returned might +// differ based on the authorization of the 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 Simple Notification Service's +// API operation GetTopicAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetTopicAttributes +func (c *SNS) GetTopicAttributes(input *GetTopicAttributesInput) (*GetTopicAttributesOutput, error) { + req, out := c.GetTopicAttributesRequest(input) + return out, req.Send() +} + +// GetTopicAttributesWithContext is the same as GetTopicAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See GetTopicAttributes 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 *SNS) GetTopicAttributesWithContext(ctx aws.Context, input *GetTopicAttributesInput, opts ...request.Option) (*GetTopicAttributesOutput, error) { + req, out := c.GetTopicAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListEndpointsByPlatformApplication = "ListEndpointsByPlatformApplication" + +// ListEndpointsByPlatformApplicationRequest generates a "aws/request.Request" representing the +// client's request for the ListEndpointsByPlatformApplication operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListEndpointsByPlatformApplication for more information on using the ListEndpointsByPlatformApplication +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListEndpointsByPlatformApplicationRequest method. +// req, resp := client.ListEndpointsByPlatformApplicationRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListEndpointsByPlatformApplication +func (c *SNS) ListEndpointsByPlatformApplicationRequest(input *ListEndpointsByPlatformApplicationInput) (req *request.Request, output *ListEndpointsByPlatformApplicationOutput) { + op := &request.Operation{ + Name: opListEndpointsByPlatformApplication, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListEndpointsByPlatformApplicationInput{} + } + + output = &ListEndpointsByPlatformApplicationOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListEndpointsByPlatformApplication API operation for Amazon Simple Notification Service. +// +// Lists the endpoints and endpoint attributes for devices in a supported push +// notification service, such as GCM (Firebase Cloud Messaging) and APNS. The +// results for ListEndpointsByPlatformApplication are paginated and return a +// limited list of endpoints, up to 100. If additional records are available +// after the first page results, then a NextToken string will be returned. To +// receive the next page, you call ListEndpointsByPlatformApplication again +// using the NextToken string received from the previous call. When there are +// no more records to return, NextToken will be null. For more information, +// see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html). +// +// This action is throttled at 30 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation ListEndpointsByPlatformApplication for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListEndpointsByPlatformApplication +func (c *SNS) ListEndpointsByPlatformApplication(input *ListEndpointsByPlatformApplicationInput) (*ListEndpointsByPlatformApplicationOutput, error) { + req, out := c.ListEndpointsByPlatformApplicationRequest(input) + return out, req.Send() +} + +// ListEndpointsByPlatformApplicationWithContext is the same as ListEndpointsByPlatformApplication with the addition of +// the ability to pass a context and additional request options. +// +// See ListEndpointsByPlatformApplication 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 *SNS) ListEndpointsByPlatformApplicationWithContext(ctx aws.Context, input *ListEndpointsByPlatformApplicationInput, opts ...request.Option) (*ListEndpointsByPlatformApplicationOutput, error) { + req, out := c.ListEndpointsByPlatformApplicationRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListEndpointsByPlatformApplicationPages iterates over the pages of a ListEndpointsByPlatformApplication operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListEndpointsByPlatformApplication method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListEndpointsByPlatformApplication operation. +// pageNum := 0 +// err := client.ListEndpointsByPlatformApplicationPages(params, +// func(page *sns.ListEndpointsByPlatformApplicationOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListEndpointsByPlatformApplicationPages(input *ListEndpointsByPlatformApplicationInput, fn func(*ListEndpointsByPlatformApplicationOutput, bool) bool) error { + return c.ListEndpointsByPlatformApplicationPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListEndpointsByPlatformApplicationPagesWithContext same as ListEndpointsByPlatformApplicationPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListEndpointsByPlatformApplicationPagesWithContext(ctx aws.Context, input *ListEndpointsByPlatformApplicationInput, fn func(*ListEndpointsByPlatformApplicationOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListEndpointsByPlatformApplicationInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListEndpointsByPlatformApplicationRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListEndpointsByPlatformApplicationOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListOriginationNumbers = "ListOriginationNumbers" + +// ListOriginationNumbersRequest generates a "aws/request.Request" representing the +// client's request for the ListOriginationNumbers operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListOriginationNumbers for more information on using the ListOriginationNumbers +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListOriginationNumbersRequest method. +// req, resp := client.ListOriginationNumbersRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListOriginationNumbers +func (c *SNS) ListOriginationNumbersRequest(input *ListOriginationNumbersInput) (req *request.Request, output *ListOriginationNumbersOutput) { + op := &request.Operation{ + Name: opListOriginationNumbers, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "MaxResults", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListOriginationNumbersInput{} + } + + output = &ListOriginationNumbersOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListOriginationNumbers API operation for Amazon Simple Notification Service. +// +// Lists the calling AWS account's dedicated origination numbers and their metadata. +// For more information about origination numbers, see Origination numbers (https://docs.aws.amazon.com/sns/latest/dg/channels-sms-originating-identities-origination-numbers.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation ListOriginationNumbers for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeValidationException "ValidationException" +// Indicates that a parameter in the request is invalid. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListOriginationNumbers +func (c *SNS) ListOriginationNumbers(input *ListOriginationNumbersInput) (*ListOriginationNumbersOutput, error) { + req, out := c.ListOriginationNumbersRequest(input) + return out, req.Send() +} + +// ListOriginationNumbersWithContext is the same as ListOriginationNumbers with the addition of +// the ability to pass a context and additional request options. +// +// See ListOriginationNumbers 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 *SNS) ListOriginationNumbersWithContext(ctx aws.Context, input *ListOriginationNumbersInput, opts ...request.Option) (*ListOriginationNumbersOutput, error) { + req, out := c.ListOriginationNumbersRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListOriginationNumbersPages iterates over the pages of a ListOriginationNumbers operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListOriginationNumbers method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListOriginationNumbers operation. +// pageNum := 0 +// err := client.ListOriginationNumbersPages(params, +// func(page *sns.ListOriginationNumbersOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListOriginationNumbersPages(input *ListOriginationNumbersInput, fn func(*ListOriginationNumbersOutput, bool) bool) error { + return c.ListOriginationNumbersPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListOriginationNumbersPagesWithContext same as ListOriginationNumbersPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListOriginationNumbersPagesWithContext(ctx aws.Context, input *ListOriginationNumbersInput, fn func(*ListOriginationNumbersOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListOriginationNumbersInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListOriginationNumbersRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListOriginationNumbersOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListPhoneNumbersOptedOut = "ListPhoneNumbersOptedOut" + +// ListPhoneNumbersOptedOutRequest generates a "aws/request.Request" representing the +// client's request for the ListPhoneNumbersOptedOut operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListPhoneNumbersOptedOut for more information on using the ListPhoneNumbersOptedOut +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListPhoneNumbersOptedOutRequest method. +// req, resp := client.ListPhoneNumbersOptedOutRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPhoneNumbersOptedOut +func (c *SNS) ListPhoneNumbersOptedOutRequest(input *ListPhoneNumbersOptedOutInput) (req *request.Request, output *ListPhoneNumbersOptedOutOutput) { + op := &request.Operation{ + Name: opListPhoneNumbersOptedOut, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ListPhoneNumbersOptedOutInput{} + } + + output = &ListPhoneNumbersOptedOutOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListPhoneNumbersOptedOut API operation for Amazon Simple Notification Service. +// +// Returns a list of phone numbers that are opted out, meaning you cannot send +// SMS messages to them. +// +// The results for ListPhoneNumbersOptedOut are paginated, and each page returns +// up to 100 phone numbers. If additional phone numbers are available after +// the first page of results, then a NextToken string will be returned. To receive +// the next page, you call ListPhoneNumbersOptedOut again using the NextToken +// string received from the previous call. When there are no more records to +// return, NextToken will be null. +// +// 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 Simple Notification Service's +// API operation ListPhoneNumbersOptedOut for usage and error information. +// +// Returned Error Codes: +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPhoneNumbersOptedOut +func (c *SNS) ListPhoneNumbersOptedOut(input *ListPhoneNumbersOptedOutInput) (*ListPhoneNumbersOptedOutOutput, error) { + req, out := c.ListPhoneNumbersOptedOutRequest(input) + return out, req.Send() +} + +// ListPhoneNumbersOptedOutWithContext is the same as ListPhoneNumbersOptedOut with the addition of +// the ability to pass a context and additional request options. +// +// See ListPhoneNumbersOptedOut 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 *SNS) ListPhoneNumbersOptedOutWithContext(ctx aws.Context, input *ListPhoneNumbersOptedOutInput, opts ...request.Option) (*ListPhoneNumbersOptedOutOutput, error) { + req, out := c.ListPhoneNumbersOptedOutRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListPlatformApplications = "ListPlatformApplications" + +// ListPlatformApplicationsRequest generates a "aws/request.Request" representing the +// client's request for the ListPlatformApplications operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListPlatformApplications for more information on using the ListPlatformApplications +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListPlatformApplicationsRequest method. +// req, resp := client.ListPlatformApplicationsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPlatformApplications +func (c *SNS) ListPlatformApplicationsRequest(input *ListPlatformApplicationsInput) (req *request.Request, output *ListPlatformApplicationsOutput) { + op := &request.Operation{ + Name: opListPlatformApplications, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListPlatformApplicationsInput{} + } + + output = &ListPlatformApplicationsOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListPlatformApplications API operation for Amazon Simple Notification Service. +// +// Lists the platform application objects for the supported push notification +// services, such as APNS and GCM (Firebase Cloud Messaging). The results for +// ListPlatformApplications are paginated and return a limited list of applications, +// up to 100. If additional records are available after the first page results, +// then a NextToken string will be returned. To receive the next page, you call +// ListPlatformApplications using the NextToken string received from the previous +// call. When there are no more records to return, NextToken will be null. For +// more information, see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html). +// +// This action is throttled at 15 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation ListPlatformApplications for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPlatformApplications +func (c *SNS) ListPlatformApplications(input *ListPlatformApplicationsInput) (*ListPlatformApplicationsOutput, error) { + req, out := c.ListPlatformApplicationsRequest(input) + return out, req.Send() +} + +// ListPlatformApplicationsWithContext is the same as ListPlatformApplications with the addition of +// the ability to pass a context and additional request options. +// +// See ListPlatformApplications 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 *SNS) ListPlatformApplicationsWithContext(ctx aws.Context, input *ListPlatformApplicationsInput, opts ...request.Option) (*ListPlatformApplicationsOutput, error) { + req, out := c.ListPlatformApplicationsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListPlatformApplicationsPages iterates over the pages of a ListPlatformApplications operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListPlatformApplications method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListPlatformApplications operation. +// pageNum := 0 +// err := client.ListPlatformApplicationsPages(params, +// func(page *sns.ListPlatformApplicationsOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListPlatformApplicationsPages(input *ListPlatformApplicationsInput, fn func(*ListPlatformApplicationsOutput, bool) bool) error { + return c.ListPlatformApplicationsPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListPlatformApplicationsPagesWithContext same as ListPlatformApplicationsPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListPlatformApplicationsPagesWithContext(ctx aws.Context, input *ListPlatformApplicationsInput, fn func(*ListPlatformApplicationsOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListPlatformApplicationsInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListPlatformApplicationsRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListPlatformApplicationsOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListSMSSandboxPhoneNumbers = "ListSMSSandboxPhoneNumbers" + +// ListSMSSandboxPhoneNumbersRequest generates a "aws/request.Request" representing the +// client's request for the ListSMSSandboxPhoneNumbers operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListSMSSandboxPhoneNumbers for more information on using the ListSMSSandboxPhoneNumbers +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListSMSSandboxPhoneNumbersRequest method. +// req, resp := client.ListSMSSandboxPhoneNumbersRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSMSSandboxPhoneNumbers +func (c *SNS) ListSMSSandboxPhoneNumbersRequest(input *ListSMSSandboxPhoneNumbersInput) (req *request.Request, output *ListSMSSandboxPhoneNumbersOutput) { + op := &request.Operation{ + Name: opListSMSSandboxPhoneNumbers, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "MaxResults", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListSMSSandboxPhoneNumbersInput{} + } + + output = &ListSMSSandboxPhoneNumbersOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListSMSSandboxPhoneNumbers API operation for Amazon Simple Notification Service. +// +// Lists the calling AWS account's current verified and pending destination +// phone numbers in the SMS sandbox. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation ListSMSSandboxPhoneNumbers for usage and error information. +// +// Returned Error Codes: +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSMSSandboxPhoneNumbers +func (c *SNS) ListSMSSandboxPhoneNumbers(input *ListSMSSandboxPhoneNumbersInput) (*ListSMSSandboxPhoneNumbersOutput, error) { + req, out := c.ListSMSSandboxPhoneNumbersRequest(input) + return out, req.Send() +} + +// ListSMSSandboxPhoneNumbersWithContext is the same as ListSMSSandboxPhoneNumbers with the addition of +// the ability to pass a context and additional request options. +// +// See ListSMSSandboxPhoneNumbers 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 *SNS) ListSMSSandboxPhoneNumbersWithContext(ctx aws.Context, input *ListSMSSandboxPhoneNumbersInput, opts ...request.Option) (*ListSMSSandboxPhoneNumbersOutput, error) { + req, out := c.ListSMSSandboxPhoneNumbersRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListSMSSandboxPhoneNumbersPages iterates over the pages of a ListSMSSandboxPhoneNumbers operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListSMSSandboxPhoneNumbers method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListSMSSandboxPhoneNumbers operation. +// pageNum := 0 +// err := client.ListSMSSandboxPhoneNumbersPages(params, +// func(page *sns.ListSMSSandboxPhoneNumbersOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListSMSSandboxPhoneNumbersPages(input *ListSMSSandboxPhoneNumbersInput, fn func(*ListSMSSandboxPhoneNumbersOutput, bool) bool) error { + return c.ListSMSSandboxPhoneNumbersPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListSMSSandboxPhoneNumbersPagesWithContext same as ListSMSSandboxPhoneNumbersPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListSMSSandboxPhoneNumbersPagesWithContext(ctx aws.Context, input *ListSMSSandboxPhoneNumbersInput, fn func(*ListSMSSandboxPhoneNumbersOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListSMSSandboxPhoneNumbersInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListSMSSandboxPhoneNumbersRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListSMSSandboxPhoneNumbersOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListSubscriptions = "ListSubscriptions" + +// ListSubscriptionsRequest generates a "aws/request.Request" representing the +// client's request for the ListSubscriptions operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListSubscriptions for more information on using the ListSubscriptions +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListSubscriptionsRequest method. +// req, resp := client.ListSubscriptionsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptions +func (c *SNS) ListSubscriptionsRequest(input *ListSubscriptionsInput) (req *request.Request, output *ListSubscriptionsOutput) { + op := &request.Operation{ + Name: opListSubscriptions, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListSubscriptionsInput{} + } + + output = &ListSubscriptionsOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListSubscriptions API operation for Amazon Simple Notification Service. +// +// Returns a list of the requester's subscriptions. Each call returns a limited +// list of subscriptions, up to 100. If there are more subscriptions, a NextToken +// is also returned. Use the NextToken parameter in a new ListSubscriptions +// call to get further results. +// +// This action is throttled at 30 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation ListSubscriptions for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptions +func (c *SNS) ListSubscriptions(input *ListSubscriptionsInput) (*ListSubscriptionsOutput, error) { + req, out := c.ListSubscriptionsRequest(input) + return out, req.Send() +} + +// ListSubscriptionsWithContext is the same as ListSubscriptions with the addition of +// the ability to pass a context and additional request options. +// +// See ListSubscriptions 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 *SNS) ListSubscriptionsWithContext(ctx aws.Context, input *ListSubscriptionsInput, opts ...request.Option) (*ListSubscriptionsOutput, error) { + req, out := c.ListSubscriptionsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListSubscriptionsPages iterates over the pages of a ListSubscriptions operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListSubscriptions method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListSubscriptions operation. +// pageNum := 0 +// err := client.ListSubscriptionsPages(params, +// func(page *sns.ListSubscriptionsOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListSubscriptionsPages(input *ListSubscriptionsInput, fn func(*ListSubscriptionsOutput, bool) bool) error { + return c.ListSubscriptionsPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListSubscriptionsPagesWithContext same as ListSubscriptionsPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListSubscriptionsPagesWithContext(ctx aws.Context, input *ListSubscriptionsInput, fn func(*ListSubscriptionsOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListSubscriptionsInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListSubscriptionsRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListSubscriptionsOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListSubscriptionsByTopic = "ListSubscriptionsByTopic" + +// ListSubscriptionsByTopicRequest generates a "aws/request.Request" representing the +// client's request for the ListSubscriptionsByTopic operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListSubscriptionsByTopic for more information on using the ListSubscriptionsByTopic +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListSubscriptionsByTopicRequest method. +// req, resp := client.ListSubscriptionsByTopicRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptionsByTopic +func (c *SNS) ListSubscriptionsByTopicRequest(input *ListSubscriptionsByTopicInput) (req *request.Request, output *ListSubscriptionsByTopicOutput) { + op := &request.Operation{ + Name: opListSubscriptionsByTopic, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListSubscriptionsByTopicInput{} + } + + output = &ListSubscriptionsByTopicOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListSubscriptionsByTopic API operation for Amazon Simple Notification Service. +// +// Returns a list of the subscriptions to a specific topic. Each call returns +// a limited list of subscriptions, up to 100. If there are more subscriptions, +// a NextToken is also returned. Use the NextToken parameter in a new ListSubscriptionsByTopic +// call to get further results. +// +// This action is throttled at 30 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation ListSubscriptionsByTopic for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptionsByTopic +func (c *SNS) ListSubscriptionsByTopic(input *ListSubscriptionsByTopicInput) (*ListSubscriptionsByTopicOutput, error) { + req, out := c.ListSubscriptionsByTopicRequest(input) + return out, req.Send() +} + +// ListSubscriptionsByTopicWithContext is the same as ListSubscriptionsByTopic with the addition of +// the ability to pass a context and additional request options. +// +// See ListSubscriptionsByTopic 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 *SNS) ListSubscriptionsByTopicWithContext(ctx aws.Context, input *ListSubscriptionsByTopicInput, opts ...request.Option) (*ListSubscriptionsByTopicOutput, error) { + req, out := c.ListSubscriptionsByTopicRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListSubscriptionsByTopicPages iterates over the pages of a ListSubscriptionsByTopic operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListSubscriptionsByTopic method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListSubscriptionsByTopic operation. +// pageNum := 0 +// err := client.ListSubscriptionsByTopicPages(params, +// func(page *sns.ListSubscriptionsByTopicOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListSubscriptionsByTopicPages(input *ListSubscriptionsByTopicInput, fn func(*ListSubscriptionsByTopicOutput, bool) bool) error { + return c.ListSubscriptionsByTopicPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListSubscriptionsByTopicPagesWithContext same as ListSubscriptionsByTopicPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListSubscriptionsByTopicPagesWithContext(ctx aws.Context, input *ListSubscriptionsByTopicInput, fn func(*ListSubscriptionsByTopicOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListSubscriptionsByTopicInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListSubscriptionsByTopicRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListSubscriptionsByTopicOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opListTagsForResource = "ListTagsForResource" + +// ListTagsForResourceRequest generates a "aws/request.Request" representing the +// client's request for the ListTagsForResource operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListTagsForResource for more information on using the ListTagsForResource +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListTagsForResourceRequest method. +// req, resp := client.ListTagsForResourceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTagsForResource +func (c *SNS) ListTagsForResourceRequest(input *ListTagsForResourceInput) (req *request.Request, output *ListTagsForResourceOutput) { + op := &request.Operation{ + Name: opListTagsForResource, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ListTagsForResourceInput{} + } + + output = &ListTagsForResourceOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListTagsForResource API operation for Amazon Simple Notification Service. +// +// List all tags added to the specified Amazon SNS topic. For an overview, see +// Amazon SNS Tags (https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html) +// in the Amazon Simple Notification Service Developer 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 Simple Notification Service's +// API operation ListTagsForResource for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeTagPolicyException "TagPolicy" +// The request doesn't comply with the IAM tag policy. Correct your request +// and then retry it. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeConcurrentAccessException "ConcurrentAccess" +// Can't perform multiple operations on a tag simultaneously. Perform the operations +// sequentially. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTagsForResource +func (c *SNS) ListTagsForResource(input *ListTagsForResourceInput) (*ListTagsForResourceOutput, error) { + req, out := c.ListTagsForResourceRequest(input) + return out, req.Send() +} + +// ListTagsForResourceWithContext is the same as ListTagsForResource with the addition of +// the ability to pass a context and additional request options. +// +// See ListTagsForResource 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 *SNS) ListTagsForResourceWithContext(ctx aws.Context, input *ListTagsForResourceInput, opts ...request.Option) (*ListTagsForResourceOutput, error) { + req, out := c.ListTagsForResourceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListTopics = "ListTopics" + +// ListTopicsRequest generates a "aws/request.Request" representing the +// client's request for the ListTopics operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListTopics for more information on using the ListTopics +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListTopicsRequest method. +// req, resp := client.ListTopicsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTopics +func (c *SNS) ListTopicsRequest(input *ListTopicsInput) (req *request.Request, output *ListTopicsOutput) { + op := &request.Operation{ + Name: opListTopics, + HTTPMethod: "POST", + HTTPPath: "/", + Paginator: &request.Paginator{ + InputTokens: []string{"NextToken"}, + OutputTokens: []string{"NextToken"}, + LimitToken: "", + TruncationToken: "", + }, + } + + if input == nil { + input = &ListTopicsInput{} + } + + output = &ListTopicsOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListTopics API operation for Amazon Simple Notification Service. +// +// Returns a list of the requester's topics. Each call returns a limited list +// of topics, up to 100. If there are more topics, a NextToken is also returned. +// Use the NextToken parameter in a new ListTopics call to get further results. +// +// This action is throttled at 30 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation ListTopics for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTopics +func (c *SNS) ListTopics(input *ListTopicsInput) (*ListTopicsOutput, error) { + req, out := c.ListTopicsRequest(input) + return out, req.Send() +} + +// ListTopicsWithContext is the same as ListTopics with the addition of +// the ability to pass a context and additional request options. +// +// See ListTopics 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 *SNS) ListTopicsWithContext(ctx aws.Context, input *ListTopicsInput, opts ...request.Option) (*ListTopicsOutput, error) { + req, out := c.ListTopicsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +// ListTopicsPages iterates over the pages of a ListTopics operation, +// calling the "fn" function with the response data for each page. To stop +// iterating, return false from the fn function. +// +// See ListTopics method for more information on how to use this operation. +// +// Note: This operation can generate multiple requests to a service. +// +// // Example iterating over at most 3 pages of a ListTopics operation. +// pageNum := 0 +// err := client.ListTopicsPages(params, +// func(page *sns.ListTopicsOutput, lastPage bool) bool { +// pageNum++ +// fmt.Println(page) +// return pageNum <= 3 +// }) +// +func (c *SNS) ListTopicsPages(input *ListTopicsInput, fn func(*ListTopicsOutput, bool) bool) error { + return c.ListTopicsPagesWithContext(aws.BackgroundContext(), input, fn) +} + +// ListTopicsPagesWithContext same as ListTopicsPages except +// it takes a Context and allows setting request options on the pages. +// +// 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 *SNS) ListTopicsPagesWithContext(ctx aws.Context, input *ListTopicsInput, fn func(*ListTopicsOutput, bool) bool, opts ...request.Option) error { + p := request.Pagination{ + NewRequest: func() (*request.Request, error) { + var inCpy *ListTopicsInput + if input != nil { + tmp := *input + inCpy = &tmp + } + req, _ := c.ListTopicsRequest(inCpy) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return req, nil + }, + } + + for p.Next() { + if !fn(p.Page().(*ListTopicsOutput), !p.HasNextPage()) { + break + } + } + + return p.Err() +} + +const opOptInPhoneNumber = "OptInPhoneNumber" + +// OptInPhoneNumberRequest generates a "aws/request.Request" representing the +// client's request for the OptInPhoneNumber operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See OptInPhoneNumber for more information on using the OptInPhoneNumber +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the OptInPhoneNumberRequest method. +// req, resp := client.OptInPhoneNumberRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/OptInPhoneNumber +func (c *SNS) OptInPhoneNumberRequest(input *OptInPhoneNumberInput) (req *request.Request, output *OptInPhoneNumberOutput) { + op := &request.Operation{ + Name: opOptInPhoneNumber, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &OptInPhoneNumberInput{} + } + + output = &OptInPhoneNumberOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// OptInPhoneNumber API operation for Amazon Simple Notification Service. +// +// Use this request to opt in a phone number that is opted out, which enables +// you to resume sending SMS messages to the number. +// +// You can opt in a phone number only once every 30 days. +// +// 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 Simple Notification Service's +// API operation OptInPhoneNumber for usage and error information. +// +// Returned Error Codes: +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/OptInPhoneNumber +func (c *SNS) OptInPhoneNumber(input *OptInPhoneNumberInput) (*OptInPhoneNumberOutput, error) { + req, out := c.OptInPhoneNumberRequest(input) + return out, req.Send() +} + +// OptInPhoneNumberWithContext is the same as OptInPhoneNumber with the addition of +// the ability to pass a context and additional request options. +// +// See OptInPhoneNumber 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 *SNS) OptInPhoneNumberWithContext(ctx aws.Context, input *OptInPhoneNumberInput, opts ...request.Option) (*OptInPhoneNumberOutput, error) { + req, out := c.OptInPhoneNumberRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opPublish = "Publish" + +// PublishRequest generates a "aws/request.Request" representing the +// client's request for the Publish operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See Publish for more information on using the Publish +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the PublishRequest method. +// req, resp := client.PublishRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Publish +func (c *SNS) PublishRequest(input *PublishInput) (req *request.Request, output *PublishOutput) { + op := &request.Operation{ + Name: opPublish, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &PublishInput{} + } + + output = &PublishOutput{} + req = c.newRequest(op, input, output) + return +} + +// Publish API operation for Amazon Simple Notification Service. +// +// Sends a message to an Amazon SNS topic, a text message (SMS message) directly +// to a phone number, or a message to a mobile platform endpoint (when you specify +// the TargetArn). +// +// If you send a message to a topic, Amazon SNS delivers the message to each +// endpoint that is subscribed to the topic. The format of the message depends +// on the notification protocol for each subscribed endpoint. +// +// When a messageId is returned, the message has been saved and Amazon SNS will +// attempt to deliver it shortly. +// +// To use the Publish action for sending a message to a mobile endpoint, such +// as an app on a Kindle device or mobile phone, you must specify the EndpointArn +// for the TargetArn parameter. The EndpointArn is returned when making a call +// with the CreatePlatformEndpoint action. +// +// For more information about formatting messages, see Send Custom Platform-Specific +// Payloads in Messages to Mobile Devices (https://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html). +// +// You can publish messages only to topics and endpoints in the same AWS Region. +// +// 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 Simple Notification Service's +// API operation Publish for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInvalidParameterValueException "ParameterValueInvalid" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeEndpointDisabledException "EndpointDisabled" +// Exception error indicating endpoint disabled. +// +// * ErrCodePlatformApplicationDisabledException "PlatformApplicationDisabled" +// Exception error indicating platform application disabled. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeKMSDisabledException "KMSDisabled" +// The request was rejected because the specified customer master key (CMK) +// isn't enabled. +// +// * ErrCodeKMSInvalidStateException "KMSInvalidState" +// The request was rejected because the state of the specified resource isn't +// valid for this request. For more information, see How Key State Affects Use +// of a Customer Master Key (https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html) +// in the AWS Key Management Service Developer Guide. +// +// * ErrCodeKMSNotFoundException "KMSNotFound" +// The request was rejected because the specified entity or resource can't be +// found. +// +// * ErrCodeKMSOptInRequired "KMSOptInRequired" +// The AWS access key ID needs a subscription for the service. +// +// * ErrCodeKMSThrottlingException "KMSThrottling" +// The request was denied due to request throttling. For more information about +// throttling, see Limits (https://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second) +// in the AWS Key Management Service Developer Guide. +// +// * ErrCodeKMSAccessDeniedException "KMSAccessDenied" +// The ciphertext references a key that doesn't exist or that you don't have +// access to. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Publish +func (c *SNS) Publish(input *PublishInput) (*PublishOutput, error) { + req, out := c.PublishRequest(input) + return out, req.Send() +} + +// PublishWithContext is the same as Publish with the addition of +// the ability to pass a context and additional request options. +// +// See Publish 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 *SNS) PublishWithContext(ctx aws.Context, input *PublishInput, opts ...request.Option) (*PublishOutput, error) { + req, out := c.PublishRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opRemovePermission = "RemovePermission" + +// RemovePermissionRequest generates a "aws/request.Request" representing the +// client's request for the RemovePermission operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See RemovePermission for more information on using the RemovePermission +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the RemovePermissionRequest method. +// req, resp := client.RemovePermissionRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/RemovePermission +func (c *SNS) RemovePermissionRequest(input *RemovePermissionInput) (req *request.Request, output *RemovePermissionOutput) { + op := &request.Operation{ + Name: opRemovePermission, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &RemovePermissionInput{} + } + + output = &RemovePermissionOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// RemovePermission API operation for Amazon Simple Notification Service. +// +// Removes a statement from a topic's access control policy. +// +// 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 Simple Notification Service's +// API operation RemovePermission for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/RemovePermission +func (c *SNS) RemovePermission(input *RemovePermissionInput) (*RemovePermissionOutput, error) { + req, out := c.RemovePermissionRequest(input) + return out, req.Send() +} + +// RemovePermissionWithContext is the same as RemovePermission with the addition of +// the ability to pass a context and additional request options. +// +// See RemovePermission 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 *SNS) RemovePermissionWithContext(ctx aws.Context, input *RemovePermissionInput, opts ...request.Option) (*RemovePermissionOutput, error) { + req, out := c.RemovePermissionRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSetEndpointAttributes = "SetEndpointAttributes" + +// SetEndpointAttributesRequest generates a "aws/request.Request" representing the +// client's request for the SetEndpointAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See SetEndpointAttributes for more information on using the SetEndpointAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SetEndpointAttributesRequest method. +// req, resp := client.SetEndpointAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetEndpointAttributes +func (c *SNS) SetEndpointAttributesRequest(input *SetEndpointAttributesInput) (req *request.Request, output *SetEndpointAttributesOutput) { + op := &request.Operation{ + Name: opSetEndpointAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SetEndpointAttributesInput{} + } + + output = &SetEndpointAttributesOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// SetEndpointAttributes API operation for Amazon Simple Notification Service. +// +// Sets the attributes for an endpoint for a device on one of the supported +// push notification services, such as GCM (Firebase Cloud Messaging) and APNS. +// For more information, see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.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 Simple Notification Service's +// API operation SetEndpointAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetEndpointAttributes +func (c *SNS) SetEndpointAttributes(input *SetEndpointAttributesInput) (*SetEndpointAttributesOutput, error) { + req, out := c.SetEndpointAttributesRequest(input) + return out, req.Send() +} + +// SetEndpointAttributesWithContext is the same as SetEndpointAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See SetEndpointAttributes 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 *SNS) SetEndpointAttributesWithContext(ctx aws.Context, input *SetEndpointAttributesInput, opts ...request.Option) (*SetEndpointAttributesOutput, error) { + req, out := c.SetEndpointAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSetPlatformApplicationAttributes = "SetPlatformApplicationAttributes" + +// SetPlatformApplicationAttributesRequest generates a "aws/request.Request" representing the +// client's request for the SetPlatformApplicationAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See SetPlatformApplicationAttributes for more information on using the SetPlatformApplicationAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SetPlatformApplicationAttributesRequest method. +// req, resp := client.SetPlatformApplicationAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetPlatformApplicationAttributes +func (c *SNS) SetPlatformApplicationAttributesRequest(input *SetPlatformApplicationAttributesInput) (req *request.Request, output *SetPlatformApplicationAttributesOutput) { + op := &request.Operation{ + Name: opSetPlatformApplicationAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SetPlatformApplicationAttributesInput{} + } + + output = &SetPlatformApplicationAttributesOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// SetPlatformApplicationAttributes API operation for Amazon Simple Notification Service. +// +// Sets the attributes of the platform application object for the supported +// push notification services, such as APNS and GCM (Firebase Cloud Messaging). +// For more information, see Using Amazon SNS Mobile Push Notifications (https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html). +// For information on configuring attributes for message delivery status, see +// Using Amazon SNS Application Attributes for Message Delivery Status (https://docs.aws.amazon.com/sns/latest/dg/sns-msg-status.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 Simple Notification Service's +// API operation SetPlatformApplicationAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetPlatformApplicationAttributes +func (c *SNS) SetPlatformApplicationAttributes(input *SetPlatformApplicationAttributesInput) (*SetPlatformApplicationAttributesOutput, error) { + req, out := c.SetPlatformApplicationAttributesRequest(input) + return out, req.Send() +} + +// SetPlatformApplicationAttributesWithContext is the same as SetPlatformApplicationAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See SetPlatformApplicationAttributes 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 *SNS) SetPlatformApplicationAttributesWithContext(ctx aws.Context, input *SetPlatformApplicationAttributesInput, opts ...request.Option) (*SetPlatformApplicationAttributesOutput, error) { + req, out := c.SetPlatformApplicationAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSetSMSAttributes = "SetSMSAttributes" + +// SetSMSAttributesRequest generates a "aws/request.Request" representing the +// client's request for the SetSMSAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See SetSMSAttributes for more information on using the SetSMSAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SetSMSAttributesRequest method. +// req, resp := client.SetSMSAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSMSAttributes +func (c *SNS) SetSMSAttributesRequest(input *SetSMSAttributesInput) (req *request.Request, output *SetSMSAttributesOutput) { + op := &request.Operation{ + Name: opSetSMSAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SetSMSAttributesInput{} + } + + output = &SetSMSAttributesOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// SetSMSAttributes API operation for Amazon Simple Notification Service. +// +// Use this request to set the default settings for sending SMS messages and +// receiving daily SMS usage reports. +// +// You can override some of these settings for a single message when you use +// the Publish action with the MessageAttributes.entry.N parameter. For more +// information, see Publishing to a mobile phone (https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html) +// in the Amazon SNS Developer Guide. +// +// To use this operation, you must grant the Amazon SNS service principal (sns.amazonaws.com) +// permission to perform the s3:ListBucket action. +// +// 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 Simple Notification Service's +// API operation SetSMSAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSMSAttributes +func (c *SNS) SetSMSAttributes(input *SetSMSAttributesInput) (*SetSMSAttributesOutput, error) { + req, out := c.SetSMSAttributesRequest(input) + return out, req.Send() +} + +// SetSMSAttributesWithContext is the same as SetSMSAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See SetSMSAttributes 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 *SNS) SetSMSAttributesWithContext(ctx aws.Context, input *SetSMSAttributesInput, opts ...request.Option) (*SetSMSAttributesOutput, error) { + req, out := c.SetSMSAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSetSubscriptionAttributes = "SetSubscriptionAttributes" + +// SetSubscriptionAttributesRequest generates a "aws/request.Request" representing the +// client's request for the SetSubscriptionAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See SetSubscriptionAttributes for more information on using the SetSubscriptionAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SetSubscriptionAttributesRequest method. +// req, resp := client.SetSubscriptionAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSubscriptionAttributes +func (c *SNS) SetSubscriptionAttributesRequest(input *SetSubscriptionAttributesInput) (req *request.Request, output *SetSubscriptionAttributesOutput) { + op := &request.Operation{ + Name: opSetSubscriptionAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SetSubscriptionAttributesInput{} + } + + output = &SetSubscriptionAttributesOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// SetSubscriptionAttributes API operation for Amazon Simple Notification Service. +// +// Allows a subscription owner to set an attribute of the subscription to a +// new value. +// +// 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 Simple Notification Service's +// API operation SetSubscriptionAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeFilterPolicyLimitExceededException "FilterPolicyLimitExceeded" +// Indicates that the number of filter polices in your AWS account exceeds the +// limit. To add more filter polices, submit an SNS Limit Increase case in the +// AWS Support Center. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSubscriptionAttributes +func (c *SNS) SetSubscriptionAttributes(input *SetSubscriptionAttributesInput) (*SetSubscriptionAttributesOutput, error) { + req, out := c.SetSubscriptionAttributesRequest(input) + return out, req.Send() +} + +// SetSubscriptionAttributesWithContext is the same as SetSubscriptionAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See SetSubscriptionAttributes 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 *SNS) SetSubscriptionAttributesWithContext(ctx aws.Context, input *SetSubscriptionAttributesInput, opts ...request.Option) (*SetSubscriptionAttributesOutput, error) { + req, out := c.SetSubscriptionAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSetTopicAttributes = "SetTopicAttributes" + +// SetTopicAttributesRequest generates a "aws/request.Request" representing the +// client's request for the SetTopicAttributes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See SetTopicAttributes for more information on using the SetTopicAttributes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SetTopicAttributesRequest method. +// req, resp := client.SetTopicAttributesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetTopicAttributes +func (c *SNS) SetTopicAttributesRequest(input *SetTopicAttributesInput) (req *request.Request, output *SetTopicAttributesOutput) { + op := &request.Operation{ + Name: opSetTopicAttributes, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SetTopicAttributesInput{} + } + + output = &SetTopicAttributesOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// SetTopicAttributes API operation for Amazon Simple Notification Service. +// +// Allows a topic owner to set an attribute of the topic to a new value. +// +// 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 Simple Notification Service's +// API operation SetTopicAttributes for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetTopicAttributes +func (c *SNS) SetTopicAttributes(input *SetTopicAttributesInput) (*SetTopicAttributesOutput, error) { + req, out := c.SetTopicAttributesRequest(input) + return out, req.Send() +} + +// SetTopicAttributesWithContext is the same as SetTopicAttributes with the addition of +// the ability to pass a context and additional request options. +// +// See SetTopicAttributes 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 *SNS) SetTopicAttributesWithContext(ctx aws.Context, input *SetTopicAttributesInput, opts ...request.Option) (*SetTopicAttributesOutput, error) { + req, out := c.SetTopicAttributesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opSubscribe = "Subscribe" + +// SubscribeRequest generates a "aws/request.Request" representing the +// client's request for the Subscribe operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See Subscribe for more information on using the Subscribe +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the SubscribeRequest method. +// req, resp := client.SubscribeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Subscribe +func (c *SNS) SubscribeRequest(input *SubscribeInput) (req *request.Request, output *SubscribeOutput) { + op := &request.Operation{ + Name: opSubscribe, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &SubscribeInput{} + } + + output = &SubscribeOutput{} + req = c.newRequest(op, input, output) + return +} + +// Subscribe API operation for Amazon Simple Notification Service. +// +// Subscribes an endpoint to an Amazon SNS topic. If the endpoint type is HTTP/S +// or email, or if the endpoint and the topic are not in the same AWS account, +// the endpoint owner must run the ConfirmSubscription action to confirm the +// subscription. +// +// You call the ConfirmSubscription action with the token from the subscription +// response. Confirmation tokens are valid for three days. +// +// This action is throttled at 100 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation Subscribe for usage and error information. +// +// Returned Error Codes: +// * ErrCodeSubscriptionLimitExceededException "SubscriptionLimitExceeded" +// Indicates that the customer already owns the maximum allowed number of subscriptions. +// +// * ErrCodeFilterPolicyLimitExceededException "FilterPolicyLimitExceeded" +// Indicates that the number of filter polices in your AWS account exceeds the +// limit. To add more filter polices, submit an SNS Limit Increase case in the +// AWS Support Center. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Subscribe +func (c *SNS) Subscribe(input *SubscribeInput) (*SubscribeOutput, error) { + req, out := c.SubscribeRequest(input) + return out, req.Send() +} + +// SubscribeWithContext is the same as Subscribe with the addition of +// the ability to pass a context and additional request options. +// +// See Subscribe 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 *SNS) SubscribeWithContext(ctx aws.Context, input *SubscribeInput, opts ...request.Option) (*SubscribeOutput, error) { + req, out := c.SubscribeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opTagResource = "TagResource" + +// TagResourceRequest generates a "aws/request.Request" representing the +// client's request for the TagResource operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See TagResource for more information on using the TagResource +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the TagResourceRequest method. +// req, resp := client.TagResourceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/TagResource +func (c *SNS) TagResourceRequest(input *TagResourceInput) (req *request.Request, output *TagResourceOutput) { + op := &request.Operation{ + Name: opTagResource, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &TagResourceInput{} + } + + output = &TagResourceOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// TagResource API operation for Amazon Simple Notification Service. +// +// Add tags to the specified Amazon SNS topic. For an overview, see Amazon SNS +// Tags (https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html) in the Amazon +// SNS Developer Guide. +// +// When you use topic tags, keep the following guidelines in mind: +// +// * Adding more than 50 tags to a topic isn't recommended. +// +// * Tags don't have any semantic meaning. Amazon SNS interprets tags as +// character strings. +// +// * Tags are case-sensitive. +// +// * A new tag with a key identical to that of an existing tag overwrites +// the existing tag. +// +// * Tagging actions are limited to 10 TPS per AWS account, per AWS region. +// If your application requires a higher throughput, file a technical support +// request (https://console.aws.amazon.com/support/home#/case/create?issueType=technical). +// +// 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 Simple Notification Service's +// API operation TagResource for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeTagLimitExceededException "TagLimitExceeded" +// Can't add more than 50 tags to a topic. +// +// * ErrCodeStaleTagException "StaleTag" +// A tag has been added to a resource with the same ARN as a deleted resource. +// Wait a short while and then retry the operation. +// +// * ErrCodeTagPolicyException "TagPolicy" +// The request doesn't comply with the IAM tag policy. Correct your request +// and then retry it. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeConcurrentAccessException "ConcurrentAccess" +// Can't perform multiple operations on a tag simultaneously. Perform the operations +// sequentially. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/TagResource +func (c *SNS) TagResource(input *TagResourceInput) (*TagResourceOutput, error) { + req, out := c.TagResourceRequest(input) + return out, req.Send() +} + +// TagResourceWithContext is the same as TagResource with the addition of +// the ability to pass a context and additional request options. +// +// See TagResource 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 *SNS) TagResourceWithContext(ctx aws.Context, input *TagResourceInput, opts ...request.Option) (*TagResourceOutput, error) { + req, out := c.TagResourceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUnsubscribe = "Unsubscribe" + +// UnsubscribeRequest generates a "aws/request.Request" representing the +// client's request for the Unsubscribe operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See Unsubscribe for more information on using the Unsubscribe +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UnsubscribeRequest method. +// req, resp := client.UnsubscribeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Unsubscribe +func (c *SNS) UnsubscribeRequest(input *UnsubscribeInput) (req *request.Request, output *UnsubscribeOutput) { + op := &request.Operation{ + Name: opUnsubscribe, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UnsubscribeInput{} + } + + output = &UnsubscribeOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// Unsubscribe API operation for Amazon Simple Notification Service. +// +// Deletes a subscription. If the subscription requires authentication for deletion, +// only the owner of the subscription or the topic's owner can unsubscribe, +// and an AWS signature is required. If the Unsubscribe call does not require +// authentication and the requester is not the subscription owner, a final cancellation +// message is delivered to the endpoint, so that the endpoint owner can easily +// resubscribe to the topic if the Unsubscribe request was unintended. +// +// This action is throttled at 100 transactions per second (TPS). +// +// 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 Simple Notification Service's +// API operation Unsubscribe for usage and error information. +// +// Returned Error Codes: +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeNotFoundException "NotFound" +// Indicates that the requested resource does not exist. +// +// * ErrCodeInvalidSecurityException "InvalidSecurity" +// The credential signature isn't valid. You must use an HTTPS endpoint and +// sign your request using Signature Version 4. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Unsubscribe +func (c *SNS) Unsubscribe(input *UnsubscribeInput) (*UnsubscribeOutput, error) { + req, out := c.UnsubscribeRequest(input) + return out, req.Send() +} + +// UnsubscribeWithContext is the same as Unsubscribe with the addition of +// the ability to pass a context and additional request options. +// +// See Unsubscribe 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 *SNS) UnsubscribeWithContext(ctx aws.Context, input *UnsubscribeInput, opts ...request.Option) (*UnsubscribeOutput, error) { + req, out := c.UnsubscribeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUntagResource = "UntagResource" + +// UntagResourceRequest generates a "aws/request.Request" representing the +// client's request for the UntagResource operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UntagResource for more information on using the UntagResource +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UntagResourceRequest method. +// req, resp := client.UntagResourceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/UntagResource +func (c *SNS) UntagResourceRequest(input *UntagResourceInput) (req *request.Request, output *UntagResourceOutput) { + op := &request.Operation{ + Name: opUntagResource, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UntagResourceInput{} + } + + output = &UntagResourceOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// UntagResource API operation for Amazon Simple Notification Service. +// +// Remove tags from the specified Amazon SNS topic. For an overview, see Amazon +// SNS Tags (https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html) in the +// Amazon SNS Developer 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 Simple Notification Service's +// API operation UntagResource for usage and error information. +// +// Returned Error Codes: +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeTagLimitExceededException "TagLimitExceeded" +// Can't add more than 50 tags to a topic. +// +// * ErrCodeStaleTagException "StaleTag" +// A tag has been added to a resource with the same ARN as a deleted resource. +// Wait a short while and then retry the operation. +// +// * ErrCodeTagPolicyException "TagPolicy" +// The request doesn't comply with the IAM tag policy. Correct your request +// and then retry it. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeConcurrentAccessException "ConcurrentAccess" +// Can't perform multiple operations on a tag simultaneously. Perform the operations +// sequentially. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/UntagResource +func (c *SNS) UntagResource(input *UntagResourceInput) (*UntagResourceOutput, error) { + req, out := c.UntagResourceRequest(input) + return out, req.Send() +} + +// UntagResourceWithContext is the same as UntagResource with the addition of +// the ability to pass a context and additional request options. +// +// See UntagResource 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 *SNS) UntagResourceWithContext(ctx aws.Context, input *UntagResourceInput, opts ...request.Option) (*UntagResourceOutput, error) { + req, out := c.UntagResourceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opVerifySMSSandboxPhoneNumber = "VerifySMSSandboxPhoneNumber" + +// VerifySMSSandboxPhoneNumberRequest generates a "aws/request.Request" representing the +// client's request for the VerifySMSSandboxPhoneNumber operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See VerifySMSSandboxPhoneNumber for more information on using the VerifySMSSandboxPhoneNumber +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the VerifySMSSandboxPhoneNumberRequest method. +// req, resp := client.VerifySMSSandboxPhoneNumberRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/VerifySMSSandboxPhoneNumber +func (c *SNS) VerifySMSSandboxPhoneNumberRequest(input *VerifySMSSandboxPhoneNumberInput) (req *request.Request, output *VerifySMSSandboxPhoneNumberOutput) { + op := &request.Operation{ + Name: opVerifySMSSandboxPhoneNumber, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &VerifySMSSandboxPhoneNumberInput{} + } + + output = &VerifySMSSandboxPhoneNumberOutput{} + req = c.newRequest(op, input, output) + req.Handlers.Unmarshal.Swap(query.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) + return +} + +// VerifySMSSandboxPhoneNumber API operation for Amazon Simple Notification Service. +// +// Verifies a destination phone number with a one-time password (OTP) for the +// calling AWS account. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer 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 Simple Notification Service's +// API operation VerifySMSSandboxPhoneNumber for usage and error information. +// +// Returned Error Codes: +// * ErrCodeAuthorizationErrorException "AuthorizationError" +// Indicates that the user has been denied access to the requested resource. +// +// * ErrCodeInternalErrorException "InternalError" +// Indicates an internal service error. +// +// * ErrCodeInvalidParameterException "InvalidParameter" +// Indicates that a request parameter does not comply with the associated constraints. +// +// * ErrCodeResourceNotFoundException "ResourceNotFound" +// Can’t perform the action on the specified resource. Make sure that the +// resource exists. +// +// * ErrCodeVerificationException "VerificationException" +// Indicates that the one-time password (OTP) used for verification is invalid. +// +// * ErrCodeThrottledException "Throttled" +// Indicates that the rate at which requests have been submitted for this action +// exceeds the limit for your account. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/VerifySMSSandboxPhoneNumber +func (c *SNS) VerifySMSSandboxPhoneNumber(input *VerifySMSSandboxPhoneNumberInput) (*VerifySMSSandboxPhoneNumberOutput, error) { + req, out := c.VerifySMSSandboxPhoneNumberRequest(input) + return out, req.Send() +} + +// VerifySMSSandboxPhoneNumberWithContext is the same as VerifySMSSandboxPhoneNumber with the addition of +// the ability to pass a context and additional request options. +// +// See VerifySMSSandboxPhoneNumber 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 *SNS) VerifySMSSandboxPhoneNumberWithContext(ctx aws.Context, input *VerifySMSSandboxPhoneNumberInput, opts ...request.Option) (*VerifySMSSandboxPhoneNumberOutput, error) { + req, out := c.VerifySMSSandboxPhoneNumberRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +type AddPermissionInput struct { + _ struct{} `type:"structure"` + + // The AWS account IDs of the users (principals) who will be given access to + // the specified actions. The users must have AWS accounts, but do not need + // to be signed up for this service. + // + // AWSAccountId is a required field + AWSAccountId []*string `type:"list" required:"true"` + + // The action you want to allow for the specified principal(s). + // + // Valid values: Any Amazon SNS action name, for example Publish. + // + // ActionName is a required field + ActionName []*string `type:"list" required:"true"` + + // A unique identifier for the new policy statement. + // + // Label is a required field + Label *string `type:"string" required:"true"` + + // The ARN of the topic whose access control policy you wish to modify. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s AddPermissionInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AddPermissionInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AddPermissionInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AddPermissionInput"} + if s.AWSAccountId == nil { + invalidParams.Add(request.NewErrParamRequired("AWSAccountId")) + } + if s.ActionName == nil { + invalidParams.Add(request.NewErrParamRequired("ActionName")) + } + if s.Label == nil { + invalidParams.Add(request.NewErrParamRequired("Label")) + } + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAWSAccountId sets the AWSAccountId field's value. +func (s *AddPermissionInput) SetAWSAccountId(v []*string) *AddPermissionInput { + s.AWSAccountId = v + return s +} + +// SetActionName sets the ActionName field's value. +func (s *AddPermissionInput) SetActionName(v []*string) *AddPermissionInput { + s.ActionName = v + return s +} + +// SetLabel sets the Label field's value. +func (s *AddPermissionInput) SetLabel(v string) *AddPermissionInput { + s.Label = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *AddPermissionInput) SetTopicArn(v string) *AddPermissionInput { + s.TopicArn = &v + return s +} + +type AddPermissionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s AddPermissionOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AddPermissionOutput) GoString() string { + return s.String() +} + +// The input for the CheckIfPhoneNumberIsOptedOut action. +type CheckIfPhoneNumberIsOptedOutInput struct { + _ struct{} `type:"structure"` + + // The phone number for which you want to check the opt out status. + // + // PhoneNumber is a required field + PhoneNumber *string `locationName:"phoneNumber" type:"string" required:"true"` +} + +// String returns the string representation +func (s CheckIfPhoneNumberIsOptedOutInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CheckIfPhoneNumberIsOptedOutInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CheckIfPhoneNumberIsOptedOutInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CheckIfPhoneNumberIsOptedOutInput"} + if s.PhoneNumber == nil { + invalidParams.Add(request.NewErrParamRequired("PhoneNumber")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *CheckIfPhoneNumberIsOptedOutInput) SetPhoneNumber(v string) *CheckIfPhoneNumberIsOptedOutInput { + s.PhoneNumber = &v + return s +} + +// The response from the CheckIfPhoneNumberIsOptedOut action. +type CheckIfPhoneNumberIsOptedOutOutput struct { + _ struct{} `type:"structure"` + + // Indicates whether the phone number is opted out: + // + // * true – The phone number is opted out, meaning you cannot publish SMS + // messages to it. + // + // * false – The phone number is opted in, meaning you can publish SMS + // messages to it. + IsOptedOut *bool `locationName:"isOptedOut" type:"boolean"` +} + +// String returns the string representation +func (s CheckIfPhoneNumberIsOptedOutOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CheckIfPhoneNumberIsOptedOutOutput) GoString() string { + return s.String() +} + +// SetIsOptedOut sets the IsOptedOut field's value. +func (s *CheckIfPhoneNumberIsOptedOutOutput) SetIsOptedOut(v bool) *CheckIfPhoneNumberIsOptedOutOutput { + s.IsOptedOut = &v + return s +} + +// Input for ConfirmSubscription action. +type ConfirmSubscriptionInput struct { + _ struct{} `type:"structure"` + + // Disallows unauthenticated unsubscribes of the subscription. If the value + // of this parameter is true and the request has an AWS signature, then only + // the topic owner and the subscription owner can unsubscribe the endpoint. + // The unsubscribe action requires AWS authentication. + AuthenticateOnUnsubscribe *string `type:"string"` + + // Short-lived token sent to an endpoint during the Subscribe action. + // + // Token is a required field + Token *string `type:"string" required:"true"` + + // The ARN of the topic for which you wish to confirm a subscription. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ConfirmSubscriptionInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ConfirmSubscriptionInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ConfirmSubscriptionInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ConfirmSubscriptionInput"} + if s.Token == nil { + invalidParams.Add(request.NewErrParamRequired("Token")) + } + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAuthenticateOnUnsubscribe sets the AuthenticateOnUnsubscribe field's value. +func (s *ConfirmSubscriptionInput) SetAuthenticateOnUnsubscribe(v string) *ConfirmSubscriptionInput { + s.AuthenticateOnUnsubscribe = &v + return s +} + +// SetToken sets the Token field's value. +func (s *ConfirmSubscriptionInput) SetToken(v string) *ConfirmSubscriptionInput { + s.Token = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *ConfirmSubscriptionInput) SetTopicArn(v string) *ConfirmSubscriptionInput { + s.TopicArn = &v + return s +} + +// Response for ConfirmSubscriptions action. +type ConfirmSubscriptionOutput struct { + _ struct{} `type:"structure"` + + // The ARN of the created subscription. + SubscriptionArn *string `type:"string"` +} + +// String returns the string representation +func (s ConfirmSubscriptionOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ConfirmSubscriptionOutput) GoString() string { + return s.String() +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *ConfirmSubscriptionOutput) SetSubscriptionArn(v string) *ConfirmSubscriptionOutput { + s.SubscriptionArn = &v + return s +} + +// Input for CreatePlatformApplication action. +type CreatePlatformApplicationInput struct { + _ struct{} `type:"structure"` + + // For a list of attributes, see SetPlatformApplicationAttributes (https://docs.aws.amazon.com/sns/latest/api/API_SetPlatformApplicationAttributes.html). + // + // Attributes is a required field + Attributes map[string]*string `type:"map" required:"true"` + + // Application names must be made up of only uppercase and lowercase ASCII letters, + // numbers, underscores, hyphens, and periods, and must be between 1 and 256 + // characters long. + // + // Name is a required field + Name *string `type:"string" required:"true"` + + // The following platforms are supported: ADM (Amazon Device Messaging), APNS + // (Apple Push Notification Service), APNS_SANDBOX, and GCM (Firebase Cloud + // Messaging). + // + // Platform is a required field + Platform *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s CreatePlatformApplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreatePlatformApplicationInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreatePlatformApplicationInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreatePlatformApplicationInput"} + if s.Attributes == nil { + invalidParams.Add(request.NewErrParamRequired("Attributes")) + } + if s.Name == nil { + invalidParams.Add(request.NewErrParamRequired("Name")) + } + if s.Platform == nil { + invalidParams.Add(request.NewErrParamRequired("Platform")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *CreatePlatformApplicationInput) SetAttributes(v map[string]*string) *CreatePlatformApplicationInput { + s.Attributes = v + return s +} + +// SetName sets the Name field's value. +func (s *CreatePlatformApplicationInput) SetName(v string) *CreatePlatformApplicationInput { + s.Name = &v + return s +} + +// SetPlatform sets the Platform field's value. +func (s *CreatePlatformApplicationInput) SetPlatform(v string) *CreatePlatformApplicationInput { + s.Platform = &v + return s +} + +// Response from CreatePlatformApplication action. +type CreatePlatformApplicationOutput struct { + _ struct{} `type:"structure"` + + // PlatformApplicationArn is returned. + PlatformApplicationArn *string `type:"string"` +} + +// String returns the string representation +func (s CreatePlatformApplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreatePlatformApplicationOutput) GoString() string { + return s.String() +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *CreatePlatformApplicationOutput) SetPlatformApplicationArn(v string) *CreatePlatformApplicationOutput { + s.PlatformApplicationArn = &v + return s +} + +// Input for CreatePlatformEndpoint action. +type CreatePlatformEndpointInput struct { + _ struct{} `type:"structure"` + + // For a list of attributes, see SetEndpointAttributes (https://docs.aws.amazon.com/sns/latest/api/API_SetEndpointAttributes.html). + Attributes map[string]*string `type:"map"` + + // Arbitrary user data to associate with the endpoint. Amazon SNS does not use + // this data. The data must be in UTF-8 format and less than 2KB. + CustomUserData *string `type:"string"` + + // PlatformApplicationArn returned from CreatePlatformApplication is used to + // create a an endpoint. + // + // PlatformApplicationArn is a required field + PlatformApplicationArn *string `type:"string" required:"true"` + + // Unique identifier created by the notification service for an app on a device. + // The specific name for Token will vary, depending on which notification service + // is being used. For example, when using APNS as the notification service, + // you need the device token. Alternatively, when using GCM (Firebase Cloud + // Messaging) or ADM, the device token equivalent is called the registration + // ID. + // + // Token is a required field + Token *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s CreatePlatformEndpointInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreatePlatformEndpointInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreatePlatformEndpointInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreatePlatformEndpointInput"} + if s.PlatformApplicationArn == nil { + invalidParams.Add(request.NewErrParamRequired("PlatformApplicationArn")) + } + if s.Token == nil { + invalidParams.Add(request.NewErrParamRequired("Token")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *CreatePlatformEndpointInput) SetAttributes(v map[string]*string) *CreatePlatformEndpointInput { + s.Attributes = v + return s +} + +// SetCustomUserData sets the CustomUserData field's value. +func (s *CreatePlatformEndpointInput) SetCustomUserData(v string) *CreatePlatformEndpointInput { + s.CustomUserData = &v + return s +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *CreatePlatformEndpointInput) SetPlatformApplicationArn(v string) *CreatePlatformEndpointInput { + s.PlatformApplicationArn = &v + return s +} + +// SetToken sets the Token field's value. +func (s *CreatePlatformEndpointInput) SetToken(v string) *CreatePlatformEndpointInput { + s.Token = &v + return s +} + +// Response from CreateEndpoint action. +type CreatePlatformEndpointOutput struct { + _ struct{} `type:"structure"` + + // EndpointArn returned from CreateEndpoint action. + EndpointArn *string `type:"string"` +} + +// String returns the string representation +func (s CreatePlatformEndpointOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreatePlatformEndpointOutput) GoString() string { + return s.String() +} + +// SetEndpointArn sets the EndpointArn field's value. +func (s *CreatePlatformEndpointOutput) SetEndpointArn(v string) *CreatePlatformEndpointOutput { + s.EndpointArn = &v + return s +} + +type CreateSMSSandboxPhoneNumberInput struct { + _ struct{} `type:"structure"` + + // The language to use for sending the OTP. The default value is en-US. + LanguageCode *string `type:"string" enum:"LanguageCodeString"` + + // The destination phone number to verify. On verification, Amazon SNS adds + // this phone number to the list of verified phone numbers that you can send + // SMS messages to. + // + // PhoneNumber is a required field + PhoneNumber *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateSMSSandboxPhoneNumberInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateSMSSandboxPhoneNumberInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateSMSSandboxPhoneNumberInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateSMSSandboxPhoneNumberInput"} + if s.PhoneNumber == nil { + invalidParams.Add(request.NewErrParamRequired("PhoneNumber")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLanguageCode sets the LanguageCode field's value. +func (s *CreateSMSSandboxPhoneNumberInput) SetLanguageCode(v string) *CreateSMSSandboxPhoneNumberInput { + s.LanguageCode = &v + return s +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *CreateSMSSandboxPhoneNumberInput) SetPhoneNumber(v string) *CreateSMSSandboxPhoneNumberInput { + s.PhoneNumber = &v + return s +} + +type CreateSMSSandboxPhoneNumberOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s CreateSMSSandboxPhoneNumberOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateSMSSandboxPhoneNumberOutput) GoString() string { + return s.String() +} + +// Input for CreateTopic action. +type CreateTopicInput struct { + _ struct{} `type:"structure"` + + // A map of attributes with their corresponding values. + // + // The following lists the names, descriptions, and values of the special request + // parameters that the CreateTopic action uses: + // + // * DeliveryPolicy – The policy that defines how Amazon SNS retries failed + // deliveries to HTTP/S endpoints. + // + // * DisplayName – The display name to use for a topic with SMS subscriptions. + // + // * FifoTopic – Set to true to create a FIFO topic. + // + // * Policy – The policy that defines who can access your topic. By default, + // only the topic owner can publish or subscribe to the topic. + // + // The following attribute applies only to server-side encryption (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html): + // + // * KmsMasterKeyId – The ID of an AWS managed customer master key (CMK) + // for Amazon SNS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms). + // For more examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) + // in the AWS Key Management Service API Reference. + // + // The following attributes apply only to FIFO topics (https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html): + // + // * FifoTopic – When this is set to true, a FIFO topic is created. + // + // * ContentBasedDeduplication – Enables content-based deduplication for + // FIFO topics. By default, ContentBasedDeduplication is set to false. If + // you create a FIFO topic and this attribute is false, you must specify + // a value for the MessageDeduplicationId parameter for the Publish (https://docs.aws.amazon.com/sns/latest/api/API_Publish.html) + // action. When you set ContentBasedDeduplication to true, Amazon SNS uses + // a SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). (Optional) To override + // the generated value, you can specify a value for the MessageDeduplicationId + // parameter for the Publish action. + Attributes map[string]*string `type:"map"` + + // The name of the topic you want to create. + // + // Constraints: Topic names must be made up of only uppercase and lowercase + // ASCII letters, numbers, underscores, and hyphens, and must be between 1 and + // 256 characters long. + // + // For a FIFO (first-in-first-out) topic, the name must end with the .fifo suffix. + // + // Name is a required field + Name *string `type:"string" required:"true"` + + // The list of tags to add to a new topic. + // + // To be able to tag a topic on creation, you must have the sns:CreateTopic + // and sns:TagResource permissions. + Tags []*Tag `type:"list"` +} + +// String returns the string representation +func (s CreateTopicInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateTopicInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateTopicInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateTopicInput"} + if s.Name == nil { + invalidParams.Add(request.NewErrParamRequired("Name")) + } + if s.Tags != nil { + for i, v := range s.Tags { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Tags", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *CreateTopicInput) SetAttributes(v map[string]*string) *CreateTopicInput { + s.Attributes = v + return s +} + +// SetName sets the Name field's value. +func (s *CreateTopicInput) SetName(v string) *CreateTopicInput { + s.Name = &v + return s +} + +// SetTags sets the Tags field's value. +func (s *CreateTopicInput) SetTags(v []*Tag) *CreateTopicInput { + s.Tags = v + return s +} + +// Response from CreateTopic action. +type CreateTopicOutput struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) assigned to the created topic. + TopicArn *string `type:"string"` +} + +// String returns the string representation +func (s CreateTopicOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateTopicOutput) GoString() string { + return s.String() +} + +// SetTopicArn sets the TopicArn field's value. +func (s *CreateTopicOutput) SetTopicArn(v string) *CreateTopicOutput { + s.TopicArn = &v + return s +} + +// Input for DeleteEndpoint action. +type DeleteEndpointInput struct { + _ struct{} `type:"structure"` + + // EndpointArn of endpoint to delete. + // + // EndpointArn is a required field + EndpointArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteEndpointInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteEndpointInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteEndpointInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteEndpointInput"} + if s.EndpointArn == nil { + invalidParams.Add(request.NewErrParamRequired("EndpointArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEndpointArn sets the EndpointArn field's value. +func (s *DeleteEndpointInput) SetEndpointArn(v string) *DeleteEndpointInput { + s.EndpointArn = &v + return s +} + +type DeleteEndpointOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteEndpointOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteEndpointOutput) GoString() string { + return s.String() +} + +// Input for DeletePlatformApplication action. +type DeletePlatformApplicationInput struct { + _ struct{} `type:"structure"` + + // PlatformApplicationArn of platform application object to delete. + // + // PlatformApplicationArn is a required field + PlatformApplicationArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeletePlatformApplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeletePlatformApplicationInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeletePlatformApplicationInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeletePlatformApplicationInput"} + if s.PlatformApplicationArn == nil { + invalidParams.Add(request.NewErrParamRequired("PlatformApplicationArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *DeletePlatformApplicationInput) SetPlatformApplicationArn(v string) *DeletePlatformApplicationInput { + s.PlatformApplicationArn = &v + return s +} + +type DeletePlatformApplicationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeletePlatformApplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeletePlatformApplicationOutput) GoString() string { + return s.String() +} + +type DeleteSMSSandboxPhoneNumberInput struct { + _ struct{} `type:"structure"` + + // The destination phone number to delete. + // + // PhoneNumber is a required field + PhoneNumber *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteSMSSandboxPhoneNumberInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteSMSSandboxPhoneNumberInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteSMSSandboxPhoneNumberInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteSMSSandboxPhoneNumberInput"} + if s.PhoneNumber == nil { + invalidParams.Add(request.NewErrParamRequired("PhoneNumber")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *DeleteSMSSandboxPhoneNumberInput) SetPhoneNumber(v string) *DeleteSMSSandboxPhoneNumberInput { + s.PhoneNumber = &v + return s +} + +type DeleteSMSSandboxPhoneNumberOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteSMSSandboxPhoneNumberOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteSMSSandboxPhoneNumberOutput) GoString() string { + return s.String() +} + +type DeleteTopicInput struct { + _ struct{} `type:"structure"` + + // The ARN of the topic you want to delete. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteTopicInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteTopicInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteTopicInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteTopicInput"} + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetTopicArn sets the TopicArn field's value. +func (s *DeleteTopicInput) SetTopicArn(v string) *DeleteTopicInput { + s.TopicArn = &v + return s +} + +type DeleteTopicOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteTopicOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteTopicOutput) GoString() string { + return s.String() +} + +// Endpoint for mobile app and device. +type Endpoint struct { + _ struct{} `type:"structure"` + + // Attributes for endpoint. + Attributes map[string]*string `type:"map"` + + // EndpointArn for mobile app and device. + EndpointArn *string `type:"string"` +} + +// String returns the string representation +func (s Endpoint) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Endpoint) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *Endpoint) SetAttributes(v map[string]*string) *Endpoint { + s.Attributes = v + return s +} + +// SetEndpointArn sets the EndpointArn field's value. +func (s *Endpoint) SetEndpointArn(v string) *Endpoint { + s.EndpointArn = &v + return s +} + +// Input for GetEndpointAttributes action. +type GetEndpointAttributesInput struct { + _ struct{} `type:"structure"` + + // EndpointArn for GetEndpointAttributes input. + // + // EndpointArn is a required field + EndpointArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s GetEndpointAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetEndpointAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetEndpointAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetEndpointAttributesInput"} + if s.EndpointArn == nil { + invalidParams.Add(request.NewErrParamRequired("EndpointArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEndpointArn sets the EndpointArn field's value. +func (s *GetEndpointAttributesInput) SetEndpointArn(v string) *GetEndpointAttributesInput { + s.EndpointArn = &v + return s +} + +// Response from GetEndpointAttributes of the EndpointArn. +type GetEndpointAttributesOutput struct { + _ struct{} `type:"structure"` + + // Attributes include the following: + // + // * CustomUserData – arbitrary user data to associate with the endpoint. + // Amazon SNS does not use this data. The data must be in UTF-8 format and + // less than 2KB. + // + // * Enabled – flag that enables/disables delivery to the endpoint. Amazon + // SNS will set this to false when a notification service indicates to Amazon + // SNS that the endpoint is invalid. Users can set it back to true, typically + // after updating Token. + // + // * Token – device token, also referred to as a registration id, for an + // app and mobile device. This is returned from the notification service + // when an app and mobile device are registered with the notification service. + // The device token for the iOS platform is returned in lowercase. + Attributes map[string]*string `type:"map"` +} + +// String returns the string representation +func (s GetEndpointAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetEndpointAttributesOutput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetEndpointAttributesOutput) SetAttributes(v map[string]*string) *GetEndpointAttributesOutput { + s.Attributes = v + return s +} + +// Input for GetPlatformApplicationAttributes action. +type GetPlatformApplicationAttributesInput struct { + _ struct{} `type:"structure"` + + // PlatformApplicationArn for GetPlatformApplicationAttributesInput. + // + // PlatformApplicationArn is a required field + PlatformApplicationArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s GetPlatformApplicationAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetPlatformApplicationAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetPlatformApplicationAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetPlatformApplicationAttributesInput"} + if s.PlatformApplicationArn == nil { + invalidParams.Add(request.NewErrParamRequired("PlatformApplicationArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *GetPlatformApplicationAttributesInput) SetPlatformApplicationArn(v string) *GetPlatformApplicationAttributesInput { + s.PlatformApplicationArn = &v + return s +} + +// Response for GetPlatformApplicationAttributes action. +type GetPlatformApplicationAttributesOutput struct { + _ struct{} `type:"structure"` + + // Attributes include the following: + // + // * EventEndpointCreated – Topic ARN to which EndpointCreated event notifications + // should be sent. + // + // * EventEndpointDeleted – Topic ARN to which EndpointDeleted event notifications + // should be sent. + // + // * EventEndpointUpdated – Topic ARN to which EndpointUpdate event notifications + // should be sent. + // + // * EventDeliveryFailure – Topic ARN to which DeliveryFailure event notifications + // should be sent upon Direct Publish delivery failure (permanent) to one + // of the application's endpoints. + Attributes map[string]*string `type:"map"` +} + +// String returns the string representation +func (s GetPlatformApplicationAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetPlatformApplicationAttributesOutput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetPlatformApplicationAttributesOutput) SetAttributes(v map[string]*string) *GetPlatformApplicationAttributesOutput { + s.Attributes = v + return s +} + +// The input for the GetSMSAttributes request. +type GetSMSAttributesInput struct { + _ struct{} `type:"structure"` + + // A list of the individual attribute names, such as MonthlySpendLimit, for + // which you want values. + // + // For all attribute names, see SetSMSAttributes (https://docs.aws.amazon.com/sns/latest/api/API_SetSMSAttributes.html). + // + // If you don't use this parameter, Amazon SNS returns all SMS attributes. + Attributes []*string `locationName:"attributes" type:"list"` +} + +// String returns the string representation +func (s GetSMSAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSMSAttributesInput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetSMSAttributesInput) SetAttributes(v []*string) *GetSMSAttributesInput { + s.Attributes = v + return s +} + +// The response from the GetSMSAttributes request. +type GetSMSAttributesOutput struct { + _ struct{} `type:"structure"` + + // The SMS attribute names and their values. + Attributes map[string]*string `locationName:"attributes" type:"map"` +} + +// String returns the string representation +func (s GetSMSAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSMSAttributesOutput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetSMSAttributesOutput) SetAttributes(v map[string]*string) *GetSMSAttributesOutput { + s.Attributes = v + return s +} + +type GetSMSSandboxAccountStatusInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s GetSMSSandboxAccountStatusInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSMSSandboxAccountStatusInput) GoString() string { + return s.String() +} + +type GetSMSSandboxAccountStatusOutput struct { + _ struct{} `type:"structure"` + + // Indicates whether the calling account is in the SMS sandbox. + // + // IsInSandbox is a required field + IsInSandbox *bool `type:"boolean" required:"true"` +} + +// String returns the string representation +func (s GetSMSSandboxAccountStatusOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSMSSandboxAccountStatusOutput) GoString() string { + return s.String() +} + +// SetIsInSandbox sets the IsInSandbox field's value. +func (s *GetSMSSandboxAccountStatusOutput) SetIsInSandbox(v bool) *GetSMSSandboxAccountStatusOutput { + s.IsInSandbox = &v + return s +} + +// Input for GetSubscriptionAttributes. +type GetSubscriptionAttributesInput struct { + _ struct{} `type:"structure"` + + // The ARN of the subscription whose properties you want to get. + // + // SubscriptionArn is a required field + SubscriptionArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s GetSubscriptionAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSubscriptionAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetSubscriptionAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetSubscriptionAttributesInput"} + if s.SubscriptionArn == nil { + invalidParams.Add(request.NewErrParamRequired("SubscriptionArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *GetSubscriptionAttributesInput) SetSubscriptionArn(v string) *GetSubscriptionAttributesInput { + s.SubscriptionArn = &v + return s +} + +// Response for GetSubscriptionAttributes action. +type GetSubscriptionAttributesOutput struct { + _ struct{} `type:"structure"` + + // A map of the subscription's attributes. Attributes in this map include the + // following: + // + // * ConfirmationWasAuthenticated – true if the subscription confirmation + // request was authenticated. + // + // * DeliveryPolicy – The JSON serialization of the subscription's delivery + // policy. + // + // * EffectiveDeliveryPolicy – The JSON serialization of the effective + // delivery policy that takes into account the topic delivery policy and + // account system defaults. + // + // * FilterPolicy – The filter policy JSON that is assigned to the subscription. + // For more information, see Amazon SNS Message Filtering (https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html) + // in the Amazon SNS Developer Guide. + // + // * Owner – The AWS account ID of the subscription's owner. + // + // * PendingConfirmation – true if the subscription hasn't been confirmed. + // To confirm a pending subscription, call the ConfirmSubscription action + // with a confirmation token. + // + // * RawMessageDelivery – true if raw message delivery is enabled for the + // subscription. Raw messages are free of JSON formatting and can be sent + // to HTTP/S and Amazon SQS endpoints. + // + // * RedrivePolicy – When specified, sends undeliverable messages to the + // specified Amazon SQS dead-letter queue. Messages that can't be delivered + // due to client errors (for example, when the subscribed endpoint is unreachable) + // or server errors (for example, when the service that powers the subscribed + // endpoint becomes unavailable) are held in the dead-letter queue for further + // analysis or reprocessing. + // + // * SubscriptionArn – The subscription's ARN. + // + // * TopicArn – The topic ARN that the subscription is associated with. + // + // The following attribute applies only to Amazon Kinesis Data Firehose delivery + // stream subscriptions: + // + // * SubscriptionRoleArn – The ARN of the IAM role that has the following: + // Permission to write to the Kinesis Data Firehose delivery stream Amazon + // SNS listed as a trusted entity Specifying a valid ARN for this attribute + // is required for Kinesis Data Firehose delivery stream subscriptions. For + // more information, see Fanout to Kinesis Data Firehose delivery streams + // (https://docs.aws.amazon.com/sns/latest/dg/sns-firehose-as-subscriber.html) + // in the Amazon SNS Developer Guide. + Attributes map[string]*string `type:"map"` +} + +// String returns the string representation +func (s GetSubscriptionAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetSubscriptionAttributesOutput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetSubscriptionAttributesOutput) SetAttributes(v map[string]*string) *GetSubscriptionAttributesOutput { + s.Attributes = v + return s +} + +// Input for GetTopicAttributes action. +type GetTopicAttributesInput struct { + _ struct{} `type:"structure"` + + // The ARN of the topic whose properties you want to get. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s GetTopicAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetTopicAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetTopicAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetTopicAttributesInput"} + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetTopicArn sets the TopicArn field's value. +func (s *GetTopicAttributesInput) SetTopicArn(v string) *GetTopicAttributesInput { + s.TopicArn = &v + return s +} + +// Response for GetTopicAttributes action. +type GetTopicAttributesOutput struct { + _ struct{} `type:"structure"` + + // A map of the topic's attributes. Attributes in this map include the following: + // + // * DeliveryPolicy – The JSON serialization of the topic's delivery policy. + // + // * DisplayName – The human-readable name used in the From field for notifications + // to email and email-json endpoints. + // + // * Owner – The AWS account ID of the topic's owner. + // + // * Policy – The JSON serialization of the topic's access control policy. + // + // * SubscriptionsConfirmed – The number of confirmed subscriptions for + // the topic. + // + // * SubscriptionsDeleted – The number of deleted subscriptions for the + // topic. + // + // * SubscriptionsPending – The number of subscriptions pending confirmation + // for the topic. + // + // * TopicArn – The topic's ARN. + // + // * EffectiveDeliveryPolicy – The JSON serialization of the effective + // delivery policy, taking system defaults into account. + // + // The following attribute applies only to server-side-encryption (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html): + // + // * KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) + // for Amazon SNS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms). + // For more examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) + // in the AWS Key Management Service API Reference. + // + // The following attributes apply only to FIFO topics (https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html): + // + // * FifoTopic – When this is set to true, a FIFO topic is created. + // + // * ContentBasedDeduplication – Enables content-based deduplication for + // FIFO topics. By default, ContentBasedDeduplication is set to false. If + // you create a FIFO topic and this attribute is false, you must specify + // a value for the MessageDeduplicationId parameter for the Publish (https://docs.aws.amazon.com/sns/latest/api/API_Publish.html) + // action. When you set ContentBasedDeduplication to true, Amazon SNS uses + // a SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). (Optional) To override + // the generated value, you can specify a value for the MessageDeduplicationId + // parameter for the Publish action. + Attributes map[string]*string `type:"map"` +} + +// String returns the string representation +func (s GetTopicAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetTopicAttributesOutput) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *GetTopicAttributesOutput) SetAttributes(v map[string]*string) *GetTopicAttributesOutput { + s.Attributes = v + return s +} + +// Input for ListEndpointsByPlatformApplication action. +type ListEndpointsByPlatformApplicationInput struct { + _ struct{} `type:"structure"` + + // NextToken string is used when calling ListEndpointsByPlatformApplication + // action to retrieve additional records that are available after the first + // page results. + NextToken *string `type:"string"` + + // PlatformApplicationArn for ListEndpointsByPlatformApplicationInput action. + // + // PlatformApplicationArn is a required field + PlatformApplicationArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ListEndpointsByPlatformApplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListEndpointsByPlatformApplicationInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListEndpointsByPlatformApplicationInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListEndpointsByPlatformApplicationInput"} + if s.PlatformApplicationArn == nil { + invalidParams.Add(request.NewErrParamRequired("PlatformApplicationArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetNextToken sets the NextToken field's value. +func (s *ListEndpointsByPlatformApplicationInput) SetNextToken(v string) *ListEndpointsByPlatformApplicationInput { + s.NextToken = &v + return s +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *ListEndpointsByPlatformApplicationInput) SetPlatformApplicationArn(v string) *ListEndpointsByPlatformApplicationInput { + s.PlatformApplicationArn = &v + return s +} + +// Response for ListEndpointsByPlatformApplication action. +type ListEndpointsByPlatformApplicationOutput struct { + _ struct{} `type:"structure"` + + // Endpoints returned for ListEndpointsByPlatformApplication action. + Endpoints []*Endpoint `type:"list"` + + // NextToken string is returned when calling ListEndpointsByPlatformApplication + // action if additional records are available after the first page results. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListEndpointsByPlatformApplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListEndpointsByPlatformApplicationOutput) GoString() string { + return s.String() +} + +// SetEndpoints sets the Endpoints field's value. +func (s *ListEndpointsByPlatformApplicationOutput) SetEndpoints(v []*Endpoint) *ListEndpointsByPlatformApplicationOutput { + s.Endpoints = v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListEndpointsByPlatformApplicationOutput) SetNextToken(v string) *ListEndpointsByPlatformApplicationOutput { + s.NextToken = &v + return s +} + +type ListOriginationNumbersInput struct { + _ struct{} `type:"structure"` + + // The maximum number of origination numbers to return. + MaxResults *int64 `min:"1" type:"integer"` + + // Token that the previous ListOriginationNumbers request returns. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListOriginationNumbersInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListOriginationNumbersInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListOriginationNumbersInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListOriginationNumbersInput"} + if s.MaxResults != nil && *s.MaxResults < 1 { + invalidParams.Add(request.NewErrParamMinValue("MaxResults", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMaxResults sets the MaxResults field's value. +func (s *ListOriginationNumbersInput) SetMaxResults(v int64) *ListOriginationNumbersInput { + s.MaxResults = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListOriginationNumbersInput) SetNextToken(v string) *ListOriginationNumbersInput { + s.NextToken = &v + return s +} + +type ListOriginationNumbersOutput struct { + _ struct{} `type:"structure"` + + // A NextToken string is returned when you call the ListOriginationNumbers operation + // if additional pages of records are available. + NextToken *string `type:"string"` + + // A list of the calling account's verified and pending origination numbers. + PhoneNumbers []*PhoneNumberInformation `type:"list"` +} + +// String returns the string representation +func (s ListOriginationNumbersOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListOriginationNumbersOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListOriginationNumbersOutput) SetNextToken(v string) *ListOriginationNumbersOutput { + s.NextToken = &v + return s +} + +// SetPhoneNumbers sets the PhoneNumbers field's value. +func (s *ListOriginationNumbersOutput) SetPhoneNumbers(v []*PhoneNumberInformation) *ListOriginationNumbersOutput { + s.PhoneNumbers = v + return s +} + +// The input for the ListPhoneNumbersOptedOut action. +type ListPhoneNumbersOptedOutInput struct { + _ struct{} `type:"structure"` + + // A NextToken string is used when you call the ListPhoneNumbersOptedOut action + // to retrieve additional records that are available after the first page of + // results. + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListPhoneNumbersOptedOutInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPhoneNumbersOptedOutInput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListPhoneNumbersOptedOutInput) SetNextToken(v string) *ListPhoneNumbersOptedOutInput { + s.NextToken = &v + return s +} + +// The response from the ListPhoneNumbersOptedOut action. +type ListPhoneNumbersOptedOutOutput struct { + _ struct{} `type:"structure"` + + // A NextToken string is returned when you call the ListPhoneNumbersOptedOut + // action if additional records are available after the first page of results. + NextToken *string `locationName:"nextToken" type:"string"` + + // A list of phone numbers that are opted out of receiving SMS messages. The + // list is paginated, and each page can contain up to 100 phone numbers. + PhoneNumbers []*string `locationName:"phoneNumbers" type:"list"` +} + +// String returns the string representation +func (s ListPhoneNumbersOptedOutOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPhoneNumbersOptedOutOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListPhoneNumbersOptedOutOutput) SetNextToken(v string) *ListPhoneNumbersOptedOutOutput { + s.NextToken = &v + return s +} + +// SetPhoneNumbers sets the PhoneNumbers field's value. +func (s *ListPhoneNumbersOptedOutOutput) SetPhoneNumbers(v []*string) *ListPhoneNumbersOptedOutOutput { + s.PhoneNumbers = v + return s +} + +// Input for ListPlatformApplications action. +type ListPlatformApplicationsInput struct { + _ struct{} `type:"structure"` + + // NextToken string is used when calling ListPlatformApplications action to + // retrieve additional records that are available after the first page results. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListPlatformApplicationsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPlatformApplicationsInput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListPlatformApplicationsInput) SetNextToken(v string) *ListPlatformApplicationsInput { + s.NextToken = &v + return s +} + +// Response for ListPlatformApplications action. +type ListPlatformApplicationsOutput struct { + _ struct{} `type:"structure"` + + // NextToken string is returned when calling ListPlatformApplications action + // if additional records are available after the first page results. + NextToken *string `type:"string"` + + // Platform applications returned when calling ListPlatformApplications action. + PlatformApplications []*PlatformApplication `type:"list"` +} + +// String returns the string representation +func (s ListPlatformApplicationsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPlatformApplicationsOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListPlatformApplicationsOutput) SetNextToken(v string) *ListPlatformApplicationsOutput { + s.NextToken = &v + return s +} + +// SetPlatformApplications sets the PlatformApplications field's value. +func (s *ListPlatformApplicationsOutput) SetPlatformApplications(v []*PlatformApplication) *ListPlatformApplicationsOutput { + s.PlatformApplications = v + return s +} + +type ListSMSSandboxPhoneNumbersInput struct { + _ struct{} `type:"structure"` + + // The maximum number of phone numbers to return. + MaxResults *int64 `min:"1" type:"integer"` + + // Token that the previous ListSMSSandboxPhoneNumbersInput request returns. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListSMSSandboxPhoneNumbersInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSMSSandboxPhoneNumbersInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListSMSSandboxPhoneNumbersInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListSMSSandboxPhoneNumbersInput"} + if s.MaxResults != nil && *s.MaxResults < 1 { + invalidParams.Add(request.NewErrParamMinValue("MaxResults", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMaxResults sets the MaxResults field's value. +func (s *ListSMSSandboxPhoneNumbersInput) SetMaxResults(v int64) *ListSMSSandboxPhoneNumbersInput { + s.MaxResults = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSMSSandboxPhoneNumbersInput) SetNextToken(v string) *ListSMSSandboxPhoneNumbersInput { + s.NextToken = &v + return s +} + +type ListSMSSandboxPhoneNumbersOutput struct { + _ struct{} `type:"structure"` + + // A NextToken string is returned when you call the ListSMSSandboxPhoneNumbersInput + // operation if additional pages of records are available. + NextToken *string `type:"string"` + + // A list of the calling account's pending and verified phone numbers. + // + // PhoneNumbers is a required field + PhoneNumbers []*SMSSandboxPhoneNumber `type:"list" required:"true"` +} + +// String returns the string representation +func (s ListSMSSandboxPhoneNumbersOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSMSSandboxPhoneNumbersOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSMSSandboxPhoneNumbersOutput) SetNextToken(v string) *ListSMSSandboxPhoneNumbersOutput { + s.NextToken = &v + return s +} + +// SetPhoneNumbers sets the PhoneNumbers field's value. +func (s *ListSMSSandboxPhoneNumbersOutput) SetPhoneNumbers(v []*SMSSandboxPhoneNumber) *ListSMSSandboxPhoneNumbersOutput { + s.PhoneNumbers = v + return s +} + +// Input for ListSubscriptionsByTopic action. +type ListSubscriptionsByTopicInput struct { + _ struct{} `type:"structure"` + + // Token returned by the previous ListSubscriptionsByTopic request. + NextToken *string `type:"string"` + + // The ARN of the topic for which you wish to find subscriptions. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ListSubscriptionsByTopicInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSubscriptionsByTopicInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListSubscriptionsByTopicInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListSubscriptionsByTopicInput"} + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSubscriptionsByTopicInput) SetNextToken(v string) *ListSubscriptionsByTopicInput { + s.NextToken = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *ListSubscriptionsByTopicInput) SetTopicArn(v string) *ListSubscriptionsByTopicInput { + s.TopicArn = &v + return s +} + +// Response for ListSubscriptionsByTopic action. +type ListSubscriptionsByTopicOutput struct { + _ struct{} `type:"structure"` + + // Token to pass along to the next ListSubscriptionsByTopic request. This element + // is returned if there are more subscriptions to retrieve. + NextToken *string `type:"string"` + + // A list of subscriptions. + Subscriptions []*Subscription `type:"list"` +} + +// String returns the string representation +func (s ListSubscriptionsByTopicOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSubscriptionsByTopicOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSubscriptionsByTopicOutput) SetNextToken(v string) *ListSubscriptionsByTopicOutput { + s.NextToken = &v + return s +} + +// SetSubscriptions sets the Subscriptions field's value. +func (s *ListSubscriptionsByTopicOutput) SetSubscriptions(v []*Subscription) *ListSubscriptionsByTopicOutput { + s.Subscriptions = v + return s +} + +// Input for ListSubscriptions action. +type ListSubscriptionsInput struct { + _ struct{} `type:"structure"` + + // Token returned by the previous ListSubscriptions request. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListSubscriptionsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSubscriptionsInput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSubscriptionsInput) SetNextToken(v string) *ListSubscriptionsInput { + s.NextToken = &v + return s +} + +// Response for ListSubscriptions action +type ListSubscriptionsOutput struct { + _ struct{} `type:"structure"` + + // Token to pass along to the next ListSubscriptions request. This element is + // returned if there are more subscriptions to retrieve. + NextToken *string `type:"string"` + + // A list of subscriptions. + Subscriptions []*Subscription `type:"list"` +} + +// String returns the string representation +func (s ListSubscriptionsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListSubscriptionsOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListSubscriptionsOutput) SetNextToken(v string) *ListSubscriptionsOutput { + s.NextToken = &v + return s +} + +// SetSubscriptions sets the Subscriptions field's value. +func (s *ListSubscriptionsOutput) SetSubscriptions(v []*Subscription) *ListSubscriptionsOutput { + s.Subscriptions = v + return s +} + +type ListTagsForResourceInput struct { + _ struct{} `type:"structure"` + + // The ARN of the topic for which to list tags. + // + // ResourceArn is a required field + ResourceArn *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListTagsForResourceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListTagsForResourceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListTagsForResourceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListTagsForResourceInput"} + if s.ResourceArn == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceArn")) + } + if s.ResourceArn != nil && len(*s.ResourceArn) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceArn", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetResourceArn sets the ResourceArn field's value. +func (s *ListTagsForResourceInput) SetResourceArn(v string) *ListTagsForResourceInput { + s.ResourceArn = &v + return s +} + +type ListTagsForResourceOutput struct { + _ struct{} `type:"structure"` + + // The tags associated with the specified topic. + Tags []*Tag `type:"list"` +} + +// String returns the string representation +func (s ListTagsForResourceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListTagsForResourceOutput) GoString() string { + return s.String() +} + +// SetTags sets the Tags field's value. +func (s *ListTagsForResourceOutput) SetTags(v []*Tag) *ListTagsForResourceOutput { + s.Tags = v + return s +} + +type ListTopicsInput struct { + _ struct{} `type:"structure"` + + // Token returned by the previous ListTopics request. + NextToken *string `type:"string"` +} + +// String returns the string representation +func (s ListTopicsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListTopicsInput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListTopicsInput) SetNextToken(v string) *ListTopicsInput { + s.NextToken = &v + return s +} + +// Response for ListTopics action. +type ListTopicsOutput struct { + _ struct{} `type:"structure"` + + // Token to pass along to the next ListTopics request. This element is returned + // if there are additional topics to retrieve. + NextToken *string `type:"string"` + + // A list of topic ARNs. + Topics []*Topic `type:"list"` +} + +// String returns the string representation +func (s ListTopicsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListTopicsOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListTopicsOutput) SetNextToken(v string) *ListTopicsOutput { + s.NextToken = &v + return s +} + +// SetTopics sets the Topics field's value. +func (s *ListTopicsOutput) SetTopics(v []*Topic) *ListTopicsOutput { + s.Topics = v + return s +} + +// The user-specified message attribute value. For string data types, the value +// attribute has the same restrictions on the content as the message body. For +// more information, see Publish (https://docs.aws.amazon.com/sns/latest/api/API_Publish.html). +// +// Name, type, and value must not be empty or null. In addition, the message +// body should not be empty or null. All parts of the message attribute, including +// name, type, and value, are included in the message size restriction, which +// is currently 256 KB (262,144 bytes). For more information, see Amazon SNS +// message attributes (https://docs.aws.amazon.com/sns/latest/dg/SNSMessageAttributes.html) +// and Publishing to a mobile phone (https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html) +// in the Amazon SNS Developer Guide. +type MessageAttributeValue struct { + _ struct{} `type:"structure"` + + // Binary type attributes can store any binary data, for example, compressed + // data, encrypted data, or images. + // + // BinaryValue is automatically base64 encoded/decoded by the SDK. + BinaryValue []byte `type:"blob"` + + // Amazon SNS supports the following logical data types: String, String.Array, + // Number, and Binary. For more information, see Message Attribute Data Types + // (https://docs.aws.amazon.com/sns/latest/dg/SNSMessageAttributes.html#SNSMessageAttributes.DataTypes). + // + // DataType is a required field + DataType *string `type:"string" required:"true"` + + // Strings are Unicode with UTF8 binary encoding. For a list of code values, + // see ASCII Printable Characters (https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters). + StringValue *string `type:"string"` +} + +// String returns the string representation +func (s MessageAttributeValue) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MessageAttributeValue) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *MessageAttributeValue) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "MessageAttributeValue"} + if s.DataType == nil { + invalidParams.Add(request.NewErrParamRequired("DataType")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetBinaryValue sets the BinaryValue field's value. +func (s *MessageAttributeValue) SetBinaryValue(v []byte) *MessageAttributeValue { + s.BinaryValue = v + return s +} + +// SetDataType sets the DataType field's value. +func (s *MessageAttributeValue) SetDataType(v string) *MessageAttributeValue { + s.DataType = &v + return s +} + +// SetStringValue sets the StringValue field's value. +func (s *MessageAttributeValue) SetStringValue(v string) *MessageAttributeValue { + s.StringValue = &v + return s +} + +// Input for the OptInPhoneNumber action. +type OptInPhoneNumberInput struct { + _ struct{} `type:"structure"` + + // The phone number to opt in. Use E.164 format. + // + // PhoneNumber is a required field + PhoneNumber *string `locationName:"phoneNumber" type:"string" required:"true"` +} + +// String returns the string representation +func (s OptInPhoneNumberInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s OptInPhoneNumberInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *OptInPhoneNumberInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "OptInPhoneNumberInput"} + if s.PhoneNumber == nil { + invalidParams.Add(request.NewErrParamRequired("PhoneNumber")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *OptInPhoneNumberInput) SetPhoneNumber(v string) *OptInPhoneNumberInput { + s.PhoneNumber = &v + return s +} + +// The response for the OptInPhoneNumber action. +type OptInPhoneNumberOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s OptInPhoneNumberOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s OptInPhoneNumberOutput) GoString() string { + return s.String() +} + +// A list of phone numbers and their metadata. +type PhoneNumberInformation struct { + _ struct{} `type:"structure"` + + // The date and time when the phone number was created. + CreatedAt *time.Time `type:"timestamp"` + + // The two-character code for the country or region, in ISO 3166-1 alpha-2 format. + Iso2CountryCode *string `type:"string"` + + // The capabilities of each phone number. + NumberCapabilities []*string `type:"list"` + + // The phone number. + PhoneNumber *string `type:"string"` + + // The list of supported routes. + RouteType *string `type:"string" enum:"RouteType"` + + // The status of the phone number. + Status *string `type:"string"` +} + +// String returns the string representation +func (s PhoneNumberInformation) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PhoneNumberInformation) GoString() string { + return s.String() +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *PhoneNumberInformation) SetCreatedAt(v time.Time) *PhoneNumberInformation { + s.CreatedAt = &v + return s +} + +// SetIso2CountryCode sets the Iso2CountryCode field's value. +func (s *PhoneNumberInformation) SetIso2CountryCode(v string) *PhoneNumberInformation { + s.Iso2CountryCode = &v + return s +} + +// SetNumberCapabilities sets the NumberCapabilities field's value. +func (s *PhoneNumberInformation) SetNumberCapabilities(v []*string) *PhoneNumberInformation { + s.NumberCapabilities = v + return s +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *PhoneNumberInformation) SetPhoneNumber(v string) *PhoneNumberInformation { + s.PhoneNumber = &v + return s +} + +// SetRouteType sets the RouteType field's value. +func (s *PhoneNumberInformation) SetRouteType(v string) *PhoneNumberInformation { + s.RouteType = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *PhoneNumberInformation) SetStatus(v string) *PhoneNumberInformation { + s.Status = &v + return s +} + +// Platform application object. +type PlatformApplication struct { + _ struct{} `type:"structure"` + + // Attributes for platform application object. + Attributes map[string]*string `type:"map"` + + // PlatformApplicationArn for platform application object. + PlatformApplicationArn *string `type:"string"` +} + +// String returns the string representation +func (s PlatformApplication) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PlatformApplication) GoString() string { + return s.String() +} + +// SetAttributes sets the Attributes field's value. +func (s *PlatformApplication) SetAttributes(v map[string]*string) *PlatformApplication { + s.Attributes = v + return s +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *PlatformApplication) SetPlatformApplicationArn(v string) *PlatformApplication { + s.PlatformApplicationArn = &v + return s +} + +// Input for Publish action. +type PublishInput struct { + _ struct{} `type:"structure"` + + // The message you want to send. + // + // If you are publishing to a topic and you want to send the same message to + // all transport protocols, include the text of the message as a String value. + // If you want to send different messages for each transport protocol, set the + // value of the MessageStructure parameter to json and use a JSON object for + // the Message parameter. + // + // Constraints: + // + // * With the exception of SMS, messages must be UTF-8 encoded strings and + // at most 256 KB in size (262,144 bytes, not 262,144 characters). + // + // * For SMS, each message can contain up to 140 characters. This character + // limit depends on the encoding schema. For example, an SMS message can + // contain 160 GSM characters, 140 ASCII characters, or 70 UCS-2 characters. + // If you publish a message that exceeds this size limit, Amazon SNS sends + // the message as multiple messages, each fitting within the size limit. + // Messages aren't truncated mid-word but are cut off at whole-word boundaries. + // The total size limit for a single SMS Publish action is 1,600 characters. + // + // JSON-specific constraints: + // + // * Keys in the JSON object that correspond to supported transport protocols + // must have simple JSON string values. + // + // * The values will be parsed (unescaped) before they are used in outgoing + // messages. + // + // * Outbound notifications are JSON encoded (meaning that the characters + // will be reescaped for sending). + // + // * Values have a minimum length of 0 (the empty string, "", is allowed). + // + // * Values have a maximum length bounded by the overall message size (so, + // including multiple protocols may limit message sizes). + // + // * Non-string values will cause the key to be ignored. + // + // * Keys that do not correspond to supported transport protocols are ignored. + // + // * Duplicate keys are not allowed. + // + // * Failure to parse or validate any key or value in the message will cause + // the Publish call to return an error (no partial delivery). + // + // Message is a required field + Message *string `type:"string" required:"true"` + + // Message attributes for Publish action. + MessageAttributes map[string]*MessageAttributeValue `locationNameKey:"Name" locationNameValue:"Value" type:"map"` + + // This parameter applies only to FIFO (first-in-first-out) topics. The MessageDeduplicationId + // can contain up to 128 alphanumeric characters (a-z, A-Z, 0-9) and punctuation + // (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). + // + // Every message must have a unique MessageDeduplicationId, which is a token + // used for deduplication of sent messages. If a message with a particular MessageDeduplicationId + // is sent successfully, any message sent with the same MessageDeduplicationId + // during the 5-minute deduplication interval is treated as a duplicate. + // + // If the topic has ContentBasedDeduplication set, the system generates a MessageDeduplicationId + // based on the contents of the message. Your MessageDeduplicationId overrides + // the generated one. + MessageDeduplicationId *string `type:"string"` + + // This parameter applies only to FIFO (first-in-first-out) topics. The MessageGroupId + // can contain up to 128 alphanumeric characters (a-z, A-Z, 0-9) and punctuation + // (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). + // + // The MessageGroupId is a tag that specifies that a message belongs to a specific + // message group. Messages that belong to the same message group are processed + // in a FIFO manner (however, messages in different message groups might be + // processed out of order). Every message must include a MessageGroupId. + MessageGroupId *string `type:"string"` + + // Set MessageStructure to json if you want to send a different message for + // each protocol. For example, using one publish action, you can send a short + // message to your SMS subscribers and a longer message to your email subscribers. + // If you set MessageStructure to json, the value of the Message parameter must: + // + // * be a syntactically valid JSON object; and + // + // * contain at least a top-level JSON key of "default" with a value that + // is a string. + // + // You can define other top-level keys that define the message you want to send + // to a specific transport protocol (e.g., "http"). + // + // Valid value: json + MessageStructure *string `type:"string"` + + // The phone number to which you want to deliver an SMS message. Use E.164 format. + // + // If you don't specify a value for the PhoneNumber parameter, you must specify + // a value for the TargetArn or TopicArn parameters. + PhoneNumber *string `type:"string"` + + // Optional parameter to be used as the "Subject" line when the message is delivered + // to email endpoints. This field will also be included, if present, in the + // standard JSON messages delivered to other endpoints. + // + // Constraints: Subjects must be ASCII text that begins with a letter, number, + // or punctuation mark; must not include line breaks or control characters; + // and must be less than 100 characters long. + Subject *string `type:"string"` + + // If you don't specify a value for the TargetArn parameter, you must specify + // a value for the PhoneNumber or TopicArn parameters. + TargetArn *string `type:"string"` + + // The topic you want to publish to. + // + // If you don't specify a value for the TopicArn parameter, you must specify + // a value for the PhoneNumber or TargetArn parameters. + TopicArn *string `type:"string"` +} + +// String returns the string representation +func (s PublishInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PublishInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *PublishInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "PublishInput"} + if s.Message == nil { + invalidParams.Add(request.NewErrParamRequired("Message")) + } + if s.MessageAttributes != nil { + for i, v := range s.MessageAttributes { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "MessageAttributes", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMessage sets the Message field's value. +func (s *PublishInput) SetMessage(v string) *PublishInput { + s.Message = &v + return s +} + +// SetMessageAttributes sets the MessageAttributes field's value. +func (s *PublishInput) SetMessageAttributes(v map[string]*MessageAttributeValue) *PublishInput { + s.MessageAttributes = v + return s +} + +// SetMessageDeduplicationId sets the MessageDeduplicationId field's value. +func (s *PublishInput) SetMessageDeduplicationId(v string) *PublishInput { + s.MessageDeduplicationId = &v + return s +} + +// SetMessageGroupId sets the MessageGroupId field's value. +func (s *PublishInput) SetMessageGroupId(v string) *PublishInput { + s.MessageGroupId = &v + return s +} + +// SetMessageStructure sets the MessageStructure field's value. +func (s *PublishInput) SetMessageStructure(v string) *PublishInput { + s.MessageStructure = &v + return s +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *PublishInput) SetPhoneNumber(v string) *PublishInput { + s.PhoneNumber = &v + return s +} + +// SetSubject sets the Subject field's value. +func (s *PublishInput) SetSubject(v string) *PublishInput { + s.Subject = &v + return s +} + +// SetTargetArn sets the TargetArn field's value. +func (s *PublishInput) SetTargetArn(v string) *PublishInput { + s.TargetArn = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *PublishInput) SetTopicArn(v string) *PublishInput { + s.TopicArn = &v + return s +} + +// Response for Publish action. +type PublishOutput struct { + _ struct{} `type:"structure"` + + // Unique identifier assigned to the published message. + // + // Length Constraint: Maximum 100 characters + MessageId *string `type:"string"` + + // This response element applies only to FIFO (first-in-first-out) topics. + // + // The sequence number is a large, non-consecutive number that Amazon SNS assigns + // to each message. The length of SequenceNumber is 128 bits. SequenceNumber + // continues to increase for each MessageGroupId. + SequenceNumber *string `type:"string"` +} + +// String returns the string representation +func (s PublishOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PublishOutput) GoString() string { + return s.String() +} + +// SetMessageId sets the MessageId field's value. +func (s *PublishOutput) SetMessageId(v string) *PublishOutput { + s.MessageId = &v + return s +} + +// SetSequenceNumber sets the SequenceNumber field's value. +func (s *PublishOutput) SetSequenceNumber(v string) *PublishOutput { + s.SequenceNumber = &v + return s +} + +// Input for RemovePermission action. +type RemovePermissionInput struct { + _ struct{} `type:"structure"` + + // The unique label of the statement you want to remove. + // + // Label is a required field + Label *string `type:"string" required:"true"` + + // The ARN of the topic whose access control policy you wish to modify. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s RemovePermissionInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RemovePermissionInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *RemovePermissionInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "RemovePermissionInput"} + if s.Label == nil { + invalidParams.Add(request.NewErrParamRequired("Label")) + } + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLabel sets the Label field's value. +func (s *RemovePermissionInput) SetLabel(v string) *RemovePermissionInput { + s.Label = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *RemovePermissionInput) SetTopicArn(v string) *RemovePermissionInput { + s.TopicArn = &v + return s +} + +type RemovePermissionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s RemovePermissionOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RemovePermissionOutput) GoString() string { + return s.String() +} + +// A verified or pending destination phone number in the SMS sandbox. +// +// When you start using Amazon SNS to send SMS messages, your AWS account is +// in the SMS sandbox. The SMS sandbox provides a safe environment for you to +// try Amazon SNS features without risking your reputation as an SMS sender. +// While your account is in the SMS sandbox, you can use all of the features +// of Amazon SNS. However, you can send SMS messages only to verified destination +// phone numbers. For more information, including how to move out of the sandbox +// to send messages without restrictions, see SMS sandbox (https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html) +// in the Amazon SNS Developer Guide. +type SMSSandboxPhoneNumber struct { + _ struct{} `type:"structure"` + + // The destination phone number. + PhoneNumber *string `type:"string"` + + // The destination phone number's verification status. + Status *string `type:"string" enum:"SMSSandboxPhoneNumberVerificationStatus"` +} + +// String returns the string representation +func (s SMSSandboxPhoneNumber) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SMSSandboxPhoneNumber) GoString() string { + return s.String() +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *SMSSandboxPhoneNumber) SetPhoneNumber(v string) *SMSSandboxPhoneNumber { + s.PhoneNumber = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *SMSSandboxPhoneNumber) SetStatus(v string) *SMSSandboxPhoneNumber { + s.Status = &v + return s +} + +// Input for SetEndpointAttributes action. +type SetEndpointAttributesInput struct { + _ struct{} `type:"structure"` + + // A map of the endpoint attributes. Attributes in this map include the following: + // + // * CustomUserData – arbitrary user data to associate with the endpoint. + // Amazon SNS does not use this data. The data must be in UTF-8 format and + // less than 2KB. + // + // * Enabled – flag that enables/disables delivery to the endpoint. Amazon + // SNS will set this to false when a notification service indicates to Amazon + // SNS that the endpoint is invalid. Users can set it back to true, typically + // after updating Token. + // + // * Token – device token, also referred to as a registration id, for an + // app and mobile device. This is returned from the notification service + // when an app and mobile device are registered with the notification service. + // + // Attributes is a required field + Attributes map[string]*string `type:"map" required:"true"` + + // EndpointArn used for SetEndpointAttributes action. + // + // EndpointArn is a required field + EndpointArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SetEndpointAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetEndpointAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetEndpointAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SetEndpointAttributesInput"} + if s.Attributes == nil { + invalidParams.Add(request.NewErrParamRequired("Attributes")) + } + if s.EndpointArn == nil { + invalidParams.Add(request.NewErrParamRequired("EndpointArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *SetEndpointAttributesInput) SetAttributes(v map[string]*string) *SetEndpointAttributesInput { + s.Attributes = v + return s +} + +// SetEndpointArn sets the EndpointArn field's value. +func (s *SetEndpointAttributesInput) SetEndpointArn(v string) *SetEndpointAttributesInput { + s.EndpointArn = &v + return s +} + +type SetEndpointAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetEndpointAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetEndpointAttributesOutput) GoString() string { + return s.String() +} + +// Input for SetPlatformApplicationAttributes action. +type SetPlatformApplicationAttributesInput struct { + _ struct{} `type:"structure"` + + // A map of the platform application attributes. Attributes in this map include + // the following: + // + // * PlatformCredential – The credential received from the notification + // service. For APNS and APNS_SANDBOX, PlatformCredential is private key. + // For GCM (Firebase Cloud Messaging), PlatformCredential is API key. For + // ADM, PlatformCredential is client secret. + // + // * PlatformPrincipal – The principal received from the notification service. + // For APNS and APNS_SANDBOX, PlatformPrincipal is SSL certificate. For GCM + // (Firebase Cloud Messaging), there is no PlatformPrincipal. For ADM, PlatformPrincipal + // is client id. + // + // * EventEndpointCreated – Topic ARN to which EndpointCreated event notifications + // are sent. + // + // * EventEndpointDeleted – Topic ARN to which EndpointDeleted event notifications + // are sent. + // + // * EventEndpointUpdated – Topic ARN to which EndpointUpdate event notifications + // are sent. + // + // * EventDeliveryFailure – Topic ARN to which DeliveryFailure event notifications + // are sent upon Direct Publish delivery failure (permanent) to one of the + // application's endpoints. + // + // * SuccessFeedbackRoleArn – IAM role ARN used to give Amazon SNS write + // access to use CloudWatch Logs on your behalf. + // + // * FailureFeedbackRoleArn – IAM role ARN used to give Amazon SNS write + // access to use CloudWatch Logs on your behalf. + // + // * SuccessFeedbackSampleRate – Sample rate percentage (0-100) of successfully + // delivered messages. + // + // Attributes is a required field + Attributes map[string]*string `type:"map" required:"true"` + + // PlatformApplicationArn for SetPlatformApplicationAttributes action. + // + // PlatformApplicationArn is a required field + PlatformApplicationArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SetPlatformApplicationAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetPlatformApplicationAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetPlatformApplicationAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SetPlatformApplicationAttributesInput"} + if s.Attributes == nil { + invalidParams.Add(request.NewErrParamRequired("Attributes")) + } + if s.PlatformApplicationArn == nil { + invalidParams.Add(request.NewErrParamRequired("PlatformApplicationArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *SetPlatformApplicationAttributesInput) SetAttributes(v map[string]*string) *SetPlatformApplicationAttributesInput { + s.Attributes = v + return s +} + +// SetPlatformApplicationArn sets the PlatformApplicationArn field's value. +func (s *SetPlatformApplicationAttributesInput) SetPlatformApplicationArn(v string) *SetPlatformApplicationAttributesInput { + s.PlatformApplicationArn = &v + return s +} + +type SetPlatformApplicationAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetPlatformApplicationAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetPlatformApplicationAttributesOutput) GoString() string { + return s.String() +} + +// The input for the SetSMSAttributes action. +type SetSMSAttributesInput struct { + _ struct{} `type:"structure"` + + // The default settings for sending SMS messages from your account. You can + // set values for the following attribute names: + // + // MonthlySpendLimit – The maximum amount in USD that you are willing to spend + // each month to send SMS messages. When Amazon SNS determines that sending + // an SMS message would incur a cost that exceeds this limit, it stops sending + // SMS messages within minutes. + // + // Amazon SNS stops sending SMS messages within minutes of the limit being crossed. + // During that interval, if you continue to send SMS messages, you will incur + // costs that exceed your limit. + // + // By default, the spend limit is set to the maximum allowed by Amazon SNS. + // If you want to raise the limit, submit an SNS Limit Increase case (https://console.aws.amazon.com/support/home#/case/create?issueType=service-limit-increase&limitType=service-code-sns). + // For New limit value, enter your desired monthly spend limit. In the Use Case + // Description field, explain that you are requesting an SMS monthly spend limit + // increase. + // + // DeliveryStatusIAMRole – The ARN of the IAM role that allows Amazon SNS + // to write logs about SMS deliveries in CloudWatch Logs. For each SMS message + // that you send, Amazon SNS writes a log that includes the message price, the + // success or failure status, the reason for failure (if the message failed), + // the message dwell time, and other information. + // + // DeliveryStatusSuccessSamplingRate – The percentage of successful SMS deliveries + // for which Amazon SNS will write logs in CloudWatch Logs. The value can be + // an integer from 0 - 100. For example, to write logs only for failed deliveries, + // set this value to 0. To write logs for 10% of your successful deliveries, + // set it to 10. + // + // DefaultSenderID – A string, such as your business brand, that is displayed + // as the sender on the receiving device. Support for sender IDs varies by country. + // The sender ID can be 1 - 11 alphanumeric characters, and it must contain + // at least one letter. + // + // DefaultSMSType – The type of SMS message that you will send by default. + // You can assign the following values: + // + // * Promotional – (Default) Noncritical messages, such as marketing messages. + // Amazon SNS optimizes the message delivery to incur the lowest cost. + // + // * Transactional – Critical messages that support customer transactions, + // such as one-time passcodes for multi-factor authentication. Amazon SNS + // optimizes the message delivery to achieve the highest reliability. + // + // UsageReportS3Bucket – The name of the Amazon S3 bucket to receive daily + // SMS usage reports from Amazon SNS. Each day, Amazon SNS will deliver a usage + // report as a CSV file to the bucket. The report includes the following information + // for each SMS message that was successfully delivered by your account: + // + // * Time that the message was published (in UTC) + // + // * Message ID + // + // * Destination phone number + // + // * Message type + // + // * Delivery status + // + // * Message price (in USD) + // + // * Part number (a message is split into multiple parts if it is too long + // for a single message) + // + // * Total number of parts + // + // To receive the report, the bucket must have a policy that allows the Amazon + // SNS service principle to perform the s3:PutObject and s3:GetBucketLocation + // actions. + // + // For an example bucket policy and usage report, see Monitoring SMS Activity + // (https://docs.aws.amazon.com/sns/latest/dg/sms_stats.html) in the Amazon + // SNS Developer Guide. + // + // Attributes is a required field + Attributes map[string]*string `locationName:"attributes" type:"map" required:"true"` +} + +// String returns the string representation +func (s SetSMSAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetSMSAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetSMSAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SetSMSAttributesInput"} + if s.Attributes == nil { + invalidParams.Add(request.NewErrParamRequired("Attributes")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *SetSMSAttributesInput) SetAttributes(v map[string]*string) *SetSMSAttributesInput { + s.Attributes = v + return s +} + +// The response for the SetSMSAttributes action. +type SetSMSAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetSMSAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetSMSAttributesOutput) GoString() string { + return s.String() +} + +// Input for SetSubscriptionAttributes action. +type SetSubscriptionAttributesInput struct { + _ struct{} `type:"structure"` + + // A map of attributes with their corresponding values. + // + // The following lists the names, descriptions, and values of the special request + // parameters that this action uses: + // + // * DeliveryPolicy – The policy that defines how Amazon SNS retries failed + // deliveries to HTTP/S endpoints. + // + // * FilterPolicy – The simple JSON object that lets your subscriber receive + // only a subset of messages, rather than receiving every message published + // to the topic. + // + // * RawMessageDelivery – When set to true, enables raw message delivery + // to Amazon SQS or HTTP/S endpoints. This eliminates the need for the endpoints + // to process JSON formatting, which is otherwise created for Amazon SNS + // metadata. + // + // * RedrivePolicy – When specified, sends undeliverable messages to the + // specified Amazon SQS dead-letter queue. Messages that can't be delivered + // due to client errors (for example, when the subscribed endpoint is unreachable) + // or server errors (for example, when the service that powers the subscribed + // endpoint becomes unavailable) are held in the dead-letter queue for further + // analysis or reprocessing. + // + // The following attribute applies only to Amazon Kinesis Data Firehose delivery + // stream subscriptions: + // + // * SubscriptionRoleArn – The ARN of the IAM role that has the following: + // Permission to write to the Kinesis Data Firehose delivery stream Amazon + // SNS listed as a trusted entity Specifying a valid ARN for this attribute + // is required for Kinesis Data Firehose delivery stream subscriptions. For + // more information, see Fanout to Kinesis Data Firehose delivery streams + // (https://docs.aws.amazon.com/sns/latest/dg/sns-firehose-as-subscriber.html) + // in the Amazon SNS Developer Guide. + // + // AttributeName is a required field + AttributeName *string `type:"string" required:"true"` + + // The new value for the attribute in JSON format. + AttributeValue *string `type:"string"` + + // The ARN of the subscription to modify. + // + // SubscriptionArn is a required field + SubscriptionArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SetSubscriptionAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetSubscriptionAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetSubscriptionAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SetSubscriptionAttributesInput"} + if s.AttributeName == nil { + invalidParams.Add(request.NewErrParamRequired("AttributeName")) + } + if s.SubscriptionArn == nil { + invalidParams.Add(request.NewErrParamRequired("SubscriptionArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributeName sets the AttributeName field's value. +func (s *SetSubscriptionAttributesInput) SetAttributeName(v string) *SetSubscriptionAttributesInput { + s.AttributeName = &v + return s +} + +// SetAttributeValue sets the AttributeValue field's value. +func (s *SetSubscriptionAttributesInput) SetAttributeValue(v string) *SetSubscriptionAttributesInput { + s.AttributeValue = &v + return s +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *SetSubscriptionAttributesInput) SetSubscriptionArn(v string) *SetSubscriptionAttributesInput { + s.SubscriptionArn = &v + return s +} + +type SetSubscriptionAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetSubscriptionAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetSubscriptionAttributesOutput) GoString() string { + return s.String() +} + +// Input for SetTopicAttributes action. +type SetTopicAttributesInput struct { + _ struct{} `type:"structure"` + + // A map of attributes with their corresponding values. + // + // The following lists the names, descriptions, and values of the special request + // parameters that the SetTopicAttributes action uses: + // + // * DeliveryPolicy – The policy that defines how Amazon SNS retries failed + // deliveries to HTTP/S endpoints. + // + // * DisplayName – The display name to use for a topic with SMS subscriptions. + // + // * Policy – The policy that defines who can access your topic. By default, + // only the topic owner can publish or subscribe to the topic. + // + // The following attribute applies only to server-side-encryption (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html): + // + // * KmsMasterKeyId – The ID of an AWS-managed customer master key (CMK) + // for Amazon SNS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms). + // For more examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) + // in the AWS Key Management Service API Reference. + // + // The following attribute applies only to FIFO topics (https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html): + // + // * ContentBasedDeduplication – Enables content-based deduplication for + // FIFO topics. By default, ContentBasedDeduplication is set to false. If + // you create a FIFO topic and this attribute is false, you must specify + // a value for the MessageDeduplicationId parameter for the Publish (https://docs.aws.amazon.com/sns/latest/api/API_Publish.html) + // action. When you set ContentBasedDeduplication to true, Amazon SNS uses + // a SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). (Optional) To override + // the generated value, you can specify a value for the MessageDeduplicationId + // parameter for the Publish action. + // + // AttributeName is a required field + AttributeName *string `type:"string" required:"true"` + + // The new value for the attribute. + AttributeValue *string `type:"string"` + + // The ARN of the topic to modify. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SetTopicAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetTopicAttributesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetTopicAttributesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SetTopicAttributesInput"} + if s.AttributeName == nil { + invalidParams.Add(request.NewErrParamRequired("AttributeName")) + } + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributeName sets the AttributeName field's value. +func (s *SetTopicAttributesInput) SetAttributeName(v string) *SetTopicAttributesInput { + s.AttributeName = &v + return s +} + +// SetAttributeValue sets the AttributeValue field's value. +func (s *SetTopicAttributesInput) SetAttributeValue(v string) *SetTopicAttributesInput { + s.AttributeValue = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *SetTopicAttributesInput) SetTopicArn(v string) *SetTopicAttributesInput { + s.TopicArn = &v + return s +} + +type SetTopicAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetTopicAttributesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SetTopicAttributesOutput) GoString() string { + return s.String() +} + +// Input for Subscribe action. +type SubscribeInput struct { + _ struct{} `type:"structure"` + + // A map of attributes with their corresponding values. + // + // The following lists the names, descriptions, and values of the special request + // parameters that the SetTopicAttributes action uses: + // + // * DeliveryPolicy – The policy that defines how Amazon SNS retries failed + // deliveries to HTTP/S endpoints. + // + // * FilterPolicy – The simple JSON object that lets your subscriber receive + // only a subset of messages, rather than receiving every message published + // to the topic. + // + // * RawMessageDelivery – When set to true, enables raw message delivery + // to Amazon SQS or HTTP/S endpoints. This eliminates the need for the endpoints + // to process JSON formatting, which is otherwise created for Amazon SNS + // metadata. + // + // * RedrivePolicy – When specified, sends undeliverable messages to the + // specified Amazon SQS dead-letter queue. Messages that can't be delivered + // due to client errors (for example, when the subscribed endpoint is unreachable) + // or server errors (for example, when the service that powers the subscribed + // endpoint becomes unavailable) are held in the dead-letter queue for further + // analysis or reprocessing. + // + // The following attribute applies only to Amazon Kinesis Data Firehose delivery + // stream subscriptions: + // + // * SubscriptionRoleArn – The ARN of the IAM role that has the following: + // Permission to write to the Kinesis Data Firehose delivery stream Amazon + // SNS listed as a trusted entity Specifying a valid ARN for this attribute + // is required for Kinesis Data Firehose delivery stream subscriptions. For + // more information, see Fanout to Kinesis Data Firehose delivery streams + // (https://docs.aws.amazon.com/sns/latest/dg/sns-firehose-as-subscriber.html) + // in the Amazon SNS Developer Guide. + Attributes map[string]*string `type:"map"` + + // The endpoint that you want to receive notifications. Endpoints vary by protocol: + // + // * For the http protocol, the (public) endpoint is a URL beginning with + // http://. + // + // * For the https protocol, the (public) endpoint is a URL beginning with + // https://. + // + // * For the email protocol, the endpoint is an email address. + // + // * For the email-json protocol, the endpoint is an email address. + // + // * For the sms protocol, the endpoint is a phone number of an SMS-enabled + // device. + // + // * For the sqs protocol, the endpoint is the ARN of an Amazon SQS queue. + // + // * For the application protocol, the endpoint is the EndpointArn of a mobile + // app and device. + // + // * For the lambda protocol, the endpoint is the ARN of an AWS Lambda function. + // + // * For the firehose protocol, the endpoint is the ARN of an Amazon Kinesis + // Data Firehose delivery stream. + Endpoint *string `type:"string"` + + // The protocol that you want to use. Supported protocols include: + // + // * http – delivery of JSON-encoded message via HTTP POST + // + // * https – delivery of JSON-encoded message via HTTPS POST + // + // * email – delivery of message via SMTP + // + // * email-json – delivery of JSON-encoded message via SMTP + // + // * sms – delivery of message via SMS + // + // * sqs – delivery of JSON-encoded message to an Amazon SQS queue + // + // * application – delivery of JSON-encoded message to an EndpointArn for + // a mobile app and device + // + // * lambda – delivery of JSON-encoded message to an AWS Lambda function + // + // * firehose – delivery of JSON-encoded message to an Amazon Kinesis Data + // Firehose delivery stream. + // + // Protocol is a required field + Protocol *string `type:"string" required:"true"` + + // Sets whether the response from the Subscribe request includes the subscription + // ARN, even if the subscription is not yet confirmed. + // + // If you set this parameter to true, the response includes the ARN in all cases, + // even if the subscription is not yet confirmed. In addition to the ARN for + // confirmed subscriptions, the response also includes the pending subscription + // ARN value for subscriptions that aren't yet confirmed. A subscription becomes + // confirmed when the subscriber calls the ConfirmSubscription action with a + // confirmation token. + // + // The default value is false. + ReturnSubscriptionArn *bool `type:"boolean"` + + // The ARN of the topic you want to subscribe to. + // + // TopicArn is a required field + TopicArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SubscribeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SubscribeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SubscribeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SubscribeInput"} + if s.Protocol == nil { + invalidParams.Add(request.NewErrParamRequired("Protocol")) + } + if s.TopicArn == nil { + invalidParams.Add(request.NewErrParamRequired("TopicArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *SubscribeInput) SetAttributes(v map[string]*string) *SubscribeInput { + s.Attributes = v + return s +} + +// SetEndpoint sets the Endpoint field's value. +func (s *SubscribeInput) SetEndpoint(v string) *SubscribeInput { + s.Endpoint = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *SubscribeInput) SetProtocol(v string) *SubscribeInput { + s.Protocol = &v + return s +} + +// SetReturnSubscriptionArn sets the ReturnSubscriptionArn field's value. +func (s *SubscribeInput) SetReturnSubscriptionArn(v bool) *SubscribeInput { + s.ReturnSubscriptionArn = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *SubscribeInput) SetTopicArn(v string) *SubscribeInput { + s.TopicArn = &v + return s +} + +// Response for Subscribe action. +type SubscribeOutput struct { + _ struct{} `type:"structure"` + + // The ARN of the subscription if it is confirmed, or the string "pending confirmation" + // if the subscription requires confirmation. However, if the API request parameter + // ReturnSubscriptionArn is true, then the value is always the subscription + // ARN, even if the subscription requires confirmation. + SubscriptionArn *string `type:"string"` +} + +// String returns the string representation +func (s SubscribeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SubscribeOutput) GoString() string { + return s.String() +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *SubscribeOutput) SetSubscriptionArn(v string) *SubscribeOutput { + s.SubscriptionArn = &v + return s +} + +// A wrapper type for the attributes of an Amazon SNS subscription. +type Subscription struct { + _ struct{} `type:"structure"` + + // The subscription's endpoint (format depends on the protocol). + Endpoint *string `type:"string"` + + // The subscription's owner. + Owner *string `type:"string"` + + // The subscription's protocol. + Protocol *string `type:"string"` + + // The subscription's ARN. + SubscriptionArn *string `type:"string"` + + // The ARN of the subscription's topic. + TopicArn *string `type:"string"` +} + +// String returns the string representation +func (s Subscription) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Subscription) GoString() string { + return s.String() +} + +// SetEndpoint sets the Endpoint field's value. +func (s *Subscription) SetEndpoint(v string) *Subscription { + s.Endpoint = &v + return s +} + +// SetOwner sets the Owner field's value. +func (s *Subscription) SetOwner(v string) *Subscription { + s.Owner = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *Subscription) SetProtocol(v string) *Subscription { + s.Protocol = &v + return s +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *Subscription) SetSubscriptionArn(v string) *Subscription { + s.SubscriptionArn = &v + return s +} + +// SetTopicArn sets the TopicArn field's value. +func (s *Subscription) SetTopicArn(v string) *Subscription { + s.TopicArn = &v + return s +} + +// The list of tags to be added to the specified topic. +type Tag struct { + _ struct{} `type:"structure"` + + // The required key portion of the tag. + // + // Key is a required field + Key *string `min:"1" type:"string" required:"true"` + + // The optional value portion of the tag. + // + // Value is a required field + Value *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s Tag) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Tag) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *Tag) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "Tag"} + if s.Key == nil { + invalidParams.Add(request.NewErrParamRequired("Key")) + } + if s.Key != nil && len(*s.Key) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Key", 1)) + } + if s.Value == nil { + invalidParams.Add(request.NewErrParamRequired("Value")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKey sets the Key field's value. +func (s *Tag) SetKey(v string) *Tag { + s.Key = &v + return s +} + +// SetValue sets the Value field's value. +func (s *Tag) SetValue(v string) *Tag { + s.Value = &v + return s +} + +type TagResourceInput struct { + _ struct{} `type:"structure"` + + // The ARN of the topic to which to add tags. + // + // ResourceArn is a required field + ResourceArn *string `min:"1" type:"string" required:"true"` + + // The tags to be added to the specified topic. A tag consists of a required + // key and an optional value. + // + // Tags is a required field + Tags []*Tag `type:"list" required:"true"` +} + +// String returns the string representation +func (s TagResourceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TagResourceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TagResourceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TagResourceInput"} + if s.ResourceArn == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceArn")) + } + if s.ResourceArn != nil && len(*s.ResourceArn) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceArn", 1)) + } + if s.Tags == nil { + invalidParams.Add(request.NewErrParamRequired("Tags")) + } + if s.Tags != nil { + for i, v := range s.Tags { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Tags", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetResourceArn sets the ResourceArn field's value. +func (s *TagResourceInput) SetResourceArn(v string) *TagResourceInput { + s.ResourceArn = &v + return s +} + +// SetTags sets the Tags field's value. +func (s *TagResourceInput) SetTags(v []*Tag) *TagResourceInput { + s.Tags = v + return s +} + +type TagResourceOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s TagResourceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TagResourceOutput) GoString() string { + return s.String() +} + +// A wrapper type for the topic's Amazon Resource Name (ARN). To retrieve a +// topic's attributes, use GetTopicAttributes. +type Topic struct { + _ struct{} `type:"structure"` + + // The topic's ARN. + TopicArn *string `type:"string"` +} + +// String returns the string representation +func (s Topic) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Topic) GoString() string { + return s.String() +} + +// SetTopicArn sets the TopicArn field's value. +func (s *Topic) SetTopicArn(v string) *Topic { + s.TopicArn = &v + return s +} + +// Input for Unsubscribe action. +type UnsubscribeInput struct { + _ struct{} `type:"structure"` + + // The ARN of the subscription to be deleted. + // + // SubscriptionArn is a required field + SubscriptionArn *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s UnsubscribeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UnsubscribeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UnsubscribeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UnsubscribeInput"} + if s.SubscriptionArn == nil { + invalidParams.Add(request.NewErrParamRequired("SubscriptionArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetSubscriptionArn sets the SubscriptionArn field's value. +func (s *UnsubscribeInput) SetSubscriptionArn(v string) *UnsubscribeInput { + s.SubscriptionArn = &v + return s +} + +type UnsubscribeOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s UnsubscribeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UnsubscribeOutput) GoString() string { + return s.String() +} + +type UntagResourceInput struct { + _ struct{} `type:"structure"` + + // The ARN of the topic from which to remove tags. + // + // ResourceArn is a required field + ResourceArn *string `min:"1" type:"string" required:"true"` + + // The list of tag keys to remove from the specified topic. + // + // TagKeys is a required field + TagKeys []*string `type:"list" required:"true"` +} + +// String returns the string representation +func (s UntagResourceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UntagResourceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UntagResourceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UntagResourceInput"} + if s.ResourceArn == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceArn")) + } + if s.ResourceArn != nil && len(*s.ResourceArn) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ResourceArn", 1)) + } + if s.TagKeys == nil { + invalidParams.Add(request.NewErrParamRequired("TagKeys")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetResourceArn sets the ResourceArn field's value. +func (s *UntagResourceInput) SetResourceArn(v string) *UntagResourceInput { + s.ResourceArn = &v + return s +} + +// SetTagKeys sets the TagKeys field's value. +func (s *UntagResourceInput) SetTagKeys(v []*string) *UntagResourceInput { + s.TagKeys = v + return s +} + +type UntagResourceOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s UntagResourceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UntagResourceOutput) GoString() string { + return s.String() +} + +type VerifySMSSandboxPhoneNumberInput struct { + _ struct{} `type:"structure"` + + // The OTP sent to the destination number from the CreateSMSSandBoxPhoneNumber + // call. + // + // OneTimePassword is a required field + OneTimePassword *string `min:"5" type:"string" required:"true"` + + // The destination phone number to verify. + // + // PhoneNumber is a required field + PhoneNumber *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s VerifySMSSandboxPhoneNumberInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VerifySMSSandboxPhoneNumberInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VerifySMSSandboxPhoneNumberInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VerifySMSSandboxPhoneNumberInput"} + if s.OneTimePassword == nil { + invalidParams.Add(request.NewErrParamRequired("OneTimePassword")) + } + if s.OneTimePassword != nil && len(*s.OneTimePassword) < 5 { + invalidParams.Add(request.NewErrParamMinLen("OneTimePassword", 5)) + } + if s.PhoneNumber == nil { + invalidParams.Add(request.NewErrParamRequired("PhoneNumber")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetOneTimePassword sets the OneTimePassword field's value. +func (s *VerifySMSSandboxPhoneNumberInput) SetOneTimePassword(v string) *VerifySMSSandboxPhoneNumberInput { + s.OneTimePassword = &v + return s +} + +// SetPhoneNumber sets the PhoneNumber field's value. +func (s *VerifySMSSandboxPhoneNumberInput) SetPhoneNumber(v string) *VerifySMSSandboxPhoneNumberInput { + s.PhoneNumber = &v + return s +} + +// The destination phone number's verification status. +type VerifySMSSandboxPhoneNumberOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s VerifySMSSandboxPhoneNumberOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VerifySMSSandboxPhoneNumberOutput) GoString() string { + return s.String() +} + +// Supported language code for sending OTP message +const ( + // LanguageCodeStringEnUs is a LanguageCodeString enum value + LanguageCodeStringEnUs = "en-US" + + // LanguageCodeStringEnGb is a LanguageCodeString enum value + LanguageCodeStringEnGb = "en-GB" + + // LanguageCodeStringEs419 is a LanguageCodeString enum value + LanguageCodeStringEs419 = "es-419" + + // LanguageCodeStringEsEs is a LanguageCodeString enum value + LanguageCodeStringEsEs = "es-ES" + + // LanguageCodeStringDeDe is a LanguageCodeString enum value + LanguageCodeStringDeDe = "de-DE" + + // LanguageCodeStringFrCa is a LanguageCodeString enum value + LanguageCodeStringFrCa = "fr-CA" + + // LanguageCodeStringFrFr is a LanguageCodeString enum value + LanguageCodeStringFrFr = "fr-FR" + + // LanguageCodeStringItIt is a LanguageCodeString enum value + LanguageCodeStringItIt = "it-IT" + + // LanguageCodeStringJaJp is a LanguageCodeString enum value + LanguageCodeStringJaJp = "ja-JP" + + // LanguageCodeStringPtBr is a LanguageCodeString enum value + LanguageCodeStringPtBr = "pt-BR" + + // LanguageCodeStringKrKr is a LanguageCodeString enum value + LanguageCodeStringKrKr = "kr-KR" + + // LanguageCodeStringZhCn is a LanguageCodeString enum value + LanguageCodeStringZhCn = "zh-CN" + + // LanguageCodeStringZhTw is a LanguageCodeString enum value + LanguageCodeStringZhTw = "zh-TW" +) + +// LanguageCodeString_Values returns all elements of the LanguageCodeString enum +func LanguageCodeString_Values() []string { + return []string{ + LanguageCodeStringEnUs, + LanguageCodeStringEnGb, + LanguageCodeStringEs419, + LanguageCodeStringEsEs, + LanguageCodeStringDeDe, + LanguageCodeStringFrCa, + LanguageCodeStringFrFr, + LanguageCodeStringItIt, + LanguageCodeStringJaJp, + LanguageCodeStringPtBr, + LanguageCodeStringKrKr, + LanguageCodeStringZhCn, + LanguageCodeStringZhTw, + } +} + +// Enum listing out all supported number capabilities. +const ( + // NumberCapabilitySms is a NumberCapability enum value + NumberCapabilitySms = "SMS" + + // NumberCapabilityMms is a NumberCapability enum value + NumberCapabilityMms = "MMS" + + // NumberCapabilityVoice is a NumberCapability enum value + NumberCapabilityVoice = "VOICE" +) + +// NumberCapability_Values returns all elements of the NumberCapability enum +func NumberCapability_Values() []string { + return []string{ + NumberCapabilitySms, + NumberCapabilityMms, + NumberCapabilityVoice, + } +} + +// Enum listing out all supported route types. The following enum values are +// supported. 1. Transactional : Non-marketing traffic 2. Promotional : Marketing +// 3. Premium : Premium routes for OTP delivery to the carriers +const ( + // RouteTypeTransactional is a RouteType enum value + RouteTypeTransactional = "Transactional" + + // RouteTypePromotional is a RouteType enum value + RouteTypePromotional = "Promotional" + + // RouteTypePremium is a RouteType enum value + RouteTypePremium = "Premium" +) + +// RouteType_Values returns all elements of the RouteType enum +func RouteType_Values() []string { + return []string{ + RouteTypeTransactional, + RouteTypePromotional, + RouteTypePremium, + } +} + +// Enum listing out all supported destination phone number verification statuses. +// The following enum values are supported. 1. PENDING : The destination phone +// number is pending verification. 2. VERIFIED : The destination phone number +// is verified. +const ( + // SMSSandboxPhoneNumberVerificationStatusPending is a SMSSandboxPhoneNumberVerificationStatus enum value + SMSSandboxPhoneNumberVerificationStatusPending = "Pending" + + // SMSSandboxPhoneNumberVerificationStatusVerified is a SMSSandboxPhoneNumberVerificationStatus enum value + SMSSandboxPhoneNumberVerificationStatusVerified = "Verified" +) + +// SMSSandboxPhoneNumberVerificationStatus_Values returns all elements of the SMSSandboxPhoneNumberVerificationStatus enum +func SMSSandboxPhoneNumberVerificationStatus_Values() []string { + return []string{ + SMSSandboxPhoneNumberVerificationStatusPending, + SMSSandboxPhoneNumberVerificationStatusVerified, + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/sns/doc.go b/vendor/github.com/aws/aws-sdk-go/service/sns/doc.go new file mode 100644 index 000000000000..714e3b87f6e0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sns/doc.go @@ -0,0 +1,44 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +// Package sns provides the client and types for making API +// requests to Amazon Simple Notification Service. +// +// Amazon Simple Notification Service (Amazon SNS) is a web service that enables +// you to build distributed web-enabled applications. Applications can use Amazon +// SNS to easily push real-time notification messages to interested subscribers +// over multiple delivery protocols. For more information about this product +// see the Amazon SNS product page (http://aws.amazon.com/sns/). For detailed +// information about Amazon SNS features and their associated API calls, see +// the Amazon SNS Developer Guide (https://docs.aws.amazon.com/sns/latest/dg/). +// +// For information on the permissions you need to use this API, see Identity +// and access management in Amazon SNS (https://docs.aws.amazon.com/sns/latest/dg/sns-authentication-and-access-control.html) +// in the Amazon SNS Developer Guide. +// +// We also provide SDKs that enable you to access Amazon SNS from your preferred +// programming language. The SDKs contain functionality that automatically takes +// care of tasks such as: cryptographically signing your service requests, retrying +// requests, and handling error responses. For a list of available SDKs, go +// to Tools for Amazon Web Services (http://aws.amazon.com/tools/). +// +// See https://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31 for more information on this service. +// +// See sns package documentation for more information. +// https://docs.aws.amazon.com/sdk-for-go/api/service/sns/ +// +// Using the Client +// +// To contact Amazon Simple Notification Service with the SDK use the New function to create +// a new service client. With that client you can make API requests to the service. +// These clients are safe to use concurrently. +// +// See the SDK's documentation for more information on how to use the SDK. +// https://docs.aws.amazon.com/sdk-for-go/api/ +// +// See aws.Config documentation for more information on configuring SDK clients. +// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config +// +// See the Amazon Simple Notification Service client SNS for more +// information on creating client for this service. +// https://docs.aws.amazon.com/sdk-for-go/api/service/sns/#New +package sns diff --git a/vendor/github.com/aws/aws-sdk-go/service/sns/errors.go b/vendor/github.com/aws/aws-sdk-go/service/sns/errors.go new file mode 100644 index 000000000000..8b416554ce55 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sns/errors.go @@ -0,0 +1,186 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package sns + +const ( + + // ErrCodeAuthorizationErrorException for service response error code + // "AuthorizationError". + // + // Indicates that the user has been denied access to the requested resource. + ErrCodeAuthorizationErrorException = "AuthorizationError" + + // ErrCodeConcurrentAccessException for service response error code + // "ConcurrentAccess". + // + // Can't perform multiple operations on a tag simultaneously. Perform the operations + // sequentially. + ErrCodeConcurrentAccessException = "ConcurrentAccess" + + // ErrCodeEndpointDisabledException for service response error code + // "EndpointDisabled". + // + // Exception error indicating endpoint disabled. + ErrCodeEndpointDisabledException = "EndpointDisabled" + + // ErrCodeFilterPolicyLimitExceededException for service response error code + // "FilterPolicyLimitExceeded". + // + // Indicates that the number of filter polices in your AWS account exceeds the + // limit. To add more filter polices, submit an SNS Limit Increase case in the + // AWS Support Center. + ErrCodeFilterPolicyLimitExceededException = "FilterPolicyLimitExceeded" + + // ErrCodeInternalErrorException for service response error code + // "InternalError". + // + // Indicates an internal service error. + ErrCodeInternalErrorException = "InternalError" + + // ErrCodeInvalidParameterException for service response error code + // "InvalidParameter". + // + // Indicates that a request parameter does not comply with the associated constraints. + ErrCodeInvalidParameterException = "InvalidParameter" + + // ErrCodeInvalidParameterValueException for service response error code + // "ParameterValueInvalid". + // + // Indicates that a request parameter does not comply with the associated constraints. + ErrCodeInvalidParameterValueException = "ParameterValueInvalid" + + // ErrCodeInvalidSecurityException for service response error code + // "InvalidSecurity". + // + // The credential signature isn't valid. You must use an HTTPS endpoint and + // sign your request using Signature Version 4. + ErrCodeInvalidSecurityException = "InvalidSecurity" + + // ErrCodeKMSAccessDeniedException for service response error code + // "KMSAccessDenied". + // + // The ciphertext references a key that doesn't exist or that you don't have + // access to. + ErrCodeKMSAccessDeniedException = "KMSAccessDenied" + + // ErrCodeKMSDisabledException for service response error code + // "KMSDisabled". + // + // The request was rejected because the specified customer master key (CMK) + // isn't enabled. + ErrCodeKMSDisabledException = "KMSDisabled" + + // ErrCodeKMSInvalidStateException for service response error code + // "KMSInvalidState". + // + // The request was rejected because the state of the specified resource isn't + // valid for this request. For more information, see How Key State Affects Use + // of a Customer Master Key (https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html) + // in the AWS Key Management Service Developer Guide. + ErrCodeKMSInvalidStateException = "KMSInvalidState" + + // ErrCodeKMSNotFoundException for service response error code + // "KMSNotFound". + // + // The request was rejected because the specified entity or resource can't be + // found. + ErrCodeKMSNotFoundException = "KMSNotFound" + + // ErrCodeKMSOptInRequired for service response error code + // "KMSOptInRequired". + // + // The AWS access key ID needs a subscription for the service. + ErrCodeKMSOptInRequired = "KMSOptInRequired" + + // ErrCodeKMSThrottlingException for service response error code + // "KMSThrottling". + // + // The request was denied due to request throttling. For more information about + // throttling, see Limits (https://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second) + // in the AWS Key Management Service Developer Guide. + ErrCodeKMSThrottlingException = "KMSThrottling" + + // ErrCodeNotFoundException for service response error code + // "NotFound". + // + // Indicates that the requested resource does not exist. + ErrCodeNotFoundException = "NotFound" + + // ErrCodeOptedOutException for service response error code + // "OptedOut". + // + // Indicates that the specified phone number opted out of receiving SMS messages + // from your AWS account. You can't send SMS messages to phone numbers that + // opt out. + ErrCodeOptedOutException = "OptedOut" + + // ErrCodePlatformApplicationDisabledException for service response error code + // "PlatformApplicationDisabled". + // + // Exception error indicating platform application disabled. + ErrCodePlatformApplicationDisabledException = "PlatformApplicationDisabled" + + // ErrCodeResourceNotFoundException for service response error code + // "ResourceNotFound". + // + // Can’t perform the action on the specified resource. Make sure that the + // resource exists. + ErrCodeResourceNotFoundException = "ResourceNotFound" + + // ErrCodeStaleTagException for service response error code + // "StaleTag". + // + // A tag has been added to a resource with the same ARN as a deleted resource. + // Wait a short while and then retry the operation. + ErrCodeStaleTagException = "StaleTag" + + // ErrCodeSubscriptionLimitExceededException for service response error code + // "SubscriptionLimitExceeded". + // + // Indicates that the customer already owns the maximum allowed number of subscriptions. + ErrCodeSubscriptionLimitExceededException = "SubscriptionLimitExceeded" + + // ErrCodeTagLimitExceededException for service response error code + // "TagLimitExceeded". + // + // Can't add more than 50 tags to a topic. + ErrCodeTagLimitExceededException = "TagLimitExceeded" + + // ErrCodeTagPolicyException for service response error code + // "TagPolicy". + // + // The request doesn't comply with the IAM tag policy. Correct your request + // and then retry it. + ErrCodeTagPolicyException = "TagPolicy" + + // ErrCodeThrottledException for service response error code + // "Throttled". + // + // Indicates that the rate at which requests have been submitted for this action + // exceeds the limit for your account. + ErrCodeThrottledException = "Throttled" + + // ErrCodeTopicLimitExceededException for service response error code + // "TopicLimitExceeded". + // + // Indicates that the customer already owns the maximum allowed number of topics. + ErrCodeTopicLimitExceededException = "TopicLimitExceeded" + + // ErrCodeUserErrorException for service response error code + // "UserError". + // + // Indicates that a request parameter does not comply with the associated constraints. + ErrCodeUserErrorException = "UserError" + + // ErrCodeValidationException for service response error code + // "ValidationException". + // + // Indicates that a parameter in the request is invalid. + ErrCodeValidationException = "ValidationException" + + // ErrCodeVerificationException for service response error code + // "VerificationException". + // + // Indicates that the one-time password (OTP) used for verification is invalid. + ErrCodeVerificationException = "VerificationException" +) diff --git a/vendor/github.com/aws/aws-sdk-go/service/sns/service.go b/vendor/github.com/aws/aws-sdk-go/service/sns/service.go new file mode 100644 index 000000000000..21b616043d8d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sns/service.go @@ -0,0 +1,98 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package sns + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/signer/v4" + "github.com/aws/aws-sdk-go/private/protocol/query" +) + +// SNS provides the API operation methods for making requests to +// Amazon Simple Notification Service. See this package's package overview docs +// for details on the service. +// +// SNS methods are safe to use concurrently. It is not safe to +// modify mutate any of the struct's properties though. +type SNS struct { + *client.Client +} + +// Used for custom client initialization logic +var initClient func(*client.Client) + +// Used for custom request initialization logic +var initRequest func(*request.Request) + +// Service information constants +const ( + ServiceName = "sns" // Name of service. + EndpointsID = ServiceName // ID to lookup a service endpoint with. + ServiceID = "SNS" // ServiceID is a unique identifier of a specific service. +) + +// New creates a new instance of the SNS client with a session. +// If additional configuration is needed for the client instance use the optional +// aws.Config parameter to add your extra config. +// +// Example: +// mySession := session.Must(session.NewSession()) +// +// // Create a SNS client from just a session. +// svc := sns.New(mySession) +// +// // Create a SNS client with additional configuration +// svc := sns.New(mySession, aws.NewConfig().WithRegion("us-west-2")) +func New(p client.ConfigProvider, cfgs ...*aws.Config) *SNS { + c := p.ClientConfig(EndpointsID, cfgs...) + return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName) +} + +// newClient creates, initializes and returns a new service client instance. +func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *SNS { + svc := &SNS{ + Client: client.New( + cfg, + metadata.ClientInfo{ + ServiceName: ServiceName, + ServiceID: ServiceID, + SigningName: signingName, + SigningRegion: signingRegion, + PartitionID: partitionID, + Endpoint: endpoint, + APIVersion: "2010-03-31", + }, + handlers, + ), + } + + // Handlers + svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) + svc.Handlers.Build.PushBackNamed(query.BuildHandler) + svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler) + svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler) + svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler) + + // Run custom client initialization if present + if initClient != nil { + initClient(svc.Client) + } + + return svc +} + +// newRequest creates a new request for a SNS operation and runs any +// custom request initialization. +func (c *SNS) newRequest(op *request.Operation, params, data interface{}) *request.Request { + req := c.NewRequest(op, params, data) + + // Run custom request initialization if present + if initRequest != nil { + initRequest(req) + } + + return req +} diff --git a/vendor/github.com/blang/semver/v4/LICENSE b/vendor/github.com/blang/semver/v4/LICENSE new file mode 100644 index 000000000000..5ba5c86fcb02 --- /dev/null +++ b/vendor/github.com/blang/semver/v4/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2014 Benedikt Lang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/github.com/blang/semver/v4/go.mod b/vendor/github.com/blang/semver/v4/go.mod new file mode 100644 index 000000000000..06d26221870d --- /dev/null +++ b/vendor/github.com/blang/semver/v4/go.mod @@ -0,0 +1,3 @@ +module github.com/blang/semver/v4 + +go 1.14 diff --git a/vendor/github.com/blang/semver/v4/json.go b/vendor/github.com/blang/semver/v4/json.go new file mode 100644 index 000000000000..a74bf7c44940 --- /dev/null +++ b/vendor/github.com/blang/semver/v4/json.go @@ -0,0 +1,23 @@ +package semver + +import ( + "encoding/json" +) + +// MarshalJSON implements the encoding/json.Marshaler interface. +func (v Version) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements the encoding/json.Unmarshaler interface. +func (v *Version) UnmarshalJSON(data []byte) (err error) { + var versionString string + + if err = json.Unmarshal(data, &versionString); err != nil { + return + } + + *v, err = Parse(versionString) + + return +} diff --git a/vendor/github.com/blang/semver/v4/range.go b/vendor/github.com/blang/semver/v4/range.go new file mode 100644 index 000000000000..95f7139b9770 --- /dev/null +++ b/vendor/github.com/blang/semver/v4/range.go @@ -0,0 +1,416 @@ +package semver + +import ( + "fmt" + "strconv" + "strings" + "unicode" +) + +type wildcardType int + +const ( + noneWildcard wildcardType = iota + majorWildcard wildcardType = 1 + minorWildcard wildcardType = 2 + patchWildcard wildcardType = 3 +) + +func wildcardTypefromInt(i int) wildcardType { + switch i { + case 1: + return majorWildcard + case 2: + return minorWildcard + case 3: + return patchWildcard + default: + return noneWildcard + } +} + +type comparator func(Version, Version) bool + +var ( + compEQ comparator = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == 0 + } + compNE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) != 0 + } + compGT = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == 1 + } + compGE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) >= 0 + } + compLT = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) == -1 + } + compLE = func(v1 Version, v2 Version) bool { + return v1.Compare(v2) <= 0 + } +) + +type versionRange struct { + v Version + c comparator +} + +// rangeFunc creates a Range from the given versionRange. +func (vr *versionRange) rangeFunc() Range { + return Range(func(v Version) bool { + return vr.c(v, vr.v) + }) +} + +// Range represents a range of versions. +// A Range can be used to check if a Version satisfies it: +// +// range, err := semver.ParseRange(">1.0.0 <2.0.0") +// range(semver.MustParse("1.1.1") // returns true +type Range func(Version) bool + +// OR combines the existing Range with another Range using logical OR. +func (rf Range) OR(f Range) Range { + return Range(func(v Version) bool { + return rf(v) || f(v) + }) +} + +// AND combines the existing Range with another Range using logical AND. +func (rf Range) AND(f Range) Range { + return Range(func(v Version) bool { + return rf(v) && f(v) + }) +} + +// ParseRange parses a range and returns a Range. +// If the range could not be parsed an error is returned. +// +// Valid ranges are: +// - "<1.0.0" +// - "<=1.0.0" +// - ">1.0.0" +// - ">=1.0.0" +// - "1.0.0", "=1.0.0", "==1.0.0" +// - "!1.0.0", "!=1.0.0" +// +// A Range can consist of multiple ranges separated by space: +// Ranges can be linked by logical AND: +// - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0" +// - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2 +// +// Ranges can also be linked by logical OR: +// - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x" +// +// AND has a higher precedence than OR. It's not possible to use brackets. +// +// Ranges can be combined by both AND and OR +// +// - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1` +func ParseRange(s string) (Range, error) { + parts := splitAndTrim(s) + orParts, err := splitORParts(parts) + if err != nil { + return nil, err + } + expandedParts, err := expandWildcardVersion(orParts) + if err != nil { + return nil, err + } + var orFn Range + for _, p := range expandedParts { + var andFn Range + for _, ap := range p { + opStr, vStr, err := splitComparatorVersion(ap) + if err != nil { + return nil, err + } + vr, err := buildVersionRange(opStr, vStr) + if err != nil { + return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err) + } + rf := vr.rangeFunc() + + // Set function + if andFn == nil { + andFn = rf + } else { // Combine with existing function + andFn = andFn.AND(rf) + } + } + if orFn == nil { + orFn = andFn + } else { + orFn = orFn.OR(andFn) + } + + } + return orFn, nil +} + +// splitORParts splits the already cleaned parts by '||'. +// Checks for invalid positions of the operator and returns an +// error if found. +func splitORParts(parts []string) ([][]string, error) { + var ORparts [][]string + last := 0 + for i, p := range parts { + if p == "||" { + if i == 0 { + return nil, fmt.Errorf("First element in range is '||'") + } + ORparts = append(ORparts, parts[last:i]) + last = i + 1 + } + } + if last == len(parts) { + return nil, fmt.Errorf("Last element in range is '||'") + } + ORparts = append(ORparts, parts[last:]) + return ORparts, nil +} + +// buildVersionRange takes a slice of 2: operator and version +// and builds a versionRange, otherwise an error. +func buildVersionRange(opStr, vStr string) (*versionRange, error) { + c := parseComparator(opStr) + if c == nil { + return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, "")) + } + v, err := Parse(vStr) + if err != nil { + return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err) + } + + return &versionRange{ + v: v, + c: c, + }, nil + +} + +// inArray checks if a byte is contained in an array of bytes +func inArray(s byte, list []byte) bool { + for _, el := range list { + if el == s { + return true + } + } + return false +} + +// splitAndTrim splits a range string by spaces and cleans whitespaces +func splitAndTrim(s string) (result []string) { + last := 0 + var lastChar byte + excludeFromSplit := []byte{'>', '<', '='} + for i := 0; i < len(s); i++ { + if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) { + if last < i-1 { + result = append(result, s[last:i]) + } + last = i + 1 + } else if s[i] != ' ' { + lastChar = s[i] + } + } + if last < len(s)-1 { + result = append(result, s[last:]) + } + + for i, v := range result { + result[i] = strings.Replace(v, " ", "", -1) + } + + // parts := strings.Split(s, " ") + // for _, x := range parts { + // if s := strings.TrimSpace(x); len(s) != 0 { + // result = append(result, s) + // } + // } + return +} + +// splitComparatorVersion splits the comparator from the version. +// Input must be free of leading or trailing spaces. +func splitComparatorVersion(s string) (string, string, error) { + i := strings.IndexFunc(s, unicode.IsDigit) + if i == -1 { + return "", "", fmt.Errorf("Could not get version from string: %q", s) + } + return strings.TrimSpace(s[0:i]), s[i:], nil +} + +// getWildcardType will return the type of wildcard that the +// passed version contains +func getWildcardType(vStr string) wildcardType { + parts := strings.Split(vStr, ".") + nparts := len(parts) + wildcard := parts[nparts-1] + + possibleWildcardType := wildcardTypefromInt(nparts) + if wildcard == "x" { + return possibleWildcardType + } + + return noneWildcard +} + +// createVersionFromWildcard will convert a wildcard version +// into a regular version, replacing 'x's with '0's, handling +// special cases like '1.x.x' and '1.x' +func createVersionFromWildcard(vStr string) string { + // handle 1.x.x + vStr2 := strings.Replace(vStr, ".x.x", ".x", 1) + vStr2 = strings.Replace(vStr2, ".x", ".0", 1) + parts := strings.Split(vStr2, ".") + + // handle 1.x + if len(parts) == 2 { + return vStr2 + ".0" + } + + return vStr2 +} + +// incrementMajorVersion will increment the major version +// of the passed version +func incrementMajorVersion(vStr string) (string, error) { + parts := strings.Split(vStr, ".") + i, err := strconv.Atoi(parts[0]) + if err != nil { + return "", err + } + parts[0] = strconv.Itoa(i + 1) + + return strings.Join(parts, "."), nil +} + +// incrementMajorVersion will increment the minor version +// of the passed version +func incrementMinorVersion(vStr string) (string, error) { + parts := strings.Split(vStr, ".") + i, err := strconv.Atoi(parts[1]) + if err != nil { + return "", err + } + parts[1] = strconv.Itoa(i + 1) + + return strings.Join(parts, "."), nil +} + +// expandWildcardVersion will expand wildcards inside versions +// following these rules: +// +// * when dealing with patch wildcards: +// >= 1.2.x will become >= 1.2.0 +// <= 1.2.x will become < 1.3.0 +// > 1.2.x will become >= 1.3.0 +// < 1.2.x will become < 1.2.0 +// != 1.2.x will become < 1.2.0 >= 1.3.0 +// +// * when dealing with minor wildcards: +// >= 1.x will become >= 1.0.0 +// <= 1.x will become < 2.0.0 +// > 1.x will become >= 2.0.0 +// < 1.0 will become < 1.0.0 +// != 1.x will become < 1.0.0 >= 2.0.0 +// +// * when dealing with wildcards without +// version operator: +// 1.2.x will become >= 1.2.0 < 1.3.0 +// 1.x will become >= 1.0.0 < 2.0.0 +func expandWildcardVersion(parts [][]string) ([][]string, error) { + var expandedParts [][]string + for _, p := range parts { + var newParts []string + for _, ap := range p { + if strings.Contains(ap, "x") { + opStr, vStr, err := splitComparatorVersion(ap) + if err != nil { + return nil, err + } + + versionWildcardType := getWildcardType(vStr) + flatVersion := createVersionFromWildcard(vStr) + + var resultOperator string + var shouldIncrementVersion bool + switch opStr { + case ">": + resultOperator = ">=" + shouldIncrementVersion = true + case ">=": + resultOperator = ">=" + case "<": + resultOperator = "<" + case "<=": + resultOperator = "<" + shouldIncrementVersion = true + case "", "=", "==": + newParts = append(newParts, ">="+flatVersion) + resultOperator = "<" + shouldIncrementVersion = true + case "!=", "!": + newParts = append(newParts, "<"+flatVersion) + resultOperator = ">=" + shouldIncrementVersion = true + } + + var resultVersion string + if shouldIncrementVersion { + switch versionWildcardType { + case patchWildcard: + resultVersion, _ = incrementMinorVersion(flatVersion) + case minorWildcard: + resultVersion, _ = incrementMajorVersion(flatVersion) + } + } else { + resultVersion = flatVersion + } + + ap = resultOperator + resultVersion + } + newParts = append(newParts, ap) + } + expandedParts = append(expandedParts, newParts) + } + + return expandedParts, nil +} + +func parseComparator(s string) comparator { + switch s { + case "==": + fallthrough + case "": + fallthrough + case "=": + return compEQ + case ">": + return compGT + case ">=": + return compGE + case "<": + return compLT + case "<=": + return compLE + case "!": + fallthrough + case "!=": + return compNE + } + + return nil +} + +// MustParseRange is like ParseRange but panics if the range cannot be parsed. +func MustParseRange(s string) Range { + r, err := ParseRange(s) + if err != nil { + panic(`semver: ParseRange(` + s + `): ` + err.Error()) + } + return r +} diff --git a/vendor/github.com/blang/semver/v4/semver.go b/vendor/github.com/blang/semver/v4/semver.go new file mode 100644 index 000000000000..307de610f927 --- /dev/null +++ b/vendor/github.com/blang/semver/v4/semver.go @@ -0,0 +1,476 @@ +package semver + +import ( + "errors" + "fmt" + "strconv" + "strings" +) + +const ( + numbers string = "0123456789" + alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" + alphanum = alphas + numbers +) + +// SpecVersion is the latest fully supported spec version of semver +var SpecVersion = Version{ + Major: 2, + Minor: 0, + Patch: 0, +} + +// Version represents a semver compatible version +type Version struct { + Major uint64 + Minor uint64 + Patch uint64 + Pre []PRVersion + Build []string //No Precedence +} + +// Version to string +func (v Version) String() string { + b := make([]byte, 0, 5) + b = strconv.AppendUint(b, v.Major, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Minor, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Patch, 10) + + if len(v.Pre) > 0 { + b = append(b, '-') + b = append(b, v.Pre[0].String()...) + + for _, pre := range v.Pre[1:] { + b = append(b, '.') + b = append(b, pre.String()...) + } + } + + if len(v.Build) > 0 { + b = append(b, '+') + b = append(b, v.Build[0]...) + + for _, build := range v.Build[1:] { + b = append(b, '.') + b = append(b, build...) + } + } + + return string(b) +} + +// FinalizeVersion discards prerelease and build number and only returns +// major, minor and patch number. +func (v Version) FinalizeVersion() string { + b := make([]byte, 0, 5) + b = strconv.AppendUint(b, v.Major, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Minor, 10) + b = append(b, '.') + b = strconv.AppendUint(b, v.Patch, 10) + return string(b) +} + +// Equals checks if v is equal to o. +func (v Version) Equals(o Version) bool { + return (v.Compare(o) == 0) +} + +// EQ checks if v is equal to o. +func (v Version) EQ(o Version) bool { + return (v.Compare(o) == 0) +} + +// NE checks if v is not equal to o. +func (v Version) NE(o Version) bool { + return (v.Compare(o) != 0) +} + +// GT checks if v is greater than o. +func (v Version) GT(o Version) bool { + return (v.Compare(o) == 1) +} + +// GTE checks if v is greater than or equal to o. +func (v Version) GTE(o Version) bool { + return (v.Compare(o) >= 0) +} + +// GE checks if v is greater than or equal to o. +func (v Version) GE(o Version) bool { + return (v.Compare(o) >= 0) +} + +// LT checks if v is less than o. +func (v Version) LT(o Version) bool { + return (v.Compare(o) == -1) +} + +// LTE checks if v is less than or equal to o. +func (v Version) LTE(o Version) bool { + return (v.Compare(o) <= 0) +} + +// LE checks if v is less than or equal to o. +func (v Version) LE(o Version) bool { + return (v.Compare(o) <= 0) +} + +// Compare compares Versions v to o: +// -1 == v is less than o +// 0 == v is equal to o +// 1 == v is greater than o +func (v Version) Compare(o Version) int { + if v.Major != o.Major { + if v.Major > o.Major { + return 1 + } + return -1 + } + if v.Minor != o.Minor { + if v.Minor > o.Minor { + return 1 + } + return -1 + } + if v.Patch != o.Patch { + if v.Patch > o.Patch { + return 1 + } + return -1 + } + + // Quick comparison if a version has no prerelease versions + if len(v.Pre) == 0 && len(o.Pre) == 0 { + return 0 + } else if len(v.Pre) == 0 && len(o.Pre) > 0 { + return 1 + } else if len(v.Pre) > 0 && len(o.Pre) == 0 { + return -1 + } + + i := 0 + for ; i < len(v.Pre) && i < len(o.Pre); i++ { + if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 { + continue + } else if comp == 1 { + return 1 + } else { + return -1 + } + } + + // If all pr versions are the equal but one has further prversion, this one greater + if i == len(v.Pre) && i == len(o.Pre) { + return 0 + } else if i == len(v.Pre) && i < len(o.Pre) { + return -1 + } else { + return 1 + } + +} + +// IncrementPatch increments the patch version +func (v *Version) IncrementPatch() error { + v.Patch++ + return nil +} + +// IncrementMinor increments the minor version +func (v *Version) IncrementMinor() error { + v.Minor++ + v.Patch = 0 + return nil +} + +// IncrementMajor increments the major version +func (v *Version) IncrementMajor() error { + v.Major++ + v.Minor = 0 + v.Patch = 0 + return nil +} + +// Validate validates v and returns error in case +func (v Version) Validate() error { + // Major, Minor, Patch already validated using uint64 + + for _, pre := range v.Pre { + if !pre.IsNum { //Numeric prerelease versions already uint64 + if len(pre.VersionStr) == 0 { + return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr) + } + if !containsOnly(pre.VersionStr, alphanum) { + return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr) + } + } + } + + for _, build := range v.Build { + if len(build) == 0 { + return fmt.Errorf("Build meta data can not be empty %q", build) + } + if !containsOnly(build, alphanum) { + return fmt.Errorf("Invalid character(s) found in build meta data %q", build) + } + } + + return nil +} + +// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error +func New(s string) (*Version, error) { + v, err := Parse(s) + vp := &v + return vp, err +} + +// Make is an alias for Parse, parses version string and returns a validated Version or error +func Make(s string) (Version, error) { + return Parse(s) +} + +// ParseTolerant allows for certain version specifications that do not strictly adhere to semver +// specs to be parsed by this library. It does so by normalizing versions before passing them to +// Parse(). It currently trims spaces, removes a "v" prefix, adds a 0 patch number to versions +// with only major and minor components specified, and removes leading 0s. +func ParseTolerant(s string) (Version, error) { + s = strings.TrimSpace(s) + s = strings.TrimPrefix(s, "v") + + // Split into major.minor.(patch+pr+meta) + parts := strings.SplitN(s, ".", 3) + // Remove leading zeros. + for i, p := range parts { + if len(p) > 1 { + p = strings.TrimLeft(p, "0") + if len(p) == 0 || !strings.ContainsAny(p[0:1], "0123456789") { + p = "0" + p + } + parts[i] = p + } + } + // Fill up shortened versions. + if len(parts) < 3 { + if strings.ContainsAny(parts[len(parts)-1], "+-") { + return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data") + } + for len(parts) < 3 { + parts = append(parts, "0") + } + } + s = strings.Join(parts, ".") + + return Parse(s) +} + +// Parse parses version string and returns a validated Version or error +func Parse(s string) (Version, error) { + if len(s) == 0 { + return Version{}, errors.New("Version string empty") + } + + // Split into major.minor.(patch+pr+meta) + parts := strings.SplitN(s, ".", 3) + if len(parts) != 3 { + return Version{}, errors.New("No Major.Minor.Patch elements found") + } + + // Major + if !containsOnly(parts[0], numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0]) + } + if hasLeadingZeroes(parts[0]) { + return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0]) + } + major, err := strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return Version{}, err + } + + // Minor + if !containsOnly(parts[1], numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1]) + } + if hasLeadingZeroes(parts[1]) { + return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1]) + } + minor, err := strconv.ParseUint(parts[1], 10, 64) + if err != nil { + return Version{}, err + } + + v := Version{} + v.Major = major + v.Minor = minor + + var build, prerelease []string + patchStr := parts[2] + + if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 { + build = strings.Split(patchStr[buildIndex+1:], ".") + patchStr = patchStr[:buildIndex] + } + + if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 { + prerelease = strings.Split(patchStr[preIndex+1:], ".") + patchStr = patchStr[:preIndex] + } + + if !containsOnly(patchStr, numbers) { + return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr) + } + if hasLeadingZeroes(patchStr) { + return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr) + } + patch, err := strconv.ParseUint(patchStr, 10, 64) + if err != nil { + return Version{}, err + } + + v.Patch = patch + + // Prerelease + for _, prstr := range prerelease { + parsedPR, err := NewPRVersion(prstr) + if err != nil { + return Version{}, err + } + v.Pre = append(v.Pre, parsedPR) + } + + // Build meta data + for _, str := range build { + if len(str) == 0 { + return Version{}, errors.New("Build meta data is empty") + } + if !containsOnly(str, alphanum) { + return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str) + } + v.Build = append(v.Build, str) + } + + return v, nil +} + +// MustParse is like Parse but panics if the version cannot be parsed. +func MustParse(s string) Version { + v, err := Parse(s) + if err != nil { + panic(`semver: Parse(` + s + `): ` + err.Error()) + } + return v +} + +// PRVersion represents a PreRelease Version +type PRVersion struct { + VersionStr string + VersionNum uint64 + IsNum bool +} + +// NewPRVersion creates a new valid prerelease version +func NewPRVersion(s string) (PRVersion, error) { + if len(s) == 0 { + return PRVersion{}, errors.New("Prerelease is empty") + } + v := PRVersion{} + if containsOnly(s, numbers) { + if hasLeadingZeroes(s) { + return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s) + } + num, err := strconv.ParseUint(s, 10, 64) + + // Might never be hit, but just in case + if err != nil { + return PRVersion{}, err + } + v.VersionNum = num + v.IsNum = true + } else if containsOnly(s, alphanum) { + v.VersionStr = s + v.IsNum = false + } else { + return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s) + } + return v, nil +} + +// IsNumeric checks if prerelease-version is numeric +func (v PRVersion) IsNumeric() bool { + return v.IsNum +} + +// Compare compares two PreRelease Versions v and o: +// -1 == v is less than o +// 0 == v is equal to o +// 1 == v is greater than o +func (v PRVersion) Compare(o PRVersion) int { + if v.IsNum && !o.IsNum { + return -1 + } else if !v.IsNum && o.IsNum { + return 1 + } else if v.IsNum && o.IsNum { + if v.VersionNum == o.VersionNum { + return 0 + } else if v.VersionNum > o.VersionNum { + return 1 + } else { + return -1 + } + } else { // both are Alphas + if v.VersionStr == o.VersionStr { + return 0 + } else if v.VersionStr > o.VersionStr { + return 1 + } else { + return -1 + } + } +} + +// PreRelease version to string +func (v PRVersion) String() string { + if v.IsNum { + return strconv.FormatUint(v.VersionNum, 10) + } + return v.VersionStr +} + +func containsOnly(s string, set string) bool { + return strings.IndexFunc(s, func(r rune) bool { + return !strings.ContainsRune(set, r) + }) == -1 +} + +func hasLeadingZeroes(s string) bool { + return len(s) > 1 && s[0] == '0' +} + +// NewBuildVersion creates a new valid build version +func NewBuildVersion(s string) (string, error) { + if len(s) == 0 { + return "", errors.New("Buildversion is empty") + } + if !containsOnly(s, alphanum) { + return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s) + } + return s, nil +} + +// FinalizeVersion returns the major, minor and patch number only and discards +// prerelease and build number. +func FinalizeVersion(s string) (string, error) { + v, err := Parse(s) + if err != nil { + return "", err + } + v.Pre = nil + v.Build = nil + + finalVer := v.String() + return finalVer, nil +} diff --git a/vendor/github.com/blang/semver/v4/sort.go b/vendor/github.com/blang/semver/v4/sort.go new file mode 100644 index 000000000000..e18f880826ab --- /dev/null +++ b/vendor/github.com/blang/semver/v4/sort.go @@ -0,0 +1,28 @@ +package semver + +import ( + "sort" +) + +// Versions represents multiple versions. +type Versions []Version + +// Len returns length of version collection +func (s Versions) Len() int { + return len(s) +} + +// Swap swaps two versions inside the collection by its indices +func (s Versions) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +// Less checks if version at index i is less than version at index j +func (s Versions) Less(i, j int) bool { + return s[i].LT(s[j]) +} + +// Sort sorts a slice of versions +func Sort(versions []Version) { + sort.Sort(Versions(versions)) +} diff --git a/vendor/github.com/blang/semver/v4/sql.go b/vendor/github.com/blang/semver/v4/sql.go new file mode 100644 index 000000000000..db958134f3b4 --- /dev/null +++ b/vendor/github.com/blang/semver/v4/sql.go @@ -0,0 +1,30 @@ +package semver + +import ( + "database/sql/driver" + "fmt" +) + +// Scan implements the database/sql.Scanner interface. +func (v *Version) Scan(src interface{}) (err error) { + var str string + switch src := src.(type) { + case string: + str = src + case []byte: + str = string(src) + default: + return fmt.Errorf("version.Scan: cannot convert %T to string", src) + } + + if t, err := Parse(str); err == nil { + *v = t + } + + return +} + +// Value implements the database/sql/driver.Valuer interface. +func (v Version) Value() (driver.Value, error) { + return v.String(), nil +} diff --git a/vendor/github.com/coreos/go-systemd/v22/journal/journal.go b/vendor/github.com/coreos/go-systemd/v22/journal/journal.go index a0f4837a02c9..ac24c7767d35 100644 --- a/vendor/github.com/coreos/go-systemd/v22/journal/journal.go +++ b/vendor/github.com/coreos/go-systemd/v22/journal/journal.go @@ -23,20 +23,7 @@ package journal import ( - "bytes" - "encoding/binary" - "errors" "fmt" - "io" - "io/ioutil" - "net" - "os" - "strconv" - "strings" - "sync" - "sync/atomic" - "syscall" - "unsafe" ) // Priority of a journal message @@ -53,173 +40,7 @@ const ( PriDebug ) -var ( - // This can be overridden at build-time: - // https://github.com/golang/go/wiki/GcToolchainTricks#including-build-information-in-the-executable - journalSocket = "/run/systemd/journal/socket" - - // unixConnPtr atomically holds the local unconnected Unix-domain socket. - // Concrete safe pointer type: *net.UnixConn - unixConnPtr unsafe.Pointer - // onceConn ensures that unixConnPtr is initialized exactly once. - onceConn sync.Once -) - -func init() { - onceConn.Do(initConn) -} - -// Enabled checks whether the local systemd journal is available for logging. -func Enabled() bool { - onceConn.Do(initConn) - - if (*net.UnixConn)(atomic.LoadPointer(&unixConnPtr)) == nil { - return false - } - - if _, err := net.Dial("unixgram", journalSocket); err != nil { - return false - } - - return true -} - -// Send a message to the local systemd journal. vars is a map of journald -// fields to values. Fields must be composed of uppercase letters, numbers, -// and underscores, but must not start with an underscore. Within these -// restrictions, any arbitrary field name may be used. Some names have special -// significance: see the journalctl documentation -// (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html) -// for more details. vars may be nil. -func Send(message string, priority Priority, vars map[string]string) error { - conn := (*net.UnixConn)(atomic.LoadPointer(&unixConnPtr)) - if conn == nil { - return errors.New("could not initialize socket to journald") - } - - socketAddr := &net.UnixAddr{ - Name: journalSocket, - Net: "unixgram", - } - - data := new(bytes.Buffer) - appendVariable(data, "PRIORITY", strconv.Itoa(int(priority))) - appendVariable(data, "MESSAGE", message) - for k, v := range vars { - appendVariable(data, k, v) - } - - _, _, err := conn.WriteMsgUnix(data.Bytes(), nil, socketAddr) - if err == nil { - return nil - } - if !isSocketSpaceError(err) { - return err - } - - // Large log entry, send it via tempfile and ancillary-fd. - file, err := tempFd() - if err != nil { - return err - } - defer file.Close() - _, err = io.Copy(file, data) - if err != nil { - return err - } - rights := syscall.UnixRights(int(file.Fd())) - _, _, err = conn.WriteMsgUnix([]byte{}, rights, socketAddr) - if err != nil { - return err - } - - return nil -} - // Print prints a message to the local systemd journal using Send(). func Print(priority Priority, format string, a ...interface{}) error { return Send(fmt.Sprintf(format, a...), priority, nil) } - -func appendVariable(w io.Writer, name, value string) { - if err := validVarName(name); err != nil { - fmt.Fprintf(os.Stderr, "variable name %s contains invalid character, ignoring\n", name) - } - if strings.ContainsRune(value, '\n') { - /* When the value contains a newline, we write: - * - the variable name, followed by a newline - * - the size (in 64bit little endian format) - * - the data, followed by a newline - */ - fmt.Fprintln(w, name) - binary.Write(w, binary.LittleEndian, uint64(len(value))) - fmt.Fprintln(w, value) - } else { - /* just write the variable and value all on one line */ - fmt.Fprintf(w, "%s=%s\n", name, value) - } -} - -// validVarName validates a variable name to make sure journald will accept it. -// The variable name must be in uppercase and consist only of characters, -// numbers and underscores, and may not begin with an underscore: -// https://www.freedesktop.org/software/systemd/man/sd_journal_print.html -func validVarName(name string) error { - if name == "" { - return errors.New("Empty variable name") - } else if name[0] == '_' { - return errors.New("Variable name begins with an underscore") - } - - for _, c := range name { - if !(('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_') { - return errors.New("Variable name contains invalid characters") - } - } - return nil -} - -// isSocketSpaceError checks whether the error is signaling -// an "overlarge message" condition. -func isSocketSpaceError(err error) bool { - opErr, ok := err.(*net.OpError) - if !ok || opErr == nil { - return false - } - - sysErr, ok := opErr.Err.(*os.SyscallError) - if !ok || sysErr == nil { - return false - } - - return sysErr.Err == syscall.EMSGSIZE || sysErr.Err == syscall.ENOBUFS -} - -// tempFd creates a temporary, unlinked file under `/dev/shm`. -func tempFd() (*os.File, error) { - file, err := ioutil.TempFile("/dev/shm/", "journal.XXXXX") - if err != nil { - return nil, err - } - err = syscall.Unlink(file.Name()) - if err != nil { - return nil, err - } - return file, nil -} - -// initConn initializes the global `unixConnPtr` socket. -// It is meant to be called exactly once, at program startup. -func initConn() { - autobind, err := net.ResolveUnixAddr("unixgram", "") - if err != nil { - return - } - - sock, err := net.ListenUnixgram("unixgram", autobind) - if err != nil { - return - } - - atomic.StorePointer(&unixConnPtr, unsafe.Pointer(sock)) -} diff --git a/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go b/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go new file mode 100644 index 000000000000..8d58ca0fbca0 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go @@ -0,0 +1,210 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !windows + +// Package journal provides write bindings to the local systemd journal. +// It is implemented in pure Go and connects to the journal directly over its +// unix socket. +// +// To read from the journal, see the "sdjournal" package, which wraps the +// sd-journal a C API. +// +// http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html +package journal + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "io" + "io/ioutil" + "net" + "os" + "strconv" + "strings" + "sync" + "sync/atomic" + "syscall" + "unsafe" +) + +var ( + // This can be overridden at build-time: + // https://github.com/golang/go/wiki/GcToolchainTricks#including-build-information-in-the-executable + journalSocket = "/run/systemd/journal/socket" + + // unixConnPtr atomically holds the local unconnected Unix-domain socket. + // Concrete safe pointer type: *net.UnixConn + unixConnPtr unsafe.Pointer + // onceConn ensures that unixConnPtr is initialized exactly once. + onceConn sync.Once +) + +func init() { + onceConn.Do(initConn) +} + +// Enabled checks whether the local systemd journal is available for logging. +func Enabled() bool { + onceConn.Do(initConn) + + if (*net.UnixConn)(atomic.LoadPointer(&unixConnPtr)) == nil { + return false + } + + conn, err := net.Dial("unixgram", journalSocket) + if err != nil { + return false + } + defer conn.Close() + + return true +} + +// Send a message to the local systemd journal. vars is a map of journald +// fields to values. Fields must be composed of uppercase letters, numbers, +// and underscores, but must not start with an underscore. Within these +// restrictions, any arbitrary field name may be used. Some names have special +// significance: see the journalctl documentation +// (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html) +// for more details. vars may be nil. +func Send(message string, priority Priority, vars map[string]string) error { + conn := (*net.UnixConn)(atomic.LoadPointer(&unixConnPtr)) + if conn == nil { + return errors.New("could not initialize socket to journald") + } + + socketAddr := &net.UnixAddr{ + Name: journalSocket, + Net: "unixgram", + } + + data := new(bytes.Buffer) + appendVariable(data, "PRIORITY", strconv.Itoa(int(priority))) + appendVariable(data, "MESSAGE", message) + for k, v := range vars { + appendVariable(data, k, v) + } + + _, _, err := conn.WriteMsgUnix(data.Bytes(), nil, socketAddr) + if err == nil { + return nil + } + if !isSocketSpaceError(err) { + return err + } + + // Large log entry, send it via tempfile and ancillary-fd. + file, err := tempFd() + if err != nil { + return err + } + defer file.Close() + _, err = io.Copy(file, data) + if err != nil { + return err + } + rights := syscall.UnixRights(int(file.Fd())) + _, _, err = conn.WriteMsgUnix([]byte{}, rights, socketAddr) + if err != nil { + return err + } + + return nil +} + +func appendVariable(w io.Writer, name, value string) { + if err := validVarName(name); err != nil { + fmt.Fprintf(os.Stderr, "variable name %s contains invalid character, ignoring\n", name) + } + if strings.ContainsRune(value, '\n') { + /* When the value contains a newline, we write: + * - the variable name, followed by a newline + * - the size (in 64bit little endian format) + * - the data, followed by a newline + */ + fmt.Fprintln(w, name) + binary.Write(w, binary.LittleEndian, uint64(len(value))) + fmt.Fprintln(w, value) + } else { + /* just write the variable and value all on one line */ + fmt.Fprintf(w, "%s=%s\n", name, value) + } +} + +// validVarName validates a variable name to make sure journald will accept it. +// The variable name must be in uppercase and consist only of characters, +// numbers and underscores, and may not begin with an underscore: +// https://www.freedesktop.org/software/systemd/man/sd_journal_print.html +func validVarName(name string) error { + if name == "" { + return errors.New("Empty variable name") + } else if name[0] == '_' { + return errors.New("Variable name begins with an underscore") + } + + for _, c := range name { + if !(('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_') { + return errors.New("Variable name contains invalid characters") + } + } + return nil +} + +// isSocketSpaceError checks whether the error is signaling +// an "overlarge message" condition. +func isSocketSpaceError(err error) bool { + opErr, ok := err.(*net.OpError) + if !ok || opErr == nil { + return false + } + + sysErr, ok := opErr.Err.(*os.SyscallError) + if !ok || sysErr == nil { + return false + } + + return sysErr.Err == syscall.EMSGSIZE || sysErr.Err == syscall.ENOBUFS +} + +// tempFd creates a temporary, unlinked file under `/dev/shm`. +func tempFd() (*os.File, error) { + file, err := ioutil.TempFile("/dev/shm/", "journal.XXXXX") + if err != nil { + return nil, err + } + err = syscall.Unlink(file.Name()) + if err != nil { + return nil, err + } + return file, nil +} + +// initConn initializes the global `unixConnPtr` socket. +// It is meant to be called exactly once, at program startup. +func initConn() { + autobind, err := net.ResolveUnixAddr("unixgram", "") + if err != nil { + return + } + + sock, err := net.ListenUnixgram("unixgram", autobind) + if err != nil { + return + } + + atomic.StorePointer(&unixConnPtr, unsafe.Pointer(sock)) +} diff --git a/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go b/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go new file mode 100644 index 000000000000..677aca68ed20 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go @@ -0,0 +1,35 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package journal provides write bindings to the local systemd journal. +// It is implemented in pure Go and connects to the journal directly over its +// unix socket. +// +// To read from the journal, see the "sdjournal" package, which wraps the +// sd-journal a C API. +// +// http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html +package journal + +import ( + "errors" +) + +func Enabled() bool { + return false +} + +func Send(message string, priority Priority, vars map[string]string) error { + return errors.New("could not initialize socket to journald") +} diff --git a/vendor/github.com/cortexproject/cortex/pkg/alertmanager/alertmanager.go b/vendor/github.com/cortexproject/cortex/pkg/alertmanager/alertmanager.go index fe89550f9503..30d5053ef772 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/alertmanager/alertmanager.go +++ b/vendor/github.com/cortexproject/cortex/pkg/alertmanager/alertmanager.go @@ -29,6 +29,7 @@ import ( "github.com/prometheus/alertmanager/notify/pagerduty" "github.com/prometheus/alertmanager/notify/pushover" "github.com/prometheus/alertmanager/notify/slack" + "github.com/prometheus/alertmanager/notify/sns" "github.com/prometheus/alertmanager/notify/victorops" "github.com/prometheus/alertmanager/notify/webhook" "github.com/prometheus/alertmanager/notify/wechat" @@ -515,6 +516,9 @@ func buildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, fir for i, c := range nc.PushoverConfigs { add("pushover", i, c, func(l log.Logger) (notify.Notifier, error) { return pushover.New(c, tmpl, l, httpOps...) }) } + for i, c := range nc.SNSConfigs { + add("sns", i, c, func(l log.Logger) (notify.Notifier, error) { return sns.New(c, tmpl, l, httpOps...) }) + } // If we add support for more integrations, we need to add them to validation as well. See validation.allowedIntegrationNames field. if errs.Len() > 0 { return nil, &errs diff --git a/vendor/github.com/cortexproject/cortex/pkg/alertmanager/multitenant.go b/vendor/github.com/cortexproject/cortex/pkg/alertmanager/multitenant.go index 096f9f26758e..624038092e8a 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/alertmanager/multitenant.go +++ b/vendor/github.com/cortexproject/cortex/pkg/alertmanager/multitenant.go @@ -250,6 +250,10 @@ type MultitenantAlertmanager struct { distributor *Distributor grpcServer *server.Server + // Last ring state. This variable is not protected with a mutex because it's always + // accessed by a single goroutine at a time. + ringLastState ring.ReplicationSet + // Subservices manager (ring, lifecycler) subservices *services.Manager subservicesWatcher *services.FailureWatcher @@ -488,6 +492,10 @@ func (am *MultitenantAlertmanager) starting(ctx context.Context) (err error) { } if am.cfg.ShardingEnabled { + // Store the ring state after the initial Alertmanager configs sync has been done and before we do change + // our state in the ring. + am.ringLastState, _ = am.ring.GetAllHealthy(RingOp) + // Make sure that all the alertmanagers we were initially configured with have // fetched state from the replicas, before advertising as ACTIVE. This will // reduce the possibility that we lose state when new instances join/leave. @@ -631,10 +639,8 @@ func (am *MultitenantAlertmanager) run(ctx context.Context) error { defer tick.Stop() var ringTickerChan <-chan time.Time - var ringLastState ring.ReplicationSet if am.cfg.ShardingEnabled { - ringLastState, _ = am.ring.GetAllHealthy(RingOp) ringTicker := time.NewTicker(util.DurationWithJitter(am.cfg.ShardingRing.RingCheckPeriod, 0.2)) defer ringTicker.Stop() ringTickerChan = ringTicker.C @@ -656,8 +662,8 @@ func (am *MultitenantAlertmanager) run(ctx context.Context) error { // replication set which we use to compare with the previous state. currRingState, _ := am.ring.GetAllHealthy(RingOp) - if ring.HasReplicationSetChanged(ringLastState, currRingState) { - ringLastState = currRingState + if ring.HasReplicationSetChanged(am.ringLastState, currRingState) { + am.ringLastState = currRingState if err := am.loadAndSyncConfigs(ctx, reasonRingChange); err != nil { level.Warn(am.logger).Log("msg", "error while synchronizing alertmanager configs", "err", err) } diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_storage_client.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_storage_client.go index d3c67f710542..7534b45146ef 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_storage_client.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_storage_client.go @@ -11,6 +11,7 @@ import ( "time" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" ot "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" "golang.org/x/time/rate" @@ -60,7 +61,7 @@ type DynamoDBConfig struct { Metrics MetricsAutoScalingConfig `yaml:"metrics"` ChunkGangSize int `yaml:"chunk_gang_size"` ChunkGetMaxParallelism int `yaml:"chunk_get_max_parallelism"` - BackoffConfig util.BackoffConfig `yaml:"backoff_config"` + BackoffConfig backoff.Config `yaml:"backoff_config"` } // RegisterFlags adds the flags required to config this to the given FlagSet @@ -177,7 +178,7 @@ func (a dynamoDBStorageClient) BatchWrite(ctx context.Context, input chunk.Write outstanding := input.(dynamoDBWriteBatch) unprocessed := dynamoDBWriteBatch{} - backoff := util.NewBackoff(ctx, a.cfg.BackoffConfig) + backoff := backoff.New(ctx, a.cfg.BackoffConfig) for outstanding.Len()+unprocessed.Len() > 0 && backoff.Ongoing() { requests := dynamoDBWriteBatch{} @@ -433,7 +434,7 @@ func (a dynamoDBStorageClient) getDynamoDBChunks(ctx context.Context, chunks []c result := []chunk.Chunk{} unprocessed := dynamoDBReadRequest{} - backoff := util.NewBackoff(ctx, a.cfg.BackoffConfig) + backoff := backoff.New(ctx, a.cfg.BackoffConfig) for outstanding.Len()+unprocessed.Len() > 0 && backoff.Ongoing() { requests := dynamoDBReadRequest{} diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_table_client.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_table_client.go index fa7b5f5fad77..4af3a8de6063 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_table_client.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/dynamodb_table_client.go @@ -9,13 +9,13 @@ import ( "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/weaveworks/common/instrument" "golang.org/x/time/rate" "github.com/cortexproject/cortex/pkg/chunk" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/log" ) @@ -30,7 +30,7 @@ type autoscale interface { type callManager struct { limiter *rate.Limiter - backoffConfig util.BackoffConfig + backoffConfig backoff.Config } type dynamoTableClient struct { @@ -80,7 +80,7 @@ func (d callManager) backoffAndRetry(ctx context.Context, fn func(context.Contex _ = d.limiter.Wait(ctx) } - backoff := util.NewBackoff(ctx, d.backoffConfig) + backoff := backoff.New(ctx, d.backoffConfig) for backoff.Ongoing() { if err := fn(ctx); err != nil { if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ThrottlingException" { diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/fixtures.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/fixtures.go index acc05dc0adbc..1f6633b58fea 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/fixtures.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/fixtures.go @@ -5,12 +5,12 @@ import ( "io" "time" + "github.com/grafana/dskit/backoff" "golang.org/x/time/rate" "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/objectclient" "github.com/cortexproject/cortex/pkg/chunk/testutils" - "github.com/cortexproject/cortex/pkg/util" ) type fixture struct { @@ -73,7 +73,7 @@ func dynamoDBFixture(provisionedErr, gangsize, maxParallelism int) testutils.Fix cfg: DynamoDBConfig{ ChunkGangSize: gangsize, ChunkGetMaxParallelism: maxParallelism, - BackoffConfig: util.BackoffConfig{ + BackoffConfig: backoff.Config{ MinBackoff: 1 * time.Millisecond, MaxBackoff: 5 * time.Millisecond, MaxRetries: 20, diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/retryer.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/retryer.go index 94ac71f90570..5e3b7a2710b2 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/retryer.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/aws/retryer.go @@ -5,23 +5,22 @@ import ( "time" "github.com/aws/aws-sdk-go/aws/request" + "github.com/grafana/dskit/backoff" ot "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" - - "github.com/cortexproject/cortex/pkg/util" ) // Map Cortex Backoff into AWS Retryer interface type retryer struct { - *util.Backoff + *backoff.Backoff maxRetries int } var _ request.Retryer = &retryer{} -func newRetryer(ctx context.Context, cfg util.BackoffConfig) *retryer { +func newRetryer(ctx context.Context, cfg backoff.Config) *retryer { return &retryer{ - Backoff: util.NewBackoff(ctx, cfg), + Backoff: backoff.New(ctx, cfg), maxRetries: cfg.MaxRetries, } } diff --git a/vendor/github.com/cortexproject/cortex/pkg/compactor/compactor.go b/vendor/github.com/cortexproject/cortex/pkg/compactor/compactor.go index 79dc24d830e9..ac1a9c54379e 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/compactor/compactor.go +++ b/vendor/github.com/cortexproject/cortex/pkg/compactor/compactor.go @@ -15,6 +15,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -573,7 +574,7 @@ func (c *Compactor) compactUsers(ctx context.Context) { func (c *Compactor) compactUserWithRetries(ctx context.Context, userID string) error { var lastErr error - retries := util.NewBackoff(ctx, util.BackoffConfig{ + retries := backoff.New(ctx, backoff.Config{ MinBackoff: c.compactorCfg.retryMinBackoff, MaxBackoff: c.compactorCfg.retryMaxBackoff, MaxRetries: c.compactorCfg.CompactionRetries, @@ -603,11 +604,11 @@ func (c *Compactor) compactUser(ctx context.Context, userID string) error { deduplicateBlocksFilter := block.NewDeduplicateFilter() // While fetching blocks, we filter out blocks that were marked for deletion by using IgnoreDeletionMarkFilter. - // The delay of deleteDelay/2 is added to ensure we fetch blocks that are meant to be deleted but do not have a replacement yet. + // No delay is used -- all blocks with deletion marker are ignored, and not considered for compaction. ignoreDeletionMarkFilter := block.NewIgnoreDeletionMarkFilter( ulogger, bucket, - time.Duration(c.compactorCfg.DeletionDelay.Seconds()/2)*time.Second, + 0, c.compactorCfg.MetaSyncConcurrency) fetcher, err := block.NewMetaFetcher( @@ -670,7 +671,7 @@ func (c *Compactor) compactUser(ctx context.Context, userID string) error { func (c *Compactor) discoverUsersWithRetries(ctx context.Context) ([]string, error) { var lastErr error - retries := util.NewBackoff(ctx, util.BackoffConfig{ + retries := backoff.New(ctx, backoff.Config{ MinBackoff: c.compactorCfg.retryMinBackoff, MaxBackoff: c.compactorCfg.retryMaxBackoff, MaxRetries: c.compactorCfg.CompactionRetries, diff --git a/vendor/github.com/cortexproject/cortex/pkg/cortex/modules.go b/vendor/github.com/cortexproject/cortex/pkg/cortex/modules.go index 488e9aadddd3..7605ea54e5f3 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/cortex/modules.go +++ b/vendor/github.com/cortexproject/cortex/pkg/cortex/modules.go @@ -827,7 +827,7 @@ func (t *Cortex) initQueryScheduler() (services.Service, error) { } func (t *Cortex) setupModuleManager() error { - mm := modules.NewManager() + mm := modules.NewManager(util_log.Logger) // Register all modules here. // RegisterModule(name string, initFn func()(services.Service, error)) diff --git a/vendor/github.com/cortexproject/cortex/pkg/frontend/v2/frontend_scheduler_worker.go b/vendor/github.com/cortexproject/cortex/pkg/frontend/v2/frontend_scheduler_worker.go index 1395b9a0bb1f..19f5b71ffee5 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/frontend/v2/frontend_scheduler_worker.go +++ b/vendor/github.com/cortexproject/cortex/pkg/frontend/v2/frontend_scheduler_worker.go @@ -8,6 +8,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/weaveworks/common/httpgrpc" "google.golang.org/grpc" @@ -197,12 +198,12 @@ func (w *frontendSchedulerWorker) stop() { } func (w *frontendSchedulerWorker) runOne(ctx context.Context, client schedulerpb.SchedulerForFrontendClient) { - backoffConfig := util.BackoffConfig{ + backoffConfig := backoff.Config{ MinBackoff: 50 * time.Millisecond, MaxBackoff: 1 * time.Second, } - backoff := util.NewBackoff(ctx, backoffConfig) + backoff := backoff.New(ctx, backoffConfig) for backoff.Ongoing() { loop, loopErr := client.FrontendLoop(ctx) if loopErr != nil { diff --git a/vendor/github.com/cortexproject/cortex/pkg/ingester/transfer.go b/vendor/github.com/cortexproject/cortex/pkg/ingester/transfer.go index 7425adbb1348..6d482bfdf06d 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ingester/transfer.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ingester/transfer.go @@ -9,6 +9,7 @@ import ( "time" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/weaveworks/common/user" @@ -17,7 +18,6 @@ import ( "github.com/cortexproject/cortex/pkg/cortexpb" "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/ring" - "github.com/cortexproject/cortex/pkg/util" ) var ( @@ -275,7 +275,7 @@ func (i *Ingester) TransferOut(ctx context.Context) error { if i.cfg.MaxTransferRetries <= 0 { return ring.ErrTransferDisabled } - backoff := util.NewBackoff(ctx, util.BackoffConfig{ + backoff := backoff.New(ctx, backoff.Config{ MinBackoff: 100 * time.Millisecond, MaxBackoff: 5 * time.Second, MaxRetries: i.cfg.MaxTransferRetries, diff --git a/vendor/github.com/cortexproject/cortex/pkg/querier/blocks_finder_bucket_scan.go b/vendor/github.com/cortexproject/cortex/pkg/querier/blocks_finder_bucket_scan.go index bfa20863132c..182041bcec87 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/querier/blocks_finder_bucket_scan.go +++ b/vendor/github.com/cortexproject/cortex/pkg/querier/blocks_finder_bucket_scan.go @@ -11,6 +11,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/oklog/ulid" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -270,7 +271,7 @@ pushJobsLoop: // scanUserBlocksWithRetries runs scanUserBlocks() retrying multiple times // in case of error. func (d *BucketScanBlocksFinder) scanUserBlocksWithRetries(ctx context.Context, userID string) (metas bucketindex.Blocks, deletionMarks map[ulid.ULID]*bucketindex.BlockDeletionMark, err error) { - retries := util.NewBackoff(ctx, util.BackoffConfig{ + retries := backoff.New(ctx, backoff.Config{ MinBackoff: time.Second, MaxBackoff: 30 * time.Second, MaxRetries: 3, diff --git a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/frontend_processor.go b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/frontend_processor.go index 7d25a964679c..3a6928cbb24f 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/frontend_processor.go +++ b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/frontend_processor.go @@ -8,17 +8,17 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/weaveworks/common/httpgrpc" "google.golang.org/grpc" "github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb" "github.com/cortexproject/cortex/pkg/querier/stats" querier_stats "github.com/cortexproject/cortex/pkg/querier/stats" - "github.com/cortexproject/cortex/pkg/util" ) var ( - processorBackoffConfig = util.BackoffConfig{ + processorBackoffConfig = backoff.Config{ MinBackoff: 50 * time.Millisecond, MaxBackoff: 1 * time.Second, } @@ -57,7 +57,7 @@ func (fp *frontendProcessor) notifyShutdown(ctx context.Context, conn *grpc.Clie func (fp *frontendProcessor) processQueriesOnSingleStream(ctx context.Context, conn *grpc.ClientConn, address string) { client := frontendv1pb.NewFrontendClient(conn) - backoff := util.NewBackoff(ctx, processorBackoffConfig) + backoff := backoff.New(ctx, processorBackoffConfig) for backoff.Ongoing() { c, err := client.Process(ctx) if err != nil { diff --git a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/scheduler_processor.go b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/scheduler_processor.go index cc3dc799148d..ee3f3c7cc190 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/scheduler_processor.go +++ b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/scheduler_processor.go @@ -6,6 +6,7 @@ import ( "net/http" "time" + "github.com/grafana/dskit/backoff" otgrpc "github.com/opentracing-contrib/go-grpc" "github.com/weaveworks/common/user" @@ -23,7 +24,6 @@ import ( querier_stats "github.com/cortexproject/cortex/pkg/querier/stats" "github.com/cortexproject/cortex/pkg/ring/client" "github.com/cortexproject/cortex/pkg/scheduler/schedulerpb" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/grpcclient" "github.com/cortexproject/cortex/pkg/util/grpcutil" util_log "github.com/cortexproject/cortex/pkg/util/log" @@ -87,7 +87,7 @@ func (sp *schedulerProcessor) notifyShutdown(ctx context.Context, conn *grpc.Cli func (sp *schedulerProcessor) processQueriesOnSingleStream(ctx context.Context, conn *grpc.ClientConn, address string) { schedulerClient := schedulerpb.NewSchedulerForQuerierClient(conn) - backoff := util.NewBackoff(ctx, processorBackoffConfig) + backoff := backoff.New(ctx, processorBackoffConfig) for backoff.Ongoing() { c, err := schedulerClient.QuerierLoop(ctx) if err == nil { diff --git a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/worker.go b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/worker.go index 6811c26f348b..c22856d3f751 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/querier/worker/worker.go +++ b/vendor/github.com/cortexproject/cortex/pkg/querier/worker/worker.go @@ -208,6 +208,8 @@ func (w *querierWorker) AddressRemoved(address string) { w.mu.Lock() p := w.managers[address] delete(w.managers, address) + // Called with lock. + w.resetConcurrency() w.mu.Unlock() if p != nil { diff --git a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/consul/client.go b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/consul/client.go index 1c39a473ced7..11c26df1088c 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/consul/client.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/consul/client.go @@ -10,13 +10,13 @@ import ( "time" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" consul "github.com/hashicorp/consul/api" "github.com/hashicorp/go-cleanhttp" "github.com/weaveworks/common/instrument" "golang.org/x/time/rate" "github.com/cortexproject/cortex/pkg/ring/kv/codec" - "github.com/cortexproject/cortex/pkg/util" util_log "github.com/cortexproject/cortex/pkg/util/log" ) @@ -30,7 +30,7 @@ var ( // ErrNotFound is returned by ConsulClient.Get. ErrNotFound = fmt.Errorf("Not found") - backoffConfig = util.BackoffConfig{ + backoffConfig = backoff.Config{ MinBackoff: 1 * time.Second, MaxBackoff: 1 * time.Minute, } @@ -203,7 +203,7 @@ func (c *Client) cas(ctx context.Context, key string, f func(in interface{}) (ou // into. This function blocks until the context is cancelled or f returns false. func (c *Client) WatchKey(ctx context.Context, key string, f func(interface{}) bool) { var ( - backoff = util.NewBackoff(ctx, backoffConfig) + backoff = backoff.New(ctx, backoffConfig) index = uint64(0) limiter = c.createRateLimiter() ) @@ -264,7 +264,7 @@ func (c *Client) WatchKey(ctx context.Context, key string, f func(interface{}) b // Values in Consul are assumed to be JSON. This function blocks until the context is cancelled. func (c *Client) WatchPrefix(ctx context.Context, prefix string, f func(string, interface{}) bool) { var ( - backoff = util.NewBackoff(ctx, backoffConfig) + backoff = backoff.New(ctx, backoffConfig) index = uint64(0) limiter = c.createRateLimiter() ) diff --git a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/etcd/etcd.go b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/etcd/etcd.go index 34999ab37129..0e8f612d0267 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/etcd/etcd.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/etcd/etcd.go @@ -8,12 +8,12 @@ import ( "time" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/pkg/errors" clientv3 "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/pkg/transport" "github.com/cortexproject/cortex/pkg/ring/kv/codec" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" cortex_tls "github.com/cortexproject/cortex/pkg/util/tls" @@ -178,7 +178,7 @@ func (c *Client) CAS(ctx context.Context, key string, f func(in interface{}) (ou // WatchKey implements kv.Client. func (c *Client) WatchKey(ctx context.Context, key string, f func(interface{}) bool) { - backoff := util.NewBackoff(ctx, util.BackoffConfig{ + backoff := backoff.New(ctx, backoff.Config{ MinBackoff: 1 * time.Second, MaxBackoff: 1 * time.Minute, }) @@ -214,7 +214,7 @@ outer: // WatchPrefix implements kv.Client. func (c *Client) WatchPrefix(ctx context.Context, key string, f func(string, interface{}) bool) { - backoff := util.NewBackoff(ctx, util.BackoffConfig{ + backoff := backoff.New(ctx, backoff.Config{ MinBackoff: 1 * time.Second, MaxBackoff: 1 * time.Minute, }) diff --git a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/memberlist/memberlist_client.go b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/memberlist/memberlist_client.go index 79432d4668df..29547c9ae6fb 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ring/kv/memberlist/memberlist_client.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ring/kv/memberlist/memberlist_client.go @@ -15,13 +15,13 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/hashicorp/memberlist" "github.com/prometheus/client_golang/prometheus" "github.com/thanos-io/thanos/pkg/discovery/dns" "github.com/thanos-io/thanos/pkg/extprom" "github.com/cortexproject/cortex/pkg/ring/kv/codec" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/services" @@ -512,13 +512,13 @@ func (m *KV) joinMembersOnStartup(ctx context.Context, members []string) error { level.Debug(m.logger).Log("msg", "attempt to join memberlist cluster failed", "retries", 0, "err", err) lastErr := err - cfg := util.BackoffConfig{ + cfg := backoff.Config{ MinBackoff: m.cfg.MinJoinBackoff, MaxBackoff: m.cfg.MaxJoinBackoff, MaxRetries: m.cfg.MaxJoinRetries, } - backoff := util.NewBackoff(ctx, cfg) + backoff := backoff.New(ctx, cfg) for backoff.Ongoing() { backoff.Wait() @@ -980,20 +980,8 @@ func (m *KV) NotifyMsg(msg []byte) { } else if version > 0 { m.notifyWatchers(kvPair.Key) - m.addSentMessage(message{ - Time: time.Now(), - Size: len(msg), - Pair: kvPair, - Version: version, - Changes: changes, - }) - - // Forward this message - // Memberlist will modify message once this function returns, so we need to make a copy - msgCopy := append([]byte(nil), msg...) - - // forward this message further - m.queueBroadcast(kvPair.Key, mod.MergeContent(), version, msgCopy) + // Don't resend original message, but only changes. + m.broadcastNewValue(kvPair.Key, mod, version, codec) } } @@ -1213,6 +1201,17 @@ func (m *KV) mergeValueForKey(key string, incomingValue Mergeable, casVersion ui total, removed := result.RemoveTombstones(limit) m.storeTombstones.WithLabelValues(key).Set(float64(total)) m.storeRemovedTombstones.WithLabelValues(key).Add(float64(removed)) + + // Remove tombstones from change too. If change turns out to be empty after this, + // we don't need to change local value either! + // + // Note that "result" and "change" may actually be the same Mergeable. That is why we + // call RemoveTombstones on "result" first, so that we get the correct metrics. Calling + // RemoveTombstones twice with same limit should be noop. + change.RemoveTombstones(limit) + if len(change.MergeContent()) == 0 { + return nil, 0, nil + } } newVersion := curr.version + 1 diff --git a/vendor/github.com/cortexproject/cortex/pkg/ring/lifecycler.go b/vendor/github.com/cortexproject/cortex/pkg/ring/lifecycler.go index 37897b70ba54..6a0f6cb67829 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ring/lifecycler.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ring/lifecycler.go @@ -576,7 +576,8 @@ func (i *Lifecycler) initRing(ctx context.Context) error { return ringDesc, true, nil } - // If the ingester failed to clean it's ring entry up in can leave it's state in LEAVING. + // If the ingester failed to clean its ring entry up in can leave its state in LEAVING + // OR unregister_on_shutdown=false // Move it into ACTIVE to ensure the ingester joins the ring. if instanceDesc.State == LEAVING && len(instanceDesc.Tokens) == i.cfg.NumTokens { instanceDesc.State = ACTIVE @@ -588,6 +589,17 @@ func (i *Lifecycler) initRing(ctx context.Context) error { i.setTokens(tokens) level.Info(log.Logger).Log("msg", "existing entry found in ring", "state", i.GetState(), "tokens", len(tokens), "ring", i.RingName) + + // Update the ring if the instance has been changed and the heartbeat is disabled. + // We dont need to update KV here when heartbeat is enabled as this info will eventually be update on KV + // on the next heartbeat + if i.cfg.HeartbeatPeriod == 0 && !instanceDesc.Equal(ringDesc.Ingesters[i.ID]) { + // Update timestamp to give gossiping client a chance register ring change. + instanceDesc.Timestamp = time.Now().Unix() + ringDesc.Ingesters[i.ID] = instanceDesc + return ringDesc, true, nil + } + // we haven't modified the ring, don't try to store it. return nil, true, nil }) diff --git a/vendor/github.com/cortexproject/cortex/pkg/ring/util.go b/vendor/github.com/cortexproject/cortex/pkg/ring/util.go index 06e053dd2691..7754ec49d595 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ring/util.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ring/util.go @@ -6,6 +6,8 @@ import ( "sort" "time" + "github.com/grafana/dskit/backoff" + "github.com/cortexproject/cortex/pkg/util" ) @@ -70,7 +72,7 @@ func GetInstancePort(configPort, listenPort int) int { // WaitInstanceState waits until the input instanceID is registered within the // ring matching the provided state. A timeout should be provided within the context. func WaitInstanceState(ctx context.Context, r ReadRing, instanceID string, state InstanceState) error { - backoff := util.NewBackoff(ctx, util.BackoffConfig{ + backoff := backoff.New(ctx, backoff.Config{ MinBackoff: 100 * time.Millisecond, MaxBackoff: time.Second, MaxRetries: 0, diff --git a/vendor/github.com/cortexproject/cortex/pkg/storegateway/bucket_stores.go b/vendor/github.com/cortexproject/cortex/pkg/storegateway/bucket_stores.go index 3c3da94b06ab..4c677c7c2fd3 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/storegateway/bucket_stores.go +++ b/vendor/github.com/cortexproject/cortex/pkg/storegateway/bucket_stores.go @@ -14,6 +14,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/dskit/backoff" "github.com/oklog/ulid" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -34,7 +35,6 @@ import ( "github.com/cortexproject/cortex/pkg/storage/bucket" "github.com/cortexproject/cortex/pkg/storage/tsdb" - "github.com/cortexproject/cortex/pkg/util" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/spanlogger" "github.com/cortexproject/cortex/pkg/util/validation" @@ -160,7 +160,7 @@ func (u *BucketStores) SyncBlocks(ctx context.Context) error { } func (u *BucketStores) syncUsersBlocksWithRetries(ctx context.Context, f func(context.Context, *store.BucketStore) error) error { - retries := util.NewBackoff(ctx, util.BackoffConfig{ + retries := backoff.New(ctx, backoff.Config{ MinBackoff: 1 * time.Second, MaxBackoff: 10 * time.Second, MaxRetries: 3, diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/backoff_retry.go b/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/backoff_retry.go index 2c8cc5dcadb1..70ab38c6b734 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/backoff_retry.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/backoff_retry.go @@ -3,17 +3,16 @@ package grpcclient import ( "context" + "github.com/grafana/dskit/backoff" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - - "github.com/cortexproject/cortex/pkg/util" ) // NewBackoffRetry gRPC middleware. -func NewBackoffRetry(cfg util.BackoffConfig) grpc.UnaryClientInterceptor { +func NewBackoffRetry(cfg backoff.Config) grpc.UnaryClientInterceptor { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { - backoff := util.NewBackoff(ctx, cfg) + backoff := backoff.New(ctx, cfg) for backoff.Ongoing() { err := invoker(ctx, method, req, reply, cc, opts...) if err == nil { diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/grpcclient.go b/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/grpcclient.go index e876804c4b41..dc5b11b4d347 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/grpcclient.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/grpcclient/grpcclient.go @@ -5,13 +5,13 @@ import ( "time" "github.com/go-kit/kit/log" + "github.com/grafana/dskit/backoff" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/keepalive" - "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/grpc/encoding/snappy" "github.com/cortexproject/cortex/pkg/util/tls" ) @@ -24,8 +24,8 @@ type Config struct { RateLimit float64 `yaml:"rate_limit"` RateLimitBurst int `yaml:"rate_limit_burst"` - BackoffOnRatelimits bool `yaml:"backoff_on_ratelimits"` - BackoffConfig util.BackoffConfig `yaml:"backoff_config"` + BackoffOnRatelimits bool `yaml:"backoff_on_ratelimits"` + BackoffConfig backoff.Config `yaml:"backoff_config"` TLSEnabled bool `yaml:"tls_enabled"` TLS tls.ClientConfig `yaml:",inline"` @@ -46,7 +46,7 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { f.BoolVar(&cfg.BackoffOnRatelimits, prefix+".backoff-on-ratelimits", false, "Enable backoff and retry when we hit ratelimits.") f.BoolVar(&cfg.TLSEnabled, prefix+".tls-enabled", cfg.TLSEnabled, "Enable TLS in the GRPC client. This flag needs to be enabled when any other TLS flag is set. If set to false, insecure connection to gRPC server will be used.") - cfg.BackoffConfig.RegisterFlags(prefix, f) + cfg.BackoffConfig.RegisterFlagsWithPrefix(prefix, f) cfg.TLS.RegisterFlagsWithPrefix(prefix, f) } diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/module_service.go b/vendor/github.com/cortexproject/cortex/pkg/util/module_service.go index 0d4fb43d1f2b..1caa3cfe3ae4 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/module_service.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/module_service.go @@ -4,10 +4,10 @@ import ( "context" "fmt" + "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" - util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/services" ) @@ -18,6 +18,7 @@ type moduleService struct { service services.Service name string + logger log.Logger // startDeps, stopDeps return map of service names to services startDeps, stopDeps func(string) map[string]services.Service @@ -26,9 +27,10 @@ type moduleService struct { // NewModuleService wraps a module service, and makes sure that dependencies are started/stopped before module service starts or stops. // If any dependency fails to start, this service fails as well. // On stop, errors from failed dependencies are ignored. -func NewModuleService(name string, service services.Service, startDeps, stopDeps func(string) map[string]services.Service) services.Service { +func NewModuleService(name string, logger log.Logger, service services.Service, startDeps, stopDeps func(string) map[string]services.Service) services.Service { w := &moduleService{ name: name, + logger: logger, service: service, startDeps: startDeps, stopDeps: stopDeps, @@ -46,7 +48,7 @@ func (w *moduleService) start(serviceContext context.Context) error { continue } - level.Debug(util_log.Logger).Log("msg", "module waiting for initialization", "module", w.name, "waiting_for", m) + level.Debug(w.logger).Log("msg", "module waiting for initialization", "module", w.name, "waiting_for", m) err := s.AwaitRunning(serviceContext) if err != nil { @@ -56,7 +58,7 @@ func (w *moduleService) start(serviceContext context.Context) error { // we don't want to let this service to stop until all dependant services are stopped, // so we use independent context here - level.Info(util_log.Logger).Log("msg", "initialising", "module", w.name) + level.Info(w.logger).Log("msg", "initialising", "module", w.name) err := w.service.StartAsync(context.Background()) if err != nil { return errors.Wrapf(err, "error starting module: %s", w.name) @@ -78,7 +80,7 @@ func (w *moduleService) stop(_ error) error { // Only wait for other modules, if underlying service is still running. w.waitForModulesToStop() - level.Debug(util_log.Logger).Log("msg", "stopping", "module", w.name) + level.Debug(w.logger).Log("msg", "stopping", "module", w.name) err = services.StopAndAwaitTerminated(context.Background(), w.service) } else { @@ -86,9 +88,9 @@ func (w *moduleService) stop(_ error) error { } if err != nil && err != ErrStopProcess { - level.Warn(util_log.Logger).Log("msg", "module failed with error", "module", w.name, "err", err) + level.Warn(w.logger).Log("msg", "module failed with error", "module", w.name, "err", err) } else { - level.Info(util_log.Logger).Log("msg", "module stopped", "module", w.name) + level.Info(w.logger).Log("msg", "module stopped", "module", w.name) } return err } @@ -101,7 +103,7 @@ func (w *moduleService) waitForModulesToStop() { continue } - level.Debug(util_log.Logger).Log("msg", "module waiting for", "module", w.name, "waiting_for", n) + level.Debug(w.logger).Log("msg", "module waiting for", "module", w.name, "waiting_for", n) // Passed context isn't canceled, so we can only get error here, if service // fails. But we don't care *how* service stops, as long as it is done. _ = s.AwaitTerminated(context.Background()) diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/modules/module_service_wrapper.go b/vendor/github.com/cortexproject/cortex/pkg/util/modules/module_service_wrapper.go index 73f1014bd583..e91d39474de8 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/modules/module_service_wrapper.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/modules/module_service_wrapper.go @@ -1,13 +1,15 @@ package modules import ( + "github.com/go-kit/kit/log" + "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/services" ) // This function wraps module service, and adds waiting for dependencies to start before starting, // and dependant modules to stop before stopping this module service. -func newModuleServiceWrapper(serviceMap map[string]services.Service, mod string, modServ services.Service, startDeps []string, stopDeps []string) services.Service { +func newModuleServiceWrapper(serviceMap map[string]services.Service, mod string, logger log.Logger, modServ services.Service, startDeps []string, stopDeps []string) services.Service { getDeps := func(deps []string) map[string]services.Service { r := map[string]services.Service{} for _, m := range deps { @@ -19,7 +21,7 @@ func newModuleServiceWrapper(serviceMap map[string]services.Service, mod string, return r } - return util.NewModuleService(mod, modServ, + return util.NewModuleService(mod, logger, modServ, func(_ string) map[string]services.Service { return getDeps(startDeps) }, diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/modules/modules.go b/vendor/github.com/cortexproject/cortex/pkg/util/modules/modules.go index 918e66f88806..a029cacf02b5 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/modules/modules.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/modules/modules.go @@ -4,6 +4,7 @@ import ( "fmt" "sort" + "github.com/go-kit/kit/log" "github.com/pkg/errors" "github.com/cortexproject/cortex/pkg/util/services" @@ -25,6 +26,7 @@ type module struct { // in the right order of dependencies. type Manager struct { modules map[string]*module + logger log.Logger } // UserInvisibleModule is an option for `RegisterModule` that marks module not visible to user. Modules are user visible by default. @@ -33,9 +35,10 @@ func UserInvisibleModule(m *module) { } // NewManager creates a new Manager -func NewManager() *Manager { +func NewManager(logger log.Logger) *Manager { return &Manager{ modules: make(map[string]*module), + logger: logger, } } @@ -108,7 +111,7 @@ func (m *Manager) initModule(name string, initMap map[string]bool, servicesMap m if s != nil { // We pass servicesMap, which isn't yet complete. By the time service starts, // it will be fully built, so there is no need for extra synchronization. - serv = newModuleServiceWrapper(servicesMap, n, s, m.DependenciesForModule(n), m.findInverseDependencies(n, deps[ix+1:])) + serv = newModuleServiceWrapper(servicesMap, n, m.logger, s, m.DependenciesForModule(n), m.findInverseDependencies(n, deps[ix+1:])) } } diff --git a/vendor/github.com/cortexproject/cortex/pkg/util/validation/notifications_limit_flag.go b/vendor/github.com/cortexproject/cortex/pkg/util/validation/notifications_limit_flag.go index c49bb8c1d3e8..97f2901d5b4f 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/util/validation/notifications_limit_flag.go +++ b/vendor/github.com/cortexproject/cortex/pkg/util/validation/notifications_limit_flag.go @@ -10,7 +10,7 @@ import ( ) var allowedIntegrationNames = []string{ - "webhook", "email", "pagerduty", "opsgenie", "wechat", "slack", "victorops", "pushover", + "webhook", "email", "pagerduty", "opsgenie", "wechat", "slack", "victorops", "pushover", "sns", } type NotificationRateLimitMap map[string]float64 diff --git a/vendor/github.com/dimchansky/utfbom/.gitignore b/vendor/github.com/dimchansky/utfbom/.gitignore new file mode 100644 index 000000000000..d7ec5cebb98d --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/.gitignore @@ -0,0 +1,37 @@ +# Binaries for programs and plugins +*.exe +*.dll +*.so +*.dylib +*.o +*.a + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.prof + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 +.glide/ + +# Gogland +.idea/ \ No newline at end of file diff --git a/vendor/github.com/dimchansky/utfbom/.travis.yml b/vendor/github.com/dimchansky/utfbom/.travis.yml new file mode 100644 index 000000000000..19312ee35fc0 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/.travis.yml @@ -0,0 +1,29 @@ +language: go +sudo: false + +go: + - 1.10.x + - 1.11.x + - 1.12.x + - 1.13.x + - 1.14.x + - 1.15.x + +cache: + directories: + - $HOME/.cache/go-build + - $HOME/gopath/pkg/mod + +env: + global: + - GO111MODULE=on + +before_install: + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover + - go get golang.org/x/tools/cmd/goimports + - go get golang.org/x/lint/golint +script: + - gofiles=$(find ./ -name '*.go') && [ -z "$gofiles" ] || unformatted=$(goimports -l $gofiles) && [ -z "$unformatted" ] || (echo >&2 "Go files must be formatted with gofmt. Following files has problem:\n $unformatted" && false) + - golint ./... # This won't break the build, just show warnings + - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/dimchansky/utfbom/LICENSE b/vendor/github.com/dimchansky/utfbom/LICENSE new file mode 100644 index 000000000000..6279cb87f434 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2018-2020, Dmitrij Koniajev (dimchansky@gmail.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/dimchansky/utfbom/README.md b/vendor/github.com/dimchansky/utfbom/README.md new file mode 100644 index 000000000000..8ece280089a5 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/README.md @@ -0,0 +1,66 @@ +# utfbom [![Godoc](https://godoc.org/github.com/dimchansky/utfbom?status.png)](https://godoc.org/github.com/dimchansky/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Build Status](https://travis-ci.org/dimchansky/utfbom.svg?branch=master)](https://travis-ci.org/dimchansky/utfbom) [![Go Report Card](https://goreportcard.com/badge/github.com/dimchansky/utfbom)](https://goreportcard.com/report/github.com/dimchansky/utfbom) [![Coverage Status](https://coveralls.io/repos/github/dimchansky/utfbom/badge.svg?branch=master)](https://coveralls.io/github/dimchansky/utfbom?branch=master) + +The package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It can also return the encoding detected by the BOM. + +## Installation + + go get -u github.com/dimchansky/utfbom + +## Example + +```go +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + + "github.com/dimchansky/utfbom" +) + +func main() { + trySkip([]byte("\xEF\xBB\xBFhello")) + trySkip([]byte("hello")) +} + +func trySkip(byteData []byte) { + fmt.Println("Input:", byteData) + + // just skip BOM + output, err := ioutil.ReadAll(utfbom.SkipOnly(bytes.NewReader(byteData))) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("ReadAll with BOM skipping", output) + + // skip BOM and detect encoding + sr, enc := utfbom.Skip(bytes.NewReader(byteData)) + fmt.Printf("Detected encoding: %s\n", enc) + output, err = ioutil.ReadAll(sr) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("ReadAll with BOM detection and skipping", output) + fmt.Println() +} +``` + +Output: + +``` +$ go run main.go +Input: [239 187 191 104 101 108 108 111] +ReadAll with BOM skipping [104 101 108 108 111] +Detected encoding: UTF8 +ReadAll with BOM detection and skipping [104 101 108 108 111] + +Input: [104 101 108 108 111] +ReadAll with BOM skipping [104 101 108 108 111] +Detected encoding: Unknown +ReadAll with BOM detection and skipping [104 101 108 108 111] +``` + + diff --git a/vendor/github.com/dimchansky/utfbom/go.mod b/vendor/github.com/dimchansky/utfbom/go.mod new file mode 100644 index 000000000000..8f8620af3b50 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/go.mod @@ -0,0 +1 @@ +module github.com/dimchansky/utfbom diff --git a/vendor/github.com/dimchansky/utfbom/utfbom.go b/vendor/github.com/dimchansky/utfbom/utfbom.go new file mode 100644 index 000000000000..77a303e564b1 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/utfbom.go @@ -0,0 +1,192 @@ +// Package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. +// It wraps an io.Reader object, creating another object (Reader) that also implements the io.Reader +// interface but provides automatic BOM checking and removing as necessary. +package utfbom + +import ( + "errors" + "io" +) + +// Encoding is type alias for detected UTF encoding. +type Encoding int + +// Constants to identify detected UTF encodings. +const ( + // Unknown encoding, returned when no BOM was detected + Unknown Encoding = iota + + // UTF8, BOM bytes: EF BB BF + UTF8 + + // UTF-16, big-endian, BOM bytes: FE FF + UTF16BigEndian + + // UTF-16, little-endian, BOM bytes: FF FE + UTF16LittleEndian + + // UTF-32, big-endian, BOM bytes: 00 00 FE FF + UTF32BigEndian + + // UTF-32, little-endian, BOM bytes: FF FE 00 00 + UTF32LittleEndian +) + +// String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface. +func (e Encoding) String() string { + switch e { + case UTF8: + return "UTF8" + case UTF16BigEndian: + return "UTF16BigEndian" + case UTF16LittleEndian: + return "UTF16LittleEndian" + case UTF32BigEndian: + return "UTF32BigEndian" + case UTF32LittleEndian: + return "UTF32LittleEndian" + default: + return "Unknown" + } +} + +const maxConsecutiveEmptyReads = 100 + +// Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. +// It also returns the encoding detected by the BOM. +// If the detected encoding is not needed, you can call the SkipOnly function. +func Skip(rd io.Reader) (*Reader, Encoding) { + // Is it already a Reader? + b, ok := rd.(*Reader) + if ok { + return b, Unknown + } + + enc, left, err := detectUtf(rd) + return &Reader{ + rd: rd, + buf: left, + err: err, + }, enc +} + +// SkipOnly creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. +func SkipOnly(rd io.Reader) *Reader { + r, _ := Skip(rd) + return r +} + +// Reader implements automatic BOM (Unicode Byte Order Mark) checking and +// removing as necessary for an io.Reader object. +type Reader struct { + rd io.Reader // reader provided by the client + buf []byte // buffered data + err error // last error +} + +// Read is an implementation of io.Reader interface. +// The bytes are taken from the underlying Reader, but it checks for BOMs, removing them as necessary. +func (r *Reader) Read(p []byte) (n int, err error) { + if len(p) == 0 { + return 0, nil + } + + if r.buf == nil { + if r.err != nil { + return 0, r.readErr() + } + + return r.rd.Read(p) + } + + // copy as much as we can + n = copy(p, r.buf) + r.buf = nilIfEmpty(r.buf[n:]) + return n, nil +} + +func (r *Reader) readErr() error { + err := r.err + r.err = nil + return err +} + +var errNegativeRead = errors.New("utfbom: reader returned negative count from Read") + +func detectUtf(rd io.Reader) (enc Encoding, buf []byte, err error) { + buf, err = readBOM(rd) + + if len(buf) >= 4 { + if isUTF32BigEndianBOM4(buf) { + return UTF32BigEndian, nilIfEmpty(buf[4:]), err + } + if isUTF32LittleEndianBOM4(buf) { + return UTF32LittleEndian, nilIfEmpty(buf[4:]), err + } + } + + if len(buf) > 2 && isUTF8BOM3(buf) { + return UTF8, nilIfEmpty(buf[3:]), err + } + + if (err != nil && err != io.EOF) || (len(buf) < 2) { + return Unknown, nilIfEmpty(buf), err + } + + if isUTF16BigEndianBOM2(buf) { + return UTF16BigEndian, nilIfEmpty(buf[2:]), err + } + if isUTF16LittleEndianBOM2(buf) { + return UTF16LittleEndian, nilIfEmpty(buf[2:]), err + } + + return Unknown, nilIfEmpty(buf), err +} + +func readBOM(rd io.Reader) (buf []byte, err error) { + const maxBOMSize = 4 + var bom [maxBOMSize]byte // used to read BOM + + // read as many bytes as possible + for nEmpty, n := 0, 0; err == nil && len(buf) < maxBOMSize; buf = bom[:len(buf)+n] { + if n, err = rd.Read(bom[len(buf):]); n < 0 { + panic(errNegativeRead) + } + if n > 0 { + nEmpty = 0 + } else { + nEmpty++ + if nEmpty >= maxConsecutiveEmptyReads { + err = io.ErrNoProgress + } + } + } + return +} + +func isUTF32BigEndianBOM4(buf []byte) bool { + return buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0xFE && buf[3] == 0xFF +} + +func isUTF32LittleEndianBOM4(buf []byte) bool { + return buf[0] == 0xFF && buf[1] == 0xFE && buf[2] == 0x00 && buf[3] == 0x00 +} + +func isUTF8BOM3(buf []byte) bool { + return buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF +} + +func isUTF16BigEndianBOM2(buf []byte) bool { + return buf[0] == 0xFE && buf[1] == 0xFF +} + +func isUTF16LittleEndianBOM2(buf []byte) bool { + return buf[0] == 0xFF && buf[1] == 0xFE +} + +func nilIfEmpty(buf []byte) (res []byte) { + if len(buf) > 0 { + res = buf + } + return +} diff --git a/vendor/github.com/go-kit/kit/log/doc.go b/vendor/github.com/go-kit/kit/log/doc.go index 918c0af46f57..f744382fe499 100644 --- a/vendor/github.com/go-kit/kit/log/doc.go +++ b/vendor/github.com/go-kit/kit/log/doc.go @@ -39,8 +39,8 @@ // // A contextual logger stores keyvals that it includes in all log events. // Building appropriate contextual loggers reduces repetition and aids -// consistency in the resulting log output. With and WithPrefix add context to -// a logger. We can use With to improve the RunTask example. +// consistency in the resulting log output. With, WithPrefix, and WithSuffix +// add context to a logger. We can use With to improve the RunTask example. // // func RunTask(task Task, logger log.Logger) string { // logger = log.With(logger, "taskID", task.ID) diff --git a/vendor/github.com/go-kit/kit/log/level/level.go b/vendor/github.com/go-kit/kit/log/level/level.go index fceafc454a5d..c0c050f72ff2 100644 --- a/vendor/github.com/go-kit/kit/log/level/level.go +++ b/vendor/github.com/go-kit/kit/log/level/level.go @@ -172,7 +172,7 @@ func WarnValue() Value { return warnValue } // InfoValue returns the unique value added to log events by Info. func InfoValue() Value { return infoValue } -// DebugValue returns the unique value added to log events by Warn. +// DebugValue returns the unique value added to log events by Debug. func DebugValue() Value { return debugValue } var ( diff --git a/vendor/github.com/go-kit/kit/log/log.go b/vendor/github.com/go-kit/kit/log/log.go index 66a9e2fde79d..29b3b82ffbb1 100644 --- a/vendor/github.com/go-kit/kit/log/log.go +++ b/vendor/github.com/go-kit/kit/log/log.go @@ -16,8 +16,8 @@ type Logger interface { var ErrMissingValue = errors.New("(MISSING)") // With returns a new contextual logger with keyvals prepended to those passed -// to calls to Log. If logger is also a contextual logger created by With or -// WithPrefix, keyvals is appended to the existing context. +// to calls to Log. If logger is also a contextual logger created by With, +// WithPrefix, or WithSuffix, keyvals is appended to the existing context. // // The returned Logger replaces all value elements (odd indexes) containing a // Valuer with their generated value for each call to its Log method. @@ -36,14 +36,16 @@ func With(logger Logger, keyvals ...interface{}) Logger { // backing array is created if the slice must grow in Log or With. // Using the extra capacity without copying risks a data race that // would violate the Logger interface contract. - keyvals: kvs[:len(kvs):len(kvs)], - hasValuer: l.hasValuer || containsValuer(keyvals), + keyvals: kvs[:len(kvs):len(kvs)], + hasValuer: l.hasValuer || containsValuer(keyvals), + sKeyvals: l.sKeyvals, + sHasValuer: l.sHasValuer, } } // WithPrefix returns a new contextual logger with keyvals prepended to those // passed to calls to Log. If logger is also a contextual logger created by -// With or WithPrefix, keyvals is prepended to the existing context. +// With, WithPrefix, or WithSuffix, keyvals is prepended to the existing context. // // The returned Logger replaces all value elements (odd indexes) containing a // Valuer with their generated value for each call to its Log method. @@ -67,16 +69,52 @@ func WithPrefix(logger Logger, keyvals ...interface{}) Logger { } kvs = append(kvs, l.keyvals...) return &context{ - logger: l.logger, - keyvals: kvs, - hasValuer: l.hasValuer || containsValuer(keyvals), + logger: l.logger, + keyvals: kvs, + hasValuer: l.hasValuer || containsValuer(keyvals), + sKeyvals: l.sKeyvals, + sHasValuer: l.sHasValuer, } } -// context is the Logger implementation returned by With and WithPrefix. It -// wraps a Logger and holds keyvals that it includes in all log events. Its -// Log method calls bindValues to generate values for each Valuer in the -// context keyvals. +// WithSuffix returns a new contextual logger with keyvals appended to those +// passed to calls to Log. If logger is also a contextual logger created by +// With, WithPrefix, or WithSuffix, keyvals is appended to the existing context. +// +// The returned Logger replaces all value elements (odd indexes) containing a +// Valuer with their generated value for each call to its Log method. +func WithSuffix(logger Logger, keyvals ...interface{}) Logger { + if len(keyvals) == 0 { + return logger + } + l := newContext(logger) + // Limiting the capacity of the stored keyvals ensures that a new + // backing array is created if the slice must grow in Log or With. + // Using the extra capacity without copying risks a data race that + // would violate the Logger interface contract. + n := len(l.sKeyvals) + len(keyvals) + if len(keyvals)%2 != 0 { + n++ + } + kvs := make([]interface{}, 0, n) + kvs = append(kvs, keyvals...) + if len(kvs)%2 != 0 { + kvs = append(kvs, ErrMissingValue) + } + kvs = append(l.sKeyvals, kvs...) + return &context{ + logger: l.logger, + keyvals: l.keyvals, + hasValuer: l.hasValuer, + sKeyvals: kvs, + sHasValuer: l.sHasValuer || containsValuer(keyvals), + } +} + +// context is the Logger implementation returned by With, WithPrefix, and +// WithSuffix. It wraps a Logger and holds keyvals that it includes in all +// log events. Its Log method calls bindValues to generate values for each +// Valuer in the context keyvals. // // A context must always have the same number of stack frames between calls to // its Log method and the eventual binding of Valuers to their value. This @@ -89,13 +127,15 @@ func WithPrefix(logger Logger, keyvals ...interface{}) Logger { // // 1. newContext avoids introducing an additional layer when asked to // wrap another context. -// 2. With and WithPrefix avoid introducing an additional layer by -// returning a newly constructed context with a merged keyvals rather -// than simply wrapping the existing context. +// 2. With, WithPrefix, and WithSuffix avoid introducing an additional +// layer by returning a newly constructed context with a merged keyvals +// rather than simply wrapping the existing context. type context struct { - logger Logger - keyvals []interface{} - hasValuer bool + logger Logger + keyvals []interface{} + sKeyvals []interface{} // suffixes + hasValuer bool + sHasValuer bool } func newContext(logger Logger) *context { @@ -119,7 +159,11 @@ func (l *context) Log(keyvals ...interface{}) error { if len(keyvals) == 0 { kvs = append([]interface{}{}, l.keyvals...) } - bindValues(kvs[:len(l.keyvals)]) + bindValues(kvs[:(len(l.keyvals))]) + } + kvs = append(kvs, l.sKeyvals...) + if l.sHasValuer { + bindValues(kvs[len(kvs) - len(l.sKeyvals):]) } return l.logger.Log(kvs...) } diff --git a/vendor/github.com/go-kit/kit/log/stdlib.go b/vendor/github.com/go-kit/kit/log/stdlib.go index ff96b5dee525..0338edbe2ba3 100644 --- a/vendor/github.com/go-kit/kit/log/stdlib.go +++ b/vendor/github.com/go-kit/kit/log/stdlib.go @@ -1,6 +1,7 @@ package log import ( + "bytes" "io" "log" "regexp" @@ -26,9 +27,11 @@ func (w StdlibWriter) Write(p []byte) (int, error) { // messages, and place them under relevant keys. type StdlibAdapter struct { Logger - timestampKey string - fileKey string - messageKey string + timestampKey string + fileKey string + messageKey string + prefix string + joinPrefixToMsg bool } // StdlibAdapterOption sets a parameter for the StdlibAdapter. @@ -49,6 +52,16 @@ func MessageKey(key string) StdlibAdapterOption { return func(a *StdlibAdapter) { a.messageKey = key } } +// Prefix configures the adapter to parse a prefix from stdlib log events. If +// you provide a non-empty prefix to the stdlib logger, then your should provide +// that same prefix to the adapter via this option. +// +// By default, the prefix isn't included in the msg key. Set joinPrefixToMsg to +// true if you want to include the parsed prefix in the msg. +func Prefix(prefix string, joinPrefixToMsg bool) StdlibAdapterOption { + return func(a *StdlibAdapter) { a.prefix = prefix; a.joinPrefixToMsg = joinPrefixToMsg } +} + // NewStdlibAdapter returns a new StdlibAdapter wrapper around the passed // logger. It's designed to be passed to log.SetOutput. func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { @@ -65,6 +78,8 @@ func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { } func (a StdlibAdapter) Write(p []byte) (int, error) { + p = a.handlePrefix(p) + result := subexps(p) keyvals := []interface{}{} var timestamp string @@ -84,6 +99,7 @@ func (a StdlibAdapter) Write(p []byte) (int, error) { keyvals = append(keyvals, a.fileKey, file) } if msg, ok := result["msg"]; ok { + msg = a.handleMessagePrefix(msg) keyvals = append(keyvals, a.messageKey, msg) } if err := a.Logger.Log(keyvals...); err != nil { @@ -92,11 +108,30 @@ func (a StdlibAdapter) Write(p []byte) (int, error) { return len(p), nil } +func (a StdlibAdapter) handlePrefix(p []byte) []byte { + if a.prefix != "" { + p = bytes.TrimPrefix(p, []byte(a.prefix)) + } + return p +} + +func (a StdlibAdapter) handleMessagePrefix(msg string) string { + if a.prefix == "" { + return msg + } + + msg = strings.TrimPrefix(msg, a.prefix) + if a.joinPrefixToMsg { + msg = a.prefix + msg + } + return msg +} + const ( logRegexpDate = `(?P[0-9]{4}/[0-9]{2}/[0-9]{2})?[ ]?` logRegexpTime = `(?P