vendor: update all dependencies
This commit is contained in:
parent
0b6fba34a3
commit
eb87cf6f12
2008 changed files with 352633 additions and 1004750 deletions
1
vendor/github.com/aws/aws-sdk-go/private/model/api/api.go
generated
vendored
1
vendor/github.com/aws/aws-sdk-go/private/model/api/api.go
generated
vendored
|
@ -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
|
||||
|
|
6
vendor/github.com/aws/aws-sdk-go/private/model/api/customization_passes.go
generated
vendored
6
vendor/github.com/aws/aws-sdk-go/private/model/api/customization_passes.go
generated
vendored
|
@ -59,6 +59,12 @@ func s3Customizations(a *API) {
|
|||
delete(s.MemberRefs, "ContentMD5")
|
||||
}
|
||||
|
||||
for _, refName := range []string{"Bucket", "SSECustomerKey", "CopySourceSSECustomerKey"} {
|
||||
if ref, ok := s.MemberRefs[refName]; ok {
|
||||
ref.GenerateGetter = true
|
||||
}
|
||||
}
|
||||
|
||||
// Expires should be a string not time.Time since the format is not
|
||||
// enforced by S3, and any value can be set to this field outside of the SDK.
|
||||
if strings.HasSuffix(name, "Output") {
|
||||
|
|
4
vendor/github.com/aws/aws-sdk-go/private/model/api/docstring.go
generated
vendored
4
vendor/github.com/aws/aws-sdk-go/private/model/api/docstring.go
generated
vendored
|
@ -62,6 +62,10 @@ func (d *apiDocumentation) setup() {
|
|||
}
|
||||
|
||||
parts := strings.Split(ref, "$")
|
||||
if len(parts) != 2 {
|
||||
fmt.Fprintf(os.Stderr, "Shape Doc %s has unexpected reference format, %q\n", shape, ref)
|
||||
continue
|
||||
}
|
||||
if sh := d.API.Shapes[parts[0]]; sh != nil {
|
||||
if m := sh.MemberRefs[parts[1]]; m != nil {
|
||||
m.Documentation = docstring(doc)
|
||||
|
|
318
vendor/github.com/aws/aws-sdk-go/private/model/api/example.go
generated
vendored
Normal file
318
vendor/github.com/aws/aws-sdk-go/private/model/api/example.go
generated
vendored
Normal file
|
@ -0,0 +1,318 @@
|
|||
// +build codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/aws/aws-sdk-go/private/util"
|
||||
)
|
||||
|
||||
type Examples map[string][]Example
|
||||
|
||||
// ExamplesDefinition is the structural representation of the examples-1.json file
|
||||
type ExamplesDefinition struct {
|
||||
*API `json:"-"`
|
||||
Examples Examples `json:"examples"`
|
||||
}
|
||||
|
||||
// Example is a single entry within the examples-1.json file.
|
||||
type Example struct {
|
||||
API *API `json:"-"`
|
||||
Operation *Operation `json:"-"`
|
||||
OperationName string `json:"-"`
|
||||
Index string `json:"-"`
|
||||
Builder examplesBuilder `json:"-"`
|
||||
VisitedErrors map[string]struct{} `json:"-"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ID string `json:"id"`
|
||||
Comments Comments `json:"comments"`
|
||||
Input map[string]interface{} `json:"input"`
|
||||
Output map[string]interface{} `json:"output"`
|
||||
}
|
||||
|
||||
type Comments struct {
|
||||
Input map[string]interface{} `json:"input"`
|
||||
Output map[string]interface{} `json:"output"`
|
||||
}
|
||||
|
||||
var exampleFuncMap = template.FuncMap{
|
||||
"commentify": commentify,
|
||||
"wrap": wrap,
|
||||
"generateExampleInput": generateExampleInput,
|
||||
"generateTypes": generateTypes,
|
||||
}
|
||||
|
||||
var exampleCustomizations = map[string]template.FuncMap{}
|
||||
|
||||
var exampleTmpls = template.Must(template.New("example").Funcs(exampleFuncMap).Parse(`
|
||||
{{ generateTypes . }}
|
||||
{{ commentify (wrap .Title 80 false) }}
|
||||
//
|
||||
{{ commentify (wrap .Description 80 false) }}
|
||||
func Example{{ .API.StructName }}_{{ .MethodName }}() {
|
||||
svc := {{ .API.PackageName }}.New(session.New())
|
||||
input := &{{ .Operation.InputRef.Shape.GoTypeWithPkgNameElem }} {
|
||||
{{ generateExampleInput . -}}
|
||||
}
|
||||
|
||||
result, err := svc.{{ .OperationName }}(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
{{ range $_, $ref := .Operation.ErrorRefs -}}
|
||||
{{ if not ($.HasVisitedError $ref) -}}
|
||||
case {{ .API.PackageName }}.{{ $ref.Shape.ErrorCodeName }}:
|
||||
fmt.Println({{ .API.PackageName }}.{{ $ref.Shape.ErrorCodeName }}, aerr.Error())
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
`))
|
||||
|
||||
// Names will return the name of the example. This will also be the name of the operation
|
||||
// that is to be tested.
|
||||
func (exs Examples) Names() []string {
|
||||
names := make([]string, 0, len(exs))
|
||||
for k := range exs {
|
||||
names = append(names, k)
|
||||
}
|
||||
|
||||
sort.Strings(names)
|
||||
return names
|
||||
}
|
||||
|
||||
func (exs Examples) GoCode() string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
for _, opName := range exs.Names() {
|
||||
examples := exs[opName]
|
||||
for _, ex := range examples {
|
||||
buf.WriteString(util.GoFmt(ex.GoCode()))
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// ExampleCode will generate the example code for the given Example shape.
|
||||
// TODO: Can delete
|
||||
func (ex Example) GoCode() string {
|
||||
var buf bytes.Buffer
|
||||
m := exampleFuncMap
|
||||
if fMap, ok := exampleCustomizations[ex.API.PackageName()]; ok {
|
||||
m = fMap
|
||||
}
|
||||
tmpl := exampleTmpls.Funcs(m)
|
||||
if err := tmpl.ExecuteTemplate(&buf, "example", &ex); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return strings.TrimSpace(buf.String())
|
||||
}
|
||||
|
||||
func generateExampleInput(ex Example) string {
|
||||
if ex.Operation.HasInput() {
|
||||
return ex.Builder.BuildShape(&ex.Operation.InputRef, ex.Input, false)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// generateTypes will generate no types for default examples, but customizations may
|
||||
// require their own defined types.
|
||||
func generateTypes(ex Example) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// correctType will cast the value to the correct type when printing the string.
|
||||
// This is due to the json decoder choosing numbers to be floats, but the shape may
|
||||
// actually be an int. To counter this, we pass the shape's type and properly do the
|
||||
// casting here.
|
||||
func correctType(memName string, t string, value interface{}) string {
|
||||
if value == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
v := ""
|
||||
switch value.(type) {
|
||||
case string:
|
||||
v = value.(string)
|
||||
case int:
|
||||
v = fmt.Sprintf("%d", value.(int))
|
||||
case float64:
|
||||
if t == "integer" || t == "long" || t == "int64" {
|
||||
v = fmt.Sprintf("%d", int(value.(float64)))
|
||||
} else {
|
||||
v = fmt.Sprintf("%f", value.(float64))
|
||||
}
|
||||
case bool:
|
||||
v = fmt.Sprintf("%t", value.(bool))
|
||||
}
|
||||
|
||||
return convertToCorrectType(memName, t, v)
|
||||
}
|
||||
|
||||
func convertToCorrectType(memName, t, v string) string {
|
||||
return fmt.Sprintf("%s: %s,\n", memName, getValue(t, v))
|
||||
}
|
||||
|
||||
func getValue(t, v string) string {
|
||||
if t[0] == '*' {
|
||||
t = t[1:]
|
||||
}
|
||||
switch t {
|
||||
case "string":
|
||||
return fmt.Sprintf("aws.String(%q)", v)
|
||||
case "integer", "long", "int64":
|
||||
return fmt.Sprintf("aws.Int64(%s)", v)
|
||||
case "float", "float64", "double":
|
||||
return fmt.Sprintf("aws.Float64(%s)", v)
|
||||
case "boolean":
|
||||
return fmt.Sprintf("aws.Bool(%s)", v)
|
||||
default:
|
||||
panic("Unsupported type: " + t)
|
||||
}
|
||||
}
|
||||
|
||||
// AttachExamples will create a new ExamplesDefinition from the examples file
|
||||
// and reference the API object.
|
||||
func (a *API) AttachExamples(filename string) {
|
||||
p := ExamplesDefinition{API: a}
|
||||
|
||||
f, err := os.Open(filename)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.NewDecoder(f).Decode(&p)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
p.setup()
|
||||
}
|
||||
|
||||
var examplesBuilderCustomizations = map[string]examplesBuilder{
|
||||
"wafregional": wafregionalExamplesBuilder{},
|
||||
}
|
||||
|
||||
func (p *ExamplesDefinition) setup() {
|
||||
var builder examplesBuilder
|
||||
ok := false
|
||||
if builder, ok = examplesBuilderCustomizations[p.API.PackageName()]; !ok {
|
||||
builder = defaultExamplesBuilder{}
|
||||
}
|
||||
|
||||
keys := p.Examples.Names()
|
||||
for _, n := range keys {
|
||||
examples := p.Examples[n]
|
||||
for i, e := range examples {
|
||||
n = p.ExportableName(n)
|
||||
e.OperationName = n
|
||||
e.API = p.API
|
||||
e.Index = fmt.Sprintf("shared%02d", i)
|
||||
|
||||
e.Builder = builder
|
||||
|
||||
e.VisitedErrors = map[string]struct{}{}
|
||||
op := p.API.Operations[e.OperationName]
|
||||
e.OperationName = p.ExportableName(e.OperationName)
|
||||
e.Operation = op
|
||||
p.Examples[n][i] = e
|
||||
}
|
||||
}
|
||||
|
||||
p.API.Examples = p.Examples
|
||||
}
|
||||
|
||||
var exampleHeader = template.Must(template.New("exampleHeader").Parse(`
|
||||
import (
|
||||
{{ .Builder.Imports .API }}
|
||||
)
|
||||
|
||||
var _ time.Duration
|
||||
var _ strings.Reader
|
||||
var _ aws.Config
|
||||
|
||||
func parseTime(layout, value string) *time.Time {
|
||||
t, err := time.Parse(layout, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
`))
|
||||
|
||||
type exHeader struct {
|
||||
Builder examplesBuilder
|
||||
API *API
|
||||
}
|
||||
|
||||
// ExamplesGoCode will return a code representation of the entry within the
|
||||
// examples.json file.
|
||||
func (a *API) ExamplesGoCode() string {
|
||||
var buf bytes.Buffer
|
||||
var builder examplesBuilder
|
||||
ok := false
|
||||
if builder, ok = examplesBuilderCustomizations[a.PackageName()]; !ok {
|
||||
builder = defaultExamplesBuilder{}
|
||||
}
|
||||
|
||||
if err := exampleHeader.ExecuteTemplate(&buf, "exampleHeader", &exHeader{builder, a}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
code := a.Examples.GoCode()
|
||||
if len(code) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
buf.WriteString(code)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// TODO: In the operation docuentation where we list errors, this needs to be done
|
||||
// there as well.
|
||||
func (ex *Example) HasVisitedError(errRef *ShapeRef) bool {
|
||||
errName := errRef.Shape.ErrorCodeName()
|
||||
_, ok := ex.VisitedErrors[errName]
|
||||
ex.VisitedErrors[errName] = struct{}{}
|
||||
return ok
|
||||
}
|
||||
|
||||
func parseTimeString(ref *ShapeRef, memName, v string) string {
|
||||
if ref.Location == "header" {
|
||||
return fmt.Sprintf("%s: parseTime(%q, %q),\n", memName, "Mon, 2 Jan 2006 15:04:05 GMT", v)
|
||||
} else {
|
||||
switch ref.API.Metadata.Protocol {
|
||||
case "json", "rest-json":
|
||||
return fmt.Sprintf("%s: parseTime(%q, %q),\n", memName, "2006-01-02T15:04:05Z", v)
|
||||
case "rest-xml", "ec2", "query":
|
||||
return fmt.Sprintf("%s: parseTime(%q, %q),\n", memName, "2006-01-02T15:04:05Z", v)
|
||||
default:
|
||||
panic("Unsupported time type: " + ref.API.Metadata.Protocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ex *Example) MethodName() string {
|
||||
return fmt.Sprintf("%s_%s", ex.OperationName, ex.Index)
|
||||
}
|
206
vendor/github.com/aws/aws-sdk-go/private/model/api/example_test.go
generated
vendored
Normal file
206
vendor/github.com/aws/aws-sdk-go/private/model/api/example_test.go
generated
vendored
Normal file
|
@ -0,0 +1,206 @@
|
|||
// +build 1.6,codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func buildAPI() *API {
|
||||
a := &API{}
|
||||
|
||||
stringShape := &Shape{
|
||||
API: a,
|
||||
ShapeName: "string",
|
||||
Type: "string",
|
||||
}
|
||||
stringShapeRef := &ShapeRef{
|
||||
API: a,
|
||||
ShapeName: "string",
|
||||
Shape: stringShape,
|
||||
}
|
||||
|
||||
intShape := &Shape{
|
||||
API: a,
|
||||
ShapeName: "int",
|
||||
Type: "int",
|
||||
}
|
||||
intShapeRef := &ShapeRef{
|
||||
API: a,
|
||||
ShapeName: "int",
|
||||
Shape: intShape,
|
||||
}
|
||||
|
||||
input := &Shape{
|
||||
API: a,
|
||||
ShapeName: "FooInput",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"BarShape": stringShapeRef,
|
||||
},
|
||||
Type: "structure",
|
||||
}
|
||||
output := &Shape{
|
||||
API: a,
|
||||
ShapeName: "FooOutput",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"BazShape": intShapeRef,
|
||||
},
|
||||
Type: "structure",
|
||||
}
|
||||
|
||||
inputRef := ShapeRef{
|
||||
API: a,
|
||||
ShapeName: "FooInput",
|
||||
Shape: input,
|
||||
}
|
||||
outputRef := ShapeRef{
|
||||
API: a,
|
||||
ShapeName: "Foooutput",
|
||||
Shape: output,
|
||||
}
|
||||
|
||||
operations := map[string]*Operation{
|
||||
"Foo": &Operation{
|
||||
API: a,
|
||||
Name: "Foo",
|
||||
ExportedName: "Foo",
|
||||
InputRef: inputRef,
|
||||
OutputRef: outputRef,
|
||||
},
|
||||
}
|
||||
|
||||
a.Operations = operations
|
||||
a.Shapes = map[string]*Shape{
|
||||
"FooInput": input,
|
||||
"FooOutput": output,
|
||||
}
|
||||
a.Metadata = Metadata{
|
||||
ServiceAbbreviation: "FooService",
|
||||
}
|
||||
|
||||
a.Setup()
|
||||
return a
|
||||
}
|
||||
|
||||
func TestExampleGeneration(t *testing.T) {
|
||||
example := `
|
||||
{
|
||||
"version": "1.0",
|
||||
"examples": {
|
||||
"Foo": [
|
||||
{
|
||||
"input": {
|
||||
"BarShape": "Hello world"
|
||||
},
|
||||
"output": {
|
||||
"BazShape": 1
|
||||
},
|
||||
"comments": {
|
||||
"input": {
|
||||
},
|
||||
"output": {
|
||||
}
|
||||
},
|
||||
"description": "Foo bar baz qux",
|
||||
"title": "I pity the foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`
|
||||
a := buildAPI()
|
||||
def := &ExamplesDefinition{}
|
||||
err := json.Unmarshal([]byte(example), def)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
def.API = a
|
||||
|
||||
def.setup()
|
||||
expected := `
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/fooservice"
|
||||
)
|
||||
|
||||
var _ time.Duration
|
||||
var _ bytes.Buffer
|
||||
var _ aws.Config
|
||||
|
||||
func parseTime(layout, value string) *time.Time {
|
||||
t, err := time.Parse(layout, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
// I pity the foo
|
||||
//
|
||||
// Foo bar baz qux
|
||||
func ExampleFooService_Foo_shared00() {
|
||||
svc := fooservice.New(session.New())
|
||||
input := &fooservice.FooInput{
|
||||
BarShape: aws.String("Hello world"),
|
||||
}
|
||||
|
||||
result, err := svc.Foo(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
`
|
||||
if expected != a.ExamplesGoCode() {
|
||||
t.Log([]byte(expected))
|
||||
t.Log([]byte(a.ExamplesGoCode()))
|
||||
t.Errorf("Expected:\n%s\nReceived:\n%s\n", expected, a.ExamplesGoCode())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildShape(t *testing.T) {
|
||||
a := buildAPI()
|
||||
cases := []struct {
|
||||
defs map[string]interface{}
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
defs: map[string]interface{}{
|
||||
"barShape": "Hello World",
|
||||
},
|
||||
expected: "BarShape: aws.String(\"Hello World\"),\n",
|
||||
},
|
||||
{
|
||||
defs: map[string]interface{}{
|
||||
"BarShape": "Hello World",
|
||||
},
|
||||
expected: "BarShape: aws.String(\"Hello World\"),\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
ref := a.Operations["Foo"].InputRef
|
||||
shapeStr := defaultExamplesBuilder{}.BuildShape(&ref, c.defs, false)
|
||||
if c.expected != shapeStr {
|
||||
t.Errorf("Expected:\n%s\nReceived:\n%s", c.expected, shapeStr)
|
||||
}
|
||||
}
|
||||
}
|
256
vendor/github.com/aws/aws-sdk-go/private/model/api/examples_builder.go
generated
vendored
Normal file
256
vendor/github.com/aws/aws-sdk-go/private/model/api/examples_builder.go
generated
vendored
Normal file
|
@ -0,0 +1,256 @@
|
|||
// +build codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type examplesBuilder interface {
|
||||
BuildShape(*ShapeRef, map[string]interface{}, bool) string
|
||||
BuildList(string, string, *ShapeRef, []interface{}) string
|
||||
BuildComplex(string, string, *ShapeRef, map[string]interface{}) string
|
||||
Imports(*API) string
|
||||
}
|
||||
|
||||
type defaultExamplesBuilder struct{}
|
||||
|
||||
// BuildShape will recursively build the referenced shape based on the json object
|
||||
// provided.
|
||||
// isMap will dictate how the field name is specified. If isMap is true, we will expect
|
||||
// the member name to be quotes like "Foo".
|
||||
func (builder defaultExamplesBuilder) BuildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string {
|
||||
order := make([]string, len(shapes))
|
||||
for k := range shapes {
|
||||
order = append(order, k)
|
||||
}
|
||||
sort.Strings(order)
|
||||
|
||||
ret := ""
|
||||
for _, name := range order {
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
shape := shapes[name]
|
||||
|
||||
// If the shape isn't a map, we want to export the value, since every field
|
||||
// defined in our shapes are exported.
|
||||
if len(name) > 0 && !isMap && strings.ToLower(name[0:1]) == name[0:1] {
|
||||
name = strings.Title(name)
|
||||
}
|
||||
|
||||
memName := name
|
||||
if isMap {
|
||||
memName = fmt.Sprintf("%q", memName)
|
||||
}
|
||||
|
||||
switch v := shape.(type) {
|
||||
case map[string]interface{}:
|
||||
ret += builder.BuildComplex(name, memName, ref, v)
|
||||
case []interface{}:
|
||||
ret += builder.BuildList(name, memName, ref, v)
|
||||
default:
|
||||
ret += builder.BuildScalar(name, memName, ref, v)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// BuildList will construct a list shape based off the service's definition
|
||||
// of that list.
|
||||
func (builder defaultExamplesBuilder) BuildList(name, memName string, ref *ShapeRef, v []interface{}) string {
|
||||
ret := ""
|
||||
|
||||
if len(v) == 0 || ref == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
t := ""
|
||||
dataType := ""
|
||||
format := ""
|
||||
isComplex := false
|
||||
passRef := ref
|
||||
isMap := false
|
||||
|
||||
if ref.Shape.MemberRefs[name] != nil {
|
||||
t = builder.GoType(&ref.Shape.MemberRefs[name].Shape.MemberRef, false)
|
||||
dataType = ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type
|
||||
passRef = ref.Shape.MemberRefs[name]
|
||||
if dataType == "map" {
|
||||
t = fmt.Sprintf("map[string]%s", builder.GoType(&ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef, false))
|
||||
passRef = &ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef
|
||||
isMap = true
|
||||
}
|
||||
} else if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil {
|
||||
t = builder.GoType(&ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef, false)
|
||||
dataType = ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type
|
||||
passRef = &ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef
|
||||
} else {
|
||||
t = builder.GoType(&ref.Shape.MemberRef, false)
|
||||
dataType = ref.Shape.MemberRef.Shape.Type
|
||||
passRef = &ref.Shape.MemberRef
|
||||
}
|
||||
|
||||
switch v[0].(type) {
|
||||
case string:
|
||||
format = "%s"
|
||||
case bool:
|
||||
format = "%t"
|
||||
case float64:
|
||||
if dataType == "integer" || dataType == "int64" {
|
||||
format = "%d"
|
||||
} else {
|
||||
format = "%f"
|
||||
}
|
||||
default:
|
||||
if ref.Shape.MemberRefs[name] != nil {
|
||||
} else {
|
||||
passRef = ref.Shape.MemberRef.Shape.MemberRefs[name]
|
||||
|
||||
// if passRef is nil that means we are either in a map or within a nested array
|
||||
if passRef == nil {
|
||||
passRef = &ref.Shape.MemberRef
|
||||
}
|
||||
}
|
||||
isComplex = true
|
||||
}
|
||||
ret += fmt.Sprintf("%s: []%s {\n", memName, t)
|
||||
for _, elem := range v {
|
||||
if isComplex {
|
||||
ret += fmt.Sprintf("{\n%s\n},\n", builder.BuildShape(passRef, elem.(map[string]interface{}), isMap))
|
||||
} else {
|
||||
if dataType == "integer" || dataType == "int64" || dataType == "long" {
|
||||
elem = int(elem.(float64))
|
||||
}
|
||||
ret += fmt.Sprintf("%s,\n", getValue(t, fmt.Sprintf(format, elem)))
|
||||
}
|
||||
}
|
||||
ret += "},\n"
|
||||
return ret
|
||||
}
|
||||
|
||||
// BuildScalar will build atomic Go types.
|
||||
func (builder defaultExamplesBuilder) BuildScalar(name, memName string, ref *ShapeRef, shape interface{}) string {
|
||||
if ref == nil || ref.Shape == nil {
|
||||
return ""
|
||||
} else if ref.Shape.MemberRefs[name] == nil {
|
||||
if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil {
|
||||
return correctType(memName, ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.Type, shape)
|
||||
}
|
||||
if ref.Shape.Type != "structure" && ref.Shape.Type != "map" {
|
||||
return correctType(memName, ref.Shape.Type, shape)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
switch v := shape.(type) {
|
||||
case bool:
|
||||
return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%t", v))
|
||||
case int:
|
||||
if ref.Shape.MemberRefs[name].Shape.Type == "timestamp" {
|
||||
return parseTimeString(ref, memName, fmt.Sprintf("%d", v))
|
||||
}
|
||||
return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%d", v))
|
||||
case float64:
|
||||
dataType := ref.Shape.MemberRefs[name].Shape.Type
|
||||
if dataType == "integer" || dataType == "int64" || dataType == "long" {
|
||||
return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%d", int(shape.(float64))))
|
||||
}
|
||||
return convertToCorrectType(memName, ref.Shape.MemberRefs[name].Shape.Type, fmt.Sprintf("%f", v))
|
||||
case string:
|
||||
t := ref.Shape.MemberRefs[name].Shape.Type
|
||||
switch t {
|
||||
case "timestamp":
|
||||
return parseTimeString(ref, memName, fmt.Sprintf("%s", v))
|
||||
case "blob":
|
||||
if (ref.Shape.MemberRefs[name].Streaming || ref.Shape.MemberRefs[name].Shape.Streaming) && ref.Shape.Payload == name {
|
||||
return fmt.Sprintf("%s: aws.ReadSeekCloser(strings.NewReader(%q)),\n", memName, v)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s: []byte(%q),\n", memName, v)
|
||||
default:
|
||||
return convertToCorrectType(memName, t, v)
|
||||
}
|
||||
default:
|
||||
panic(fmt.Errorf("Unsupported scalar type: %v", reflect.TypeOf(v)))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (builder defaultExamplesBuilder) BuildComplex(name, memName string, ref *ShapeRef, v map[string]interface{}) string {
|
||||
t := ""
|
||||
if ref == nil {
|
||||
return builder.BuildShape(nil, v, true)
|
||||
}
|
||||
|
||||
member := ref.Shape.MemberRefs[name]
|
||||
|
||||
if member != nil && member.Shape != nil {
|
||||
t = ref.Shape.MemberRefs[name].Shape.Type
|
||||
} else {
|
||||
t = ref.Shape.Type
|
||||
}
|
||||
|
||||
switch t {
|
||||
case "structure":
|
||||
passRef := ref.Shape.MemberRefs[name]
|
||||
// passRef will be nil if the entry is a map. In that case
|
||||
// we want to pass the reference, because the previous call
|
||||
// passed the value reference.
|
||||
if passRef == nil {
|
||||
passRef = ref
|
||||
}
|
||||
return fmt.Sprintf(`%s: &%s{
|
||||
%s
|
||||
},
|
||||
`, memName, builder.GoType(passRef, true), builder.BuildShape(passRef, v, false))
|
||||
case "map":
|
||||
return fmt.Sprintf(`%s: %s{
|
||||
%s
|
||||
},
|
||||
`, name, builder.GoType(ref.Shape.MemberRefs[name], false), builder.BuildShape(&ref.Shape.MemberRefs[name].Shape.ValueRef, v, true))
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (builder defaultExamplesBuilder) GoType(ref *ShapeRef, elem bool) string {
|
||||
prefix := ""
|
||||
if ref.Shape.Type == "list" {
|
||||
ref = &ref.Shape.MemberRef
|
||||
prefix = "[]*"
|
||||
}
|
||||
|
||||
name := ref.GoTypeWithPkgName()
|
||||
if elem {
|
||||
name = ref.GoTypeElem()
|
||||
if !strings.Contains(name, ".") {
|
||||
name = strings.Join([]string{ref.API.PackageName(), name}, ".")
|
||||
}
|
||||
}
|
||||
|
||||
if ref.Shape.Type != "structure" && ref.Shape.Type != "list" {
|
||||
return name
|
||||
}
|
||||
|
||||
return prefix + name
|
||||
}
|
||||
|
||||
func (builder defaultExamplesBuilder) Imports(a *API) string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
buf.WriteString(`"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
`)
|
||||
|
||||
buf.WriteString(fmt.Sprintf("\"%s/%s\"", "github.com/aws/aws-sdk-go/service", a.PackageName()))
|
||||
return buf.String()
|
||||
}
|
28
vendor/github.com/aws/aws-sdk-go/private/model/api/examples_builder_customizations.go
generated
vendored
Normal file
28
vendor/github.com/aws/aws-sdk-go/private/model/api/examples_builder_customizations.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// +build codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type wafregionalExamplesBuilder struct {
|
||||
defaultExamplesBuilder
|
||||
}
|
||||
|
||||
func (builder wafregionalExamplesBuilder) Imports(a *API) string {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
buf.WriteString(`"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/waf"
|
||||
`)
|
||||
|
||||
buf.WriteString(fmt.Sprintf("\"%s/%s\"", "github.com/aws/aws-sdk-go/service", a.PackageName()))
|
||||
return buf.String()
|
||||
}
|
49
vendor/github.com/aws/aws-sdk-go/private/model/api/shape.go
generated
vendored
49
vendor/github.com/aws/aws-sdk-go/private/model/api/shape.go
generated
vendored
|
@ -33,6 +33,8 @@ type ShapeRef struct {
|
|||
Deprecated bool `json:"deprecated"`
|
||||
|
||||
OrigShapeName string `json:"-"`
|
||||
|
||||
GenerateGetter bool
|
||||
}
|
||||
|
||||
// ErrorInfo represents the error block of a shape's structure
|
||||
|
@ -145,6 +147,14 @@ func (s *Shape) GoTypeWithPkgName() string {
|
|||
return goType(s, true)
|
||||
}
|
||||
|
||||
func (s *Shape) GoTypeWithPkgNameElem() string {
|
||||
t := goType(s, true)
|
||||
if strings.HasPrefix(t, "*") {
|
||||
return t[1:]
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// GenAccessors returns if the shape's reference should have setters generated.
|
||||
func (s *ShapeRef) UseIndirection() bool {
|
||||
switch s.Shape.Type {
|
||||
|
@ -244,11 +254,11 @@ func goType(s *Shape, withPkgName bool) string {
|
|||
}
|
||||
return "*" + s.ShapeName
|
||||
case "map":
|
||||
return "map[string]" + s.ValueRef.GoType()
|
||||
return "map[string]" + goType(s.ValueRef.Shape, withPkgName)
|
||||
case "jsonvalue":
|
||||
return "aws.JSONValue"
|
||||
case "list":
|
||||
return "[]" + s.MemberRef.GoType()
|
||||
return "[]" + goType(s.MemberRef.Shape, withPkgName)
|
||||
case "boolean":
|
||||
return "*bool"
|
||||
case "string", "character":
|
||||
|
@ -392,16 +402,18 @@ func (ref *ShapeRef) GoTags(toplevel bool, isRequired bool) string {
|
|||
if ref.Shape.Payload != "" {
|
||||
tags = append(tags, ShapeTag{"payload", ref.Shape.Payload})
|
||||
}
|
||||
if ref.XMLNamespace.Prefix != "" {
|
||||
tags = append(tags, ShapeTag{"xmlPrefix", ref.XMLNamespace.Prefix})
|
||||
} else if ref.Shape.XMLNamespace.Prefix != "" {
|
||||
tags = append(tags, ShapeTag{"xmlPrefix", ref.Shape.XMLNamespace.Prefix})
|
||||
}
|
||||
if ref.XMLNamespace.URI != "" {
|
||||
tags = append(tags, ShapeTag{"xmlURI", ref.XMLNamespace.URI})
|
||||
} else if ref.Shape.XMLNamespace.URI != "" {
|
||||
tags = append(tags, ShapeTag{"xmlURI", ref.Shape.XMLNamespace.URI})
|
||||
}
|
||||
}
|
||||
|
||||
if ref.XMLNamespace.Prefix != "" {
|
||||
tags = append(tags, ShapeTag{"xmlPrefix", ref.XMLNamespace.Prefix})
|
||||
} else if ref.Shape.XMLNamespace.Prefix != "" {
|
||||
tags = append(tags, ShapeTag{"xmlPrefix", ref.Shape.XMLNamespace.Prefix})
|
||||
}
|
||||
|
||||
if ref.XMLNamespace.URI != "" {
|
||||
tags = append(tags, ShapeTag{"xmlURI", ref.XMLNamespace.URI})
|
||||
} else if ref.Shape.XMLNamespace.URI != "" {
|
||||
tags = append(tags, ShapeTag{"xmlURI", ref.Shape.XMLNamespace.URI})
|
||||
}
|
||||
|
||||
if ref.IdempotencyToken || ref.Shape.IdempotencyToken {
|
||||
|
@ -570,6 +582,19 @@ func (s *{{ $builderShapeName }}) Set{{ $name }}(v {{ $context.GoStructValueType
|
|||
return s
|
||||
}
|
||||
|
||||
{{ if $elem.GenerateGetter -}}
|
||||
func (s *{{ $builderShapeName }}) get{{ $name }}() (v {{ $context.GoStructValueType $name $elem }}) {
|
||||
{{ if $elem.UseIndirection -}}
|
||||
if s.{{ $name }} == nil {
|
||||
return v
|
||||
}
|
||||
return *s.{{ $name }}
|
||||
{{ else -}}
|
||||
return s.{{ $name }}
|
||||
{{ end -}}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
`))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue