mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-01 10:20:35 +00:00
change github.com/aws/aws-sdk-go to be the same revision in kubernetes
This commit is contained in:
12
vendor/github.com/aws/aws-sdk-go/private/model/api/api.go
generated
vendored
12
vendor/github.com/aws/aws-sdk-go/private/model/api/api.go
generated
vendored
@@ -70,7 +70,6 @@ type Metadata struct {
|
||||
JSONVersion string
|
||||
TargetPrefix string
|
||||
Protocol string
|
||||
ProtocolSettings ProtocolSettings
|
||||
UID string
|
||||
EndpointsID string
|
||||
ServiceID string
|
||||
@@ -78,15 +77,8 @@ type Metadata struct {
|
||||
NoResolveEndpoint bool
|
||||
}
|
||||
|
||||
// ProtocolSettings define how the SDK should handle requests in the context
|
||||
// of of a protocol.
|
||||
type ProtocolSettings struct {
|
||||
HTTP2 string `json:"h2,omitempty"`
|
||||
}
|
||||
|
||||
var serviceAliases map[string]string
|
||||
|
||||
// Bootstrap loads SDK model customizations prior to the API model is parsed.
|
||||
func Bootstrap() error {
|
||||
b, err := ioutil.ReadFile(filepath.Join("..", "models", "customizations", "service-aliases.json"))
|
||||
if err != nil {
|
||||
@@ -855,7 +847,7 @@ func (a *API) APIErrorsGoCode() string {
|
||||
// removeOperation removes an operation, its input/output shapes, as well as
|
||||
// any references/shapes that are unique to this operation.
|
||||
func (a *API) removeOperation(name string) {
|
||||
debugLogger.Logln("removing operation,", name)
|
||||
fmt.Println("removing operation,", name)
|
||||
op := a.Operations[name]
|
||||
|
||||
delete(a.Operations, name)
|
||||
@@ -869,7 +861,7 @@ func (a *API) removeOperation(name string) {
|
||||
// shapes. Will also remove member reference targeted shapes if those shapes do
|
||||
// not have any additional references.
|
||||
func (a *API) removeShape(s *Shape) {
|
||||
debugLogger.Logln("removing shape,", s.ShapeName)
|
||||
fmt.Println("removing shape,", s.ShapeName)
|
||||
|
||||
delete(a.Shapes, s.ShapeName)
|
||||
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
{
|
||||
"version":"2.0",
|
||||
"metadata":{
|
||||
"apiVersion":"0000-00-00",
|
||||
"endpointPrefix":"rpcservice",
|
||||
"jsonVersion":"1.1",
|
||||
"protocol":"json",
|
||||
"serviceAbbreviation":"RPCService",
|
||||
"serviceFullName":"RPC Service",
|
||||
"serviceId":"RPCService",
|
||||
"signatureVersion":"v4",
|
||||
"targetPrefix":"RPCService_00000000",
|
||||
"uid":"RPCService-0000-00-00"
|
||||
},
|
||||
"operations":{
|
||||
"GetEventStream":{
|
||||
"name":"GetEventStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"GetEventStreamRequest"},
|
||||
"output":{"shape":"GetEventStreamResponse"}
|
||||
},
|
||||
"EmptyStream":{
|
||||
"name":"EmptyStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"EmptyStreamRequest"},
|
||||
"output":{"shape":"EmptyStreamResponse"}
|
||||
}
|
||||
},
|
||||
"shapes":{
|
||||
"Bool":{"type":"boolean"},
|
||||
"Byte":{"type":"byte"},
|
||||
"Short":{"type":"short"},
|
||||
"Integer":{"type":"integer"},
|
||||
"Long":{"type":"long"},
|
||||
"Blob":{"type":"blob"},
|
||||
"String":{"type":"string"},
|
||||
"Time":{"type":"timestamp"},
|
||||
"GetEventStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"InputVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"GetEventStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StrVal":{"shape":"String"},
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"EventStream":{"shape":"EventStream"}
|
||||
}
|
||||
},
|
||||
"EventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"Headers":{"shape":"HeaderOnlyEvent"},
|
||||
"ImplicitPayload":{"shape":"ImplicitPayloadEvent"},
|
||||
"ExplicitPayload":{"shape":"ExplicitPayloadEvent"},
|
||||
"PayloadOnly":{"shape":"PayloadOnlyEvent"},
|
||||
"PayloadOnlyBlob":{"shape":"PayloadOnlyBlobEvent"},
|
||||
"PayloadOnlyString":{"shape":"PayloadOnlyStringEvent"},
|
||||
"Empty":{"shape":"EmptyEvent"},
|
||||
"Exception":{"shape":"ExceptionEvent"}
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"EmptyStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"EmptyStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"EventStream":{"shape":"EmptyEventStream"}
|
||||
}
|
||||
},
|
||||
"EmptyEventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"HeaderOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BoolVal":{
|
||||
"shape":"Bool",
|
||||
"eventheader":true
|
||||
},
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short",
|
||||
"eventheader":true
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer",
|
||||
"eventheader":true
|
||||
},
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"BlobVal":{
|
||||
"shape":"Blob",
|
||||
"eventheader":true
|
||||
},
|
||||
"TimeVal":{
|
||||
"shape":"Time",
|
||||
"eventheader":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ImplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short"
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer"
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ExplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyBlobEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BlobPayload":{
|
||||
"shape":"Blob",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyStringEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StringPayload":{
|
||||
"shape":"String",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"EmptyEvent": {
|
||||
"type":"structure",
|
||||
"members":{},
|
||||
"event": true
|
||||
},
|
||||
"NestedShape": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"StrVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"ExceptionEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"message":{"shape":"String"}
|
||||
},
|
||||
"exception":true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": "2.0",
|
||||
"service": null,
|
||||
"operations": {
|
||||
},
|
||||
"shapes":{}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
{
|
||||
"version":"2.0",
|
||||
"metadata":{
|
||||
"apiVersion":"0000-00-00",
|
||||
"endpointPrefix":"restjsonservice",
|
||||
"jsonVersion":"1.1",
|
||||
"protocol":"rest-json",
|
||||
"serviceAbbreviation":"RESTJSONService",
|
||||
"serviceFullName":"REST JSON Service",
|
||||
"serviceId":"RESTJSONService",
|
||||
"signatureVersion":"v4",
|
||||
"targetPrefix":"RESTJSONService_00000000",
|
||||
"uid":"RESTJSONService-0000-00-00"
|
||||
},
|
||||
"operations":{
|
||||
"GetEventStream":{
|
||||
"name":"GetEventStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"GetEventStreamRequest"},
|
||||
"output":{"shape":"GetEventStreamResponse"}
|
||||
},
|
||||
"EmptyStream":{
|
||||
"name":"EmptyStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"EmptyStreamRequest"},
|
||||
"output":{"shape":"EmptyStreamResponse"}
|
||||
}
|
||||
},
|
||||
"shapes":{
|
||||
"Bool":{"type":"boolean"},
|
||||
"Byte":{"type":"byte"},
|
||||
"Short":{"type":"short"},
|
||||
"Integer":{"type":"integer"},
|
||||
"Long":{"type":"long"},
|
||||
"Blob":{"type":"blob"},
|
||||
"String":{"type":"string"},
|
||||
"Time":{"type":"timestamp"},
|
||||
"GetEventStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"InputVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"GetEventStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StrVal":{"shape":"String"},
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"EventStream":{"shape":"EventStream"}
|
||||
}
|
||||
},
|
||||
"EventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"Headers":{"shape":"HeaderOnlyEvent"},
|
||||
"ImplicitPayload":{"shape":"ImplicitPayloadEvent"},
|
||||
"ExplicitPayload":{"shape":"ExplicitPayloadEvent"},
|
||||
"PayloadOnly":{"shape":"PayloadOnlyEvent"},
|
||||
"PayloadOnlyBlob":{"shape":"PayloadOnlyBlobEvent"},
|
||||
"PayloadOnlyString":{"shape":"PayloadOnlyStringEvent"},
|
||||
"Empty":{"shape":"EmptyEvent"},
|
||||
"Exception":{"shape":"ExceptionEvent"}
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"EmptyStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"EmptyStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"EventStream":{"shape":"EmptyEventStream"}
|
||||
}
|
||||
},
|
||||
"EmptyEventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"HeaderOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BoolVal":{
|
||||
"shape":"Bool",
|
||||
"eventheader":true
|
||||
},
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short",
|
||||
"eventheader":true
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer",
|
||||
"eventheader":true
|
||||
},
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"BlobVal":{
|
||||
"shape":"Blob",
|
||||
"eventheader":true
|
||||
},
|
||||
"TimeVal":{
|
||||
"shape":"Time",
|
||||
"eventheader":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ImplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short"
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer"
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ExplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyBlobEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BlobPayload":{
|
||||
"shape":"Blob",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyStringEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StringPayload":{
|
||||
"shape":"String",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"EmptyEvent": {
|
||||
"type":"structure",
|
||||
"members":{},
|
||||
"event": true
|
||||
},
|
||||
"NestedShape": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"StrVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"ExceptionEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"message":{"shape":"String"}
|
||||
},
|
||||
"exception":true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": "2.0",
|
||||
"service": null,
|
||||
"operations": {
|
||||
},
|
||||
"shapes":{}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
{
|
||||
"version":"2.0",
|
||||
"metadata":{
|
||||
"apiVersion":"0000-00-00",
|
||||
"endpointPrefix":"restxmlservice",
|
||||
"jsonVersion":"1.1",
|
||||
"protocol":"rest-xml",
|
||||
"serviceAbbreviation":"RESTXMLService",
|
||||
"serviceFullName":"REST XML Service",
|
||||
"serviceId":"RESTXMLService",
|
||||
"signatureVersion":"v4",
|
||||
"targetPrefix":"RESTXMLService_00000000",
|
||||
"uid":"RESTXMLService-0000-00-00"
|
||||
},
|
||||
"operations":{
|
||||
"GetEventStream":{
|
||||
"name":"GetEventStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"GetEventStreamRequest"},
|
||||
"output":{"shape":"GetEventStreamResponse"}
|
||||
},
|
||||
"EmptyStream":{
|
||||
"name":"EmptyStream",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape":"EmptyStreamRequest"},
|
||||
"output":{"shape":"EmptyStreamResponse"}
|
||||
}
|
||||
},
|
||||
"shapes":{
|
||||
"Bool":{"type":"boolean"},
|
||||
"Byte":{"type":"byte"},
|
||||
"Short":{"type":"short"},
|
||||
"Integer":{"type":"integer"},
|
||||
"Long":{"type":"long"},
|
||||
"Blob":{"type":"blob"},
|
||||
"String":{"type":"string"},
|
||||
"Time":{"type":"timestamp"},
|
||||
"GetEventStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"InputVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"GetEventStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StrVal":{"shape":"String"},
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"EventStream":{"shape":"EventStream"}
|
||||
}
|
||||
},
|
||||
"EventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"Headers":{"shape":"HeaderOnlyEvent"},
|
||||
"ImplicitPayload":{"shape":"ImplicitPayloadEvent"},
|
||||
"ExplicitPayload":{"shape":"ExplicitPayloadEvent"},
|
||||
"PayloadOnly":{"shape":"PayloadOnlyEvent"},
|
||||
"PayloadOnlyBlob":{"shape":"PayloadOnlyBlobEvent"},
|
||||
"PayloadOnlyString":{"shape":"PayloadOnlyStringEvent"},
|
||||
"Empty":{"shape":"EmptyEvent"},
|
||||
"Exception":{"shape":"ExceptionEvent"}
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"EmptyStreamRequest":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"EmptyStreamResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"EventStream":{"shape":"EmptyEventStream"}
|
||||
}
|
||||
},
|
||||
"EmptyEventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"HeaderOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BoolVal":{
|
||||
"shape":"Bool",
|
||||
"eventheader":true
|
||||
},
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short",
|
||||
"eventheader":true
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer",
|
||||
"eventheader":true
|
||||
},
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"BlobVal":{
|
||||
"shape":"Blob",
|
||||
"eventheader":true
|
||||
},
|
||||
"TimeVal":{
|
||||
"shape":"Time",
|
||||
"eventheader":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ImplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"ByteVal":{
|
||||
"shape":"Byte",
|
||||
"eventheader":true
|
||||
},
|
||||
"ShortVal":{
|
||||
"shape":"Short"
|
||||
},
|
||||
"IntegerVal":{
|
||||
"shape":"Integer"
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"ExplicitPayloadEvent": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"LongVal":{
|
||||
"shape":"Long",
|
||||
"eventheader":true
|
||||
},
|
||||
"StringVal":{
|
||||
"shape":"String",
|
||||
"eventheader":true
|
||||
},
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"NestedVal":{
|
||||
"shape":"NestedShape",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyBlobEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"BlobPayload":{
|
||||
"shape":"Blob",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"PayloadOnlyStringEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"StringPayload":{
|
||||
"shape":"String",
|
||||
"eventpayload":true
|
||||
}
|
||||
},
|
||||
"event":true
|
||||
},
|
||||
"EmptyEvent": {
|
||||
"type":"structure",
|
||||
"members":{},
|
||||
"event": true
|
||||
},
|
||||
"NestedShape": {
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"StrVal":{"shape":"String"}
|
||||
}
|
||||
},
|
||||
"ExceptionEvent":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"IntVal":{"shape":"Integer"},
|
||||
"message":{"shape":"String"}
|
||||
},
|
||||
"exception":true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": "2.0",
|
||||
"service": null,
|
||||
"operations": {
|
||||
},
|
||||
"shapes":{}
|
||||
}
|
||||
5
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/generate.go
generated
vendored
5
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/generate.go
generated
vendored
@@ -1,5 +0,0 @@
|
||||
// Package service contains automatically generated AWS clients.
|
||||
package service
|
||||
|
||||
//go:generate go run -tags codegen ../../../cli/gen-api/main.go -path=../service -svc-import-path "github.com/aws/aws-sdk-go/private/model/api/codegentest/service" ../models/*/*/api-2.json
|
||||
//go:generate gofmt -s -w ../service
|
||||
1202
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restjsonservice/api.go
generated
vendored
1202
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restjsonservice/api.go
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package restjsonservice provides the client and types for making API
|
||||
// requests to REST JSON Service.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00 for more information on this service.
|
||||
//
|
||||
// See restjsonservice package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/restjsonservice/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact REST JSON 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 REST JSON Service client RESTJSONService for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/restjsonservice/#New
|
||||
package restjsonservice
|
||||
@@ -1,3 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package restjsonservice
|
||||
@@ -1,525 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// +build go1.6
|
||||
|
||||
package restjsonservice
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/corehandlers"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamtest"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restjson"
|
||||
)
|
||||
|
||||
var _ time.Time
|
||||
var _ awserr.Error
|
||||
|
||||
func TestEmptyStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEmptyStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockEmptyStreamReadEvents() (
|
||||
[]EmptyEventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EmptyEventStreamEvent{}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restjson.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
|
||||
func TestGetEventStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetEventStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGetEventStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockGetEventStreamReadEvents() (
|
||||
[]EventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&EmptyEvent{},
|
||||
&ExplicitPayloadEvent{
|
||||
LongVal: aws.Int64(1234),
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
StringVal: aws.String("string value goes here"),
|
||||
},
|
||||
&HeaderOnlyEvent{
|
||||
BlobVal: []byte("blob value goes here"),
|
||||
BoolVal: aws.Bool(true),
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
LongVal: aws.Int64(1234),
|
||||
ShortVal: aws.Int64(12),
|
||||
StringVal: aws.String("string value goes here"),
|
||||
TimeVal: aws.Time(time.Unix(1396594860, 0).UTC()),
|
||||
},
|
||||
&ImplicitPayloadEvent{
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
ShortVal: aws.Int64(12),
|
||||
},
|
||||
&PayloadOnlyEvent{
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
},
|
||||
&PayloadOnlyBlobEvent{
|
||||
BlobPayload: []byte("blob value goes here"),
|
||||
},
|
||||
&PayloadOnlyStringEvent{
|
||||
StringPayload: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restjson.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Empty"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ExplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[1].(*ExplicitPayloadEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[1].(*ExplicitPayloadEvent).StringVal),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[1]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Headers"),
|
||||
},
|
||||
{
|
||||
Name: "BlobVal",
|
||||
Value: eventstream.BytesValue(expectEvents[2].(*HeaderOnlyEvent).BlobVal),
|
||||
},
|
||||
{
|
||||
Name: "BoolVal",
|
||||
Value: eventstream.BoolValue(*expectEvents[2].(*HeaderOnlyEvent).BoolVal),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[2].(*HeaderOnlyEvent).ByteVal)),
|
||||
},
|
||||
{
|
||||
Name: "IntegerVal",
|
||||
Value: eventstream.Int32Value(int32(*expectEvents[2].(*HeaderOnlyEvent).IntegerVal)),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[2].(*HeaderOnlyEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "ShortVal",
|
||||
Value: eventstream.Int16Value(int16(*expectEvents[2].(*HeaderOnlyEvent).ShortVal)),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[2].(*HeaderOnlyEvent).StringVal),
|
||||
},
|
||||
{
|
||||
Name: "TimeVal",
|
||||
Value: eventstream.TimestampValue(*expectEvents[2].(*HeaderOnlyEvent).TimeVal),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ImplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[3].(*ImplicitPayloadEvent).ByteVal)),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[3]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnly"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[4]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyBlob"),
|
||||
},
|
||||
},
|
||||
Payload: expectEvents[5].(*PayloadOnlyBlobEvent).BlobPayload,
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyString"),
|
||||
},
|
||||
},
|
||||
Payload: []byte(*expectEvents[6].(*PayloadOnlyStringEvent).StringPayload),
|
||||
},
|
||||
}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
func TestGetEventStream_ReadException(t *testing.T) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restjson.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventExceptionTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.ExceptionTypeHeader,
|
||||
Value: eventstream.StringValue("Exception"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[0]),
|
||||
},
|
||||
}
|
||||
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
err = resp.EventStream.Err()
|
||||
if err == nil {
|
||||
t.Fatalf("expect err, got none")
|
||||
}
|
||||
|
||||
expectErr := &ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
}
|
||||
aerr, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
t.Errorf("expect exception, got %T, %#v", err, err)
|
||||
}
|
||||
if e, a := expectErr.Code(), aerr.Code(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := expectErr.Message(), aerr.Message(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := expectErr, aerr; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
var _ awserr.Error = (*ExceptionEvent)(nil)
|
||||
|
||||
type loopReader struct {
|
||||
source *bytes.Reader
|
||||
}
|
||||
|
||||
func (c *loopReader) Read(p []byte) (int, error) {
|
||||
if c.source.Len() == 0 {
|
||||
c.source.Seek(0, 0)
|
||||
}
|
||||
|
||||
return c.source.Read(p)
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package restjsonserviceiface provides an interface to enable mocking the REST JSON Service 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 restjsonserviceiface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restjsonservice"
|
||||
)
|
||||
|
||||
// RESTJSONServiceAPI provides an interface to enable mocking the
|
||||
// restjsonservice.RESTJSONService 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 SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // REST JSON Service.
|
||||
// func myFunc(svc restjsonserviceiface.RESTJSONServiceAPI) bool {
|
||||
// // Make svc.EmptyStream request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := restjsonservice.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockRESTJSONServiceClient struct {
|
||||
// restjsonserviceiface.RESTJSONServiceAPI
|
||||
// }
|
||||
// func (m *mockRESTJSONServiceClient) EmptyStream(input *restjsonservice.EmptyStreamInput) (*restjsonservice.EmptyStreamOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockRESTJSONServiceClient{}
|
||||
//
|
||||
// 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 RESTJSONServiceAPI interface {
|
||||
EmptyStream(*restjsonservice.EmptyStreamInput) (*restjsonservice.EmptyStreamOutput, error)
|
||||
EmptyStreamWithContext(aws.Context, *restjsonservice.EmptyStreamInput, ...request.Option) (*restjsonservice.EmptyStreamOutput, error)
|
||||
EmptyStreamRequest(*restjsonservice.EmptyStreamInput) (*request.Request, *restjsonservice.EmptyStreamOutput)
|
||||
|
||||
GetEventStream(*restjsonservice.GetEventStreamInput) (*restjsonservice.GetEventStreamOutput, error)
|
||||
GetEventStreamWithContext(aws.Context, *restjsonservice.GetEventStreamInput, ...request.Option) (*restjsonservice.GetEventStreamOutput, error)
|
||||
GetEventStreamRequest(*restjsonservice.GetEventStreamInput) (*request.Request, *restjsonservice.GetEventStreamOutput)
|
||||
}
|
||||
|
||||
var _ RESTJSONServiceAPI = (*restjsonservice.RESTJSONService)(nil)
|
||||
@@ -1,99 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package restjsonservice
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// RESTJSONService provides the API operation methods for making requests to
|
||||
// REST JSON Service. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// RESTJSONService methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type RESTJSONService 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 = "RESTJSONService" // Name of service.
|
||||
EndpointsID = "restjsonservice" // ID to lookup a service endpoint with.
|
||||
ServiceID = "RESTJSONService" // ServiceID is a unique identifer of a specific service.
|
||||
)
|
||||
|
||||
// New creates a new instance of the RESTJSONService 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 RESTJSONService client from just a session.
|
||||
// svc := restjsonservice.New(mySession)
|
||||
//
|
||||
// // Create a RESTJSONService client with additional configuration
|
||||
// svc := restjsonservice.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *RESTJSONService {
|
||||
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) *RESTJSONService {
|
||||
svc := &RESTJSONService{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
ServiceID: ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "0000-00-00",
|
||||
JSONVersion: "1.1",
|
||||
TargetPrefix: "RESTJSONService_00000000",
|
||||
},
|
||||
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)
|
||||
|
||||
svc.Handlers.UnmarshalStream.PushBackNamed(restjson.UnmarshalHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a RESTJSONService operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *RESTJSONService) 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
|
||||
}
|
||||
1202
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restxmlservice/api.go
generated
vendored
1202
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restxmlservice/api.go
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package restxmlservice provides the client and types for making API
|
||||
// requests to REST XML Service.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/RESTXMLService-0000-00-00 for more information on this service.
|
||||
//
|
||||
// See restxmlservice package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/restxmlservice/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact REST XML 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 REST XML Service client RESTXMLService for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/restxmlservice/#New
|
||||
package restxmlservice
|
||||
@@ -1,3 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package restxmlservice
|
||||
@@ -1,525 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// +build go1.6
|
||||
|
||||
package restxmlservice
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/corehandlers"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamtest"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restxml"
|
||||
)
|
||||
|
||||
var _ time.Time
|
||||
var _ awserr.Error
|
||||
|
||||
func TestEmptyStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEmptyStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockEmptyStreamReadEvents() (
|
||||
[]EmptyEventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EmptyEventStreamEvent{}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restxml.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
|
||||
func TestGetEventStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetEventStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGetEventStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockGetEventStreamReadEvents() (
|
||||
[]EventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&EmptyEvent{},
|
||||
&ExplicitPayloadEvent{
|
||||
LongVal: aws.Int64(1234),
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
StringVal: aws.String("string value goes here"),
|
||||
},
|
||||
&HeaderOnlyEvent{
|
||||
BlobVal: []byte("blob value goes here"),
|
||||
BoolVal: aws.Bool(true),
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
LongVal: aws.Int64(1234),
|
||||
ShortVal: aws.Int64(12),
|
||||
StringVal: aws.String("string value goes here"),
|
||||
TimeVal: aws.Time(time.Unix(1396594860, 0).UTC()),
|
||||
},
|
||||
&ImplicitPayloadEvent{
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
ShortVal: aws.Int64(12),
|
||||
},
|
||||
&PayloadOnlyEvent{
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
},
|
||||
&PayloadOnlyBlobEvent{
|
||||
BlobPayload: []byte("blob value goes here"),
|
||||
},
|
||||
&PayloadOnlyStringEvent{
|
||||
StringPayload: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restxml.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Empty"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ExplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[1].(*ExplicitPayloadEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[1].(*ExplicitPayloadEvent).StringVal),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[1]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Headers"),
|
||||
},
|
||||
{
|
||||
Name: "BlobVal",
|
||||
Value: eventstream.BytesValue(expectEvents[2].(*HeaderOnlyEvent).BlobVal),
|
||||
},
|
||||
{
|
||||
Name: "BoolVal",
|
||||
Value: eventstream.BoolValue(*expectEvents[2].(*HeaderOnlyEvent).BoolVal),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[2].(*HeaderOnlyEvent).ByteVal)),
|
||||
},
|
||||
{
|
||||
Name: "IntegerVal",
|
||||
Value: eventstream.Int32Value(int32(*expectEvents[2].(*HeaderOnlyEvent).IntegerVal)),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[2].(*HeaderOnlyEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "ShortVal",
|
||||
Value: eventstream.Int16Value(int16(*expectEvents[2].(*HeaderOnlyEvent).ShortVal)),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[2].(*HeaderOnlyEvent).StringVal),
|
||||
},
|
||||
{
|
||||
Name: "TimeVal",
|
||||
Value: eventstream.TimestampValue(*expectEvents[2].(*HeaderOnlyEvent).TimeVal),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ImplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[3].(*ImplicitPayloadEvent).ByteVal)),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[3]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnly"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[4]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyBlob"),
|
||||
},
|
||||
},
|
||||
Payload: expectEvents[5].(*PayloadOnlyBlobEvent).BlobPayload,
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyString"),
|
||||
},
|
||||
},
|
||||
Payload: []byte(*expectEvents[6].(*PayloadOnlyStringEvent).StringPayload),
|
||||
},
|
||||
}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
func TestGetEventStream_ReadException(t *testing.T) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(restxml.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventExceptionTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.ExceptionTypeHeader,
|
||||
Value: eventstream.StringValue("Exception"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[0]),
|
||||
},
|
||||
}
|
||||
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
err = resp.EventStream.Err()
|
||||
if err == nil {
|
||||
t.Fatalf("expect err, got none")
|
||||
}
|
||||
|
||||
expectErr := &ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
}
|
||||
aerr, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
t.Errorf("expect exception, got %T, %#v", err, err)
|
||||
}
|
||||
if e, a := expectErr.Code(), aerr.Code(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := expectErr.Message(), aerr.Message(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := expectErr, aerr; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
var _ awserr.Error = (*ExceptionEvent)(nil)
|
||||
|
||||
type loopReader struct {
|
||||
source *bytes.Reader
|
||||
}
|
||||
|
||||
func (c *loopReader) Read(p []byte) (int, error) {
|
||||
if c.source.Len() == 0 {
|
||||
c.source.Seek(0, 0)
|
||||
}
|
||||
|
||||
return c.source.Read(p)
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package restxmlserviceiface provides an interface to enable mocking the REST XML Service 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 restxmlserviceiface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/model/api/codegentest/service/restxmlservice"
|
||||
)
|
||||
|
||||
// RESTXMLServiceAPI provides an interface to enable mocking the
|
||||
// restxmlservice.RESTXMLService 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 SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // REST XML Service.
|
||||
// func myFunc(svc restxmlserviceiface.RESTXMLServiceAPI) bool {
|
||||
// // Make svc.EmptyStream request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := restxmlservice.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockRESTXMLServiceClient struct {
|
||||
// restxmlserviceiface.RESTXMLServiceAPI
|
||||
// }
|
||||
// func (m *mockRESTXMLServiceClient) EmptyStream(input *restxmlservice.EmptyStreamInput) (*restxmlservice.EmptyStreamOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockRESTXMLServiceClient{}
|
||||
//
|
||||
// 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 RESTXMLServiceAPI interface {
|
||||
EmptyStream(*restxmlservice.EmptyStreamInput) (*restxmlservice.EmptyStreamOutput, error)
|
||||
EmptyStreamWithContext(aws.Context, *restxmlservice.EmptyStreamInput, ...request.Option) (*restxmlservice.EmptyStreamOutput, error)
|
||||
EmptyStreamRequest(*restxmlservice.EmptyStreamInput) (*request.Request, *restxmlservice.EmptyStreamOutput)
|
||||
|
||||
GetEventStream(*restxmlservice.GetEventStreamInput) (*restxmlservice.GetEventStreamOutput, error)
|
||||
GetEventStreamWithContext(aws.Context, *restxmlservice.GetEventStreamInput, ...request.Option) (*restxmlservice.GetEventStreamOutput, error)
|
||||
GetEventStreamRequest(*restxmlservice.GetEventStreamInput) (*request.Request, *restxmlservice.GetEventStreamOutput)
|
||||
}
|
||||
|
||||
var _ RESTXMLServiceAPI = (*restxmlservice.RESTXMLService)(nil)
|
||||
@@ -1,99 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package restxmlservice
|
||||
|
||||
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/restxml"
|
||||
)
|
||||
|
||||
// RESTXMLService provides the API operation methods for making requests to
|
||||
// REST XML Service. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// RESTXMLService methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type RESTXMLService 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 = "RESTXMLService" // Name of service.
|
||||
EndpointsID = "restxmlservice" // ID to lookup a service endpoint with.
|
||||
ServiceID = "RESTXMLService" // ServiceID is a unique identifer of a specific service.
|
||||
)
|
||||
|
||||
// New creates a new instance of the RESTXMLService 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 RESTXMLService client from just a session.
|
||||
// svc := restxmlservice.New(mySession)
|
||||
//
|
||||
// // Create a RESTXMLService client with additional configuration
|
||||
// svc := restxmlservice.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *RESTXMLService {
|
||||
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) *RESTXMLService {
|
||||
svc := &RESTXMLService{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
ServiceID: ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "0000-00-00",
|
||||
JSONVersion: "1.1",
|
||||
TargetPrefix: "RESTXMLService_00000000",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(restxml.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler)
|
||||
|
||||
svc.Handlers.UnmarshalStream.PushBackNamed(restxml.UnmarshalHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a RESTXMLService operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *RESTXMLService) 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
|
||||
}
|
||||
1299
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/rpcservice/api.go
generated
vendored
1299
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/rpcservice/api.go
generated
vendored
File diff suppressed because it is too large
Load Diff
26
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/rpcservice/doc.go
generated
vendored
26
vendor/github.com/aws/aws-sdk-go/private/model/api/codegentest/service/rpcservice/doc.go
generated
vendored
@@ -1,26 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package rpcservice provides the client and types for making API
|
||||
// requests to RPC Service.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/RPCService-0000-00-00 for more information on this service.
|
||||
//
|
||||
// See rpcservice package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/rpcservice/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact RPC 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 RPC Service client RPCService for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/rpcservice/#New
|
||||
package rpcservice
|
||||
@@ -1,3 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package rpcservice
|
||||
@@ -1,575 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// +build go1.6
|
||||
|
||||
package rpcservice
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/corehandlers"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamtest"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
)
|
||||
|
||||
var _ time.Time
|
||||
var _ awserr.Error
|
||||
|
||||
func TestEmptyStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEmptyStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockEmptyStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.EmptyStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockEmptyStreamReadEvents() (
|
||||
[]EmptyEventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EmptyEventStreamEvent{
|
||||
&EmptyStreamOutput{},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(jsonrpc.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("initial-response"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[0]),
|
||||
},
|
||||
}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
|
||||
func TestGetEventStream_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
expectResp := expectEvents[0].(*GetEventStreamOutput)
|
||||
if e, a := expectResp.IntVal, resp.IntVal; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := expectResp.StrVal, resp.StrVal; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
// Trim off response output type pseudo event so only event messages remain.
|
||||
expectEvents = expectEvents[1:]
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetEventStream_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGetEventStream_Read(b *testing.B) {
|
||||
_, eventMsgs := mockGetEventStreamReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockGetEventStreamReadEvents() (
|
||||
[]EventStreamEvent,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&GetEventStreamOutput{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
&EmptyEvent{},
|
||||
&ExplicitPayloadEvent{
|
||||
LongVal: aws.Int64(1234),
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
StringVal: aws.String("string value goes here"),
|
||||
},
|
||||
&HeaderOnlyEvent{
|
||||
BlobVal: []byte("blob value goes here"),
|
||||
BoolVal: aws.Bool(true),
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
LongVal: aws.Int64(1234),
|
||||
ShortVal: aws.Int64(12),
|
||||
StringVal: aws.String("string value goes here"),
|
||||
TimeVal: aws.Time(time.Unix(1396594860, 0).UTC()),
|
||||
},
|
||||
&ImplicitPayloadEvent{
|
||||
ByteVal: aws.Int64(1),
|
||||
IntegerVal: aws.Int64(123),
|
||||
ShortVal: aws.Int64(12),
|
||||
},
|
||||
&PayloadOnlyEvent{
|
||||
NestedVal: &NestedShape{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
},
|
||||
&PayloadOnlyBlobEvent{
|
||||
BlobPayload: []byte("blob value goes here"),
|
||||
},
|
||||
&PayloadOnlyStringEvent{
|
||||
StringPayload: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(jsonrpc.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("initial-response"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[0]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Empty"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ExplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[2].(*ExplicitPayloadEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[2].(*ExplicitPayloadEvent).StringVal),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[2]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("Headers"),
|
||||
},
|
||||
{
|
||||
Name: "BlobVal",
|
||||
Value: eventstream.BytesValue(expectEvents[3].(*HeaderOnlyEvent).BlobVal),
|
||||
},
|
||||
{
|
||||
Name: "BoolVal",
|
||||
Value: eventstream.BoolValue(*expectEvents[3].(*HeaderOnlyEvent).BoolVal),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[3].(*HeaderOnlyEvent).ByteVal)),
|
||||
},
|
||||
{
|
||||
Name: "IntegerVal",
|
||||
Value: eventstream.Int32Value(int32(*expectEvents[3].(*HeaderOnlyEvent).IntegerVal)),
|
||||
},
|
||||
{
|
||||
Name: "LongVal",
|
||||
Value: eventstream.Int64Value(*expectEvents[3].(*HeaderOnlyEvent).LongVal),
|
||||
},
|
||||
{
|
||||
Name: "ShortVal",
|
||||
Value: eventstream.Int16Value(int16(*expectEvents[3].(*HeaderOnlyEvent).ShortVal)),
|
||||
},
|
||||
{
|
||||
Name: "StringVal",
|
||||
Value: eventstream.StringValue(*expectEvents[3].(*HeaderOnlyEvent).StringVal),
|
||||
},
|
||||
{
|
||||
Name: "TimeVal",
|
||||
Value: eventstream.TimestampValue(*expectEvents[3].(*HeaderOnlyEvent).TimeVal),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("ImplicitPayload"),
|
||||
},
|
||||
{
|
||||
Name: "ByteVal",
|
||||
Value: eventstream.Int8Value(int8(*expectEvents[4].(*ImplicitPayloadEvent).ByteVal)),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[4]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnly"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[5]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyBlob"),
|
||||
},
|
||||
},
|
||||
Payload: expectEvents[6].(*PayloadOnlyBlobEvent).BlobPayload,
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("PayloadOnlyString"),
|
||||
},
|
||||
},
|
||||
Payload: []byte(*expectEvents[7].(*PayloadOnlyStringEvent).StringPayload),
|
||||
},
|
||||
}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
func TestGetEventStream_ReadException(t *testing.T) {
|
||||
expectEvents := []EventStreamEvent{
|
||||
&GetEventStreamOutput{
|
||||
IntVal: aws.Int64(123),
|
||||
StrVal: aws.String("string value goes here"),
|
||||
},
|
||||
&ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
},
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed(jsonrpc.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("initial-response"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[0]),
|
||||
},
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
eventstreamtest.EventExceptionTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.ExceptionTypeHeader,
|
||||
Value: eventstream.StringValue("Exception"),
|
||||
},
|
||||
},
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[1]),
|
||||
},
|
||||
}
|
||||
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.GetEventStream(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
err = resp.EventStream.Err()
|
||||
if err == nil {
|
||||
t.Fatalf("expect err, got none")
|
||||
}
|
||||
|
||||
expectErr := &ExceptionEvent{
|
||||
IntVal: aws.Int64(123),
|
||||
Message_: aws.String("string value goes here"),
|
||||
}
|
||||
aerr, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
t.Errorf("expect exception, got %T, %#v", err, err)
|
||||
}
|
||||
if e, a := expectErr.Code(), aerr.Code(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := expectErr.Message(), aerr.Message(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := expectErr, aerr; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
var _ awserr.Error = (*ExceptionEvent)(nil)
|
||||
|
||||
type loopReader struct {
|
||||
source *bytes.Reader
|
||||
}
|
||||
|
||||
func (c *loopReader) Read(p []byte) (int, error) {
|
||||
if c.source.Len() == 0 {
|
||||
c.source.Seek(0, 0)
|
||||
}
|
||||
|
||||
return c.source.Read(p)
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package rpcserviceiface provides an interface to enable mocking the RPC Service 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 rpcserviceiface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/model/api/codegentest/service/rpcservice"
|
||||
)
|
||||
|
||||
// RPCServiceAPI provides an interface to enable mocking the
|
||||
// rpcservice.RPCService 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 SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // RPC Service.
|
||||
// func myFunc(svc rpcserviceiface.RPCServiceAPI) bool {
|
||||
// // Make svc.EmptyStream request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := rpcservice.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockRPCServiceClient struct {
|
||||
// rpcserviceiface.RPCServiceAPI
|
||||
// }
|
||||
// func (m *mockRPCServiceClient) EmptyStream(input *rpcservice.EmptyStreamInput) (*rpcservice.EmptyStreamOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockRPCServiceClient{}
|
||||
//
|
||||
// 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 RPCServiceAPI interface {
|
||||
EmptyStream(*rpcservice.EmptyStreamInput) (*rpcservice.EmptyStreamOutput, error)
|
||||
EmptyStreamWithContext(aws.Context, *rpcservice.EmptyStreamInput, ...request.Option) (*rpcservice.EmptyStreamOutput, error)
|
||||
EmptyStreamRequest(*rpcservice.EmptyStreamInput) (*request.Request, *rpcservice.EmptyStreamOutput)
|
||||
|
||||
GetEventStream(*rpcservice.GetEventStreamInput) (*rpcservice.GetEventStreamOutput, error)
|
||||
GetEventStreamWithContext(aws.Context, *rpcservice.GetEventStreamInput, ...request.Option) (*rpcservice.GetEventStreamOutput, error)
|
||||
GetEventStreamRequest(*rpcservice.GetEventStreamInput) (*request.Request, *rpcservice.GetEventStreamOutput)
|
||||
}
|
||||
|
||||
var _ RPCServiceAPI = (*rpcservice.RPCService)(nil)
|
||||
@@ -1,99 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package rpcservice
|
||||
|
||||
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/jsonrpc"
|
||||
)
|
||||
|
||||
// RPCService provides the API operation methods for making requests to
|
||||
// RPC Service. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// RPCService methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type RPCService 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 = "RPCService" // Name of service.
|
||||
EndpointsID = "rpcservice" // ID to lookup a service endpoint with.
|
||||
ServiceID = "RPCService" // ServiceID is a unique identifer of a specific service.
|
||||
)
|
||||
|
||||
// New creates a new instance of the RPCService 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 RPCService client from just a session.
|
||||
// svc := rpcservice.New(mySession)
|
||||
//
|
||||
// // Create a RPCService client with additional configuration
|
||||
// svc := rpcservice.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *RPCService {
|
||||
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) *RPCService {
|
||||
svc := &RPCService{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
ServiceID: ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "0000-00-00",
|
||||
JSONVersion: "1.1",
|
||||
TargetPrefix: "RPCService_00000000",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
|
||||
|
||||
svc.Handlers.UnmarshalStream.PushBackNamed(jsonrpc.UnmarshalHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a RPCService operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *RPCService) 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
|
||||
}
|
||||
4
vendor/github.com/aws/aws-sdk-go/private/model/api/customization_passes.go
generated
vendored
4
vendor/github.com/aws/aws-sdk-go/private/model/api/customization_passes.go
generated
vendored
@@ -54,8 +54,8 @@ func s3Customizations(a *API) {
|
||||
var strExpires *Shape
|
||||
|
||||
var keepContentMD5Ref = map[string]struct{}{
|
||||
"PutObjectInput": {},
|
||||
"UploadPartInput": {},
|
||||
"PutObjectInput": struct{}{},
|
||||
"UploadPartInput": struct{}{},
|
||||
}
|
||||
|
||||
for name, s := range a.Shapes {
|
||||
|
||||
9
vendor/github.com/aws/aws-sdk-go/private/model/api/docstring.go
generated
vendored
9
vendor/github.com/aws/aws-sdk-go/private/model/api/docstring.go
generated
vendored
@@ -47,13 +47,8 @@ func (a *API) AttachDocs(filename string) {
|
||||
func (d *apiDocumentation) setup() {
|
||||
d.API.Documentation = docstring(d.Service)
|
||||
|
||||
for opName, doc := range d.Operations {
|
||||
if _, ok := d.API.Operations[opName]; !ok {
|
||||
panic(fmt.Sprintf("%s, doc op %q not found in API op set",
|
||||
d.API.name, opName),
|
||||
)
|
||||
}
|
||||
d.API.Operations[opName].Documentation = docstring(doc)
|
||||
for op, doc := range d.Operations {
|
||||
d.API.Operations[op].Documentation = docstring(doc)
|
||||
}
|
||||
|
||||
for shape, info := range d.Shapes {
|
||||
|
||||
711
vendor/github.com/aws/aws-sdk-go/private/model/api/eventstream.go
generated
vendored
711
vendor/github.com/aws/aws-sdk-go/private/model/api/eventstream.go
generated
vendored
@@ -6,14 +6,12 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// EventStreamAPI provides details about the event stream async API and
|
||||
// associated EventStream shapes.
|
||||
type EventStreamAPI struct {
|
||||
API *API
|
||||
Name string
|
||||
Operation *Operation
|
||||
Shape *Shape
|
||||
@@ -24,10 +22,9 @@ type EventStreamAPI struct {
|
||||
// EventStream represents a single eventstream group (input/output) and the
|
||||
// modeled events that are known for the stream.
|
||||
type EventStream struct {
|
||||
Name string
|
||||
Shape *Shape
|
||||
Events []*Event
|
||||
Exceptions []*Event
|
||||
Name string
|
||||
Shape *Shape
|
||||
Events []*Event
|
||||
}
|
||||
|
||||
// Event is a single EventStream event that can be sent or received in an
|
||||
@@ -75,16 +72,6 @@ The events that can be sent are:
|
||||
return commentify(w.String())
|
||||
}
|
||||
|
||||
func hasEventStream(topShape *Shape) bool {
|
||||
for _, ref := range topShape.MemberRefs {
|
||||
if ref.Shape.IsEventStream {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func eventStreamAPIShapeRefDoc(refName string) string {
|
||||
return commentify(fmt.Sprintf("Use %s to use the API's stream.", refName))
|
||||
}
|
||||
@@ -112,8 +99,7 @@ func (a *API) setupEventStreams() {
|
||||
a.Metadata.Protocol))
|
||||
}
|
||||
|
||||
op.EventStreamAPI = &EventStreamAPI{
|
||||
API: a,
|
||||
eventStreamAPI := &EventStreamAPI{
|
||||
Name: op.ExportedName + eventStreamMemberName,
|
||||
Operation: op,
|
||||
Outbound: outbound,
|
||||
@@ -122,18 +108,11 @@ func (a *API) setupEventStreams() {
|
||||
|
||||
streamShape := &Shape{
|
||||
API: a,
|
||||
ShapeName: op.EventStreamAPI.Name,
|
||||
Documentation: op.EventStreamAPI.ShapeDoc(),
|
||||
ShapeName: eventStreamAPI.Name,
|
||||
Documentation: eventStreamAPI.ShapeDoc(),
|
||||
Type: "structure",
|
||||
EventStreamAPI: op.EventStreamAPI,
|
||||
IsEventStream: true,
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Inbound": &ShapeRef{
|
||||
ShapeName: inbound.Shape.ShapeName,
|
||||
},
|
||||
},
|
||||
EventStreamAPI: eventStreamAPI,
|
||||
}
|
||||
inbound.Shape.refs = append(inbound.Shape.refs, streamShape.MemberRefs["Inbound"])
|
||||
streamShapeRef := &ShapeRef{
|
||||
API: a,
|
||||
ShapeName: streamShape.ShapeName,
|
||||
@@ -141,7 +120,7 @@ func (a *API) setupEventStreams() {
|
||||
Documentation: eventStreamAPIShapeRefDoc(eventStreamMemberName),
|
||||
}
|
||||
streamShape.refs = []*ShapeRef{streamShapeRef}
|
||||
op.EventStreamAPI.Shape = streamShape
|
||||
eventStreamAPI.Shape = streamShape
|
||||
|
||||
if _, ok := op.OutputRef.Shape.MemberRefs[eventStreamMemberName]; ok {
|
||||
panic(fmt.Sprintf("shape ref already exists, %s.%s",
|
||||
@@ -173,14 +152,9 @@ func setupEventStream(topShape *Shape) *EventStream {
|
||||
Name: ref.Shape.ShapeName,
|
||||
Shape: ref.Shape,
|
||||
}
|
||||
|
||||
if topShape.API.Metadata.Protocol == "json" {
|
||||
topShape.EventFor = append(topShape.EventFor, eventStream)
|
||||
}
|
||||
|
||||
for _, eventRefName := range ref.Shape.MemberNames() {
|
||||
eventRef := ref.Shape.MemberRefs[eventRefName]
|
||||
if !(eventRef.Shape.IsEvent || eventRef.Shape.Exception) {
|
||||
if !eventRef.Shape.IsEvent {
|
||||
panic(fmt.Sprintf("unexpected non-event member reference %s.%s",
|
||||
ref.Shape.ShapeName, eventRefName))
|
||||
}
|
||||
@@ -188,19 +162,11 @@ func setupEventStream(topShape *Shape) *EventStream {
|
||||
updateEventPayloadRef(eventRef.Shape)
|
||||
|
||||
eventRef.Shape.EventFor = append(eventRef.Shape.EventFor, eventStream)
|
||||
|
||||
// Exceptions and events are two different lists to allow the SDK
|
||||
// to easly generate code with the two handled differently.
|
||||
event := &Event{
|
||||
eventStream.Events = append(eventStream.Events, &Event{
|
||||
Name: eventRefName,
|
||||
Shape: eventRef.Shape,
|
||||
For: eventStream,
|
||||
}
|
||||
if eventRef.Shape.Exception {
|
||||
eventStream.Exceptions = append(eventStream.Exceptions, event)
|
||||
} else {
|
||||
eventStream.Events = append(eventStream.Events, event)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Remove the eventstream references as they will be added elsewhere.
|
||||
@@ -233,18 +199,22 @@ func updateEventPayloadRef(parent *Shape) {
|
||||
|
||||
func renderEventStreamAPIShape(w io.Writer, s *Shape) error {
|
||||
// Imports needed by the EventStream APIs.
|
||||
s.API.imports["fmt"] = true
|
||||
s.API.imports["bytes"] = true
|
||||
s.API.imports["io"] = true
|
||||
s.API.imports["sync"] = true
|
||||
s.API.imports["sync/atomic"] = true
|
||||
s.API.imports["github.com/aws/aws-sdk-go/aws/awserr"] = true
|
||||
s.API.imports["github.com/aws/aws-sdk-go/private/protocol/eventstream"] = true
|
||||
s.API.imports["github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi"] = true
|
||||
|
||||
return eventStreamAPIShapeTmpl.Execute(w, s)
|
||||
}
|
||||
|
||||
// EventStreamReaderInterfaceName returns the interface name for the
|
||||
// EventStream's reader interface.
|
||||
func EventStreamReaderInterfaceName(s *Shape) string {
|
||||
return s.ShapeName + "Reader"
|
||||
}
|
||||
|
||||
// Template for an EventStream API Shape that will provide read/writing events
|
||||
// across the EventStream. This is a special shape that's only public members
|
||||
// are the Events channel and a Close and Err method.
|
||||
@@ -370,7 +340,7 @@ var eventStreamAPIReaderTmpl = template.Must(template.New("eventStreamAPIReaderT
|
||||
// * {{ $event.Shape.ShapeName }}
|
||||
{{- end }}
|
||||
type {{ $.EventStreamAPI.Inbound.Name }}Event interface {
|
||||
event{{ $.EventStreamAPI.Inbound.Name }}()
|
||||
event{{ $.EventStreamAPI.Name }}()
|
||||
}
|
||||
|
||||
// {{ $.ShapeName }}Reader provides the interface for reading EventStream
|
||||
@@ -402,10 +372,6 @@ type read{{ $.ShapeName }} struct {
|
||||
|
||||
done chan struct{}
|
||||
closeOnce sync.Once
|
||||
|
||||
{{ if eq $.API.Metadata.Protocol "json" -}}
|
||||
initResp eventstreamapi.Unmarshaler
|
||||
{{ end -}}
|
||||
}
|
||||
|
||||
func newRead{{ $.ShapeName }}(
|
||||
@@ -413,16 +379,10 @@ func newRead{{ $.ShapeName }}(
|
||||
unmarshalers request.HandlerList,
|
||||
logger aws.Logger,
|
||||
logLevel aws.LogLevelType,
|
||||
{{ if eq $.API.Metadata.Protocol "json" -}}
|
||||
initResp eventstreamapi.Unmarshaler,
|
||||
{{ end -}}
|
||||
) *read{{ $.ShapeName }} {
|
||||
r := &read{{ $.ShapeName }}{
|
||||
stream: make(chan {{ $.EventStreamAPI.Inbound.Name }}Event),
|
||||
done: make(chan struct{}),
|
||||
{{ if eq $.API.Metadata.Protocol "json" -}}
|
||||
initResp: initResp,
|
||||
{{ end -}}
|
||||
}
|
||||
|
||||
r.eventReader = eventstreamapi.NewEventReader(
|
||||
@@ -496,24 +456,13 @@ func (r *read{{ $.ShapeName }}) unmarshalerForEventType(
|
||||
eventType string,
|
||||
) (eventstreamapi.Unmarshaler, error) {
|
||||
switch eventType {
|
||||
{{- if eq $.API.Metadata.Protocol "json" }}
|
||||
case "initial-response":
|
||||
return r.initResp, nil
|
||||
{{ end -}}
|
||||
{{- range $_, $event := $.EventStreamAPI.Inbound.Events }}
|
||||
case {{ printf "%q" $event.Name }}:
|
||||
return &{{ $event.Shape.ShapeName }}{}, nil
|
||||
{{ end -}}
|
||||
{{- range $_, $event := $.EventStreamAPI.Inbound.Exceptions }}
|
||||
case {{ printf "%q" $event.Name }}:
|
||||
return &{{ $event.Shape.ShapeName }}{}, nil
|
||||
{{ end -}}
|
||||
default:
|
||||
return nil, awserr.New(
|
||||
request.ErrCodeSerialization,
|
||||
fmt.Sprintf("unknown event type name, %s, for {{ $.ShapeName }}", eventType),
|
||||
nil,
|
||||
)
|
||||
return nil, fmt.Errorf(
|
||||
"unknown event type name, %s, for {{ $.ShapeName }}", eventType)
|
||||
}
|
||||
}
|
||||
`))
|
||||
@@ -536,9 +485,6 @@ func (s *{{ $.ShapeName }}) runEventStreamLoop(r *request.Request) {
|
||||
r.Handlers.UnmarshalStream,
|
||||
r.Config.Logger,
|
||||
r.Config.LogLevel.Value(),
|
||||
{{ if eq $.API.Metadata.Protocol "json" -}}
|
||||
s,
|
||||
{{ end -}}
|
||||
)
|
||||
go reader.readEventStream()
|
||||
|
||||
@@ -550,85 +496,13 @@ func (s *{{ $.ShapeName }}) runEventStreamLoop(r *request.Request) {
|
||||
|
||||
s.{{ $.EventStreamsMemberName }} = eventStream
|
||||
}
|
||||
|
||||
{{ if eq $.API.Metadata.Protocol "json" -}}
|
||||
func (s *{{ $.ShapeName }}) unmarshalInitialResponse(r *request.Request) {
|
||||
// Wait for the initial response event, which must be the first event to be
|
||||
// received from the API.
|
||||
select {
|
||||
case event, ok := <-s.EventStream.Events():
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
es := s.EventStream
|
||||
v, ok := event.(*{{ $.ShapeName }})
|
||||
if !ok || v == nil {
|
||||
r.Error = awserr.New(
|
||||
request.ErrCodeSerialization,
|
||||
fmt.Sprintf("invalid event, %T, expect *SubscribeToShardOutput, %v", event, v),
|
||||
nil,
|
||||
)
|
||||
return
|
||||
}
|
||||
*s = *v
|
||||
s.EventStream = es
|
||||
}
|
||||
}
|
||||
{{ end -}}
|
||||
`))
|
||||
|
||||
// EventStreamHeaderTypeMap provides the mapping of a EventStream Header's
|
||||
// Value type to the shape reference's member type.
|
||||
type EventStreamHeaderTypeMap struct {
|
||||
Header string
|
||||
Member string
|
||||
}
|
||||
|
||||
var eventStreamEventShapeTmplFuncs = template.FuncMap{
|
||||
"EventStreamHeaderTypeMap": func(ref *ShapeRef) EventStreamHeaderTypeMap {
|
||||
switch ref.Shape.Type {
|
||||
case "boolean":
|
||||
return EventStreamHeaderTypeMap{Header: "bool", Member: "bool"}
|
||||
case "byte":
|
||||
return EventStreamHeaderTypeMap{Header: "int8", Member: "int64"}
|
||||
case "short":
|
||||
return EventStreamHeaderTypeMap{Header: "int16", Member: "int64"}
|
||||
case "integer":
|
||||
return EventStreamHeaderTypeMap{Header: "int32", Member: "int64"}
|
||||
case "long":
|
||||
return EventStreamHeaderTypeMap{Header: "int64", Member: "int64"}
|
||||
case "timestamp":
|
||||
return EventStreamHeaderTypeMap{Header: "time.Time", Member: "time.Time"}
|
||||
case "blob":
|
||||
return EventStreamHeaderTypeMap{Header: "[]byte", Member: "[]byte"}
|
||||
case "string":
|
||||
return EventStreamHeaderTypeMap{Header: "string", Member: "string"}
|
||||
// TODO case "uuid" what is modeled type
|
||||
default:
|
||||
panic("unsupported EventStream header type, " + ref.Shape.Type)
|
||||
}
|
||||
},
|
||||
"HasNonBlobPayloadMembers": eventHasNonBlobPayloadMembers,
|
||||
}
|
||||
|
||||
// Returns if the event has any members which are not the event's blob payload,
|
||||
// nor a header.
|
||||
func eventHasNonBlobPayloadMembers(s *Shape) bool {
|
||||
num := len(s.MemberRefs)
|
||||
for _, ref := range s.MemberRefs {
|
||||
if ref.IsEventHeader || (ref.IsEventPayload && (ref.Shape.Type == "blob" || ref.Shape.Type == "string")) {
|
||||
num--
|
||||
}
|
||||
}
|
||||
return num > 0
|
||||
}
|
||||
|
||||
// Template for an EventStream Event shape. This is a normal API shape that is
|
||||
// decorated as an EventStream Event.
|
||||
//
|
||||
// Executed in the context of a Shape.
|
||||
var eventStreamEventShapeTmpl = template.Must(template.New("eventStreamEventShapeTmpl").
|
||||
Funcs(eventStreamEventShapeTmplFuncs).Parse(`
|
||||
var eventStreamEventShapeTmpl = template.Must(template.New("eventStreamEventShapeTmpl").Parse(`
|
||||
{{ range $_, $eventstream := $.EventFor }}
|
||||
// The {{ $.ShapeName }} is and event in the {{ $eventstream.Name }} group of events.
|
||||
func (s *{{ $.ShapeName }}) event{{ $eventstream.Name }}() {}
|
||||
@@ -640,541 +514,24 @@ func (s *{{ $.ShapeName }}) UnmarshalEvent(
|
||||
payloadUnmarshaler protocol.PayloadUnmarshaler,
|
||||
msg eventstream.Message,
|
||||
) error {
|
||||
{{- range $memName, $memRef := $.MemberRefs }}
|
||||
{{- if $memRef.IsEventHeader }}
|
||||
if hv := msg.Headers.Get("{{ $memName }}"); hv != nil {
|
||||
{{ $types := EventStreamHeaderTypeMap $memRef -}}
|
||||
v := hv.Get().({{ $types.Header }})
|
||||
{{- if ne $types.Header $types.Member }}
|
||||
m := {{ $types.Member }}(v)
|
||||
s.{{ $memName }} = {{ if $memRef.UseIndirection }}&{{ end }}m
|
||||
{{- else }}
|
||||
s.{{ $memName }} = {{ if $memRef.UseIndirection }}&{{ end }}v
|
||||
{{- end }}
|
||||
{{- range $fieldIdx, $fieldName := $.MemberNames }}
|
||||
{{- $fieldRef := index $.MemberRefs $fieldName -}}
|
||||
{{ if $fieldRef.IsEventHeader }}
|
||||
// TODO handle event header, {{ $fieldName }}
|
||||
{{- else if (and ($fieldRef.IsEventPayload) (eq $fieldRef.Shape.Type "blob")) }}
|
||||
s.{{ $fieldName }} = make([]byte, len(msg.Payload))
|
||||
copy(s.{{ $fieldName }}, msg.Payload)
|
||||
{{- else }}
|
||||
if err := payloadUnmarshaler.UnmarshalPayload(
|
||||
bytes.NewReader(msg.Payload), s,
|
||||
); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal payload, %v", err)
|
||||
}
|
||||
{{- else if (and ($memRef.IsEventPayload) (eq $memRef.Shape.Type "blob")) }}
|
||||
s.{{ $memName }} = make([]byte, len(msg.Payload))
|
||||
copy(s.{{ $memName }}, msg.Payload)
|
||||
{{- else if (and ($memRef.IsEventPayload) (eq $memRef.Shape.Type "string")) }}
|
||||
s.{{ $memName }} = aws.String(string(msg.Payload))
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if HasNonBlobPayloadMembers $ }}
|
||||
if err := payloadUnmarshaler.UnmarshalPayload(
|
||||
bytes.NewReader(msg.Payload), s,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
{{- end }}
|
||||
return nil
|
||||
}
|
||||
`))
|
||||
|
||||
var eventStreamExceptionEventShapeTmpl = template.Must(
|
||||
template.New("eventStreamExceptionEventShapeTmpl").Parse(`
|
||||
// Code returns the exception type name.
|
||||
func (s {{ $.ShapeName }}) Code() string {
|
||||
{{- if $.ErrorInfo.Code }}
|
||||
return "{{ $.ErrorInfo.Code }}"
|
||||
{{- else }}
|
||||
return "{{ $.ShapeName }}"
|
||||
{{ end -}}
|
||||
}
|
||||
|
||||
// Message returns the exception's message.
|
||||
func (s {{ $.ShapeName }}) Message() string {
|
||||
{{- if index $.MemberRefs "Message_" }}
|
||||
return *s.Message_
|
||||
{{- else }}
|
||||
return ""
|
||||
{{ end -}}
|
||||
}
|
||||
|
||||
// OrigErr always returns nil, satisfies awserr.Error interface.
|
||||
func (s {{ $.ShapeName }}) OrigErr() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s {{ $.ShapeName }}) Error() string {
|
||||
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
|
||||
}
|
||||
`))
|
||||
|
||||
// APIEventStreamTestGoCode generates Go code for EventStream operation tests.
|
||||
func (a *API) APIEventStreamTestGoCode() string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
a.resetImports()
|
||||
a.imports["bytes"] = true
|
||||
a.imports["io/ioutil"] = true
|
||||
a.imports["net/http"] = true
|
||||
a.imports["reflect"] = true
|
||||
a.imports["testing"] = true
|
||||
a.imports["time"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/aws/corehandlers"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/aws/request"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/aws/awserr"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/awstesting/unit"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/private/protocol"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/private/protocol/"+a.ProtocolPackage()] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/private/protocol/eventstream"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi"] = true
|
||||
a.imports["github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamtest"] = true
|
||||
|
||||
unused := `
|
||||
var _ time.Time
|
||||
var _ awserr.Error
|
||||
`
|
||||
|
||||
if err := eventStreamTestTmpl.Execute(&buf, a); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return a.importsGoCode() + unused + strings.TrimSpace(buf.String())
|
||||
}
|
||||
|
||||
func valueForType(s *Shape, visited []string) string {
|
||||
for _, v := range visited {
|
||||
if v == s.ShapeName {
|
||||
return "nil"
|
||||
}
|
||||
}
|
||||
|
||||
visited = append(visited, s.ShapeName)
|
||||
|
||||
switch s.Type {
|
||||
case "blob":
|
||||
return `[]byte("blob value goes here")`
|
||||
case "string":
|
||||
return `aws.String("string value goes here")`
|
||||
case "boolean":
|
||||
return `aws.Bool(true)`
|
||||
case "byte":
|
||||
return `aws.Int64(1)`
|
||||
case "short":
|
||||
return `aws.Int64(12)`
|
||||
case "integer":
|
||||
return `aws.Int64(123)`
|
||||
case "long":
|
||||
return `aws.Int64(1234)`
|
||||
case "float":
|
||||
return `aws.Float64(123.4)`
|
||||
case "double":
|
||||
return `aws.Float64(123.45)`
|
||||
case "timestamp":
|
||||
return `aws.Time(time.Unix(1396594860, 0).UTC())`
|
||||
case "structure":
|
||||
w := bytes.NewBuffer(nil)
|
||||
fmt.Fprintf(w, "&%s{\n", s.ShapeName)
|
||||
for _, refName := range s.MemberNames() {
|
||||
fmt.Fprintf(w, "%s: %s,\n", refName, valueForType(s.MemberRefs[refName].Shape, visited))
|
||||
}
|
||||
fmt.Fprintf(w, "}")
|
||||
return w.String()
|
||||
case "list":
|
||||
w := bytes.NewBuffer(nil)
|
||||
fmt.Fprintf(w, "%s{\n", s.GoType())
|
||||
for i := 0; i < 3; i++ {
|
||||
fmt.Fprintf(w, "%s,\n", valueForType(s.MemberRef.Shape, visited))
|
||||
}
|
||||
fmt.Fprintf(w, "}")
|
||||
return w.String()
|
||||
|
||||
case "map":
|
||||
w := bytes.NewBuffer(nil)
|
||||
fmt.Fprintf(w, "%s{\n", s.GoType())
|
||||
for _, k := range []string{"a", "b", "c"} {
|
||||
fmt.Fprintf(w, "%q: %s,\n", k, valueForType(s.ValueRef.Shape, visited))
|
||||
}
|
||||
fmt.Fprintf(w, "}")
|
||||
return w.String()
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("valueForType does not support %s, %s", s.ShapeName, s.Type))
|
||||
}
|
||||
}
|
||||
|
||||
func setEventHeaderValueForType(s *Shape, memVar string) string {
|
||||
switch s.Type {
|
||||
case "blob":
|
||||
return fmt.Sprintf("eventstream.BytesValue(%s)", memVar)
|
||||
case "string":
|
||||
return fmt.Sprintf("eventstream.StringValue(*%s)", memVar)
|
||||
case "boolean":
|
||||
return fmt.Sprintf("eventstream.BoolValue(*%s)", memVar)
|
||||
case "byte":
|
||||
return fmt.Sprintf("eventstream.Int8Value(int8(*%s))", memVar)
|
||||
case "short":
|
||||
return fmt.Sprintf("eventstream.Int16Value(int16(*%s))", memVar)
|
||||
case "integer":
|
||||
return fmt.Sprintf("eventstream.Int32Value(int32(*%s))", memVar)
|
||||
case "long":
|
||||
return fmt.Sprintf("eventstream.Int64Value(*%s)", memVar)
|
||||
case "float":
|
||||
return fmt.Sprintf("eventstream.Float32Value(float32(*%s))", memVar)
|
||||
case "double":
|
||||
return fmt.Sprintf("eventstream.Float64Value(*%s)", memVar)
|
||||
case "timestamp":
|
||||
return fmt.Sprintf("eventstream.TimestampValue(*%s)", memVar)
|
||||
default:
|
||||
panic(fmt.Sprintf("value type %s not supported for event headers, %s", s.Type, s.ShapeName))
|
||||
}
|
||||
}
|
||||
|
||||
func templateMap(args ...interface{}) map[string]interface{} {
|
||||
if len(args)%2 != 0 {
|
||||
panic(fmt.Sprintf("invalid map call, non-even args %v", args))
|
||||
}
|
||||
|
||||
m := map[string]interface{}{}
|
||||
for i := 0; i < len(args); i += 2 {
|
||||
k, ok := args[i].(string)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("invalid map call, arg is not string, %T, %v", args[i], args[i]))
|
||||
}
|
||||
m[k] = args[i+1]
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
var eventStreamTestTmpl = template.Must(
|
||||
template.New("eventStreamTestTmpl").Funcs(template.FuncMap{
|
||||
"ValueForType": valueForType,
|
||||
"HasNonBlobPayloadMembers": eventHasNonBlobPayloadMembers,
|
||||
"SetEventHeaderValueForType": setEventHeaderValueForType,
|
||||
"Map": templateMap,
|
||||
"OptionalAddInt": func(do bool, a, b int) int {
|
||||
if !do {
|
||||
return a
|
||||
}
|
||||
return a + b
|
||||
},
|
||||
"HasNonEventStreamMember": func(s *Shape) bool {
|
||||
for _, ref := range s.MemberRefs {
|
||||
if !ref.Shape.IsEventStream {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
}).Parse(`
|
||||
{{ range $opName, $op := $.Operations }}
|
||||
{{ if $op.EventStreamAPI }}
|
||||
{{ if $op.EventStreamAPI.Inbound }}
|
||||
{{ template "event stream inbound tests" $op.EventStreamAPI }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
type loopReader struct {
|
||||
source *bytes.Reader
|
||||
}
|
||||
|
||||
func (c *loopReader) Read(p []byte) (int, error) {
|
||||
if c.source.Len() == 0 {
|
||||
c.source.Seek(0, 0)
|
||||
}
|
||||
|
||||
return c.source.Read(p)
|
||||
}
|
||||
|
||||
{{ define "event stream inbound tests" }}
|
||||
func Test{{ $.Operation.ExportedName }}_Read(t *testing.T) {
|
||||
expectEvents, eventMsgs := mock{{ $.Operation.ExportedName }}ReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.{{ $.Operation.ExportedName }}(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
{{- if and (eq $.Operation.API.Metadata.Protocol "json") (HasNonEventStreamMember $.Operation.OutputRef.Shape) }}
|
||||
expectResp := expectEvents[0].(*{{ $.Operation.OutputRef.Shape.ShapeName }})
|
||||
{{- range $name, $ref := $.Operation.OutputRef.Shape.MemberRefs }}
|
||||
{{- if not $ref.Shape.IsEventStream }}
|
||||
if e, a := expectResp.{{ $name }}, resp.{{ $name }}; !reflect.DeepEqual(e,a) {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
// Trim off response output type pseudo event so only event messages remain.
|
||||
expectEvents = expectEvents[1:]
|
||||
{{ end }}
|
||||
|
||||
var i int
|
||||
for event := range resp.EventStream.Events() {
|
||||
if event == nil {
|
||||
t.Errorf("%d, expect event, got nil", i)
|
||||
}
|
||||
if e, a := expectEvents[i], event; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %T %v, got %T %v", i, e, e, a, a)
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test{{ $.Operation.ExportedName }}_ReadClose(t *testing.T) {
|
||||
_, eventMsgs := mock{{ $.Operation.ExportedName }}ReadEvents()
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.{{ $.Operation.ExportedName }}(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
resp.EventStream.Close()
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
if err := resp.EventStream.Err(); err != nil {
|
||||
t.Errorf("expect no error, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark{{ $.Operation.ExportedName }}_Read(b *testing.B) {
|
||||
_, eventMsgs := mock{{ $.Operation.ExportedName }}ReadEvents()
|
||||
var buf bytes.Buffer
|
||||
encoder := eventstream.NewEncoder(&buf)
|
||||
for _, msg := range eventMsgs {
|
||||
if err := encoder.Encode(msg); err != nil {
|
||||
b.Fatalf("failed to encode message, %v", err)
|
||||
}
|
||||
}
|
||||
stream := &loopReader{source: bytes.NewReader(buf.Bytes())}
|
||||
|
||||
sess := unit.Session
|
||||
svc := New(sess, &aws.Config{
|
||||
Endpoint: aws.String("https://example.com"),
|
||||
DisableParamValidation: aws.Bool(true),
|
||||
})
|
||||
svc.Handlers.Send.Swap(corehandlers.SendHandler.Name,
|
||||
request.NamedHandler{Name: "mockSend",
|
||||
Fn: func(r *request.Request) {
|
||||
r.HTTPResponse = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Header: http.Header{},
|
||||
Body: ioutil.NopCloser(stream),
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
resp, err := svc.{{ $.Operation.ExportedName }}(nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create request, %v", err)
|
||||
}
|
||||
defer resp.EventStream.Close()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err = resp.EventStream.Err(); err != nil {
|
||||
b.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
event := <-resp.EventStream.Events()
|
||||
if event == nil {
|
||||
b.Fatalf("expect event, got nil, %v, %d", resp.EventStream.Err(), i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mock{{ $.Operation.ExportedName }}ReadEvents() (
|
||||
[]{{ $.Inbound.Name }}Event,
|
||||
[]eventstream.Message,
|
||||
) {
|
||||
expectEvents := []{{ $.Inbound.Name }}Event {
|
||||
{{- if eq $.Operation.API.Metadata.Protocol "json" }}
|
||||
{{- template "set event type" $.Operation.OutputRef.Shape }}
|
||||
{{- end }}
|
||||
{{- range $_, $event := $.Inbound.Events }}
|
||||
{{- template "set event type" $event.Shape }}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed({{ $.API.ProtocolPackage }}.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
_ = payloadMarshaler
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{{- if eq $.Operation.API.Metadata.Protocol "json" }}
|
||||
{{- template "set event message" Map "idx" 0 "parentShape" $.Operation.OutputRef.Shape "eventName" "initial-response" }}
|
||||
{{- end }}
|
||||
{{- range $idx, $event := $.Inbound.Events }}
|
||||
{{- $offsetIdx := OptionalAddInt (eq $.Operation.API.Metadata.Protocol "json") $idx 1 }}
|
||||
{{- template "set event message" Map "idx" $offsetIdx "parentShape" $event.Shape "eventName" $event.Name }}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
return expectEvents, eventMsgs
|
||||
}
|
||||
|
||||
{{- if $.Inbound.Exceptions }}
|
||||
func Test{{ $.Operation.ExportedName }}_ReadException(t *testing.T) {
|
||||
expectEvents := []{{ $.Inbound.Name }}Event {
|
||||
{{- if eq $.Operation.API.Metadata.Protocol "json" }}
|
||||
{{- template "set event type" $.Operation.OutputRef.Shape }}
|
||||
{{- end }}
|
||||
|
||||
{{- $exception := index $.Inbound.Exceptions 0 }}
|
||||
{{- template "set event type" $exception.Shape }}
|
||||
}
|
||||
|
||||
var marshalers request.HandlerList
|
||||
marshalers.PushBackNamed({{ $.API.ProtocolPackage }}.BuildHandler)
|
||||
payloadMarshaler := protocol.HandlerPayloadMarshal{
|
||||
Marshalers: marshalers,
|
||||
}
|
||||
|
||||
eventMsgs := []eventstream.Message{
|
||||
{{- if eq $.Operation.API.Metadata.Protocol "json" }}
|
||||
{{- template "set event message" Map "idx" 0 "parentShape" $.Operation.OutputRef.Shape "eventName" "initial-response" }}
|
||||
{{- end }}
|
||||
|
||||
{{- $offsetIdx := OptionalAddInt (eq $.Operation.API.Metadata.Protocol "json") 0 1 }}
|
||||
{{- $exception := index $.Inbound.Exceptions 0 }}
|
||||
{{- template "set event message" Map "idx" $offsetIdx "parentShape" $exception.Shape "eventName" $exception.Name }}
|
||||
}
|
||||
|
||||
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t,
|
||||
eventstreamtest.ServeEventStream{
|
||||
T: t,
|
||||
Events: eventMsgs,
|
||||
},
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, %v", err)
|
||||
}
|
||||
defer cleanupFn()
|
||||
|
||||
svc := New(sess)
|
||||
resp, err := svc.{{ $.Operation.ExportedName }}(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error got, %v", err)
|
||||
}
|
||||
|
||||
defer resp.EventStream.Close()
|
||||
|
||||
<-resp.EventStream.Events()
|
||||
|
||||
err = resp.EventStream.Err()
|
||||
if err == nil {
|
||||
t.Fatalf("expect err, got none")
|
||||
}
|
||||
|
||||
expectErr := {{ ValueForType $exception.Shape nil }}
|
||||
aerr, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
t.Errorf("expect exception, got %T, %#v", err, err)
|
||||
}
|
||||
if e, a := expectErr.Code(), aerr.Code(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := expectErr.Message(), aerr.Message(); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := expectErr, aerr; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
{{- range $_, $exception := $.Inbound.Exceptions }}
|
||||
var _ awserr.Error = (*{{ $exception.Shape.ShapeName }})(nil)
|
||||
{{- end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Params: *Shape */}}
|
||||
{{ define "set event type" }}
|
||||
&{{ $.ShapeName }}{
|
||||
{{- range $memName, $memRef := $.MemberRefs }}
|
||||
{{- if not $memRef.Shape.IsEventStream }}
|
||||
{{ $memName }}: {{ ValueForType $memRef.Shape nil }},
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
},
|
||||
{{- end }}
|
||||
|
||||
{{/* Params: idx:int, parentShape:*Shape, eventName:string */}}
|
||||
{{ define "set event message" }}
|
||||
{
|
||||
Headers: eventstream.Headers{
|
||||
{{- if $.parentShape.Exception }}
|
||||
eventstreamtest.EventExceptionTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.ExceptionTypeHeader,
|
||||
Value: eventstream.StringValue("{{ $.eventName }}"),
|
||||
},
|
||||
{{- else }}
|
||||
eventstreamtest.EventMessageTypeHeader,
|
||||
{
|
||||
Name: eventstreamapi.EventTypeHeader,
|
||||
Value: eventstream.StringValue("{{ $.eventName }}"),
|
||||
},
|
||||
{{- end }}
|
||||
{{- range $memName, $memRef := $.parentShape.MemberRefs }}
|
||||
{{- template "set event message header" Map "idx" $.idx "parentShape" $.parentShape "memName" $memName "memRef" $memRef }}
|
||||
{{- end }}
|
||||
},
|
||||
{{- template "set event message payload" Map "idx" $.idx "parentShape" $.parentShape }}
|
||||
},
|
||||
{{- end }}
|
||||
|
||||
{{/* Params: idx:int, parentShape:*Shape, memName:string, memRef:*ShapeRef */}}
|
||||
{{ define "set event message header" }}
|
||||
{{- if $.memRef.IsEventHeader }}
|
||||
{
|
||||
Name: "{{ $.memName }}",
|
||||
{{- $shapeValueVar := printf "expectEvents[%d].(%s).%s" $.idx $.parentShape.GoType $.memName }}
|
||||
Value: {{ SetEventHeaderValueForType $.memRef.Shape $shapeValueVar }},
|
||||
},
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Params: idx:int, parentShape:*Shape, memName:string, memRef:*ShapeRef */}}
|
||||
{{ define "set event message payload" }}
|
||||
{{- $payloadMemName := $.parentShape.PayloadRefName }}
|
||||
{{- if HasNonBlobPayloadMembers $.parentShape }}
|
||||
Payload: eventstreamtest.MarshalEventPayload(payloadMarshaler, expectEvents[{{ $.idx }}]),
|
||||
{{- else if $payloadMemName }}
|
||||
{{- $shapeType := (index $.parentShape.MemberRefs $payloadMemName).Shape.Type }}
|
||||
{{- if eq $shapeType "blob" }}
|
||||
Payload: expectEvents[{{ $.idx }}].({{ $.parentShape.GoType }}).{{ $payloadMemName }},
|
||||
{{- else if eq $shapeType "string" }}
|
||||
Payload: []byte(*expectEvents[{{ $.idx }}].({{ $.parentShape.GoType }}).{{ $payloadMemName }}),
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
var eventStreamTestTmpl = template.Must(template.New("eventStreamTestTmpl").Parse(`
|
||||
`))
|
||||
|
||||
96
vendor/github.com/aws/aws-sdk-go/private/model/api/list_of_shame.go
generated
vendored
96
vendor/github.com/aws/aws-sdk-go/private/model/api/list_of_shame.go
generated
vendored
@@ -1,34 +1,13 @@
|
||||
package api
|
||||
|
||||
type persistAPIType struct {
|
||||
output bool
|
||||
input bool
|
||||
}
|
||||
|
||||
type persistAPITypes map[string]map[string]persistAPIType
|
||||
|
||||
func (ts persistAPITypes) Lookup(serviceName, opName string) persistAPIType {
|
||||
service, ok := shamelist[serviceName]
|
||||
if !ok {
|
||||
return persistAPIType{}
|
||||
}
|
||||
|
||||
return service[opName]
|
||||
}
|
||||
|
||||
func (ts persistAPITypes) Input(serviceName, opName string) bool {
|
||||
return ts.Lookup(serviceName, opName).input
|
||||
}
|
||||
|
||||
func (ts persistAPITypes) Output(serviceName, opName string) bool {
|
||||
return ts.Lookup(serviceName, opName).output
|
||||
}
|
||||
|
||||
// shamelist is used to not rename certain operation's input and output shapes.
|
||||
// We need to maintain backwards compatibility with pre-existing services. Since
|
||||
// not generating unique input/output shapes is not desired, we will generate
|
||||
// unique input/output shapes for new operations.
|
||||
var shamelist = persistAPITypes{
|
||||
var shamelist = map[string]map[string]struct {
|
||||
input bool
|
||||
output bool
|
||||
}{
|
||||
"APIGateway": {
|
||||
"CreateApiKey": {
|
||||
output: true,
|
||||
@@ -373,11 +352,6 @@ var shamelist = persistAPITypes{
|
||||
output: true,
|
||||
},
|
||||
},
|
||||
"ElasticTranscoder": {
|
||||
"CreateJob": {
|
||||
output: true,
|
||||
},
|
||||
},
|
||||
"Glacier": {
|
||||
"DescribeJob": {
|
||||
output: true,
|
||||
@@ -457,54 +431,6 @@ var shamelist = persistAPITypes{
|
||||
output: true,
|
||||
},
|
||||
},
|
||||
"MQ": {
|
||||
"CreateBroker": {
|
||||
input: true,
|
||||
output: true,
|
||||
},
|
||||
"CreateConfiguration": {
|
||||
input: true,
|
||||
output: true,
|
||||
},
|
||||
"CreateUser": {
|
||||
input: true,
|
||||
},
|
||||
"DeleteBroker": {
|
||||
output: true,
|
||||
},
|
||||
"DescribeBroker": {
|
||||
output: true,
|
||||
},
|
||||
"DescribeUser": {
|
||||
output: true,
|
||||
},
|
||||
"DescribeConfigurationRevision": {
|
||||
output: true,
|
||||
},
|
||||
"ListBrokers": {
|
||||
output: true,
|
||||
},
|
||||
"ListConfigurations": {
|
||||
output: true,
|
||||
},
|
||||
"ListConfigurationRevisions": {
|
||||
output: true,
|
||||
},
|
||||
"ListUsers": {
|
||||
output: true,
|
||||
},
|
||||
"UpdateBroker": {
|
||||
input: true,
|
||||
output: true,
|
||||
},
|
||||
"UpdateConfiguration": {
|
||||
input: true,
|
||||
output: true,
|
||||
},
|
||||
"UpdateUser": {
|
||||
input: true,
|
||||
},
|
||||
},
|
||||
"RDS": {
|
||||
"ModifyDBClusterParameterGroup": {
|
||||
output: true,
|
||||
@@ -546,20 +472,6 @@ var shamelist = persistAPITypes{
|
||||
output: true,
|
||||
},
|
||||
},
|
||||
"ServerlessApplicationRepository": {
|
||||
"CreateApplication": {
|
||||
input: true,
|
||||
},
|
||||
"CreateApplicationVersion": {
|
||||
input: true,
|
||||
},
|
||||
"CreateCloudFormationChangeSet": {
|
||||
input: true,
|
||||
},
|
||||
"UpdateApplication": {
|
||||
input: true,
|
||||
},
|
||||
},
|
||||
"SWF": {
|
||||
"CountClosedWorkflowExecutions": {
|
||||
output: true,
|
||||
|
||||
9
vendor/github.com/aws/aws-sdk-go/private/model/api/load.go
generated
vendored
9
vendor/github.com/aws/aws-sdk-go/private/model/api/load.go
generated
vendored
@@ -40,12 +40,13 @@ func (a *API) Setup() {
|
||||
a.resolveReferences()
|
||||
a.fixStutterNames()
|
||||
a.renameExportable()
|
||||
a.applyShapeNameAliases()
|
||||
a.createInputOutputShapes()
|
||||
a.renameAPIPayloadShapes()
|
||||
if !a.NoRenameToplevelShapes {
|
||||
a.renameToplevelShapes()
|
||||
}
|
||||
|
||||
a.renameCollidingFields()
|
||||
a.updateTopLevelShapeReferences()
|
||||
a.suppressHTTP2EventStreams()
|
||||
a.createInputOutputShapes()
|
||||
a.setupEventStreams()
|
||||
a.customizationPasses()
|
||||
|
||||
|
||||
54
vendor/github.com/aws/aws-sdk-go/private/model/api/logger.go
generated
vendored
54
vendor/github.com/aws/aws-sdk-go/private/model/api/logger.go
generated
vendored
@@ -1,54 +0,0 @@
|
||||
// +build codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var debugLogger *logger
|
||||
var initDebugLoggerOnce sync.Once
|
||||
|
||||
// logger provides a basic logging
|
||||
type logger struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
// LogDebug initialize's the debug logger for the componenets in the api
|
||||
// package to log debug lines to.
|
||||
//
|
||||
// Panics if called multiple times.
|
||||
//
|
||||
// Must be used prior to any model loading or code gen.
|
||||
func LogDebug(w io.Writer) {
|
||||
var initialized bool
|
||||
initDebugLoggerOnce.Do(func() {
|
||||
debugLogger = &logger{
|
||||
w: w,
|
||||
}
|
||||
initialized = true
|
||||
})
|
||||
|
||||
if !initialized && debugLogger != nil {
|
||||
panic("LogDebug called multiple times. Can only be called once")
|
||||
}
|
||||
}
|
||||
|
||||
// Logf logs using the fmt printf pattern. Appends a new line to the end of the
|
||||
// logged statement.
|
||||
func (l *logger) Logf(format string, args ...interface{}) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(l.w, format+"\n", args...)
|
||||
}
|
||||
|
||||
// Logln logs using the fmt println pattern.
|
||||
func (l *logger) Logln(args ...interface{}) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(l.w, args...)
|
||||
}
|
||||
8
vendor/github.com/aws/aws-sdk-go/private/model/api/operation.go
generated
vendored
8
vendor/github.com/aws/aws-sdk-go/private/model/api/operation.go
generated
vendored
@@ -25,8 +25,6 @@ type Operation struct {
|
||||
Deprecated bool `json:"deprecated"`
|
||||
AuthType string `json:"authtype"`
|
||||
imports map[string]bool
|
||||
|
||||
EventStreamAPI *EventStreamAPI
|
||||
}
|
||||
|
||||
// A HTTPInfo defines the method of HTTP request for the Operation.
|
||||
@@ -134,9 +132,6 @@ func (c *{{ .API.StructName }}) {{ .ExportedName }}Request(` +
|
||||
req.Handlers.Send.Swap(client.LogHTTPResponseHandler.Name, client.LogHTTPResponseHeaderHandler)
|
||||
req.Handlers.Unmarshal.Swap({{ .API.ProtocolPackage }}.UnmarshalHandler.Name, rest.UnmarshalHandler)
|
||||
req.Handlers.Unmarshal.PushBack(output.runEventStreamLoop)
|
||||
{{ if eq .API.Metadata.Protocol "json" -}}
|
||||
req.Handlers.Unmarshal.PushBack(output.unmarshalInitialResponse)
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
return
|
||||
}
|
||||
@@ -257,10 +252,9 @@ func (o *Operation) GoCode() string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
if len(o.OutputRef.Shape.EventStreamsMemberName) != 0 {
|
||||
// TODO need better was of updating protocol unmarshalers
|
||||
o.API.imports["github.com/aws/aws-sdk-go/aws/client"] = true
|
||||
o.API.imports["github.com/aws/aws-sdk-go/private/protocol"] = true
|
||||
o.API.imports["github.com/aws/aws-sdk-go/private/protocol/rest"] = true
|
||||
o.API.imports["github.com/aws/aws-sdk-go/private/protocol/"+o.API.ProtocolPackage()] = true
|
||||
}
|
||||
|
||||
err := tplOperation.Execute(&buf, o)
|
||||
|
||||
4
vendor/github.com/aws/aws-sdk-go/private/model/api/param_filler.go
generated
vendored
4
vendor/github.com/aws/aws-sdk-go/private/model/api/param_filler.go
generated
vendored
@@ -3,8 +3,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
@@ -83,7 +83,7 @@ func (f paramFiller) paramsStructAny(value interface{}, shape *Shape) string {
|
||||
case "jsonvalue":
|
||||
v, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
panic("failed to marshal JSONValue, " + err.Error())
|
||||
panic("failed to marshal JSONValue, "+err.Error())
|
||||
}
|
||||
const tmpl = `func() aws.JSONValue {
|
||||
var m aws.JSONValue
|
||||
|
||||
157
vendor/github.com/aws/aws-sdk-go/private/model/api/passes.go
generated
vendored
157
vendor/github.com/aws/aws-sdk-go/private/model/api/passes.go
generated
vendored
@@ -71,6 +71,14 @@ type referenceResolver struct {
|
||||
visited map[*ShapeRef]bool
|
||||
}
|
||||
|
||||
var jsonvalueShape = &Shape{
|
||||
ShapeName: "JSONValue",
|
||||
Type: "jsonvalue",
|
||||
ValueRef: ShapeRef{
|
||||
JSONValue: true,
|
||||
},
|
||||
}
|
||||
|
||||
// resolveReference updates a shape reference to reference the API and
|
||||
// its shape definition. All other nested references are also resolved.
|
||||
func (r *referenceResolver) resolveReference(ref *ShapeRef) {
|
||||
@@ -86,16 +94,7 @@ func (r *referenceResolver) resolveReference(ref *ShapeRef) {
|
||||
|
||||
if ref.JSONValue {
|
||||
ref.ShapeName = "JSONValue"
|
||||
if _, ok := r.API.Shapes[ref.ShapeName]; !ok {
|
||||
r.API.Shapes[ref.ShapeName] = &Shape{
|
||||
API: r.API,
|
||||
ShapeName: "JSONValue",
|
||||
Type: "jsonvalue",
|
||||
ValueRef: ShapeRef{
|
||||
JSONValue: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
r.API.Shapes[ref.ShapeName] = jsonvalueShape
|
||||
}
|
||||
|
||||
ref.API = r.API // resolve reference back to API
|
||||
@@ -123,6 +122,40 @@ func (r *referenceResolver) resolveShape(shape *Shape) {
|
||||
}
|
||||
}
|
||||
|
||||
// renameToplevelShapes renames all top level shapes of an API to their
|
||||
// exportable variant. The shapes are also updated to include notations
|
||||
// if they are Input or Outputs.
|
||||
func (a *API) renameToplevelShapes() {
|
||||
for _, v := range a.OperationList() {
|
||||
if v.HasInput() {
|
||||
name := v.ExportedName + "Input"
|
||||
switch {
|
||||
case a.Shapes[name] == nil:
|
||||
if service, ok := shamelist[a.name]; ok {
|
||||
if check, ok := service[v.Name]; ok && check.input {
|
||||
break
|
||||
}
|
||||
}
|
||||
v.InputRef.Shape.Rename(name)
|
||||
}
|
||||
}
|
||||
if v.HasOutput() {
|
||||
name := v.ExportedName + "Output"
|
||||
switch {
|
||||
case a.Shapes[name] == nil:
|
||||
if service, ok := shamelist[a.name]; ok {
|
||||
if check, ok := service[v.Name]; ok && check.output {
|
||||
break
|
||||
}
|
||||
}
|
||||
v.OutputRef.Shape.Rename(name)
|
||||
}
|
||||
}
|
||||
v.InputRef.Payload = a.ExportableName(v.InputRef.Payload)
|
||||
v.OutputRef.Payload = a.ExportableName(v.OutputRef.Payload)
|
||||
}
|
||||
}
|
||||
|
||||
// fixStutterNames fixes all name struttering based on Go naming conventions.
|
||||
// "Stuttering" is when the prefix of a structure or function matches the
|
||||
// package name (case insensitive).
|
||||
@@ -222,26 +255,28 @@ func (a *API) renameCollidingFields() {
|
||||
for _, v := range a.Shapes {
|
||||
namesWithSet := map[string]struct{}{}
|
||||
for k, field := range v.MemberRefs {
|
||||
if _, ok := v.MemberRefs["Set"+k]; ok {
|
||||
namesWithSet["Set"+k] = struct{}{}
|
||||
if strings.HasPrefix(k, "Set") {
|
||||
namesWithSet[k] = struct{}{}
|
||||
}
|
||||
|
||||
if collides(k) || (v.Exception && exceptionCollides(k)) {
|
||||
if collides(k) {
|
||||
renameCollidingField(k, v, field)
|
||||
}
|
||||
}
|
||||
|
||||
// checks if any field names collide with setters.
|
||||
for name := range namesWithSet {
|
||||
field := v.MemberRefs[name]
|
||||
renameCollidingField(name, v, field)
|
||||
if field, ok := v.MemberRefs["Set"+name]; ok {
|
||||
renameCollidingField(name, v, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func renameCollidingField(name string, v *Shape, field *ShapeRef) {
|
||||
newName := name + "_"
|
||||
debugLogger.Logf("Shape %s's field %q renamed to %q", v.ShapeName, name, newName)
|
||||
fmt.Printf("Shape %s's field %q renamed to %q\n", v.ShapeName, name, newName)
|
||||
delete(v.MemberRefs, name)
|
||||
v.MemberRefs[newName] = field
|
||||
}
|
||||
@@ -253,32 +288,8 @@ func collides(name string) bool {
|
||||
"GoString",
|
||||
"Validate":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func exceptionCollides(name string) bool {
|
||||
switch name {
|
||||
case "Code",
|
||||
"Message",
|
||||
"OrigErr":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *API) applyShapeNameAliases() {
|
||||
service, ok := shapeNameAliases[a.name]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Generic Shape Aliases
|
||||
for name, s := range a.Shapes {
|
||||
if alias, ok := service[name]; ok {
|
||||
s.Rename(alias)
|
||||
s.AliasedShapeName = true
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,47 +298,15 @@ func (a *API) applyShapeNameAliases() {
|
||||
// have an input and output structure in the signature.
|
||||
func (a *API) createInputOutputShapes() {
|
||||
for _, op := range a.Operations {
|
||||
createAPIParamShape(a, op.Name, &op.InputRef, op.ExportedName+"Input",
|
||||
shamelist.Input,
|
||||
)
|
||||
createAPIParamShape(a, op.Name, &op.OutputRef, op.ExportedName+"Output",
|
||||
shamelist.Output,
|
||||
)
|
||||
if !op.HasInput() {
|
||||
setAsPlacholderShape(&op.InputRef, op.ExportedName+"Input", a)
|
||||
}
|
||||
if !op.HasOutput() {
|
||||
setAsPlacholderShape(&op.OutputRef, op.ExportedName+"Output", a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *API) renameAPIPayloadShapes() {
|
||||
for _, op := range a.Operations {
|
||||
op.InputRef.Payload = a.ExportableName(op.InputRef.Payload)
|
||||
op.OutputRef.Payload = a.ExportableName(op.OutputRef.Payload)
|
||||
}
|
||||
}
|
||||
|
||||
func createAPIParamShape(a *API, opName string, ref *ShapeRef, shapeName string, shamelistLookup func(string, string) bool) {
|
||||
if len(ref.ShapeName) == 0 {
|
||||
setAsPlacholderShape(ref, shapeName, a)
|
||||
return
|
||||
}
|
||||
|
||||
// nothing to do if already the correct name.
|
||||
if s := ref.Shape; s.AliasedShapeName || s.ShapeName == shapeName || shamelistLookup(a.name, opName) {
|
||||
return
|
||||
}
|
||||
|
||||
if s, ok := a.Shapes[shapeName]; ok {
|
||||
panic(fmt.Sprintf(
|
||||
"attempting to create duplicate API parameter shape, %v, %v, %v, %v\n",
|
||||
shapeName, opName, ref.ShapeName, s.OrigShapeName,
|
||||
))
|
||||
}
|
||||
|
||||
ref.Shape.removeRef(ref)
|
||||
ref.OrigShapeName = shapeName
|
||||
ref.ShapeName = shapeName
|
||||
ref.Shape = ref.Shape.Clone(shapeName)
|
||||
ref.Shape.refs = append(ref.Shape.refs, ref)
|
||||
}
|
||||
|
||||
func setAsPlacholderShape(tgtShapeRef *ShapeRef, name string, a *API) {
|
||||
shape := a.makeIOShape(name)
|
||||
shape.Placeholder = true
|
||||
@@ -374,21 +353,3 @@ func (a *API) setMetadataEndpointsKey() {
|
||||
a.Metadata.EndpointsID = a.Metadata.EndpointPrefix
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress event stream must be run before setup event stream
|
||||
func (a *API) suppressHTTP2EventStreams() {
|
||||
if a.Metadata.ProtocolSettings.HTTP2 != "eventstream" {
|
||||
return
|
||||
}
|
||||
|
||||
for name, op := range a.Operations {
|
||||
outbound := hasEventStream(op.InputRef.Shape)
|
||||
inbound := hasEventStream(op.OutputRef.Shape)
|
||||
|
||||
if !(outbound || inbound) {
|
||||
continue
|
||||
}
|
||||
|
||||
a.removeOperation(name)
|
||||
}
|
||||
}
|
||||
|
||||
712
vendor/github.com/aws/aws-sdk-go/private/model/api/passes_test.go
generated
vendored
712
vendor/github.com/aws/aws-sdk-go/private/model/api/passes_test.go
generated
vendored
@@ -1,36 +1,35 @@
|
||||
// +build go1.8,codegen
|
||||
// +build 1.6,codegen
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUniqueInputAndOutputs(t *testing.T) {
|
||||
const serviceName = "FooService"
|
||||
|
||||
shamelist[serviceName] = map[string]persistAPIType{
|
||||
"OpOutputNoRename": {
|
||||
output: true,
|
||||
},
|
||||
"OpInputNoRename": {
|
||||
input: true,
|
||||
},
|
||||
"OpBothNoRename": {
|
||||
input: true,
|
||||
output: true,
|
||||
},
|
||||
}
|
||||
shamelist["FooService"] = map[string]struct {
|
||||
input bool
|
||||
output bool
|
||||
}{}
|
||||
v := shamelist["FooService"]["OpOutputNoRename"]
|
||||
v.output = true
|
||||
shamelist["FooService"]["OpOutputNoRename"] = v
|
||||
v = shamelist["FooService"]["InputNoRename"]
|
||||
v.input = true
|
||||
shamelist["FooService"]["OpInputNoRename"] = v
|
||||
v = shamelist["FooService"]["BothNoRename"]
|
||||
v.input = true
|
||||
v.output = true
|
||||
shamelist["FooService"]["OpBothNoRename"] = v
|
||||
|
||||
cases := [][]struct {
|
||||
expectedInput string
|
||||
expectedOutput string
|
||||
operation string
|
||||
input string
|
||||
inputRef string
|
||||
output string
|
||||
outputRef string
|
||||
}{
|
||||
{
|
||||
{
|
||||
@@ -38,14 +37,18 @@ func TestUniqueInputAndOutputs(t *testing.T) {
|
||||
expectedOutput: "FooOperationOutput",
|
||||
operation: "FooOperation",
|
||||
input: "FooInputShape",
|
||||
inputRef: "FooInputShapeRef",
|
||||
output: "FooOutputShape",
|
||||
outputRef: "FooOutputShapeRef",
|
||||
},
|
||||
{
|
||||
expectedInput: "BarOperationInput",
|
||||
expectedOutput: "BarOperationOutput",
|
||||
operation: "BarOperation",
|
||||
input: "FooInputShape",
|
||||
inputRef: "FooInputShapeRef",
|
||||
output: "FooOutputShape",
|
||||
outputRef: "FooOutputShapeRef",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -54,14 +57,18 @@ func TestUniqueInputAndOutputs(t *testing.T) {
|
||||
expectedOutput: "FooOperationOutput",
|
||||
operation: "FooOperation",
|
||||
input: "FooInputShape",
|
||||
inputRef: "FooInputShapeRef",
|
||||
output: "FooOutputShape",
|
||||
outputRef: "FooOutputShapeRef",
|
||||
},
|
||||
{
|
||||
expectedInput: "OpOutputNoRenameInput",
|
||||
expectedOutput: "OpOutputNoRenameOutputShape",
|
||||
operation: "OpOutputNoRename",
|
||||
input: "OpOutputNoRenameInputShape",
|
||||
inputRef: "OpOutputNoRenameInputRef",
|
||||
output: "OpOutputNoRenameOutputShape",
|
||||
outputRef: "OpOutputNoRenameOutputRef",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -70,14 +77,18 @@ func TestUniqueInputAndOutputs(t *testing.T) {
|
||||
expectedOutput: "FooOperationOutput",
|
||||
operation: "FooOperation",
|
||||
input: "FooInputShape",
|
||||
inputRef: "FooInputShapeRef",
|
||||
output: "FooOutputShape",
|
||||
outputRef: "FooOutputShapeRef",
|
||||
},
|
||||
{
|
||||
expectedInput: "OpInputNoRenameInputShape",
|
||||
expectedOutput: "OpInputNoRenameOutput",
|
||||
operation: "OpInputNoRename",
|
||||
input: "OpInputNoRenameInputShape",
|
||||
inputRef: "OpInputNoRenameInputRef",
|
||||
output: "OpInputNoRenameOutputShape",
|
||||
outputRef: "OpInputNoRenameOutputRef",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -86,616 +97,115 @@ func TestUniqueInputAndOutputs(t *testing.T) {
|
||||
expectedOutput: "FooOperationOutput",
|
||||
operation: "FooOperation",
|
||||
input: "FooInputShape",
|
||||
inputRef: "FooInputShapeRef",
|
||||
output: "FooOutputShape",
|
||||
outputRef: "FooOutputShapeRef",
|
||||
},
|
||||
{
|
||||
expectedInput: "OpInputNoRenameInputShape",
|
||||
expectedOutput: "OpInputNoRenameOutputShape",
|
||||
operation: "OpBothNoRename",
|
||||
input: "OpInputNoRenameInputShape",
|
||||
inputRef: "OpInputNoRenameInputRef",
|
||||
output: "OpInputNoRenameOutputShape",
|
||||
outputRef: "OpInputNoRenameOutputRef",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
a := &API{
|
||||
name: serviceName,
|
||||
Operations: map[string]*Operation{},
|
||||
Shapes: map[string]*Shape{},
|
||||
for _, c := range cases {
|
||||
a := &API{
|
||||
name: "FooService",
|
||||
Operations: map[string]*Operation{},
|
||||
}
|
||||
|
||||
expected := map[string][]string{}
|
||||
a.Shapes = map[string]*Shape{}
|
||||
for _, op := range c {
|
||||
a.Operations[op.operation] = &Operation{
|
||||
ExportedName: op.operation,
|
||||
}
|
||||
a.Operations[op.operation].Name = op.operation
|
||||
a.Operations[op.operation].InputRef = ShapeRef{
|
||||
API: a,
|
||||
ShapeName: op.inputRef,
|
||||
Shape: &Shape{
|
||||
API: a,
|
||||
ShapeName: op.input,
|
||||
},
|
||||
}
|
||||
a.Operations[op.operation].OutputRef = ShapeRef{
|
||||
API: a,
|
||||
ShapeName: op.outputRef,
|
||||
Shape: &Shape{
|
||||
API: a,
|
||||
ShapeName: op.output,
|
||||
},
|
||||
}
|
||||
|
||||
expected := map[string][]string{}
|
||||
for _, op := range c {
|
||||
o := &Operation{
|
||||
Name: op.operation,
|
||||
ExportedName: op.operation,
|
||||
InputRef: ShapeRef{
|
||||
API: a,
|
||||
ShapeName: op.input,
|
||||
Shape: &Shape{
|
||||
API: a,
|
||||
ShapeName: op.input,
|
||||
},
|
||||
},
|
||||
OutputRef: ShapeRef{
|
||||
API: a,
|
||||
ShapeName: op.input,
|
||||
Shape: &Shape{
|
||||
API: a,
|
||||
ShapeName: op.input,
|
||||
},
|
||||
},
|
||||
}
|
||||
o.InputRef.Shape.refs = append(o.InputRef.Shape.refs, &o.InputRef)
|
||||
o.OutputRef.Shape.refs = append(o.OutputRef.Shape.refs, &o.OutputRef)
|
||||
|
||||
a.Operations[o.Name] = o
|
||||
|
||||
a.Shapes[op.input] = o.InputRef.Shape
|
||||
a.Shapes[op.output] = o.OutputRef.Shape
|
||||
|
||||
expected[op.operation] = append(expected[op.operation],
|
||||
op.expectedInput,
|
||||
op.expectedOutput,
|
||||
)
|
||||
a.Shapes[op.input] = &Shape{
|
||||
ShapeName: op.input,
|
||||
}
|
||||
a.Shapes[op.output] = &Shape{
|
||||
ShapeName: op.output,
|
||||
}
|
||||
|
||||
a.fixStutterNames()
|
||||
a.applyShapeNameAliases()
|
||||
a.createInputOutputShapes()
|
||||
for k, v := range expected {
|
||||
if a.Operations[k].InputRef.Shape.ShapeName != v[0] {
|
||||
t.Errorf("Error %s case: Expected %q, but received %q", k, v[0], a.Operations[k].InputRef.Shape.ShapeName)
|
||||
}
|
||||
if a.Operations[k].OutputRef.Shape.ShapeName != v[1] {
|
||||
t.Errorf("Error %s case: Expected %q, but received %q", k, v[1], a.Operations[k].OutputRef.Shape.ShapeName)
|
||||
}
|
||||
expected[op.operation] = append(expected[op.operation], op.expectedInput)
|
||||
expected[op.operation] = append(expected[op.operation], op.expectedOutput)
|
||||
}
|
||||
|
||||
a.fixStutterNames()
|
||||
a.renameToplevelShapes()
|
||||
for k, v := range expected {
|
||||
if a.Operations[k].InputRef.Shape.ShapeName != v[0] {
|
||||
t.Errorf("Error %d case: Expected %q, but received %q", k, v[0], a.Operations[k].InputRef.Shape.ShapeName)
|
||||
}
|
||||
})
|
||||
if a.Operations[k].OutputRef.Shape.ShapeName != v[1] {
|
||||
t.Errorf("Error %d case: Expected %q, but received %q", k, v[1], a.Operations[k].OutputRef.Shape.ShapeName)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollidingFields(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
MemberRefs map[string]*ShapeRef
|
||||
Expect []string
|
||||
IsException bool
|
||||
cases := []struct {
|
||||
api *API
|
||||
expected []*Shapes
|
||||
}{
|
||||
"SimpleMembers": {
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Code": {},
|
||||
"Foo": {},
|
||||
"GoString": {},
|
||||
"Message": {},
|
||||
"OrigErr": {},
|
||||
"SetFoo": {},
|
||||
"String": {},
|
||||
"Validate": {},
|
||||
{
|
||||
&API{
|
||||
name: "FooService",
|
||||
Shapes: []*Shapes{
|
||||
{
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"String": &ShapeRef{},
|
||||
"GoString": &ShapeRef{},
|
||||
"Validate": &ShapeRef{},
|
||||
"Foo": &ShapeRef{},
|
||||
"SetFoo": &ShapeRef{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Expect: []string{
|
||||
"Code",
|
||||
"Foo",
|
||||
"GoString_",
|
||||
"Message",
|
||||
"OrigErr",
|
||||
"SetFoo_",
|
||||
"String_",
|
||||
"Validate_",
|
||||
},
|
||||
},
|
||||
"ExceptionShape": {
|
||||
IsException: true,
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Code": {},
|
||||
"Message": {},
|
||||
"OrigErr": {},
|
||||
"Other": {},
|
||||
"String": {},
|
||||
},
|
||||
Expect: []string{
|
||||
"Code_",
|
||||
"Message_",
|
||||
"OrigErr_",
|
||||
"Other",
|
||||
"String_",
|
||||
[]*Shapes{
|
||||
{
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"String_": &ShapeRef{},
|
||||
"GoString_": &ShapeRef{},
|
||||
"Validate_": &ShapeRef{},
|
||||
"Foo": &ShapeRef{},
|
||||
"SetFoo_": &ShapeRef{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for k, c := range cases {
|
||||
t.Run(k, func(t *testing.T) {
|
||||
a := &API{
|
||||
Shapes: map[string]*Shape{
|
||||
"shapename": {
|
||||
ShapeName: k,
|
||||
MemberRefs: c.MemberRefs,
|
||||
Exception: c.IsException,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
a.renameCollidingFields()
|
||||
|
||||
for i, name := range a.Shapes["shapename"].MemberNames() {
|
||||
if e, a := c.Expect[i], name; e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSupressHTTP2EventStreams(t *testing.T) {
|
||||
const baseModel = `
|
||||
{
|
||||
"version":"2.0",
|
||||
"metadata":{
|
||||
"apiVersion":"0000-00-00",
|
||||
"endpointPrefix":"rpcservice",
|
||||
"jsonVersion":"1.1",
|
||||
"protocol":"json",
|
||||
"protocolSettings":{"h2":"{h2Option}"},
|
||||
"serviceAbbreviation":"RPCService",
|
||||
"serviceFullName":"RPC Service",
|
||||
"serviceId":"RPCService",
|
||||
"signatureVersion":"v4",
|
||||
"targetPrefix":"RPCService_00000000",
|
||||
"uid":"RPCService-0000-00-00"
|
||||
},
|
||||
"operations":{
|
||||
"BarOp":{
|
||||
"name":"BarOp",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape": "BarOpRequest"},
|
||||
"output":{"shape":"BarOpResponse"}
|
||||
},
|
||||
"EventStreamOp":{
|
||||
"name":"EventStreamOp",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape": "EventStreamOpRequest"},
|
||||
"output":{"shape":"EventStreamOpResponse"}
|
||||
},
|
||||
"FooOp":{
|
||||
"name":"FooOp",
|
||||
"http":{
|
||||
"method":"POST",
|
||||
"requestUri":"/"
|
||||
},
|
||||
"input":{"shape": "FooOpRequest"},
|
||||
"output":{"shape":"FooOpResponse"}
|
||||
}
|
||||
},
|
||||
"shapes":{
|
||||
"BarOpRequest":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"BarOpResponse":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"EventStreamOpRequest":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
}
|
||||
},
|
||||
"EventStreamOpResponse":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"EventStream":{"shape":"EventStream"}
|
||||
}
|
||||
},
|
||||
"FooOpRequest":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"FooOpResponse":{
|
||||
"type":"structure",
|
||||
"members":{}
|
||||
},
|
||||
"EventStream":{
|
||||
"type":"structure",
|
||||
"members":{
|
||||
"Empty":{"shape":"EmptyEvent"}
|
||||
},
|
||||
"eventstream":true
|
||||
},
|
||||
"EmptyEvent": {
|
||||
"type":"structure",
|
||||
"members":{},
|
||||
"event": true
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
cases := map[string]struct {
|
||||
Model string
|
||||
ExpectOps []string
|
||||
ExpectShapes []string
|
||||
}{
|
||||
"control": {
|
||||
Model: strings.Replace(baseModel, "{h2Option}", "", -1),
|
||||
ExpectOps: []string{"BarOp", "EventStreamOp", "FooOp"},
|
||||
ExpectShapes: []string{
|
||||
"BarOpInput", "BarOpOutput", "EmptyEvent",
|
||||
"EventStreamOpEventStream", "EventStreamOpInput",
|
||||
"EventStreamOpOutput", "FooOpInput", "FooOpOutput",
|
||||
},
|
||||
},
|
||||
"HTTP/2 with EventStreams": {
|
||||
Model: strings.Replace(baseModel, "{h2Option}", "eventstream", 1),
|
||||
ExpectOps: []string{"BarOp", "FooOp"},
|
||||
ExpectShapes: []string{
|
||||
"BarOpInput", "BarOpOutput", "FooOpInput", "FooOpOutput",
|
||||
},
|
||||
},
|
||||
"HTTP/2 with optional": {
|
||||
Model: strings.Replace(baseModel, "{h2Option}", "optional", 1),
|
||||
ExpectOps: []string{"BarOp", "EventStreamOp", "FooOp"},
|
||||
ExpectShapes: []string{
|
||||
"BarOpInput", "BarOpOutput", "EmptyEvent",
|
||||
"EventStreamOpEventStream", "EventStreamOpInput",
|
||||
"EventStreamOpOutput", "FooOpInput", "FooOpOutput",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, c := range cases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
var a API
|
||||
a.AttachString(c.Model)
|
||||
a.APIGoCode()
|
||||
|
||||
if e, a := c.ExpectOps, a.OperationNames(); !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %v ops, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := c.ExpectShapes, a.ShapeNames(); !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %v shapes, got %v", e, a)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateInputOutputShapes(t *testing.T) {
|
||||
meta := Metadata{
|
||||
APIVersion: "0000-00-00",
|
||||
EndpointPrefix: "rpcservice",
|
||||
JSONVersion: "1.1",
|
||||
Protocol: "json",
|
||||
ServiceAbbreviation: "RPCService",
|
||||
ServiceFullName: "RPC Service",
|
||||
ServiceID: "RPCService",
|
||||
SignatureVersion: "v4",
|
||||
TargetPrefix: "RPCService_00000000",
|
||||
UID: "RPCService-0000-00-00",
|
||||
}
|
||||
|
||||
type OpExpect struct {
|
||||
Input string
|
||||
Output string
|
||||
}
|
||||
|
||||
cases := map[string]struct {
|
||||
API *API
|
||||
ExpectOps map[string]OpExpect
|
||||
ExpectShapes []string
|
||||
}{
|
||||
"allRename": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpResponse"},
|
||||
},
|
||||
"SecondOp": {Name: "SecondOp",
|
||||
InputRef: ShapeRef{ShapeName: "SecondOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "SecondOpResponse"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure"},
|
||||
"FirstOpResponse": {ShapeName: "FirstOpResponse", Type: "structure"},
|
||||
"SecondOpRequest": {ShapeName: "SecondOpRequest", Type: "structure"},
|
||||
"SecondOpResponse": {ShapeName: "SecondOpResponse", Type: "structure"},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
"SecondOp": {
|
||||
Input: "SecondOpInput",
|
||||
Output: "SecondOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
"SecondOpInput", "SecondOpOutput",
|
||||
},
|
||||
},
|
||||
"noRename": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpInput"},
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpOutput"},
|
||||
},
|
||||
"SecondOp": {Name: "SecondOp",
|
||||
InputRef: ShapeRef{ShapeName: "SecondOpInput"},
|
||||
OutputRef: ShapeRef{ShapeName: "SecondOpOutput"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpInput": {ShapeName: "FirstOpInput", Type: "structure"},
|
||||
"FirstOpOutput": {ShapeName: "FirstOpOutput", Type: "structure"},
|
||||
"SecondOpInput": {ShapeName: "SecondOpInput", Type: "structure"},
|
||||
"SecondOpOutput": {ShapeName: "SecondOpOutput", Type: "structure"},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
"SecondOp": {
|
||||
Input: "SecondOpInput",
|
||||
Output: "SecondOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
"SecondOpInput", "SecondOpOutput",
|
||||
},
|
||||
},
|
||||
"renameWithNested": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpWriteMe"},
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpReadMe"},
|
||||
},
|
||||
"SecondOp": {Name: "SecondOp",
|
||||
InputRef: ShapeRef{ShapeName: "SecondOpWriteMe"},
|
||||
OutputRef: ShapeRef{ShapeName: "SecondOpReadMe"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpWriteMe": {ShapeName: "FirstOpWriteMe", Type: "structure",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Foo": {ShapeName: "String"},
|
||||
},
|
||||
},
|
||||
"FirstOpReadMe": {ShapeName: "FirstOpReadMe", Type: "structure",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Bar": {ShapeName: "Struct"},
|
||||
"Once": {ShapeName: "Once"},
|
||||
},
|
||||
},
|
||||
"SecondOpWriteMe": {ShapeName: "SecondOpWriteMe", Type: "structure"},
|
||||
"SecondOpReadMe": {ShapeName: "SecondOpReadMe", Type: "structure"},
|
||||
"Once": {ShapeName: "Once", Type: "string"},
|
||||
"String": {ShapeName: "String", Type: "string"},
|
||||
"Struct": {ShapeName: "Struct", Type: "structure",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Foo": {ShapeName: "String"},
|
||||
"Bar": {ShapeName: "Struct"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
"SecondOp": {
|
||||
Input: "SecondOpInput",
|
||||
Output: "SecondOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
"Once",
|
||||
"SecondOpInput", "SecondOpOutput",
|
||||
"String", "Struct",
|
||||
},
|
||||
},
|
||||
"aliasedInput": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpResponse"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure",
|
||||
AliasedShapeName: true,
|
||||
},
|
||||
"FirstOpResponse": {ShapeName: "FirstOpResponse", Type: "structure"},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpRequest",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpOutput", "FirstOpRequest",
|
||||
},
|
||||
},
|
||||
"aliasedOutput": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpResponse"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure"},
|
||||
"FirstOpResponse": {ShapeName: "FirstOpResponse", Type: "structure",
|
||||
AliasedShapeName: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpResponse",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpResponse",
|
||||
},
|
||||
},
|
||||
"resusedShape": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "ReusedShape"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Foo": {ShapeName: "ReusedShape"},
|
||||
"ooF": {ShapeName: "ReusedShapeList"},
|
||||
},
|
||||
},
|
||||
"ReusedShape": {ShapeName: "ReusedShape", Type: "structure"},
|
||||
"ReusedShapeList": {ShapeName: "ReusedShapeList", Type: "list",
|
||||
MemberRef: ShapeRef{ShapeName: "ReusedShape"},
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
"ReusedShape", "ReusedShapeList",
|
||||
},
|
||||
},
|
||||
"aliasedResusedShape": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
OutputRef: ShapeRef{ShapeName: "ReusedShape"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure",
|
||||
MemberRefs: map[string]*ShapeRef{
|
||||
"Foo": {ShapeName: "ReusedShape"},
|
||||
"ooF": {ShapeName: "ReusedShapeList"},
|
||||
},
|
||||
},
|
||||
"ReusedShape": {ShapeName: "ReusedShape", Type: "structure",
|
||||
AliasedShapeName: true,
|
||||
},
|
||||
"ReusedShapeList": {ShapeName: "ReusedShapeList", Type: "list",
|
||||
MemberRef: ShapeRef{ShapeName: "ReusedShape"},
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "ReusedShape",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput",
|
||||
"ReusedShape", "ReusedShapeList",
|
||||
},
|
||||
},
|
||||
"unsetInput": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
OutputRef: ShapeRef{ShapeName: "FirstOpResponse"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpResponse": {ShapeName: "FirstOpResponse", Type: "structure"},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
"unsetOutput": {
|
||||
API: &API{Metadata: meta,
|
||||
Operations: map[string]*Operation{
|
||||
"FirstOp": {Name: "FirstOp",
|
||||
InputRef: ShapeRef{ShapeName: "FirstOpRequest"},
|
||||
},
|
||||
},
|
||||
Shapes: map[string]*Shape{
|
||||
"FirstOpRequest": {ShapeName: "FirstOpRequest", Type: "structure"},
|
||||
},
|
||||
},
|
||||
ExpectOps: map[string]OpExpect{
|
||||
"FirstOp": {
|
||||
Input: "FirstOpInput",
|
||||
Output: "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
ExpectShapes: []string{
|
||||
"FirstOpInput", "FirstOpOutput",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, c := range cases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
a := c.API
|
||||
a.Setup()
|
||||
|
||||
for opName, op := range a.Operations {
|
||||
if e, a := op.InputRef.ShapeName, op.InputRef.Shape.ShapeName; e != a {
|
||||
t.Errorf("expect input ref and shape names to match, %s, %s", e, a)
|
||||
}
|
||||
if e, a := c.ExpectOps[opName].Input, op.InputRef.ShapeName; e != a {
|
||||
t.Errorf("expect %v input shape, got %v", e, a)
|
||||
}
|
||||
|
||||
if e, a := op.OutputRef.ShapeName, op.OutputRef.Shape.ShapeName; e != a {
|
||||
t.Errorf("expect output ref and shape names to match, %s, %s", e, a)
|
||||
}
|
||||
if e, a := c.ExpectOps[opName].Output, op.OutputRef.ShapeName; e != a {
|
||||
t.Errorf("expect %v output shape, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
if e, a := c.ExpectShapes, a.ShapeNames(); !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expect %v shapes, got %v", e, a)
|
||||
}
|
||||
})
|
||||
for _, c := range testCases {
|
||||
c.api.renameCollidingFields()
|
||||
if !reflect.DeepEqual(c.api.Shapes, c.expected) {
|
||||
t.Errorf("expected %v, but received %v", c.expected, c.api.Shapes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
142
vendor/github.com/aws/aws-sdk-go/private/model/api/service_name.go
generated
vendored
142
vendor/github.com/aws/aws-sdk-go/private/model/api/service_name.go
generated
vendored
@@ -14,77 +14,77 @@ func ServiceName(a *API) string {
|
||||
}
|
||||
|
||||
var oldServiceNames = map[string]string{
|
||||
"migrationhub": "mgh",
|
||||
"acmpca": "acm-pca",
|
||||
"acm": "acm",
|
||||
"alexaforbusiness": "a4b",
|
||||
"apigateway": "apigateway",
|
||||
"applicationautoscaling": "autoscaling",
|
||||
"appstream": "appstream2",
|
||||
"appsync": "appsync",
|
||||
"athena": "athena",
|
||||
"autoscalingplans": "autoscaling",
|
||||
"autoscaling": "autoscaling",
|
||||
"batch": "batch",
|
||||
"budgets": "budgets",
|
||||
"costexplorer": "ce",
|
||||
"cloud9": "cloud9",
|
||||
"clouddirectory": "clouddirectory",
|
||||
"cloudformation": "cloudformation",
|
||||
"cloudfront": "cloudfront",
|
||||
"cloudhsm": "cloudhsm",
|
||||
"cloudhsmv2": "cloudhsmv2",
|
||||
"cloudsearch": "cloudsearch",
|
||||
"cloudsearchdomain": "cloudsearchdomain",
|
||||
"cloudtrail": "cloudtrail",
|
||||
"codebuild": "codebuild",
|
||||
"codecommit": "codecommit",
|
||||
"codedeploy": "codedeploy",
|
||||
"codepipeline": "codepipeline",
|
||||
"codestar": "codestar",
|
||||
"cognitoidentity": "cognito-identity",
|
||||
"cognitoidentityprovider": "cognito-idp",
|
||||
"cognitosync": "cognito-sync",
|
||||
"comprehend": "comprehend",
|
||||
"configservice": "config",
|
||||
"connect": "connect",
|
||||
"costandusagereportservice": "cur",
|
||||
"datapipeline": "datapipeline",
|
||||
"dax": "dax",
|
||||
"devicefarm": "devicefarm",
|
||||
"directconnect": "directconnect",
|
||||
"applicationdiscoveryservice": "discovery",
|
||||
"databasemigrationservice": "dms",
|
||||
"directoryservice": "ds",
|
||||
"dynamodb": "dynamodb",
|
||||
"ec2": "ec2",
|
||||
"ecr": "ecr",
|
||||
"ecs": "ecs",
|
||||
"eks": "eks",
|
||||
"elasticache": "elasticache",
|
||||
"elasticbeanstalk": "elasticbeanstalk",
|
||||
"efs": "elasticfilesystem",
|
||||
"elb": "elasticloadbalancing",
|
||||
"elbv2": "elasticloadbalancing",
|
||||
"emr": "elasticmapreduce",
|
||||
"elastictranscoder": "elastictranscoder",
|
||||
"ses": "email",
|
||||
"marketplaceentitlementservice": "entitlement.marketplace",
|
||||
"elasticsearchservice": "es",
|
||||
"cloudwatchevents": "events",
|
||||
"firehose": "firehose",
|
||||
"fms": "fms",
|
||||
"gamelift": "gamelift",
|
||||
"glacier": "glacier",
|
||||
"glue": "glue",
|
||||
"greengrass": "greengrass",
|
||||
"guardduty": "guardduty",
|
||||
"health": "health",
|
||||
"iam": "iam",
|
||||
"inspector": "inspector",
|
||||
"iotdataplane": "data.iot",
|
||||
"iotjobsdataplane": "data.jobs.iot",
|
||||
"iot": "iot",
|
||||
"migrationhub": "mgh",
|
||||
"acmpca": "acm-pca",
|
||||
"acm": "acm",
|
||||
"alexaforbusiness": "a4b",
|
||||
"apigateway": "apigateway",
|
||||
"applicationautoscaling": "autoscaling",
|
||||
"appstream": "appstream2",
|
||||
"appsync": "appsync",
|
||||
"athena": "athena",
|
||||
"autoscalingplans": "autoscaling",
|
||||
"autoscaling": "autoscaling",
|
||||
"batch": "batch",
|
||||
"budgets": "budgets",
|
||||
"costexplorer": "ce",
|
||||
"cloud9": "cloud9",
|
||||
"clouddirectory": "clouddirectory",
|
||||
"cloudformation": "cloudformation",
|
||||
"cloudfront": "cloudfront",
|
||||
"cloudhsm": "cloudhsm",
|
||||
"cloudhsmv2": "cloudhsmv2",
|
||||
"cloudsearch": "cloudsearch",
|
||||
"cloudsearchdomain": "cloudsearchdomain",
|
||||
"cloudtrail": "cloudtrail",
|
||||
"codebuild": "codebuild",
|
||||
"codecommit": "codecommit",
|
||||
"codedeploy": "codedeploy",
|
||||
"codepipeline": "codepipeline",
|
||||
"codestar": "codestar",
|
||||
"cognitoidentity": "cognito-identity",
|
||||
"cognitoidentityprovider": "cognito-idp",
|
||||
"cognitosync": "cognito-sync",
|
||||
"comprehend": "comprehend",
|
||||
"configservice": "config",
|
||||
"connect": "connect",
|
||||
"costandusagereportservice": "cur",
|
||||
"datapipeline": "datapipeline",
|
||||
"dax": "dax",
|
||||
"devicefarm": "devicefarm",
|
||||
"directconnect": "directconnect",
|
||||
"applicationdiscoveryservice": "discovery",
|
||||
"databasemigrationservice": "dms",
|
||||
"directoryservice": "ds",
|
||||
"dynamodb": "dynamodb",
|
||||
"ec2": "ec2",
|
||||
"ecr": "ecr",
|
||||
"ecs": "ecs",
|
||||
"eks": "eks",
|
||||
"elasticache": "elasticache",
|
||||
"elasticbeanstalk": "elasticbeanstalk",
|
||||
"efs": "elasticfilesystem",
|
||||
"elb": "elasticloadbalancing",
|
||||
"elbv2": "elasticloadbalancing",
|
||||
"emr": "elasticmapreduce",
|
||||
"elastictranscoder": "elastictranscoder",
|
||||
"ses": "email",
|
||||
"marketplaceentitlementservice": "entitlement.marketplace",
|
||||
"elasticsearchservice": "es",
|
||||
"cloudwatchevents": "events",
|
||||
"firehose": "firehose",
|
||||
"fms": "fms",
|
||||
"gamelift": "gamelift",
|
||||
"glacier": "glacier",
|
||||
"glue": "glue",
|
||||
"greengrass": "greengrass",
|
||||
"guardduty": "guardduty",
|
||||
"health": "health",
|
||||
"iam": "iam",
|
||||
"inspector": "inspector",
|
||||
"iotdataplane": "data.iot",
|
||||
"iotjobsdataplane": "data.jobs.iot",
|
||||
"iot": "iot",
|
||||
"iot1clickdevicesservice": "devices.iot1click",
|
||||
"iot1clickprojects": "projects.iot1click",
|
||||
"iotanalytics": "iotanalytics",
|
||||
|
||||
131
vendor/github.com/aws/aws-sdk-go/private/model/api/shape.go
generated
vendored
131
vendor/github.com/aws/aws-sdk-go/private/model/api/shape.go
generated
vendored
@@ -10,8 +10,6 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
)
|
||||
|
||||
// ErrorInfo represents the error block of a shape's structure
|
||||
@@ -43,10 +41,9 @@ type ShapeRef struct {
|
||||
Ignore bool
|
||||
XMLNamespace XMLInfo
|
||||
Payload string
|
||||
IdempotencyToken bool `json:"idempotencyToken"`
|
||||
TimestampFormat string `json:"timestampFormat"`
|
||||
JSONValue bool `json:"jsonvalue"`
|
||||
Deprecated bool `json:"deprecated"`
|
||||
IdempotencyToken bool `json:"idempotencyToken"`
|
||||
JSONValue bool `json:"jsonvalue"`
|
||||
Deprecated bool `json:"deprecated"`
|
||||
|
||||
OrigShapeName string `json:"-"`
|
||||
|
||||
@@ -75,8 +72,7 @@ type Shape struct {
|
||||
Streaming bool
|
||||
Location string
|
||||
LocationName string
|
||||
IdempotencyToken bool `json:"idempotencyToken"`
|
||||
TimestampFormat string `json:"timestampFormat"`
|
||||
IdempotencyToken bool `json:"idempotencyToken"`
|
||||
XMLNamespace XMLInfo
|
||||
Min float64 // optional Minimum length (string, list) or value (number)
|
||||
Max float64 // optional Maximum length (string, list) or value (number)
|
||||
@@ -103,10 +99,6 @@ type Shape struct {
|
||||
// Error information that is set if the shape is an error shape.
|
||||
IsError bool
|
||||
ErrorInfo ErrorInfo `json:"error"`
|
||||
|
||||
// Flags that the shape cannot be rename. Prevents the shape from being
|
||||
// renamed further by the Input/Output.
|
||||
AliasedShapeName bool
|
||||
}
|
||||
|
||||
// ErrorCodeName will return the error shape's name formated for
|
||||
@@ -155,11 +147,6 @@ func (s *Shape) GoTags(root, required bool) string {
|
||||
// Rename changes the name of the Shape to newName. Also updates
|
||||
// the associated API's reference to use newName.
|
||||
func (s *Shape) Rename(newName string) {
|
||||
if s.AliasedShapeName {
|
||||
panic(fmt.Sprintf("attempted to rename %s, but flagged as aliased",
|
||||
s.ShapeName))
|
||||
}
|
||||
|
||||
for _, r := range s.refs {
|
||||
r.OrigShapeName = r.ShapeName
|
||||
r.ShapeName = newName
|
||||
@@ -216,32 +203,6 @@ func (s *ShapeRef) UseIndirection() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s Shape) GetTimestampFormat() string {
|
||||
format := s.TimestampFormat
|
||||
|
||||
if len(format) > 0 && !protocol.IsKnownTimestampFormat(format) {
|
||||
panic(fmt.Sprintf("Unknown timestampFormat %s, for %s",
|
||||
format, s.ShapeName))
|
||||
}
|
||||
|
||||
return format
|
||||
}
|
||||
|
||||
func (ref ShapeRef) GetTimestampFormat() string {
|
||||
format := ref.TimestampFormat
|
||||
|
||||
if len(format) == 0 {
|
||||
format = ref.Shape.TimestampFormat
|
||||
}
|
||||
|
||||
if len(format) > 0 && !protocol.IsKnownTimestampFormat(format) {
|
||||
panic(fmt.Sprintf("Unknown timestampFormat %s, for %s",
|
||||
format, ref.ShapeName))
|
||||
}
|
||||
|
||||
return format
|
||||
}
|
||||
|
||||
// GoStructValueType returns the Shape's Go type value instead of a pointer
|
||||
// for the type.
|
||||
func (s *Shape) GoStructValueType(name string, ref *ShapeRef) string {
|
||||
@@ -334,7 +295,7 @@ func goType(s *Shape, withPkgName bool) string {
|
||||
return "*string"
|
||||
case "blob":
|
||||
return "[]byte"
|
||||
case "byte", "short", "integer", "long":
|
||||
case "integer", "long":
|
||||
return "*int64"
|
||||
case "float", "double":
|
||||
return "*float64"
|
||||
@@ -407,17 +368,12 @@ func (ref *ShapeRef) GoTags(toplevel bool, isRequired bool) string {
|
||||
tags = append(tags, ShapeTag{"location", ref.Location})
|
||||
} else if ref.Shape.Location != "" {
|
||||
tags = append(tags, ShapeTag{"location", ref.Shape.Location})
|
||||
} else if ref.IsEventHeader {
|
||||
tags = append(tags, ShapeTag{"location", "header"})
|
||||
}
|
||||
|
||||
if ref.LocationName != "" {
|
||||
tags = append(tags, ShapeTag{"locationName", ref.LocationName})
|
||||
} else if ref.Shape.LocationName != "" {
|
||||
tags = append(tags, ShapeTag{"locationName", ref.Shape.LocationName})
|
||||
} else if len(ref.Shape.EventFor) != 0 && ref.API.Metadata.Protocol == "rest-xml" {
|
||||
// RPC JSON events need to have location name modeled for round trip testing.
|
||||
tags = append(tags, ShapeTag{"locationName", ref.Shape.ShapeName})
|
||||
}
|
||||
|
||||
if ref.QueryName != "" {
|
||||
@@ -445,12 +401,18 @@ func (ref *ShapeRef) GoTags(toplevel bool, isRequired bool) string {
|
||||
|
||||
// embed the timestamp type for easier lookups
|
||||
if ref.Shape.Type == "timestamp" {
|
||||
if format := ref.GetTimestampFormat(); len(format) > 0 {
|
||||
tags = append(tags, ShapeTag{
|
||||
Key: "timestampFormat",
|
||||
Val: format,
|
||||
})
|
||||
t := ShapeTag{Key: "timestampFormat"}
|
||||
if ref.Location == "header" {
|
||||
t.Val = "rfc822"
|
||||
} else {
|
||||
switch ref.API.Metadata.Protocol {
|
||||
case "json", "rest-json":
|
||||
t.Val = "unix"
|
||||
case "rest-xml", "ec2", "query":
|
||||
t.Val = "iso8601"
|
||||
}
|
||||
}
|
||||
tags = append(tags, t)
|
||||
}
|
||||
|
||||
if ref.Shape.Flattened || ref.Flattened {
|
||||
@@ -598,12 +560,6 @@ var structShapeTmpl = func() *template.Template {
|
||||
shapeTmpl.AddParseTree(
|
||||
"eventStreamEventShapeTmpl", eventStreamEventShapeTmpl.Tree),
|
||||
)
|
||||
template.Must(
|
||||
shapeTmpl.AddParseTree(
|
||||
"eventStreamExceptionEventShapeTmpl",
|
||||
eventStreamExceptionEventShapeTmpl.Tree),
|
||||
)
|
||||
shapeTmpl.Funcs(eventStreamEventShapeTmplFuncs)
|
||||
|
||||
return shapeTmpl
|
||||
}()
|
||||
@@ -642,13 +598,13 @@ type {{ .ShapeName }} struct {
|
||||
{{ if not .API.NoStringerMethods }}
|
||||
{{ .GoCodeStringers }}
|
||||
{{ end }}
|
||||
{{ if not (or .API.NoValidataShapeMethods .Exception) }}
|
||||
{{ if not .API.NoValidataShapeMethods }}
|
||||
{{ if .Validations -}}
|
||||
{{ .Validations.GoCode . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if not (or .API.NoGenStructFieldAccessors .Exception) }}
|
||||
{{ if not .API.NoGenStructFieldAccessors }}
|
||||
{{ $builderShapeName := print .ShapeName -}}
|
||||
{{ range $_, $name := $context.MemberNames -}}
|
||||
{{ $elem := index $context.MemberRefs $name -}}
|
||||
@@ -682,12 +638,8 @@ type {{ .ShapeName }} struct {
|
||||
{{ template "eventStreamAPILoopMethodTmpl" $ }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $.EventFor }}
|
||||
{{ if $.IsEvent }}
|
||||
{{ template "eventStreamEventShapeTmpl" $ }}
|
||||
|
||||
{{- if $.Exception }}
|
||||
{{ template "eventStreamExceptionEventShapeTmpl" $ }}
|
||||
{{ end -}}
|
||||
{{ end }}
|
||||
`
|
||||
|
||||
@@ -790,48 +742,3 @@ func (s *Shape) WillRefBeBase64Encoded(refName string) bool {
|
||||
|
||||
return ref.Shape.Type == "blob"
|
||||
}
|
||||
|
||||
// Clone returns a cloned version of the shape with all references clones.
|
||||
//
|
||||
// Does not clone EventStream or Validate related values.
|
||||
func (s *Shape) Clone(newName string) *Shape {
|
||||
if s.AliasedShapeName {
|
||||
panic(fmt.Sprintf("attempted to clone and rename %s, but flagged as aliased",
|
||||
s.ShapeName))
|
||||
}
|
||||
|
||||
n := new(Shape)
|
||||
*n = *s
|
||||
|
||||
debugLogger.Logln("cloning", s.ShapeName, "to", newName)
|
||||
|
||||
n.MemberRefs = map[string]*ShapeRef{}
|
||||
for k, r := range s.MemberRefs {
|
||||
nr := new(ShapeRef)
|
||||
*nr = *r
|
||||
nr.Shape.refs = append(nr.Shape.refs, nr)
|
||||
n.MemberRefs[k] = nr
|
||||
}
|
||||
|
||||
if n.MemberRef.Shape != nil {
|
||||
n.MemberRef.Shape.refs = append(n.MemberRef.Shape.refs, &n.MemberRef)
|
||||
}
|
||||
if n.KeyRef.Shape != nil {
|
||||
n.KeyRef.Shape.refs = append(n.KeyRef.Shape.refs, &n.KeyRef)
|
||||
}
|
||||
if n.ValueRef.Shape != nil {
|
||||
n.ValueRef.Shape.refs = append(n.ValueRef.Shape.refs, &n.ValueRef)
|
||||
}
|
||||
|
||||
n.refs = []*ShapeRef{}
|
||||
|
||||
n.Required = append([]string{}, n.Required...)
|
||||
n.Enum = append([]string{}, n.Enum...)
|
||||
n.EnumConsts = append([]string{}, n.EnumConsts...)
|
||||
|
||||
n.OrigShapeName = n.ShapeName
|
||||
n.API.Shapes[newName] = n
|
||||
n.ShapeName = newName
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
19
vendor/github.com/aws/aws-sdk-go/private/model/api/shape_alias.go
generated
vendored
19
vendor/github.com/aws/aws-sdk-go/private/model/api/shape_alias.go
generated
vendored
@@ -1,19 +0,0 @@
|
||||
package api
|
||||
|
||||
var shapeNameAliases = map[string]map[string]string{
|
||||
"APIGateway": map[string]string{
|
||||
"RequestValidator": "UpdateRequestValidatorOutput",
|
||||
"VpcLink": "UpdateVpcLinkOutput",
|
||||
"GatewayResponse": "UpdateGatewayResponseOutput",
|
||||
},
|
||||
"Lambda": map[string]string{
|
||||
"Concurrency": "PutFunctionConcurrencyOutput",
|
||||
},
|
||||
"Neptune": map[string]string{
|
||||
"DBClusterParameterGroupNameMessage": "ResetDBClusterParameterGroupOutput",
|
||||
"DBParameterGroupNameMessage": "ResetDBParameterGroupOutput",
|
||||
},
|
||||
"RDS": map[string]string{
|
||||
"DBClusterBacktrack": "BacktrackDBClusterOutput",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user