package protocol

import "github.com/aws/aws-sdk-go-v2/private/protocol"

Index

Constants

const (
	RFC822TimeFormatName  = "rfc822"
	ISO8601TimeFormatName = "iso8601"
	UnixTimeFormatName    = "unixTimestamp"
)

Names of time formats supported by the SDK

const (
	// RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT
	RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"

	// RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38.999999999Z
	ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"

	// RFC Output TimeStamp format is used for output time without seconds precision
	RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

	// ISO output TimeStamp format is used for output time without seconds precision
	ISO8601OutputTimeFormat = "2006-01-02T15:04:05Z"
)

Time formats supported by the SDK

const HostPrefixHandlerName = "awssdk.endpoint.HostPrefixHandler"

HostPrefixHandlerName is the handler name for the host prefix request handler.

Variables

var RandReader = rand.Reader

RandReader is the random reader the protocol package will use to read random bytes from. This is exported for testing, and should not be used.

var UnmarshalDiscardBodyHandler = aws.NamedHandler{Name: "awssdk.shared.UnmarshalDiscardBody", Fn: UnmarshalDiscardBody}

UnmarshalDiscardBodyHandler is a named request handler to empty and close a response's body

var ValidateEndpointHostHandler = aws.NamedHandler{
	Name: "awssdk.protocol.ValidateEndpointHostHandler",
	Fn: func(r *aws.Request) {
		err := ValidateEndpointHost(r.Operation.Name, r.HTTPRequest.URL.Host)
		if err != nil {
			r.Error = err
		}
	},
}

ValidateEndpointHostHandler is a request handler that will validate the request endpoint's hosts is a valid RFC 3986 host.

Functions

func CanSetIdempotencyToken

func CanSetIdempotencyToken(v reflect.Value, f reflect.StructField) bool

CanSetIdempotencyToken returns true if the struct field should be automatically populated with a Idempotency token.

Only *string and string type fields that are tagged with idempotencyToken which are not already set can be auto filled.

func DecodeJSONValue

func DecodeJSONValue(v string, escape EscapeMode) (aws.JSONValue, error)

DecodeJSONValue will attempt to decode the string input as a JSONValue. Optionally decoding base64 the value first before JSON unmarshaling.

Will panic if the escape mode is unknown.

func EncodeJSONValue

func EncodeJSONValue(v aws.JSONValue, escape EscapeMode) (string, error)

EncodeJSONValue marshals the value into a JSON string, and optionally base64 encodes the string before returning it.

Will panic if the escape mode is unknown.

func FormatTime

func FormatTime(name string, t time.Time) (string, error)

FormatTime returns a string value of the time.

func GetIdempotencyToken

func GetIdempotencyToken() string

GetIdempotencyToken returns a randomly generated idempotency token.

func GetValue

func GetValue(r reflect.Value) (string, error)

GetValue will return the value that is associated with the reflect.Value. If that value is not set, this will return an ErrValueNotSet

func IsKnownTimestampFormat

func IsKnownTimestampFormat(name string) bool

IsKnownTimestampFormat returns if the timestamp format name is know to the SDK's protocols.

func IsNotSetError

func IsNotSetError(err error) bool

IsNotSetError will return true if the error is of ErrValueNotSet

func NewHostPrefixHandler

func NewHostPrefixHandler(prefix string, labelsFn func() map[string]string) aws.NamedHandler

NewHostPrefixHandler constructs a build handler

func ParseTime

func ParseTime(formatName, value string) (time.Time, error)

ParseTime attempts to parse the time given the format. Returns the time if it was able to be parsed, and fails otherwise.

func ReplacePathElement

func ReplacePathElement(path, fieldBuf []byte, key, val string, escape bool) ([]byte, []byte, error)

ReplacePathElement replaces a single element in the path []byte. Escape is used to control whether the value will be escaped using Amazon path escape style.

func SetIdempotencyToken

func SetIdempotencyToken(v reflect.Value)

SetIdempotencyToken will set the value provided with a Idempotency Token. Given that the value can be set. Will panic if value is not setable.

func UUIDVersion4

func UUIDVersion4(u []byte) string

UUIDVersion4 returns a Version 4 random UUID from the byte slice provided

func UnmarshalDiscardBody

func UnmarshalDiscardBody(r *aws.Request)

UnmarshalDiscardBody is a request handler to empty a response's body and closing it.

func ValidHostLabel

func ValidHostLabel(label string) bool

ValidHostLabel returns if the label is a valid RFC 3986 host label.

func ValidateEndpointHost

func ValidateEndpointHost(opName, host string) error

ValidateEndpointHost validates that the host string passed in is a valid RFC 3986 host. Returns error if the host is not valid.

Types

type Attribute

type Attribute struct {
	Name  string
	Value ValueMarshaler
	Meta  Metadata
}

An Attribute is a FieldValue that resides within the imediant context of another field. Such as XML attribute for tags.

type BoolValue

type BoolValue bool

BoolValue provides encoding of bool for AWS protocols.

func (BoolValue) MarshalValue

func (v BoolValue) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (BoolValue) MarshalValueBuf

func (v BoolValue) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type BytesStream

type BytesStream []byte

A BytesStream aliases a byte slice to be used as a StreamMarshaler.

func (BytesStream) MarshalStream

func (v BytesStream) MarshalStream() (io.ReadSeeker, error)

MarshalStream marshals a byte slice into an io.ReadSeeker for encoding.

type BytesValue

type BytesValue string

BytesValue provies encoding of string for AWS protocols.

func (BytesValue) MarshalValue

func (v BytesValue) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (BytesValue) MarshalValueBuf

func (v BytesValue) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

type ErrValueNotSet

type ErrValueNotSet struct{}

ErrValueNotSet is an error that is returned when the value has not been set.

func (*ErrValueNotSet) Error

func (err *ErrValueNotSet) Error() string

type EscapeMode

type EscapeMode uint

EscapeMode is the mode that should be use for escaping a value

const (
	NoEscape EscapeMode = iota
	Base64Escape
	QuotedEscape
)

The modes for escaping a value before it is marshaled, and unmarshaled.

type FieldBuffer

type FieldBuffer struct {
	// contains filtered or unexported fields
}

A FieldBuffer provides buffering of fields so the number of allocations are reduced by providng a persistent buffer that is used between fields.

func (*FieldBuffer) GetValue

func (b *FieldBuffer) GetValue(m ValueMarshaler) ([]byte, error)

GetValue will retrieve the ValueMarshaler's value by appending the value to the buffer. Will return the buffer that was populated.

This buffer is only valid until the next time GetValue is called.

type FieldEncoder

type FieldEncoder interface {
	SetValue(t Target, k string, m ValueMarshaler, meta Metadata)
	SetStream(t Target, k string, m StreamMarshaler, meta Metadata)
	SetFields(t Target, k string, m FieldMarshaler, meta Metadata)

	Map(t Target, k string, meta Metadata) MapEncoder
	List(t Target, k string, meta Metadata) ListEncoder
}

A FieldEncoder provides the interface for encoding struct field members.

type FieldMarshaler

type FieldMarshaler interface {
	MarshalFields(FieldEncoder) error
}

A FieldMarshaler interface is used to marshal struct fields when encoding.

type FieldMarshalerFunc

type FieldMarshalerFunc func(FieldEncoder) error

FieldMarshalerFunc is a helper utility that wrapps a function and allows that function to be called as a FieldMarshaler.

func (FieldMarshalerFunc) MarshalFields

func (fn FieldMarshalerFunc) MarshalFields(e FieldEncoder) error

MarshalFields will call the underlying function passing in the field encoder with the protocol field encoder.

type Float64Value

type Float64Value float64

Float64Value provides encoding of float64 for AWS protocols.

func (Float64Value) MarshalValue

func (v Float64Value) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (Float64Value) MarshalValueBuf

func (v Float64Value) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type HeaderListEncoder

type HeaderListEncoder struct {
	Key    string
	Header http.Header
	Err    error
}

HeaderListEncoder will encode list values nested into a header key.

func (*HeaderListEncoder) End

func (e *HeaderListEncoder) End()

End does nothing for header list encodings.

func (*HeaderListEncoder) List

func (e *HeaderListEncoder) List() ListEncoder

List Is not implemented, header list of list is undefined.

func (*HeaderListEncoder) ListAddFields

func (e *HeaderListEncoder) ListAddFields(m FieldMarshaler)

ListAddFields Is not implemented, query list of FieldMarshaler is undefined.

func (*HeaderListEncoder) ListAddValue

func (e *HeaderListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the header.

func (*HeaderListEncoder) Map

func (e *HeaderListEncoder) Map() MapEncoder

Map Is not implemented, header list of map is undefined.

func (*HeaderListEncoder) Start

func (e *HeaderListEncoder) Start()

Start does nothing for header list encodings.

type HeaderMapEncoder

type HeaderMapEncoder struct {
	Prefix string
	Header http.Header
	Err    error
}

HeaderMapEncoder builds a map valu

func (*HeaderMapEncoder) End

func (e *HeaderMapEncoder) End()

End does nothing for header encodings.

func (*HeaderMapEncoder) List

func (e *HeaderMapEncoder) List(k string) ListEncoder

List executes the passed in callback with a list encoder based on the context of this HeaderMapEncoder.

func (*HeaderMapEncoder) Map

Map sets the header element with nested maps appending the passed in k to the prefix if one was set.

func (*HeaderMapEncoder) MapSetFields

func (e *HeaderMapEncoder) MapSetFields(k string, m FieldMarshaler)

MapSetFields Is not implemented, query map of FieldMarshaler is undefined.

func (*HeaderMapEncoder) MapSetValue

func (e *HeaderMapEncoder) MapSetValue(k string, v ValueMarshaler)

MapSetValue adds a single value to the header.

func (*HeaderMapEncoder) Start

func (e *HeaderMapEncoder) Start()

Start does nothing for header encodings.

type HostPrefixBuilder

type HostPrefixBuilder struct {
	Prefix   string
	LabelsFn func() map[string]string
}

HostPrefixBuilder provides the request handler to expand and prepend the host prefix into the operation's request endpoint host.

func (HostPrefixBuilder) Build

func (h HostPrefixBuilder) Build(r *aws.Request)

Build updates the passed in Request with the HostPrefix template expanded.

type Int64Value

type Int64Value int64

Int64Value provies encoding of int64 for AWS protocols.

func (Int64Value) MarshalValue

func (v Int64Value) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (Int64Value) MarshalValueBuf

func (v Int64Value) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type JSONValue

type JSONValue struct {
	V          aws.JSONValue
	EscapeMode EscapeMode
}

JSONValue provies encoding of aws.JSONValues for AWS protocols.

func (JSONValue) MarshalValue

func (v JSONValue) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (JSONValue) MarshalValueBuf

func (v JSONValue) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type ListEncoder

type ListEncoder interface {
	Start()
	End()

	Map() MapEncoder
	List() ListEncoder

	ListAddValue(v ValueMarshaler)
	ListAddFields(m FieldMarshaler)
}

A ListEncoder provides the interface for encoders that will encode List elements.

type MapEncoder

type MapEncoder interface {
	Start()
	End()

	Map(k string) MapEncoder
	List(k string) ListEncoder

	MapSetValue(k string, v ValueMarshaler)
	MapSetFields(k string, m FieldMarshaler)
}

A MapEncoder provides the interface for encoders that will encode map elements.

type MapMarshaler

type MapMarshaler interface {
	MarshalValues(enc MapEncoder) error
}

MapMarshaler is a marshaler for map encoders.

type MarshalListValues

type MarshalListValues interface {
	MarshalValues(enc ListEncoder) error
}

MarshalListValues is a marshaler for list encoders.

type Metadata

type Metadata struct {
	Attributes []Attribute

	Flatten bool

	ListLocationName     string
	MapLocationNameKey   string
	MapLocationNameValue string

	XMLNamespacePrefix string
	XMLNamespaceURI    string
}

Metadata is a collection of configuration flags for encoders to render the output.

type PathReplace

type PathReplace struct {
	// contains filtered or unexported fields
}

PathReplace replaces path elements using field buffers

func NewPathReplace

func NewPathReplace(path string) PathReplace

NewPathReplace creats a built PathReplace value that can be used to replace path elements.

func (*PathReplace) Encode

func (r *PathReplace) Encode() (path string, rawPath string)

Encode returns an unescaped path, and escaped path.

func (*PathReplace) ReplaceElement

func (r *PathReplace) ReplaceElement(key, val string) (err error)

ReplaceElement replaces a single element in the path string.

type QueryListEncoder

type QueryListEncoder struct {
	Key   string
	Query url.Values
	Err   error
}

QueryListEncoder will encode list values nested into a query key.

func (*QueryListEncoder) End

func (e *QueryListEncoder) End()

End does nothing for the query protocol.

func (*QueryListEncoder) List

func (e *QueryListEncoder) List() ListEncoder

List will return a new QueryListEncoder.

func (*QueryListEncoder) ListAddFields

func (e *QueryListEncoder) ListAddFields(m FieldMarshaler)

ListAddFields Is not implemented, query list of FieldMarshaler is undefined.

func (*QueryListEncoder) ListAddValue

func (e *QueryListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the querystring.

func (*QueryListEncoder) Map

func (e *QueryListEncoder) Map() MapEncoder

Map will return a new QueryMapEncoder.

func (*QueryListEncoder) Start

func (e *QueryListEncoder) Start()

Start does nothing for the query protocol.

type QueryMapEncoder

type QueryMapEncoder struct {
	Prefix string
	Query  url.Values
	Err    error
}

QueryMapEncoder builds a query string.

func (*QueryMapEncoder) End

func (e *QueryMapEncoder) End()

End does nothing.

func (*QueryMapEncoder) List

func (e *QueryMapEncoder) List(k string) ListEncoder

List will return a new QueryListEncoder.

func (*QueryMapEncoder) Map

func (e *QueryMapEncoder) Map(k string) MapEncoder

Map will return a new QueryMapEncoder.

func (*QueryMapEncoder) MapSetFields

func (e *QueryMapEncoder) MapSetFields(k string, m FieldMarshaler)

MapSetFields Is not implemented, query map of map is undefined.

func (*QueryMapEncoder) MapSetValue

func (e *QueryMapEncoder) MapSetValue(k string, v ValueMarshaler)

MapSetValue adds a single value to the query.

func (*QueryMapEncoder) Start

func (e *QueryMapEncoder) Start()

Start does nothing.

type QuotedValue

type QuotedValue struct {
	ValueMarshaler
}

QuotedValue represents a type that should be quoted when encoding a string value.

type ReadSeekerStream

type ReadSeekerStream struct {
	V io.ReadSeeker
}

A ReadSeekerStream wrapps an io.ReadSeeker to be used as a StreamMarshaler.

func (ReadSeekerStream) MarshalStream

func (v ReadSeekerStream) MarshalStream() (io.ReadSeeker, error)

MarshalStream returns the wrapped io.ReadSeeker for encoding.

type StreamMarshaler

type StreamMarshaler interface {
	MarshalStream() (io.ReadSeeker, error)
}

A StreamMarshaler interface is used to marshal a stream when encoding.

type StringStream

type StringStream string

A StringStream aliases a string to be used as a StreamMarshaler.

func (StringStream) MarshalStream

func (v StringStream) MarshalStream() (io.ReadSeeker, error)

MarshalStream marshals a string into an io.ReadSeeker for encoding.

type StringValue

type StringValue string

StringValue provides encoding of string for AWS protocols.

func (StringValue) MarshalValue

func (v StringValue) MarshalValue() (string, error)

MarshalValue formats the value into a string for encoding.

func (StringValue) MarshalValueBuf

func (v StringValue) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type Target

type Target int

Target is the encode and decode targets of protocol marshaling.

const (
	PathTarget Target = iota
	QueryTarget
	HeaderTarget
	HeadersTarget
	StatusCodeTarget
	BodyTarget
	PayloadTarget
)

The protocol marshaling targets.

func (Target) String

func (e Target) String() string

type TimeValue

type TimeValue struct {
	V                time.Time
	Format           string
	QuotedFormatTime bool
}

TimeValue provies encoding of time.Time for AWS protocols.

func (TimeValue) MarshalValue

func (v TimeValue) MarshalValue() (string, error)

MarshalValue formats the value into a string given a format for encoding.

func (TimeValue) MarshalValueBuf

func (v TimeValue) MarshalValueBuf(b []byte) ([]byte, error)

MarshalValueBuf formats the value into a byte slice for encoding. If there is enough room in the passed in slice v will be appended to it.

Will reset the length of the passed in slice to 0.

type ValueMarshaler

type ValueMarshaler interface {
	MarshalValue() (string, error)
	MarshalValueBuf([]byte) ([]byte, error)
}

ValueMarshaler provides a generic type for all encoding field values to be passed into a encoder's methods with.

Source Files

encode.go fields.go header_encoder.go host.go host_prefix.go idempotency.go jsonvalue.go metadata.go path_replace.go query_encoder.go target.go timestamp.go unmarshal.go value.go

Directories

PathSynopsis
private/protocol/ec2queryPackage ec2query provides serialization of AWS EC2 requests and responses.
private/protocol/json
private/protocol/json/jsonutilPackage jsonutil provides JSON serialization of AWS requests and responses.
private/protocol/jsonrpcPackage jsonrpc provides JSON RPC utilities for serialization of AWS requests and responses.
private/protocol/queryPackage query provides serialization of AWS query requests, and responses.
private/protocol/query/queryutil
private/protocol/restPackage rest provides RESTful serialization of AWS requests and responses.
private/protocol/restjsonPackage restjson provides RESTful JSON serialization of AWS requests and responses.
private/protocol/restxmlPackage restxml provides RESTful XML serialization of AWS requests and responses.
private/protocol/xml
private/protocol/xml/xmlutilPackage xmlutil provides XML serialization of AWS requests and responses.
Version
v0.24.0
Published
Jul 22, 2020
Platform
js/wasm
Imports
15 packages
Last checked
1 hour ago

Tools for package owners.