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
+101 -30
View File
@@ -23,6 +23,7 @@ type API struct {
Shapes map[string]*Shape
Waiters []Waiter
Documentation string
Examples Examples
// Set to true to avoid removing unused shapes
NoRemoveUnusedShapes bool
@@ -290,36 +291,93 @@ func (a *API) APIGoCode() string {
}
var noCrossLinkServices = map[string]struct{}{
"apigateway": struct{}{},
"budgets": struct{}{},
"cloudsearch": struct{}{},
"cloudsearchdomain": struct{}{},
"discovery": struct{}{},
"elastictranscoder": struct{}{},
"es": struct{}{},
"glacier": struct{}{},
"importexport": struct{}{},
"iot": struct{}{},
"iot-data": struct{}{},
"lambda": struct{}{},
"machinelearning": struct{}{},
"rekognition": struct{}{},
"sdb": struct{}{},
"swf": struct{}{},
"apigateway": {},
"budgets": {},
"cloudsearch": {},
"cloudsearchdomain": {},
"elastictranscoder": {},
"es": {},
"glacier": {},
"importexport": {},
"iot": {},
"iot-data": {},
"machinelearning": {},
"rekognition": {},
"sdb": {},
"swf": {},
}
func GetCrosslinkURL(baseURL, name, uid string, params ...string) string {
_, ok := noCrossLinkServices[strings.ToLower(name)]
if uid != "" && baseURL != "" && !ok {
return strings.Join(append([]string{baseURL, "goto", "WebAPI", uid}, params...), "/")
// GetCrosslinkURL returns the crosslinking URL for the shape based on the name and
// uid provided. Empty string is returned if no crosslink link could be determined.
func GetCrosslinkURL(baseURL, uid string, params ...string) string {
if uid == "" || baseURL == "" {
return ""
}
return ""
if _, ok := noCrossLinkServices[strings.ToLower(serviceIDFromUID(uid))]; ok {
return ""
}
return strings.Join(append([]string{baseURL, "goto", "WebAPI", uid}, params...), "/")
}
func serviceIDFromUID(uid string) string {
found := 0
i := len(uid) - 1
for ; i >= 0; i-- {
if uid[i] == '-' {
found++
}
// Terminate after the date component is found, e.g. es-2017-11-11
if found == 3 {
break
}
}
return uid[0:i]
}
// APIName returns the API's service name.
func (a *API) APIName() string {
return a.name
}
var tplServiceDoc = template.Must(template.New("service docs").Funcs(template.FuncMap{
"GetCrosslinkURL": GetCrosslinkURL,
}).
Parse(`
// Package {{ .PackageName }} provides the client and types for making API
// requests to {{ .Metadata.ServiceFullName }}.
{{ if .Documentation -}}
//
{{ .Documentation }}
{{ end -}}
{{ $crosslinkURL := GetCrosslinkURL $.BaseCrosslinkURL $.Metadata.UID -}}
{{ if $crosslinkURL -}}
//
// See {{ $crosslinkURL }} for more information on this service.
{{ end -}}
//
// See {{ .PackageName }} package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/{{ .PackageName }}/
//
// Using the Client
//
// To {{ .Metadata.ServiceFullName }} 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 {{ .Metadata.ServiceFullName }} client {{ .StructName }} for more
// information on creating client for this service.
// https://docs.aws.amazon.com/sdk-for-go/api/service/{{ .PackageName }}/#New
`))
// A tplService defines the template for the service generated code.
var tplService = template.Must(template.New("service").Funcs(template.FuncMap{
"ServiceNameValue": func(a *API) string {
@@ -328,7 +386,6 @@ var tplService = template.Must(template.New("service").Funcs(template.FuncMap{
}
return "ServiceName"
},
"GetCrosslinkURL": GetCrosslinkURL,
"EndpointsIDConstValue": func(a *API) string {
if a.NoConstServiceNames {
return fmt.Sprintf("%q", a.Metadata.EndpointPrefix)
@@ -346,12 +403,12 @@ var tplService = template.Must(template.New("service").Funcs(template.FuncMap{
return "EndpointsID"
},
}).Parse(`
{{ .Documentation }}// The service client's operations are safe to be used concurrently.
// It is not safe to mutate any of the client's properties though.
{{ $crosslinkURL := GetCrosslinkURL $.BaseCrosslinkURL $.APIName $.Metadata.UID -}}
{{ if ne $crosslinkURL "" -}}
// Please also see {{ $crosslinkURL }}
{{ end -}}
// {{ .StructName }} provides the API operation methods for making requests to
// {{ .Metadata.ServiceFullName }}. See this package's package overview docs
// for details on the service.
//
// {{ .StructName }} methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type {{ .StructName }} struct {
*client.Client
}
@@ -457,6 +514,20 @@ func (c *{{ .StructName }}) newRequest(op *request.Operation, params, data inter
}
`))
// ServicePackageDoc generates the contents of the doc file for the service.
//
// Will also read in the custom doc templates for the service if found.
func (a *API) ServicePackageDoc() string {
a.imports = map[string]bool{}
var buf bytes.Buffer
if err := tplServiceDoc.Execute(&buf, a); err != nil {
panic(err)
}
return buf.String()
}
// ServiceGoCode renders service go code. Returning it as a string.
func (a *API) ServiceGoCode() string {
a.resetImports()
@@ -501,7 +572,7 @@ func (a *API) ExampleGoCode() string {
"github.com/aws/aws-sdk-go/aws/session",
path.Join(a.SvcClientImportPath, a.PackageName()),
)
for k, _ := range imports {
for k := range imports {
code += fmt.Sprintf("%q\n", k)
}
code += ")\n\n"
@@ -519,7 +590,7 @@ var tplInterface = template.Must(template.New("interface").Parse(`
//
// 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
// // {{.Metadata.ServiceFullName}}. {{ $opts := .OperationList }}{{ $opt := index $opts 0 }}