Upgrade AWS SDK to the latest version

This commit is contained in:
Andrey Smirnov
2017-09-28 17:57:05 +03:00
parent 9a767b7631
commit 182c21e38c
1096 changed files with 309697 additions and 132612 deletions
+801 -213
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
package kinesis
import (
"time"
"github.com/aws/aws-sdk-go/aws/request"
)
var readDuration = 5 * time.Second
func init() {
ops := []string{
opGetRecords,
}
initRequest = func(r *request.Request) {
for _, operation := range ops {
if r.Operation.Name == operation {
r.ApplyOptions(request.WithResponseReadTimeout(readDuration))
}
}
}
}
@@ -0,0 +1,89 @@
package kinesis
import (
"io"
"net/http"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/awstesting/unit"
)
type testReader struct {
duration time.Duration
}
func (r *testReader) Read(b []byte) (int, error) {
time.Sleep(r.duration)
return 0, io.EOF
}
func (r *testReader) Close() error {
return nil
}
// GetRecords will hang unexpectedly during reads.
// See https://github.com/aws/aws-sdk-go/issues/1141
func TestKinesisGetRecordsCustomization(t *testing.T) {
readDuration = time.Millisecond
retryCount := 0
svc := New(unit.Session, &aws.Config{
MaxRetries: aws.Int(4),
})
req, _ := svc.GetRecordsRequest(&GetRecordsInput{
ShardIterator: aws.String("foo"),
})
req.Handlers.Send.Clear()
req.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = &http.Response{
StatusCode: 200,
Header: http.Header{
"X-Amz-Request-Id": []string{"abc123"},
},
Body: &testReader{duration: 10 * time.Second},
ContentLength: -1,
}
r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode)
retryCount++
})
req.ApplyOptions(request.WithResponseReadTimeout(time.Second))
err := req.Send()
if err == nil {
t.Errorf("Expected error, but received nil")
} else if v, ok := err.(awserr.Error); !ok {
t.Errorf("Expected awserr.Error but received %v", err)
} else if v.Code() != request.ErrCodeResponseTimeout {
t.Errorf("Expected 'RequestTimeout' error, but received %s instead", v.Code())
}
if retryCount != 5 {
t.Errorf("Expected '5' retries, but received %d", retryCount)
}
}
func TestKinesisGetRecordsNoTimeout(t *testing.T) {
readDuration = time.Second
svc := New(unit.Session)
req, _ := svc.GetRecordsRequest(&GetRecordsInput{
ShardIterator: aws.String("foo"),
})
req.Handlers.Send.Clear()
req.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = &http.Response{
StatusCode: 200,
Header: http.Header{
"X-Amz-Request-Id": []string{"abc123"},
},
Body: &testReader{duration: time.Duration(0)},
ContentLength: -1,
}
r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode)
})
req.ApplyOptions(request.WithResponseReadTimeout(time.Second))
err := req.Send()
if err != nil {
t.Errorf("Expected no error, but received %v", err)
}
}
+29
View File
@@ -0,0 +1,29 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package kinesis provides the client and types for making API
// requests to Amazon Kinesis.
//
// Amazon Kinesis Streams is a managed service that scales elastically for real
// time processing of streaming big data.
//
// See https://docs.aws.amazon.com/goto/WebAPI/kinesis-2013-12-02 for more information on this service.
//
// See kinesis package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/kinesis/
//
// Using the Client
//
// To Amazon Kinesis 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 Kinesis client Kinesis for more
// information on creating client for this service.
// https://docs.aws.amazon.com/sdk-for-go/api/service/kinesis/#New
package kinesis
+44 -1
View File
@@ -1,4 +1,4 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package kinesis
@@ -17,6 +17,49 @@ const (
// be used. For more information, see the returned message.
ErrCodeInvalidArgumentException = "InvalidArgumentException"
// ErrCodeKMSAccessDeniedException for service response error code
// "KMSAccessDeniedException".
//
// The ciphertext references a key that doesn't exist or that you don't have
// access to.
ErrCodeKMSAccessDeniedException = "KMSAccessDeniedException"
// ErrCodeKMSDisabledException for service response error code
// "KMSDisabledException".
//
// The request was rejected because the specified CMK isn't enabled.
ErrCodeKMSDisabledException = "KMSDisabledException"
// ErrCodeKMSInvalidStateException for service response error code
// "KMSInvalidStateException".
//
// 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 (http://docs.aws.amazon.com/kms/latest/developerguide/key-state.html)
// in the AWS Key Management Service Developer Guide.
ErrCodeKMSInvalidStateException = "KMSInvalidStateException"
// ErrCodeKMSNotFoundException for service response error code
// "KMSNotFoundException".
//
// The request was rejected because the specified entity or resource couldn't
// be found.
ErrCodeKMSNotFoundException = "KMSNotFoundException"
// 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
// "KMSThrottlingException".
//
// The request was denied due to request throttling. For more information about
// throttling, see Limits (http://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second)
// in the AWS Key Management Service Developer Guide.
ErrCodeKMSThrottlingException = "KMSThrottlingException"
// ErrCodeLimitExceededException for service response error code
// "LimitExceededException".
//
-460
View File
@@ -1,460 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
package kinesis_test
import (
"bytes"
"fmt"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
)
var _ time.Duration
var _ bytes.Buffer
func ExampleKinesis_AddTagsToStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.AddTagsToStreamInput{
StreamName: aws.String("StreamName"), // Required
Tags: map[string]*string{ // Required
"Key": aws.String("TagValue"), // Required
// More values...
},
}
resp, err := svc.AddTagsToStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_CreateStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.CreateStreamInput{
ShardCount: aws.Int64(1), // Required
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.CreateStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_DecreaseStreamRetentionPeriod() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.DecreaseStreamRetentionPeriodInput{
RetentionPeriodHours: aws.Int64(1), // Required
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.DecreaseStreamRetentionPeriod(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_DeleteStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.DeleteStreamInput{
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.DeleteStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_DescribeLimits() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
var params *kinesis.DescribeLimitsInput
resp, err := svc.DescribeLimits(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_DescribeStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.DescribeStreamInput{
StreamName: aws.String("StreamName"), // Required
ExclusiveStartShardId: aws.String("ShardId"),
Limit: aws.Int64(1),
}
resp, err := svc.DescribeStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_DisableEnhancedMonitoring() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.DisableEnhancedMonitoringInput{
ShardLevelMetrics: []*string{ // Required
aws.String("MetricsName"), // Required
// More values...
},
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.DisableEnhancedMonitoring(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_EnableEnhancedMonitoring() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.EnableEnhancedMonitoringInput{
ShardLevelMetrics: []*string{ // Required
aws.String("MetricsName"), // Required
// More values...
},
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.EnableEnhancedMonitoring(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_GetRecords() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.GetRecordsInput{
ShardIterator: aws.String("ShardIterator"), // Required
Limit: aws.Int64(1),
}
resp, err := svc.GetRecords(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_GetShardIterator() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.GetShardIteratorInput{
ShardId: aws.String("ShardId"), // Required
ShardIteratorType: aws.String("ShardIteratorType"), // Required
StreamName: aws.String("StreamName"), // Required
StartingSequenceNumber: aws.String("SequenceNumber"),
Timestamp: aws.Time(time.Now()),
}
resp, err := svc.GetShardIterator(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_IncreaseStreamRetentionPeriod() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.IncreaseStreamRetentionPeriodInput{
RetentionPeriodHours: aws.Int64(1), // Required
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.IncreaseStreamRetentionPeriod(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_ListStreams() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.ListStreamsInput{
ExclusiveStartStreamName: aws.String("StreamName"),
Limit: aws.Int64(1),
}
resp, err := svc.ListStreams(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_ListTagsForStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.ListTagsForStreamInput{
StreamName: aws.String("StreamName"), // Required
ExclusiveStartTagKey: aws.String("TagKey"),
Limit: aws.Int64(1),
}
resp, err := svc.ListTagsForStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_MergeShards() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.MergeShardsInput{
AdjacentShardToMerge: aws.String("ShardId"), // Required
ShardToMerge: aws.String("ShardId"), // Required
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.MergeShards(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_PutRecord() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.PutRecordInput{
Data: []byte("PAYLOAD"), // Required
PartitionKey: aws.String("PartitionKey"), // Required
StreamName: aws.String("StreamName"), // Required
ExplicitHashKey: aws.String("HashKey"),
SequenceNumberForOrdering: aws.String("SequenceNumber"),
}
resp, err := svc.PutRecord(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_PutRecords() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.PutRecordsInput{
Records: []*kinesis.PutRecordsRequestEntry{ // Required
{ // Required
Data: []byte("PAYLOAD"), // Required
PartitionKey: aws.String("PartitionKey"), // Required
ExplicitHashKey: aws.String("HashKey"),
},
// More values...
},
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.PutRecords(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_RemoveTagsFromStream() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.RemoveTagsFromStreamInput{
StreamName: aws.String("StreamName"), // Required
TagKeys: []*string{ // Required
aws.String("TagKey"), // Required
// More values...
},
}
resp, err := svc.RemoveTagsFromStream(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_SplitShard() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.SplitShardInput{
NewStartingHashKey: aws.String("HashKey"), // Required
ShardToSplit: aws.String("ShardId"), // Required
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.SplitShard(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleKinesis_UpdateShardCount() {
sess := session.Must(session.NewSession())
svc := kinesis.New(sess)
params := &kinesis.UpdateShardCountInput{
ScalingType: aws.String("ScalingType"), // Required
StreamName: aws.String("StreamName"), // Required
TargetShardCount: aws.Int64(1), // Required
}
resp, err := svc.UpdateShardCount(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
+13 -2
View File
@@ -1,4 +1,4 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package kinesisiface provides an interface to enable mocking the Amazon Kinesis service client
// for testing your code.
@@ -21,7 +21,7 @@ import (
//
// The best way to use this interface is so the SDK's service client's calls
// can be stubbed out for unit testing your code with the SDK without needing
// to inject custom request handlers into the the SDK's request pipeline.
// to inject custom request handlers into the SDK's request pipeline.
//
// // myFunc uses an SDK service client to make a request to
// // Amazon Kinesis.
@@ -138,12 +138,23 @@ type KinesisAPI interface {
SplitShardWithContext(aws.Context, *kinesis.SplitShardInput, ...request.Option) (*kinesis.SplitShardOutput, error)
SplitShardRequest(*kinesis.SplitShardInput) (*request.Request, *kinesis.SplitShardOutput)
StartStreamEncryption(*kinesis.StartStreamEncryptionInput) (*kinesis.StartStreamEncryptionOutput, error)
StartStreamEncryptionWithContext(aws.Context, *kinesis.StartStreamEncryptionInput, ...request.Option) (*kinesis.StartStreamEncryptionOutput, error)
StartStreamEncryptionRequest(*kinesis.StartStreamEncryptionInput) (*request.Request, *kinesis.StartStreamEncryptionOutput)
StopStreamEncryption(*kinesis.StopStreamEncryptionInput) (*kinesis.StopStreamEncryptionOutput, error)
StopStreamEncryptionWithContext(aws.Context, *kinesis.StopStreamEncryptionInput, ...request.Option) (*kinesis.StopStreamEncryptionOutput, error)
StopStreamEncryptionRequest(*kinesis.StopStreamEncryptionInput) (*request.Request, *kinesis.StopStreamEncryptionOutput)
UpdateShardCount(*kinesis.UpdateShardCountInput) (*kinesis.UpdateShardCountOutput, error)
UpdateShardCountWithContext(aws.Context, *kinesis.UpdateShardCountInput, ...request.Option) (*kinesis.UpdateShardCountOutput, error)
UpdateShardCountRequest(*kinesis.UpdateShardCountInput) (*request.Request, *kinesis.UpdateShardCountOutput)
WaitUntilStreamExists(*kinesis.DescribeStreamInput) error
WaitUntilStreamExistsWithContext(aws.Context, *kinesis.DescribeStreamInput, ...request.WaiterOption) error
WaitUntilStreamNotExists(*kinesis.DescribeStreamInput) error
WaitUntilStreamNotExistsWithContext(aws.Context, *kinesis.DescribeStreamInput, ...request.WaiterOption) error
}
var _ KinesisAPI = (*kinesis.Kinesis)(nil)
+7 -6
View File
@@ -1,4 +1,4 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package kinesis
@@ -11,11 +11,12 @@ import (
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
)
// Amazon Kinesis Streams is a managed service that scales elastically for real
// time processing of streaming big data.
// The service client's operations are safe to be used concurrently.
// It is not safe to mutate any of the client's properties though.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesis-2013-12-02
// Kinesis provides the API operation methods for making requests to
// Amazon Kinesis. See this package's package overview docs
// for details on the service.
//
// Kinesis methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type Kinesis struct {
*client.Client
}
+54 -3
View File
@@ -1,4 +1,4 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package kinesis
@@ -11,7 +11,7 @@ import (
// WaitUntilStreamExists uses the Kinesis API operation
// DescribeStream to wait for a condition to be met before returning.
// If the condition is not meet within the max attempt window an error will
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *Kinesis) WaitUntilStreamExists(input *DescribeStreamInput) error {
return c.WaitUntilStreamExistsWithContext(aws.BackgroundContext(), input)
@@ -39,7 +39,58 @@ func (c *Kinesis) WaitUntilStreamExistsWithContext(ctx aws.Context, input *Descr
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
req, _ := c.DescribeStreamRequest(input)
var inCpy *DescribeStreamInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeStreamRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilStreamNotExists uses the Kinesis API operation
// DescribeStream to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *Kinesis) WaitUntilStreamNotExists(input *DescribeStreamInput) error {
return c.WaitUntilStreamNotExistsWithContext(aws.BackgroundContext(), input)
}
// WaitUntilStreamNotExistsWithContext is an extended version of WaitUntilStreamNotExists.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// 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 *Kinesis) WaitUntilStreamNotExistsWithContext(ctx aws.Context, input *DescribeStreamInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilStreamNotExists",
MaxAttempts: 18,
Delay: request.ConstantWaiterDelay(10 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.SuccessWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeStreamInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeStreamRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil