api

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package api represents API abstractions for rendering service generated files.

Index

Constants

View Source
const (
	// ShapeValidationRequired states the shape must be set
	ShapeValidationRequired = iota

	// ShapeValidationMinVal states the shape must have at least a number of
	// elements, or for numbers a minimum value
	ShapeValidationMinVal

	// ShapeValidationNested states the shape has nested values that need
	// to be validated
	ShapeValidationNested
)
View Source
const SDKImportRoot = "github.com/aws/aws-sdk-go"

SDKImportRoot is the root import path of the SDK.

Variables

This section is empty.

Functions

func AppendDocstring

func AppendDocstring(base, toAdd string) string

func ExpandModelGlobPath

func ExpandModelGlobPath(globs ...string) ([]string, error)

ExpandModelGlobPath returns a slice of model paths expanded from the glob pattern passed in. Returns the path of the model file to be loaded. Includes all versions of a service model.

e.g:
models/apis/*/*/api-2.json

Or with specific model file:
models/apis/service/version/api-2.json
func HasCrosslinks(service string) bool

HasCrosslinks will return whether or not a service has crosslinking .

func LogDebug

func LogDebug(w io.Writer)

LogDebug initialize's the debug logger for the components 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 NewExamplesBuilder

func NewExamplesBuilder() defaultExamplesBuilder

NewExamplesBuilder returns an initialized example builder for generating example input API shapes from a model.

func NewWAFregionalExamplesBuilder

func NewWAFregionalExamplesBuilder() wafregionalExamplesBuilder

func ParamsStructFromJSON

func ParamsStructFromJSON(value interface{}, shape *Shape, prefixPackageName bool) string

ParamsStructFromJSON returns a JSON string representation of a structure.

func S3ManagerUploadInputGoCode

func S3ManagerUploadInputGoCode(a *API) string

S3ManagerUploadInputGoCode returns the Go code for the S3 Upload Manager's input structure.

func ServiceID

func ServiceID(a *API) string

ServiceID will return a unique identifier specific to a service.

func ServiceIDFromUID

func ServiceIDFromUID(uid string) string

ServiceIDFromUID will parse the service id from the uid and return the service id that was found.

func ServiceName

func ServiceName(a *API) string

ServiceName returns the SDK's naming of the service. Has backwards compatibility built in for services that were incorrectly named with the service's endpoint prefix.

func TrimModelServiceVersions

func TrimModelServiceVersions(modelPaths []string) (include, exclude []string)

TrimModelServiceVersions sorts the model paths by service version then returns recent model versions, and model version excluded.

Uses the third from last path element to determine unique service. Only one service version will be included.

models/apis/service/version/api-2.json

Types

type API

type API struct {
	Metadata      Metadata
	Operations    map[string]*Operation
	Shapes        map[string]*Shape
	Waiters       []Waiter
	Documentation string `json:"-"`
	Examples      Examples
	SmokeTests    SmokeTestSuite

	IgnoreUnsupportedAPIs bool

	// Set to true to avoid removing unused shapes
	NoRemoveUnusedShapes bool

	// Set to true to avoid renaming to 'Input/Output' postfixed shapes
	NoRenameToplevelShapes bool

	// Set to true to ignore service/request init methods (for testing)
	NoInitMethods bool

	// Set to true to ignore String() and GoString methods (for generated tests)
	NoStringerMethods bool

	// Set to true to not generate API service name constants
	NoConstServiceNames bool

	// Set to true to not generate validation shapes
	NoValidataShapeMethods bool

	// Set to true to not generate struct field accessors
	NoGenStructFieldAccessors bool

	// Set to not remove unsupported (non-legacy) JSON from API, (for generated tests).
	NoRemoveUnsupportedJSONValue bool

	BaseImportPath string

	BaseCrosslinkURL string

	HasEventStream bool `json:"-"`

	EndpointDiscoveryOp *Operation

	HasEndpointARN bool `json:"-"`

	HasOutpostID bool `json:"-"`

	HasAccountIdWithARN bool `json:"-"`

	WithGeneratedTypedErrors bool

	// Set to true to strictly enforce usage of the serviceId for the package naming
	StrictServiceId bool
	// contains filtered or unexported fields
}

An API defines a service API's definition. and logic to serialize the definition.

func (*API) APIErrorsGoCode

func (a *API) APIErrorsGoCode() string

APIErrorsGoCode returns the Go code for the errors.go file.

func (*API) APIEventStreamTestGoCode

func (a *API) APIEventStreamTestGoCode() string

APIEventStreamTestGoCode generates Go code for EventStream operation tests.

func (*API) APIGoCode

func (a *API) APIGoCode() string

APIGoCode renders the API in Go code. Returning it as a string

func (*API) APIName

func (a *API) APIName() string

APIName returns the API's service name.

func (*API) APISmokeTestsGoCode

func (a *API) APISmokeTestsGoCode() string

APISmokeTestsGoCode returns the Go Code string for the smoke tests.

func (*API) AddImport

func (a *API) AddImport(v string) error

AddImport adds the import path to the generated file's import.

func (*API) AddSDKImport

func (a *API) AddSDKImport(v ...string) error

AddSDKImport adds a SDK package import to the generated file's import.

func (*API) Attach

func (a *API) Attach(filename string) error

Attach opens a file by name, and unmarshal its JSON data. Will proceed to setup the API if not already done so.

func (*API) AttachDocs

func (a *API) AttachDocs(filename string) error

AttachDocs attaches documentation from a JSON filename.

func (*API) AttachExamples

func (a *API) AttachExamples(filename string) error

AttachExamples will create a new ExamplesDefinition from the examples file and reference the API object.

func (*API) AttachPaginators

func (a *API) AttachPaginators(filename string) error

AttachPaginators attaches pagination configuration from filename to the API.

func (*API) AttachSmokeTests

func (a *API) AttachSmokeTests(filename string) error

AttachSmokeTests attaches the smoke test cases to the API model.

func (*API) AttachString

func (a *API) AttachString(str string) error

AttachString will unmarshal a raw JSON string, and setup the API if not already done so.

func (*API) AttachWaiters

func (a *API) AttachWaiters(filename string) error

AttachWaiters reads a file of waiter definitions, and adds those to the API. Will panic if an error occurs.

func (*API) ExampleGoCode

func (a *API) ExampleGoCode() string

ExampleGoCode renders service example code. Returning it as a string.

func (*API) ExamplesGoCode

func (a *API) ExamplesGoCode() string

ExamplesGoCode will return a code representation of the entry within the examples.json file.

func (*API) ExportableName

func (a *API) ExportableName(name string) string

ExportableName a name which is exportable as a value or name in Go code

func (*API) GetCrosslinkURL

func (a *API) GetCrosslinkURL(params ...string) string

GetCrosslinkURL returns the crosslinking URL for the shape based on the name and uid provided. Empty string is returned if no crosslink link could be determined.

func (*API) ImportPath

func (a *API) ImportPath() string

ImportPath returns the client's full import path

func (*API) InterfaceGoCode

func (a *API) InterfaceGoCode() string

InterfaceGoCode returns the go code for the service's API operations as an interface{}. Assumes that the interface is being created in a different package than the service API's package.

func (*API) InterfacePackageName

func (a *API) InterfacePackageName() string

InterfacePackageName returns the package name for the interface.

func (*API) NewAPIGoCodeWithPkgName

func (a *API) NewAPIGoCodeWithPkgName(cfg string) string

NewAPIGoCodeWithPkgName returns a string of instantiating the API prefixed with its package name. Takes a string depicting the Config.

func (*API) NiceName

func (a *API) NiceName() string

NiceName returns the human friendly API name.

func (*API) OperationForMethod

func (a *API) OperationForMethod(name string) *Operation

OperationForMethod returns the API operation name that corresponds to the client method name provided.

func (*API) OperationHasOutputPlaceholder

func (a *API) OperationHasOutputPlaceholder() bool

OperationHasOutputPlaceholder returns if any of the API operation input or output shapes are place holders.

func (*API) OperationList

func (a *API) OperationList() []*Operation

OperationList returns a slice of API operation pointers

func (*API) OperationNames

func (a *API) OperationNames() []string

OperationNames returns a slice of API operations supported.

func (*API) PackageName

func (a *API) PackageName() string

PackageName name of the API package

func (*API) ProtocolPackage

func (a *API) ProtocolPackage() string

ProtocolPackage returns the package name of the protocol this API uses.

func (*API) ServiceGoCode

func (a *API) ServiceGoCode() string

ServiceGoCode renders service go code. Returning it as a string.

func (*API) ServicePackageDoc

func (a *API) ServicePackageDoc() string

ServicePackageDoc generates the contents of the doc file for the service.

Will also read in the custom doc templates for the service if found.

func (*API) Setup

func (a *API) Setup() error

Setup initializes the API.

func (*API) ShapeList

func (a *API) ShapeList() []*Shape

ShapeList returns a slice of shape pointers used by the API.

Will exclude error shapes from the list of shapes returned.

func (*API) ShapeListErrors

func (a *API) ShapeListErrors() []*Shape

ShapeListErrors returns a list of the errors defined by the API model

func (*API) ShapeNames

func (a *API) ShapeNames() []string

ShapeNames returns a slice of names for each shape used by the API.

func (*API) StructName

func (a *API) StructName() string

StructName returns the struct name for a given API.

func (*API) UseInitMethods

func (a *API) UseInitMethods() bool

UseInitMethods returns if the service's init method should be rendered.

func (*API) WaitersGoCode

func (a *API) WaitersGoCode() string

WaitersGoCode generates and returns Go code for each of the waiters of this API.

type APIs

type APIs map[string]*API

APIs provides a set of API models loaded by API package name.

type AuthType

type AuthType string

AuthType provides the enumeration of AuthType trait.

const (
	NoneAuthType           AuthType = "none"
	V4UnsignedBodyAuthType AuthType = "v4-unsigned-body"
)

Enumeration values for AuthType trait

type Comments

type Comments struct {
	Input  map[string]interface{} `json:"input"`
	Output map[string]interface{} `json:"output"`
}

type EndpointDiscovery

type EndpointDiscovery struct {
	// Required indicates that for a given operation that endpoint is required.
	// Any required endpoint discovery operation cannot have endpoint discovery
	// turned off.
	Required bool `json:"required"`
}

EndpointDiscovery represents a map of key values pairs that represents metadata about how a given API will make a call to the discovery endpoint.

type EndpointTrait

type EndpointTrait struct {
	// Specifies the hostPrefix template to prepend to the operation's request
	// endpoint host.
	HostPrefix string `json:"hostPrefix"`
}

EndpointTrait provides the structure of the modeled endpoint trait, and its properties.

type ErrorInfo

type ErrorInfo struct {
	Type           string
	Code           string
	HTTPStatusCode int
}

ErrorInfo represents the error block of a shape's structure

type Event

type Event struct {
	Name    string
	Shape   *Shape
	For     *EventStream
	Private bool
}

Event is a single EventStream event that can be sent or received in an EventStream.

type EventStream

type EventStream struct {
	Name       string
	Shape      *Shape
	Events     []*Event
	Exceptions []*Event
}

EventStream represents a single eventstream group (input/output) and the modeled events that are known for the stream.

func (*EventStream) EventGroupName

func (es *EventStream) EventGroupName() string

func (*EventStream) StreamEventTypeGetterName

func (es *EventStream) StreamEventTypeGetterName() string

func (*EventStream) StreamReaderAPIName

func (es *EventStream) StreamReaderAPIName() string

func (*EventStream) StreamReaderImplConstructorName

func (es *EventStream) StreamReaderImplConstructorName() string

func (*EventStream) StreamReaderImplName

func (es *EventStream) StreamReaderImplName() string

func (*EventStream) StreamUnknownEventName

func (es *EventStream) StreamUnknownEventName() string

func (*EventStream) StreamUnmarshalerForEventName

func (es *EventStream) StreamUnmarshalerForEventName() string

func (*EventStream) StreamWriterAPIName

func (es *EventStream) StreamWriterAPIName() string

func (*EventStream) StreamWriterImplName

func (es *EventStream) StreamWriterImplName() string

type EventStreamAPI

type EventStreamAPI struct {
	API          *API
	Operation    *Operation
	Name         string
	InputStream  *EventStream
	OutputStream *EventStream
	RequireHTTP2 bool

	// The eventstream generated code was generated with an older model that
	// does not scale with bi-directional models. This drives the need to
	// expose the output shape's event stream member as an exported member.
	Legacy bool
}

EventStreamAPI provides details about the event stream async API and associated EventStream shapes.

func (EventStreamAPI) OutputMemberName

func (e EventStreamAPI) OutputMemberName() string

func (*EventStreamAPI) ShapeDoc

func (esAPI *EventStreamAPI) ShapeDoc() string

ShapeDoc returns the docstring for the EventStream API.

func (*EventStreamAPI) StreamInputEventTypeGetterName

func (es *EventStreamAPI) StreamInputEventTypeGetterName() string

func (*EventStreamAPI) StreamOutputUnmarshalerForEventName

func (es *EventStreamAPI) StreamOutputUnmarshalerForEventName() string

type EventStreamHeaderTypeMap

type EventStreamHeaderTypeMap struct {
	Header string
	Member string
}

EventStreamHeaderTypeMap provides the mapping of a EventStream Header's Value type to the shape reference's member type.

type EventStreams

type EventStreams map[*Shape]*EventStream

EventStreams is a map of streams for the API shared across all operations. Ensurs that no stream is duplicated.

func (*EventStreams) GetStream

func (es *EventStreams) GetStream(topShape *Shape, streamShape *Shape) *EventStream

GetStream returns an EventStream for the operations top level shape, and member reference to the stream shape.

type Example

type Example struct {
	API           *API                   `json:"-"`
	Operation     *Operation             `json:"-"`
	OperationName string                 `json:"-"`
	Index         string                 `json:"-"`
	Builder       examplesBuilder        `json:"-"`
	VisitedErrors map[string]struct{}    `json:"-"`
	Title         string                 `json:"title"`
	Description   string                 `json:"description"`
	ID            string                 `json:"id"`
	Comments      Comments               `json:"comments"`
	Input         map[string]interface{} `json:"input"`
	Output        map[string]interface{} `json:"output"`
}

Example is a single entry within the examples-1.json file.

func (Example) GoCode

func (ex Example) GoCode() string

ExampleCode will generate the example code for the given Example shape. TODO: Can delete

func (*Example) HasVisitedError

func (ex *Example) HasVisitedError(errRef *ShapeRef) bool

TODO: In the operation docuentation where we list errors, this needs to be done there as well.

func (*Example) MethodName

func (ex *Example) MethodName() string

type Examples

type Examples map[string][]Example

func (Examples) GoCode

func (exs Examples) GoCode() string

func (Examples) Names

func (exs Examples) Names() []string

Names will return the name of the example. This will also be the name of the operation that is to be tested.

type ExamplesDefinition

type ExamplesDefinition struct {
	*API     `json:"-"`
	Examples Examples `json:"examples"`
}

ExamplesDefinition is the structural representation of the examples-1.json file

type HTTPChecksum

type HTTPChecksum struct {
	RequestAlgorithmMember      string `json:"requestAlgorithmMember"`
	RequestValidationModeMember string `json:"requestValidationModeMember"`
	RequestChecksumRequired     bool   `json:"requestChecksumRequired"`
}

type HTTPInfo

type HTTPInfo struct {
	Method       string
	RequestURI   string
	ResponseCode uint
}

A HTTPInfo defines the method of HTTP request for the Operation.

type IoSuffix

type IoSuffix map[string]map[string]struct{}

IoSuffix represents map of service to shape names that are suffixed with `Input`, `Output` string and are not Input or Output shapes used by any operation within the service enclosure.

func (IoSuffix) LegacyIOSuffix

func (i IoSuffix) LegacyIOSuffix(a *API, shapeName string) bool

LegacyIoSuffix returns if the shape names are legacy names that contain "Input" and "Output" name as suffix.

type Loader

type Loader struct {
	// The base Go import path the loaded models will be appended to.
	BaseImport string

	// Allows ignoring API models that are unsupported by the SDK without
	// failing the load of other supported APIs.
	IgnoreUnsupportedAPIs bool

	// Set to true to strictly enforce usage of the serviceId for the package naming
	StrictServiceId bool
}

Loader provides the loading of APIs from files.

func (Loader) Load

func (l Loader) Load(modelPaths []string) (APIs, error)

Load loads the API model files from disk returning the map of API package. Returns error if multiple API model resolve to the same package name.

type Metadata

type Metadata struct {
	APIVersion          string
	EndpointPrefix      string
	SigningName         string
	ServiceAbbreviation string
	ServiceFullName     string
	SignatureVersion    string
	JSONVersion         string
	TargetPrefix        string
	Protocol            string
	ProtocolSettings    ProtocolSettings
	UID                 string
	EndpointsID         string
	ServiceID           string

	NoResolveEndpoint  bool
	AWSQueryCompatible *awsQueryCompatible
}

A Metadata is the metadata about an API's definition.

type Operation

type Operation struct {
	API           *API `json:"-"`
	ExportedName  string
	Name          string
	Documentation string `json:"-"`
	// HTTP                HTTPInfo
	Host          string     `json:"host"`
	InputRef      ShapeRef   `json:"input"`
	OutputRef     ShapeRef   `json:"output"`
	ErrorRefs     []ShapeRef `json:"errors"`
	Paginator     *Paginator
	Deprecated    bool     `json:"deprecated"`
	DeprecatedMsg string   `json:"deprecatedMessage"`
	AuthType      AuthType `json:"authtype"`

	CustomBuildHandlers []string

	EventStreamAPI *EventStreamAPI

	IsEndpointDiscoveryOp bool               `json:"endpointoperation"`
	EndpointDiscovery     *EndpointDiscovery `json:"endpointdiscovery"`
	Endpoint              *EndpointTrait     `json:"endpoint"`

	// HTTPChecksum replaces usage of httpChecksumRequired, but some APIs
	// (s3control) still uses old trait.
	HTTPChecksum           HTTPChecksum `json:"httpChecksum"`
	IsHttpChecksumRequired bool         `json:"httpChecksumRequired"`
	// contains filtered or unexported fields
}

An Operation defines a specific API Operation.

func (*Operation) Example

func (o *Operation) Example() string

Example returns a string of the rendered Go code for the Operation

func (*Operation) ExampleInput

func (o *Operation) ExampleInput() string

ExampleInput return a string of the rendered Go code for an example's input parameters

func (*Operation) GetSigner

func (o *Operation) GetSigner() string

GetSigner returns the signer that should be used for a API request.

func (*Operation) GoCode

func (o *Operation) GoCode() string

GoCode returns a string of rendered GoCode for this Operation

func (*Operation) HasAccountIDMemberWithARN

func (o *Operation) HasAccountIDMemberWithARN() bool

HasAccountIDMemberWithARN returns true if an account id member exists for an input shape that may take in an ARN.

func (*Operation) HasInput

func (o *Operation) HasInput() bool

HasInput returns if the Operation accepts an input parameter

func (*Operation) HasOutput

func (o *Operation) HasOutput() bool

HasOutput returns if the Operation accepts an output parameter

func (*Operation) InterfaceSignature

func (o *Operation) InterfaceSignature() string

InterfaceSignature returns a string representing the Operation's interface{} functional signature.

func (*Operation) Methods

func (o *Operation) Methods() []string

Methods Returns a list of method names that will be generated.

func (*Operation) RequestChecksumRequired

func (o *Operation) RequestChecksumRequired() bool

RequestChecksumRequired returns if the request requires the Content-MD5 checksum to be computed.

func (*Operation) ShouldDiscardResponse

func (o *Operation) ShouldDiscardResponse() bool

ShouldDiscardResponse returns if the operation should discard the response returned by the service.

func (*Operation) ShouldSignRequestBody

func (o *Operation) ShouldSignRequestBody() bool

ShouldSignRequestBody returns if the operation request body should be signed or not.

type Paginator

type Paginator struct {
	InputTokens  interface{} `json:"input_token"`
	OutputTokens interface{} `json:"output_token"`
	LimitKey     string      `json:"limit_key"`
	MoreResults  string      `json:"more_results"`
}

Paginator keeps track of pagination configuration for an API operation.

func (*Paginator) InputTokensString

func (p *Paginator) InputTokensString() string

InputTokensString returns output tokens formatted as a list

func (*Paginator) OutputTokensString

func (p *Paginator) OutputTokensString() string

OutputTokensString returns output tokens formatted as a list

type ProtocolSettings

type ProtocolSettings struct {
	HTTP2 string `json:"h2,omitempty"`
}

ProtocolSettings define how the SDK should handle requests in the context of of a protocol.

type Shape

type Shape struct {
	API           *API `json:"-"`
	ShapeName     string
	Documentation string `json:"-"`
	DefaultValue  string `json:"-"`

	// References of struct members will include their originally modeled
	// member name for cross references.
	OriginalShapeName string `json:"-"`

	// Map of exported member names to the ShapeReference.
	MemberRefs map[string]*ShapeRef `json:"members"`
	MemberRef  ShapeRef             `json:"member"` // List ref
	KeyRef     ShapeRef             `json:"key"`    // map key ref
	ValueRef   ShapeRef             `json:"value"`  // map value ref
	Required   []string
	Payload    string
	Type       string
	// this is being added for type union specifically. We want to generate
	//  api as struct and handle setSDK and setResource differently
	RealType         string
	Exception        bool
	Enum             []string
	EnumConsts       []string
	Flattened        bool
	Streaming        bool
	Location         string
	LocationName     string
	IdempotencyToken bool   `json:"idempotencyToken"`
	TimestampFormat  string `json:"timestampFormat"`
	XMLNamespace     XMLInfo
	Min              float64 // optional Minimum length (string, list) or value (number)

	OutputEventStreamAPI *EventStreamAPI
	EventStream          *EventStream
	EventFor             map[string]*EventStream `json:"-"`

	IsInputEventStream  bool `json:"-"`
	IsOutputEventStream bool `json:"-"`

	IsEventStream bool `json:"eventstream"`
	IsEvent       bool `json:"event"`

	Refs []*ShapeRef // References to this shape

	OrigShapeName string `json:"-"`

	// Defines if the shape is a placeholder and should not be used directly
	Placeholder bool

	Deprecated    bool   `json:"deprecated"`
	DeprecatedMsg string `json:"deprecatedMessage"`

	Validations ShapeValidations

	// Error information that is set if the shape is an error shape.
	ErrorInfo ErrorInfo `json:"error"`

	// Flags that the shape cannot be rename. Prevents the shape from being
	// renamed further by the Input/Output.
	AliasedShapeName bool

	// Sensitive types should not be logged by SDK type loggers.
	Sensitive bool `json:"sensitive"`

	// Flags that a member of the shape is an EndpointARN
	HasEndpointARNMember bool

	// Flags that a member of the shape is an OutpostIDMember
	HasOutpostIDMember bool

	// Flags that the shape has an account id member along with EndpointARN member
	HasAccountIdMemberWithARN bool

	// Indicates the Shape is used as an operation input
	UsedAsInput bool

	// Indicates the Shape is used as an operation output
	UsedAsOutput bool

	// Indicates a structure shape is a document type
	Document bool `json:"document"`
	// contains filtered or unexported fields
}

A Shape defines the definition of a shape type

func (*Shape) Clone

func (s *Shape) Clone(newName string) *Shape

Clone returns a cloned version of the shape with all references clones.

Does not clone EventStream or Validate related values.

func (*Shape) Docstring

func (s *Shape) Docstring() string

Docstring returns the godocs formated documentation

func (*Shape) EnumName

func (s *Shape) EnumName(n int) string

EnumName returns the Nth enum in the shapes Enum list

func (*Shape) ErrorCodeName

func (s *Shape) ErrorCodeName() string

ErrorCodeName will return the error shape's name formated for error code const.

func (*Shape) ErrorName

func (s *Shape) ErrorName() string

ErrorName will return the shape's name or error code if available based on the API's protocol. This is the error code string returned by the service.

func (*Shape) GetModeledMember

func (s *Shape) GetModeledMember(name string) *ShapeRef

GetModeledMember returns the member's ShapeReference if it exists within the shape. Returns nil if the member could not be found.

func (Shape) GetTimestampFormat

func (s Shape) GetTimestampFormat() string

func (*Shape) GoCode

func (s *Shape) GoCode() string

GoCode returns the rendered Go code for the Shape.

func (*Shape) GoCodeStringers

func (s *Shape) GoCodeStringers() string

GoCodeStringers renders the Stringers for API input/output shapes

func (*Shape) GoStructType

func (s *Shape) GoStructType(name string, ref *ShapeRef) string

GoStructType returns the type of a struct field based on the API model definition.

func (*Shape) GoStructValueType

func (s *Shape) GoStructValueType(name string, ref *ShapeRef) string

GoStructValueType returns the Shape's Go type value instead of a pointer for the type.

func (*Shape) GoTags

func (s *Shape) GoTags(root, required bool) string

GoTags returns the struct tags for a shape.

func (*Shape) GoType

func (s *Shape) GoType() string

GoType returns a shape's Go type

func (*Shape) GoTypeElem

func (s *Shape) GoTypeElem() string

GoTypeElem returns the Go type for the Shape. If the shape type is a pointer just the type will be returned minus the pointer *.

func (*Shape) GoTypeWithPkgName

func (s *Shape) GoTypeWithPkgName() string

GoTypeWithPkgName returns a shape's type as a string with the package name in <packageName>.<type> format. Package naming only applies to structures.

func (*Shape) GoTypeWithPkgNameElem

func (s *Shape) GoTypeWithPkgNameElem() string

GoTypeWithPkgNameElem returns the shapes type as a string with the "*" removed if there was one preset.

func (*Shape) HasDefaultValue

func (s *Shape) HasDefaultValue() bool

func (*Shape) HasHostLabelMembers

func (s *Shape) HasHostLabelMembers() bool

HasHostLabelMembers returns true if the shape contains any members which are decorated with the hostLabel trait.

func (*Shape) HasMember

func (s *Shape) HasMember(name string) bool

HasMember will return whether or not the shape has a given member by name. Name passed in must match the SDK's exported name for the member, not the modeled member name

func (*Shape) HasPayloadMembers

func (s *Shape) HasPayloadMembers() bool

HasPayloadMembers returns if the shape has any members that will be serialized to the payload of a API message.

func (*Shape) IsEnum

func (s *Shape) IsEnum() bool

IsEnum returns whether this shape is an enum list

func (*Shape) IsInternal

func (s *Shape) IsInternal() bool

IsInternal returns whether the shape was defined in this package

func (*Shape) IsRequired

func (s *Shape) IsRequired(member string) bool

IsRequired returns if member is a required field. Required fields are fields marked as required, hostLabels, or location of uri path.

func (*Shape) IsSensitive

func (s *Shape) IsSensitive() bool

IsSensitive checks whether the Shape itself is sensitive, or if the Shape is a collection/map with a sensitive member.

func (*Shape) MemberNames

func (s *Shape) MemberNames() []string

MemberNames returns a slice of struct member names.

func (*Shape) NestedShape

func (s *Shape) NestedShape() *Shape

NestedShape returns the shape pointer value for the shape which is nested under the current shape. If the shape is not nested nil will be returned.

strucutures, the current shape is returned map: the value shape of the map is returned list: the element shape of the list is returned

func (*Shape) PayloadRefName

func (s *Shape) PayloadRefName() string

PayloadRefName returns the payload member of the shape if there is one modeled. If no payload is modeled, empty string will be returned.

func (*Shape) Rename

func (s *Shape) Rename(newName string)

Rename changes the name of the Shape to newName. Also updates the associated API's reference to use newName.

func (*Shape) WillRefBeBase64Encoded

func (s *Shape) WillRefBeBase64Encoded(refName string) bool

type ShapeRef

type ShapeRef struct {
	API           *API   `json:"-"`
	Shape         *Shape `json:"-"`
	Documentation string `json:"-"`
	DefaultValue  string `json:"-"`
	ShapeName     string `json:"shape"`
	Location      string
	LocationName  string
	QueryName     string
	Flattened     bool
	Streaming     bool
	XMLAttribute  bool

	// References of struct members will include their originally modeled
	// member name for cross references.
	OriginalMemberName string `json:"-"`

	// Ignore, if set, will not be sent over the wire
	Ignore              bool
	XMLNamespace        XMLInfo
	Payload             string
	IdempotencyToken    bool   `json:"idempotencyToken"`
	TimestampFormat     string `json:"timestampFormat"`
	JSONValue           bool   `json:"jsonvalue"`
	Deprecated          bool   `json:"deprecated"`
	DeprecatedMsg       string `json:"deprecatedMessage"`
	EndpointDiscoveryID bool   `json:"endpointdiscoveryid"`
	HostLabel           bool   `json:"hostLabel"`

	OrigShapeName string `json:"-"`

	GenerateGetter bool

	IsEventPayload bool `json:"eventpayload"`
	IsEventHeader  bool `json:"eventheader"`

	// Collection of custom tags the shape reference includes.
	CustomTags ShapeTags

	// Flags whether the member reference is a endpoint ARN
	EndpointARN bool

	// Flags whether the member reference is a Outpost ID
	OutpostIDMember bool

	// Flag whether the member reference is a Account ID when endpoint shape ARN is present
	AccountIDMemberWithARN bool

	// Flags that the member was modeled as JSONValue but suppressed by the SDK.
	SuppressedJSONValue bool `json:"-"`
}

A ShapeRef defines the usage of a shape within the API.

func (*ShapeRef) CanBeEmpty

func (ref *ShapeRef) CanBeEmpty() bool

CanBeEmpty returns if the shape value can sent request as an empty value. String, blob, list, and map are types must not be empty when the member is serialized to the URI path, or decorated with HostLabel.

func (*ShapeRef) Docstring

func (ref *ShapeRef) Docstring() string

Docstring returns the godocs formated documentation

func (ShapeRef) GetTimestampFormat

func (ref ShapeRef) GetTimestampFormat() string

func (*ShapeRef) GoTags

func (ref *ShapeRef) GoTags(toplevel bool, isRequired bool) string

GoTags returns the rendered tags string for the ShapeRef

func (*ShapeRef) GoType

func (ref *ShapeRef) GoType() string

GoType returns a shape ref's Go type.

func (*ShapeRef) GoTypeElem

func (ref *ShapeRef) GoTypeElem() string

GoTypeElem returns the Go type for the Shape. If the shape type is a pointer just the type will be returned minus the pointer *.

func (*ShapeRef) GoTypeWithPkgName

func (ref *ShapeRef) GoTypeWithPkgName() string

GoTypeWithPkgName returns a shape's type as a string with the package name in <packageName>.<type> format. Package naming only applies to structures.

func (*ShapeRef) HasDefaultValue

func (s *ShapeRef) HasDefaultValue() bool

HasDefaultValue returns whether this shape has a default value

func (*ShapeRef) IndentedDocstring

func (ref *ShapeRef) IndentedDocstring() string

IndentedDocstring is the indented form of the doc string.

func (*ShapeRef) UseIndirection

func (s *ShapeRef) UseIndirection() bool

UseIndirection returns if the shape's reference should use indirection or not.

type ShapeTag

type ShapeTag struct {
	Key, Val string
}

ShapeTag is a struct tag that will be applied to a shape's generated code

func (ShapeTag) String

func (s ShapeTag) String() string

String returns the string representation of the shape tag

type ShapeTags

type ShapeTags []ShapeTag

ShapeTags is a collection of shape tags and provides serialization of the tags in an ordered list.

func (ShapeTags) Join

func (s ShapeTags) Join(sep string) string

Join returns an ordered serialization of the shape tags with the provided separator.

func (ShapeTags) String

func (s ShapeTags) String() string

String is an alias for Join with the empty space separator.

type ShapeValidation

type ShapeValidation struct {
	// Name of the shape to be validated
	Name string
	// Reference to the shape within the context the shape is referenced
	Ref *ShapeRef
	// Type of validation needed
	Type ShapeValidationType
}

A ShapeValidation contains information about a shape and the type of validation that is needed

func (ShapeValidation) GoCode

func (sv ShapeValidation) GoCode() string

GoCode returns the generated Go code for the Shape with its validation type.

type ShapeValidationType

type ShapeValidationType int

A ShapeValidationType is the type of validation that a shape needs

type ShapeValidations

type ShapeValidations []ShapeValidation

A ShapeValidations is a collection of shape validations needed nested within a parent shape

func (ShapeValidations) GoCode

func (vs ShapeValidations) GoCode(shape *Shape) string

GoCode generates the Go code needed to perform validations for the shape and its nested fields.

func (ShapeValidations) Has

Has returns true or false if the ShapeValidations already contains the the reference and validation type.

type ShapeValueBuilder

type ShapeValueBuilder struct {
	// Specifies if API shapes modeled as blob types, input values are base64
	// encoded or not, and strings values instead.
	Base64BlobValues bool

	// The helper that will provide the logic and formated code to convert a
	// timestamp input value into a Go time.Time.
	ParseTimeString func(ref *ShapeRef, memberName, v string) string
}

ShapeValueBuilder provides the logic to build the nested values for a shape. Base64BlobValues is true if the blob field in shapeRef.Shape.Type is base64 encoded.

func NewShapeValueBuilder

func NewShapeValueBuilder() ShapeValueBuilder

NewShapeValueBuilder returns an initialized ShapeValueBuilder for generating API shape types initialized with values.

func (ShapeValueBuilder) BuildComplex

func (b ShapeValueBuilder) BuildComplex(name, memName string, ref *ShapeRef, parent *Shape, v map[string]interface{}) string

BuildComplex will build the shape's value for complex types such as structs, and maps.

func (ShapeValueBuilder) BuildList

func (b ShapeValueBuilder) BuildList(name, memName string, ref *ShapeRef, v []interface{}) string

BuildList will construct a list shape based off the service's definition of that list.

func (ShapeValueBuilder) BuildScalar

func (b ShapeValueBuilder) BuildScalar(name, memName string, ref *ShapeRef, shape interface{}, isPayload bool) string

BuildScalar will build atomic Go types.

func (ShapeValueBuilder) BuildShape

func (b ShapeValueBuilder) BuildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string

BuildShape will recursively build the referenced shape based on the json object provided. isMap will dictate how the field name is specified. If isMap is true, we will expect the member name to be quotes like "Foo".

func (ShapeValueBuilder) GoType

func (b ShapeValueBuilder) GoType(ref *ShapeRef, elem bool) string

GoType returns the string of the shape's Go type identifier.

type SmokeTestCase

type SmokeTestCase struct {
	OpName    string                 `json:"operationName"`
	Input     map[string]interface{} `json:"input"`
	ExpectErr bool                   `json:"errorExpectedFromService"`
}

SmokeTestCase provides the definition for a integration smoke test case.

func (SmokeTestCase) BuildInputShape

func (c SmokeTestCase) BuildInputShape(ref *ShapeRef) string

BuildInputShape returns the Go code as a string for initializing the test case's input shape.

type SmokeTestSuite

type SmokeTestSuite struct {
	Version       int             `json:"version"`
	DefaultRegion string          `json:"defaultRegion"`
	TestCases     []SmokeTestCase `json:"testCases"`
}

SmokeTestSuite defines the test suite for smoke tests.

type UnsupportedAPIModelError

type UnsupportedAPIModelError struct {
	Err error
}

UnsupportedAPIModelError provides wrapping of an error causing the API to fail to load because the SDK does not support the API service defined.

func (UnsupportedAPIModelError) Error

func (e UnsupportedAPIModelError) Error() string

type Waiter

type Waiter struct {
	Name          string
	Delay         int
	MaxAttempts   int
	OperationName string `json:"operation"`
	Operation     *Operation
	Acceptors     []WaiterAcceptor
}

A Waiter is an individual waiter definition.

func (*Waiter) GoCode

func (w *Waiter) GoCode() string

GoCode returns the generated Go code for an individual waiter.

func (*Waiter) InterfaceSignature

func (w *Waiter) InterfaceSignature() string

InterfaceSignature returns a string representing the Waiter's interface function signature.

type WaiterAcceptor

type WaiterAcceptor struct {
	State    string
	Matcher  string
	Argument string
	Expected interface{}
}

WaiterAcceptor is the acceptors defined in the model the SDK will use to wait on resource states with.

func (*WaiterAcceptor) ExpectedString

func (a *WaiterAcceptor) ExpectedString() string

ExpectedString returns the string that was expected by the WaiterAcceptor

type XMLInfo

type XMLInfo struct {
	Prefix string
	URI    string
}

A XMLInfo defines URL and prefix for Shapes when rendered as XML

Directories

Path Synopsis
codegentest
service
Package service contains automatically generated AWS clients.
Package service contains automatically generated AWS clients.
service/awsendpointdiscoverytest
Package awsendpointdiscoverytest provides the client and types for making API requests to AwsEndpointDiscoveryTest.
Package awsendpointdiscoverytest provides the client and types for making API requests to AwsEndpointDiscoveryTest.
service/awsendpointdiscoverytest/awsendpointdiscoverytestiface
Package awsendpointdiscoverytestiface provides an interface to enable mocking the AwsEndpointDiscoveryTest service client for testing your code.
Package awsendpointdiscoverytestiface provides an interface to enable mocking the AwsEndpointDiscoveryTest service client for testing your code.
service/awsquerycompatible
Package awsquerycompatible provides the client and types for making API requests to AWSQuery Compatible Service.
Package awsquerycompatible provides the client and types for making API requests to AWSQuery Compatible Service.
service/awsquerycompatible/awsquerycompatibleiface
Package awsquerycompatibleiface provides an interface to enable mocking the AWSQuery Compatible Service service client for testing your code.
Package awsquerycompatibleiface provides an interface to enable mocking the AWSQuery Compatible Service service client for testing your code.
service/restjsonservice
Package restjsonservice provides the client and types for making API requests to REST JSON Service.
Package restjsonservice provides the client and types for making API requests to REST JSON Service.
service/restjsonservice/restjsonserviceiface
Package restjsonserviceiface provides an interface to enable mocking the REST JSON Service service client for testing your code.
Package restjsonserviceiface provides an interface to enable mocking the REST JSON Service service client for testing your code.
service/restxmlservice
Package restxmlservice provides the client and types for making API requests to REST XML Service.
Package restxmlservice provides the client and types for making API requests to REST XML Service.
service/restxmlservice/restxmlserviceiface
Package restxmlserviceiface provides an interface to enable mocking the REST XML Service service client for testing your code.
Package restxmlserviceiface provides an interface to enable mocking the REST XML Service service client for testing your code.
service/rpcservice
Package rpcservice provides the client and types for making API requests to RPC Service.
Package rpcservice provides the client and types for making API requests to RPC Service.
service/rpcservice/rpcserviceiface
Package rpcserviceiface provides an interface to enable mocking the RPC Service service client for testing your code.
Package rpcserviceiface provides an interface to enable mocking the RPC Service service client for testing your code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL