Switch to using the dep tool and update all the dependencies

This commit is contained in:
Nick Craig-Wood
2017-05-11 15:39:54 +01:00
parent 5135ff73cb
commit 98c2d2c41b
5321 changed files with 4483197 additions and 5918 deletions
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
package polly
import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/private/protocol/rest"
)
func init() {
initRequest = func(r *request.Request) {
if r.Operation.Name == opSynthesizeSpeech {
r.Operation.BeforePresignFn = restGETPresignStrategy
}
}
}
// restGETPresignStrategy will prepare the request from a POST to a GET request.
// Enabling the presigner to sign the request as a GET.
func restGETPresignStrategy(r *request.Request) error {
r.Handlers.Build.Clear()
r.Handlers.Build.PushBack(rest.BuildAsGET)
r.Operation.HTTPMethod = "GET"
r.HTTPRequest.Method = "GET"
return nil
}
+32
View File
@@ -0,0 +1,32 @@
package polly
import (
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/unit"
"github.com/stretchr/testify/assert"
)
func TestRestGETStrategy(t *testing.T) {
svc := New(unit.Session, &aws.Config{Region: aws.String("us-west-2")})
r, _ := svc.SynthesizeSpeechRequest(nil)
err := restGETPresignStrategy(r)
assert.NoError(t, err)
assert.Equal(t, "GET", r.HTTPRequest.Method)
assert.NotEqual(t, nil, r.Operation.BeforePresignFn)
}
func TestPresign(t *testing.T) {
svc := New(unit.Session, &aws.Config{Region: aws.String("us-west-2")})
r, _ := svc.SynthesizeSpeechRequest(&SynthesizeSpeechInput{
Text: aws.String("Moo"),
OutputFormat: aws.String("mp3"),
VoiceId: aws.String("Foo"),
})
url, err := r.Presign(time.Second)
assert.NoError(t, err)
assert.Regexp(t, `^https://polly.us-west-2.amazonaws.com/v1/speech\?.*?OutputFormat=mp3.*?Text=Moo.*?VoiceId=Foo.*`, url)
}
+86
View File
@@ -0,0 +1,86 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package polly provides the client and types for making API
// requests to Amazon Polly.
//
// Amazon Polly is a web service that makes it easy to synthesize speech from
// text.
//
// The Amazon Polly service provides API operations for synthesizing high-quality
// speech from plain text and Speech Synthesis Markup Language (SSML), along
// with managing pronunciations lexicons that enable you to get the best results
// for your application domain.
//
// See https://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10 for more information on this service.
//
// See polly package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/polly/
//
// Using the Client
//
// To use the client for Amazon Polly you will first need
// to create a new instance of it.
//
// When creating a client for an AWS service you'll first need to have a Session
// already created. The Session provides configuration that can be shared
// between multiple service clients. Additional configuration can be applied to
// the Session and service's client when they are constructed. The aws package's
// Config type contains several fields such as Region for the AWS Region the
// client should make API requests too. The optional Config value can be provided
// as the variadic argument for Sessions and client creation.
//
// Once the service's client is created you can use it to make API requests the
// AWS service. These clients are safe to use concurrently.
//
// // Create a session to share configuration, and load external configuration.
// sess := session.Must(session.NewSession())
//
// // Create the service's client with the session.
// svc := polly.New(sess)
//
// See the SDK's documentation for more information on how to use service clients.
// https://docs.aws.amazon.com/sdk-for-go/api/
//
// See aws package's Config type for more information on configuration options.
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
//
// See the Amazon Polly client Polly for more
// information on creating the service's client.
// https://docs.aws.amazon.com/sdk-for-go/api/service/polly/#New
//
// Once the client is created you can make an API request to the service.
// Each API method takes a input parameter, and returns the service response
// and an error.
//
// The API method will document which error codes the service can be returned
// by the operation if the service models the API operation's errors. These
// errors will also be available as const strings prefixed with "ErrCode".
//
// result, err := svc.DeleteLexicon(params)
// if err != nil {
// // Cast err to awserr.Error to handle specific error codes.
// aerr, ok := err.(awserr.Error)
// if ok && aerr.Code() == <error code to check for> {
// // Specific error code handling
// }
// return err
// }
//
// fmt.Println("DeleteLexicon result:")
// fmt.Println(result)
//
// Using the Client with Context
//
// The service's client also provides methods to make API requests with a Context
// value. This allows you to control the timeout, and cancellation of pending
// requests. These methods also take request Option as variadic parameter to apply
// additional configuration to the API request.
//
// ctx := context.Background()
//
// result, err := svc.DeleteLexiconWithContext(ctx, params)
//
// See the request package documentation for more information on using Context pattern
// with the SDK.
// https://docs.aws.amazon.com/sdk-for-go/api/aws/request/
package polly
+103
View File
@@ -0,0 +1,103 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package polly
const (
// ErrCodeInvalidLexiconException for service response error code
// "InvalidLexiconException".
//
// Amazon Polly can't find the specified lexicon. Verify that the lexicon's
// name is spelled correctly, and then try again.
ErrCodeInvalidLexiconException = "InvalidLexiconException"
// ErrCodeInvalidNextTokenException for service response error code
// "InvalidNextTokenException".
//
// The NextToken is invalid. Verify that it's spelled correctly, and then try
// again.
ErrCodeInvalidNextTokenException = "InvalidNextTokenException"
// ErrCodeInvalidSampleRateException for service response error code
// "InvalidSampleRateException".
//
// The specified sample rate is not valid.
ErrCodeInvalidSampleRateException = "InvalidSampleRateException"
// ErrCodeInvalidSsmlException for service response error code
// "InvalidSsmlException".
//
// The SSML you provided is invalid. Verify the SSML syntax, spelling of tags
// and values, and then try again.
ErrCodeInvalidSsmlException = "InvalidSsmlException"
// ErrCodeLexiconNotFoundException for service response error code
// "LexiconNotFoundException".
//
// Amazon Polly can't find the specified lexicon. This could be caused by a
// lexicon that is missing, its name is misspelled or specifying a lexicon that
// is in a different region.
//
// Verify that the lexicon exists, is in the region (see ListLexicons) and that
// you spelled its name is spelled correctly. Then try again.
ErrCodeLexiconNotFoundException = "LexiconNotFoundException"
// ErrCodeLexiconSizeExceededException for service response error code
// "LexiconSizeExceededException".
//
// The maximum size of the specified lexicon would be exceeded by this operation.
ErrCodeLexiconSizeExceededException = "LexiconSizeExceededException"
// ErrCodeMarksNotSupportedForFormatException for service response error code
// "MarksNotSupportedForFormatException".
//
// Speech marks are not supported for the OutputFormat selected. Speech marks
// are only available for content in json format.
ErrCodeMarksNotSupportedForFormatException = "MarksNotSupportedForFormatException"
// ErrCodeMaxLexemeLengthExceededException for service response error code
// "MaxLexemeLengthExceededException".
//
// The maximum size of the lexeme would be exceeded by this operation.
ErrCodeMaxLexemeLengthExceededException = "MaxLexemeLengthExceededException"
// ErrCodeMaxLexiconsNumberExceededException for service response error code
// "MaxLexiconsNumberExceededException".
//
// The maximum number of lexicons would be exceeded by this operation.
ErrCodeMaxLexiconsNumberExceededException = "MaxLexiconsNumberExceededException"
// ErrCodeServiceFailureException for service response error code
// "ServiceFailureException".
//
// An unknown condition has caused a service failure.
ErrCodeServiceFailureException = "ServiceFailureException"
// ErrCodeSsmlMarksNotSupportedForTextTypeException for service response error code
// "SsmlMarksNotSupportedForTextTypeException".
//
// SSML speech marks are not supported for plain text-type input.
ErrCodeSsmlMarksNotSupportedForTextTypeException = "SsmlMarksNotSupportedForTextTypeException"
// ErrCodeTextLengthExceededException for service response error code
// "TextLengthExceededException".
//
// The value of the "Text" parameter is longer than the accepted limits. The
// limit for input text is a maximum of 3000 characters total, of which no more
// than 1500 can be billed characters. SSML tags are not counted as billed characters.
ErrCodeTextLengthExceededException = "TextLengthExceededException"
// ErrCodeUnsupportedPlsAlphabetException for service response error code
// "UnsupportedPlsAlphabetException".
//
// The alphabet specified by the lexicon is not a supported alphabet. Valid
// values are x-sampa and ipa.
ErrCodeUnsupportedPlsAlphabetException = "UnsupportedPlsAlphabetException"
// ErrCodeUnsupportedPlsLanguageException for service response error code
// "UnsupportedPlsLanguageException".
//
// The language specified in the lexicon is unsupported. For a list of supported
// languages, see Lexicon Attributes (http://docs.aws.amazon.com/polly/latest/dg/API_LexiconAttributes.html).
ErrCodeUnsupportedPlsLanguageException = "UnsupportedPlsLanguageException"
)
+156
View File
@@ -0,0 +1,156 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package polly_test
import (
"bytes"
"fmt"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/polly"
)
var _ time.Duration
var _ bytes.Buffer
func ExamplePolly_DeleteLexicon() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.DeleteLexiconInput{
Name: aws.String("LexiconName"), // Required
}
resp, err := svc.DeleteLexicon(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExamplePolly_DescribeVoices() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.DescribeVoicesInput{
LanguageCode: aws.String("LanguageCode"),
NextToken: aws.String("NextToken"),
}
resp, err := svc.DescribeVoices(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExamplePolly_GetLexicon() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.GetLexiconInput{
Name: aws.String("LexiconName"), // Required
}
resp, err := svc.GetLexicon(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExamplePolly_ListLexicons() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.ListLexiconsInput{
NextToken: aws.String("NextToken"),
}
resp, err := svc.ListLexicons(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExamplePolly_PutLexicon() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.PutLexiconInput{
Content: aws.String("LexiconContent"), // Required
Name: aws.String("LexiconName"), // Required
}
resp, err := svc.PutLexicon(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExamplePolly_SynthesizeSpeech() {
sess := session.Must(session.NewSession())
svc := polly.New(sess)
params := &polly.SynthesizeSpeechInput{
OutputFormat: aws.String("OutputFormat"), // Required
Text: aws.String("Text"), // Required
VoiceId: aws.String("VoiceId"), // Required
LexiconNames: []*string{
aws.String("LexiconName"), // Required
// More values...
},
SampleRate: aws.String("SampleRate"),
SpeechMarkTypes: []*string{
aws.String("SpeechMarkType"), // Required
// More values...
},
TextType: aws.String("TextType"),
}
resp, err := svc.SynthesizeSpeech(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
+88
View File
@@ -0,0 +1,88 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package pollyiface provides an interface to enable mocking the Amazon Polly service client
// for testing your code.
//
// It is important to note that this interface will have breaking changes
// when the service model is updated and adds new API operations, paginators,
// and waiters.
package pollyiface
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/polly"
)
// PollyAPI provides an interface to enable mocking the
// polly.Polly service client's API operation,
// paginators, and waiters. This make unit testing your code that calls out
// to the SDK's service client's calls easier.
//
// 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.
//
// // myFunc uses an SDK service client to make a request to
// // Amazon Polly.
// func myFunc(svc pollyiface.PollyAPI) bool {
// // Make svc.DeleteLexicon request
// }
//
// func main() {
// sess := session.New()
// svc := polly.New(sess)
//
// myFunc(svc)
// }
//
// In your _test.go file:
//
// // Define a mock struct to be used in your unit tests of myFunc.
// type mockPollyClient struct {
// pollyiface.PollyAPI
// }
// func (m *mockPollyClient) DeleteLexicon(input *polly.DeleteLexiconInput) (*polly.DeleteLexiconOutput, error) {
// // mock response/functionality
// }
//
// func TestMyFunc(t *testing.T) {
// // Setup Test
// mockSvc := &mockPollyClient{}
//
// myfunc(mockSvc)
//
// // Verify myFunc's functionality
// }
//
// It is important to note that this interface will have breaking changes
// when the service model is updated and adds new API operations, paginators,
// and waiters. Its suggested to use the pattern above for testing, or using
// tooling to generate mocks to satisfy the interfaces.
type PollyAPI interface {
DeleteLexicon(*polly.DeleteLexiconInput) (*polly.DeleteLexiconOutput, error)
DeleteLexiconWithContext(aws.Context, *polly.DeleteLexiconInput, ...request.Option) (*polly.DeleteLexiconOutput, error)
DeleteLexiconRequest(*polly.DeleteLexiconInput) (*request.Request, *polly.DeleteLexiconOutput)
DescribeVoices(*polly.DescribeVoicesInput) (*polly.DescribeVoicesOutput, error)
DescribeVoicesWithContext(aws.Context, *polly.DescribeVoicesInput, ...request.Option) (*polly.DescribeVoicesOutput, error)
DescribeVoicesRequest(*polly.DescribeVoicesInput) (*request.Request, *polly.DescribeVoicesOutput)
GetLexicon(*polly.GetLexiconInput) (*polly.GetLexiconOutput, error)
GetLexiconWithContext(aws.Context, *polly.GetLexiconInput, ...request.Option) (*polly.GetLexiconOutput, error)
GetLexiconRequest(*polly.GetLexiconInput) (*request.Request, *polly.GetLexiconOutput)
ListLexicons(*polly.ListLexiconsInput) (*polly.ListLexiconsOutput, error)
ListLexiconsWithContext(aws.Context, *polly.ListLexiconsInput, ...request.Option) (*polly.ListLexiconsOutput, error)
ListLexiconsRequest(*polly.ListLexiconsInput) (*request.Request, *polly.ListLexiconsOutput)
PutLexicon(*polly.PutLexiconInput) (*polly.PutLexiconOutput, error)
PutLexiconWithContext(aws.Context, *polly.PutLexiconInput, ...request.Option) (*polly.PutLexiconOutput, error)
PutLexiconRequest(*polly.PutLexiconInput) (*request.Request, *polly.PutLexiconOutput)
SynthesizeSpeech(*polly.SynthesizeSpeechInput) (*polly.SynthesizeSpeechOutput, error)
SynthesizeSpeechWithContext(aws.Context, *polly.SynthesizeSpeechInput, ...request.Option) (*polly.SynthesizeSpeechOutput, error)
SynthesizeSpeechRequest(*polly.SynthesizeSpeechInput) (*request.Request, *polly.SynthesizeSpeechOutput)
}
var _ PollyAPI = (*polly.Polly)(nil)
+93
View File
@@ -0,0 +1,93 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package polly
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/restjson"
)
// Polly provides the API operation methods for making requests to
// Amazon Polly. See this package's package overview docs
// for details on the service.
//
// Polly methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type Polly 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 = "polly" // Service endpoint prefix API calls made to.
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
)
// New creates a new instance of the Polly 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:
// // Create a Polly client from just a session.
// svc := polly.New(mySession)
//
// // Create a Polly client with additional configuration
// svc := polly.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
func New(p client.ConfigProvider, cfgs ...*aws.Config) *Polly {
c := p.ClientConfig(EndpointsID, cfgs...)
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
}
// newClient creates, initializes and returns a new service client instance.
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *Polly {
svc := &Polly{
Client: client.New(
cfg,
metadata.ClientInfo{
ServiceName: ServiceName,
SigningName: signingName,
SigningRegion: signingRegion,
Endpoint: endpoint,
APIVersion: "2016-06-10",
},
handlers,
),
}
// Handlers
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
// Run custom client initialization if present
if initClient != nil {
initClient(svc.Client)
}
return svc
}
// newRequest creates a new request for a Polly operation and runs any
// custom request initialization.
func (c *Polly) 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
}