Documentation ¶
Overview ¶
Package api represents API abstractions for rendering service generated files.
Index ¶
- type API
- func (a *API) APIGoCode() string
- func (a *API) Attach(filename string)
- func (a *API) AttachDocs(filename string)
- func (a *API) AttachPaginators(filename string)
- func (a *API) AttachString(str string)
- func (a *API) AttachWaiters(filename string)
- func (a *API) ExampleGoCode() string
- func (a *API) ExportableName(name string) string
- func (a *API) InterfaceGoCode() string
- func (a *API) InterfacePackageName() string
- func (a *API) NewAPIGoCodeWithPkgName(cfg string) string
- func (a *API) NiceName() string
- func (a *API) OperationList() []*Operation
- func (a *API) OperationNames() []string
- func (a *API) PackageName() string
- func (a *API) ProtocolPackage() string
- func (a *API) ServiceGoCode() string
- func (a *API) Setup()
- func (a *API) ShapeList() []*Shape
- func (a *API) ShapeNames() []string
- func (a *API) StructName() string
- func (a *API) UseInitMethods() bool
- func (a *API) WaitersGoCode() string
- type HTTPInfo
- type Metadata
- type Operation
- type Paginator
- type Shape
- func (s *Shape) Docstring() string
- func (s *Shape) EnumName(n int) string
- func (s *Shape) GoCode() string
- func (s *Shape) GoType() string
- func (s *Shape) GoTypeElem() string
- func (s *Shape) GoTypeWithPkgName() string
- func (s *Shape) IsEnum() bool
- func (s *Shape) IsInternal() bool
- func (s *Shape) IsRequired(member string) bool
- func (s *Shape) MemberNames() []string
- func (s *Shape) Rename(newName string)
- type ShapeRef
- type WaitAcceptor
- type Waiter
- type XMLInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Metadata Metadata Operations map[string]*Operation Shapes map[string]*Shape Waiters []Waiter Documentation string // 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 SvcClientImportPath string // contains filtered or unexported fields }
An API defines a service API's definition. and logic to serialize the definition.
func Load ¶
Load takes a set of files for each filetype and returns an API pointer. The API will be initialized once all files have been loaded and parsed.
Will panic if any failure opening the definition JSON files, or there are unrecognized exported names.
func (*API) Attach ¶
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 ¶
AttachDocs attaches documentation from a JSON filename.
func (*API) AttachPaginators ¶
AttachPaginators attaches pagination configuration from filename to the API.
func (*API) AttachString ¶
AttachString will unmarshal a raw JSON string, and setup the API if not already done so.
func (*API) AttachWaiters ¶ added in v0.10.3
AttachWaiters reads a file of waiter definitions, and adds those to the API. Will panic if an error occurs.
func (*API) ExampleGoCode ¶
ExampleGoCode renders service example code. Returning it as a string.
func (*API) ExportableName ¶
ExportableName a name which is exportable as a value or name in Go code
func (*API) InterfaceGoCode ¶
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 ¶
InterfacePackageName returns the package name for the interface.
func (*API) NewAPIGoCodeWithPkgName ¶
NewAPIGoCodeWithPkgName returns a string of instantiating the API prefixed with its package name. Takes a string depicting the Config.
func (*API) OperationList ¶
OperationList returns a slice of API operation pointers
func (*API) OperationNames ¶
OperationNames returns a slice of API operations supported.
func (*API) ProtocolPackage ¶
ProtocolPackage returns the package name of the protocol this API uses.
func (*API) ServiceGoCode ¶
ServiceGoCode renders service go code. Returning it as a string.
func (*API) ShapeNames ¶
ShapeNames returns a slice of names for each shape used by the API.
func (*API) StructName ¶
StructName returns the struct name for a given API.
func (*API) UseInitMethods ¶
UseInitMethods returns if the service's init method should be rendered.
func (*API) WaitersGoCode ¶ added in v0.10.3
WaitersGoCode generates and returns Go code for each of the waiters of this API.
type Metadata ¶
type Metadata struct { APIVersion string EndpointPrefix string SigningName string ServiceAbbreviation string ServiceFullName string SignatureVersion string JSONVersion string TargetPrefix string Protocol string }
A Metadata is the metadata about an API's definition.
type Operation ¶
type Operation struct { API *API `json:"-"` ExportedName string Name string Documentation string HTTP HTTPInfo InputRef ShapeRef `json:"input"` OutputRef ShapeRef `json:"output"` Paginator *Paginator }
An Operation defines a specific API Operation.
func (*Operation) ExampleInput ¶
ExampleInput return a string of the rendered Go code for an example's input parameters
func (*Operation) InterfaceSignature ¶
InterfaceSignature returns a string representing the Operation's interface{} functional signature.
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 ¶
InputTokensString returns output tokens formatted as a list
func (*Paginator) OutputTokensString ¶
OutputTokensString returns output tokens formatted as a list
type Shape ¶
type Shape struct { API *API `json:"-"` ShapeName string Documentation string MemberRefs map[string]*ShapeRef `json:"members"` MemberRef ShapeRef `json:"member"` KeyRef ShapeRef `json:"key"` ValueRef ShapeRef `json:"value"` Required []string Payload string Type string Exception bool Enum []string EnumConsts []string Flattened bool Streaming bool Location string LocationName string XMLNamespace XMLInfo Min int // optional Minimum length (string, list) or value (number) Max int // optional Minimum length (string, list) or value (number) // contains filtered or unexported fields }
A Shape defines the definition of a shape type
func (*Shape) GoTypeElem ¶
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 ¶
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) IsInternal ¶
IsInternal returns whether the shape was defined in this package
func (*Shape) IsRequired ¶
IsRequired returns if member is a required field.
func (*Shape) MemberNames ¶
MemberNames returns a slice of struct member names.
type ShapeRef ¶
type ShapeRef struct { API *API `json:"-"` Shape *Shape `json:"-"` Documentation string ShapeName string `json:"shape"` Location string LocationName string QueryName string Flattened bool Streaming bool XMLAttribute bool XMLNamespace XMLInfo Payload string }
A ShapeRef defines the usage of a shape within the API.
func (*ShapeRef) GoTypeElem ¶
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 ¶
GoTypeWithPkgName returns a shape's type as a string with the package name in <packageName>.<type> format. Package naming only applies to structures.
type WaitAcceptor ¶ added in v0.10.3
A WaitAcceptor is an individual wait acceptor definition.
func (*WaitAcceptor) ExpectedString ¶ added in v0.10.3
func (a *WaitAcceptor) ExpectedString() string
ExpectedString returns the string that was expected by the WaitAcceptor