protocol

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ISO8601TimeFormat = "2006-01-02T15:04:05Z"         // ISO 8601 formated time.
	RFC822TimeFromat  = "Mon, 2 Jan 2006 15:04:05 GMT" // RFC822 formatted time.
	UnixTimeFormat    = "unix time format"             // Special case for Unix time
)

Time formats for protocol time fields.

Variables

View Source
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.

View Source
var UnmarshalDiscardBodyHandler = request.NamedHandler{Name: "awssdk.shared.UnmarshalDiscardBody", Fn: UnmarshalDiscardBody}

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

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 DecodeBool added in v1.11.0

func DecodeBool(vp **bool) func(FieldValue)

DecodeBool converts a FieldValue into a bool pointer, updating the value pointed to by the input.

func DecodeBytes added in v1.11.0

func DecodeBytes(vp *[]byte) func(FieldValue)

DecodeBytes converts a FieldValue into a bytes slice, updating the value pointed to by the input.

func DecodeFloat64 added in v1.11.0

func DecodeFloat64(vp **float64) func(FieldValue)

DecodeFloat64 converts a FieldValue into a float64 pointer, updating the value pointed to by the input.

func DecodeInt64 added in v1.11.0

func DecodeInt64(vp **int64) func(FieldValue)

DecodeInt64 converts a FieldValue into an int64 pointer, updating the value pointed to by the input.

func DecodeReadCloser added in v1.11.0

func DecodeReadCloser(vp *io.ReadCloser) func(FieldValue)

DecodeReadCloser converts a FieldValue into an io.ReadCloser, updating the value pointed to by the input.

func DecodeReadSeeker added in v1.11.0

func DecodeReadSeeker(vp *io.ReadSeeker) func(FieldValue)

DecodeReadSeeker converts a FieldValue into an io.ReadCloser, updating the value pointed to by the input.

func DecodeString added in v1.11.0

func DecodeString(vp **string) func(FieldValue)

DecodeString converts a FieldValue into a string pointer, updating the value pointed to by the input.

func DecodeTime added in v1.11.0

func DecodeTime(vp **time.Time) func(FieldValue)

DecodeTime converts a FieldValue into a time pointer, updating the value pointed to by the input.

func EncodeBoolList added in v1.11.0

func EncodeBoolList(vs []*bool) func(ListEncoder)

EncodeBoolList returns a function that will add the slice's values to a list Encoder.

func EncodeBoolMap added in v1.11.0

func EncodeBoolMap(vs map[string]*bool) func(MapEncoder)

EncodeBoolMap returns a function that will add the map's values to a map Encoder.

func EncodeFloat64List added in v1.11.0

func EncodeFloat64List(vs []*float64) func(ListEncoder)

EncodeFloat64List returns a function that will add the slice's values to a list Encoder.

func EncodeFloat64Map added in v1.11.0

func EncodeFloat64Map(vs map[string]*float64) func(MapEncoder)

EncodeFloat64Map returns a function that will add the map's values to a map Encoder.

func EncodeInt64List added in v1.11.0

func EncodeInt64List(vs []*int64) func(ListEncoder)

EncodeInt64List returns a function that will add the slice's values to a list Encoder.

func EncodeInt64Map added in v1.11.0

func EncodeInt64Map(vs map[string]*int64) func(MapEncoder)

EncodeInt64Map returns a function that will add the map's values to a map Encoder.

func EncodeStringList added in v1.11.0

func EncodeStringList(vs []*string) func(ListEncoder)

EncodeStringList returns a function that will add the slice's values to a list Encoder.

func EncodeStringMap added in v1.11.0

func EncodeStringMap(vs map[string]*string) func(MapEncoder)

EncodeStringMap returns a function that will add the map's values to a map Encoder.

func EncodeTimeList added in v1.11.0

func EncodeTimeList(vs []*time.Time) func(ListEncoder)

EncodeTimeList returns a function that will add the slice's values to a list Encoder.

func EncodeTimeMap added in v1.11.0

func EncodeTimeMap(vs map[string]*time.Time) func(MapEncoder)

EncodeTimeMap returns a function that will add the map's values to a map Encoder.

func GetIdempotencyToken

func GetIdempotencyToken() string

GetIdempotencyToken returns a randomly generated idempotency token.

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 *request.Request)

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

Types

type Attribute added in v1.11.0

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 added in v1.11.0

type BoolValue bool

BoolValue provies encoding of bool for AWS protocols.

func (BoolValue) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (BoolValue) MarshalValueBuf added in v1.11.0

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 added in v1.11.0

type BytesStream []byte

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

func (BytesStream) MarshalStream added in v1.11.0

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

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

type BytesValue added in v1.11.0

type BytesValue string

BytesValue provies encoding of string for AWS protocols.

func (BytesValue) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (BytesValue) MarshalValueBuf added in v1.11.0

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.

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

type FieldBuffer added in v1.11.0

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 added in v1.11.0

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 FieldDecoder added in v1.11.0

type FieldDecoder interface {
	Get(t Target, k string, fn func(v FieldValue), meta Metadata)
	GetList(t Target, k string, fn func(n int, ld ListDecoder), meta Metadata)
	GetMap(t Target, k string, fn func(ks []string, md MapDecoder), meta Metadata)
	GetFields(t Target, k string, fn func() FieldUnmarshaler, meta Metadata)
}

FieldDecoder provides the interface for unmarshaling values from a type. The value is retrieved from the location referenced to by the Target. The field name that the value is retrieved from is k.

type FieldEncoder added in v1.11.0

type FieldEncoder interface {
	SetValue(t Target, k string, v ValueMarshaler, meta Metadata)
	SetStream(t Target, k string, v StreamMarshaler, meta Metadata)
	SetList(t Target, k string, fn func(ListEncoder), meta Metadata)
	SetMap(t Target, k string, fn func(MapEncoder), meta Metadata)
	SetFields(t Target, k string, m FieldMarshaler, meta Metadata)
}

A FieldEncoder provides the interface for encoding struct field members.

type FieldMarshaler added in v1.11.0

type FieldMarshaler interface {
	MarshalFields(FieldEncoder) error
}

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

type FieldUnmarshaler added in v1.11.0

type FieldUnmarshaler interface {
	UnmarshalFields(FieldDecoder) error
}

FieldUnmarshaler used by protocol unmarshaling to unmarshal a type's nested fields.

type FieldValue added in v1.11.0

type FieldValue interface{}

A FieldValue is a value that will be unmarshalered from the decoder to a concrete value.

type Float64Value added in v1.11.0

type Float64Value float64

Float64Value provies encoding of float64 for AWS protocols.

func (Float64Value) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (Float64Value) MarshalValueBuf added in v1.11.0

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 added in v1.11.0

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

HeaderListEncoder will encode list values nested into a header key.

func (*HeaderListEncoder) ListAddFields added in v1.11.0

func (e *HeaderListEncoder) ListAddFields(m FieldMarshaler)

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

func (*HeaderListEncoder) ListAddList added in v1.11.0

func (e *HeaderListEncoder) ListAddList(fn func(ListEncoder))

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

func (*HeaderListEncoder) ListAddMap added in v1.11.0

func (e *HeaderListEncoder) ListAddMap(fn func(MapEncoder))

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

func (*HeaderListEncoder) ListAddValue added in v1.11.0

func (e *HeaderListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the header.

type HeaderMapEncoder added in v1.11.0

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

HeaderMapEncoder builds a map valu

func (*HeaderMapEncoder) MapSetFields added in v1.11.0

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

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

func (*HeaderMapEncoder) MapSetList added in v1.11.0

func (e *HeaderMapEncoder) MapSetList(k string, fn func(le ListEncoder))

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

func (*HeaderMapEncoder) MapSetMap added in v1.11.0

func (e *HeaderMapEncoder) MapSetMap(k string, fn func(me MapEncoder))

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

func (*HeaderMapEncoder) MapSetValue added in v1.11.0

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

MapSetValue adds a single value to the header.

type Int64Value added in v1.11.0

type Int64Value int64

Int64Value provies encoding of int64 for AWS protocols.

func (Int64Value) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (Int64Value) MarshalValueBuf added in v1.11.0

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 added in v1.11.0

type JSONValue struct {
	V      aws.JSONValue
	Base64 bool
}

JSONValue provies encoding of aws.JSONValues for AWS protocols.

func (JSONValue) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (JSONValue) MarshalValueBuf added in v1.11.0

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 ListDecoder added in v1.11.0

type ListDecoder interface {
	ListGet(fn func(v FieldValue))
	ListGetList(fn func(n int, ld ListDecoder))
	ListGetMap(fn func(ks []string, md MapDecoder))
	ListGetFields(m FieldUnmarshaler)
}

ListDecoder provides the interface for unmarshaling list elements from the underlying decoder.

type ListEncoder added in v1.11.0

type ListEncoder interface {
	ListAddValue(v ValueMarshaler)
	ListAddList(fn func(ListEncoder))
	ListAddMap(fn func(MapEncoder))
	ListAddFields(m FieldMarshaler)
}

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

type MapDecoder added in v1.11.0

type MapDecoder interface {
	MapGet(k string, fn func(v FieldValue))
	MapGetList(k string, fn func(n int, ld ListDecoder))
	MapGetMap(k string, fn func(ks []string, fd FieldDecoder))
	MapGetFields(k string, fn func() FieldUnmarshaler)
}

MapDecoder provides the interface for unmarshaling map elements from the underlying decoder. The map key the value is retrieved from is k.

type MapEncoder added in v1.11.0

type MapEncoder interface {
	MapSetValue(k string, v ValueMarshaler)
	MapSetList(k string, fn func(ListEncoder))
	MapSetMap(k string, fn func(MapEncoder))
	MapSetFields(k string, m FieldMarshaler)
}

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

type Metadata added in v1.11.0

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 added in v1.11.0

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

PathReplace replaces path elements using field buffers

func NewPathReplace added in v1.11.0

func NewPathReplace(path string) PathReplace

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

func (*PathReplace) Encode added in v1.11.0

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

Encode returns an unescaped path, and escaped path.

func (*PathReplace) ReplaceElement added in v1.11.0

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

ReplaceElement replaces a single element in the path string.

type QueryListEncoder added in v1.11.0

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

QueryListEncoder will encode list values nested into a query key.

func (*QueryListEncoder) ListAddFields added in v1.11.0

func (e *QueryListEncoder) ListAddFields(m FieldMarshaler)

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

func (*QueryListEncoder) ListAddList added in v1.11.0

func (e *QueryListEncoder) ListAddList(fn func(le ListEncoder))

ListAddList Is not implemented, query list of list is undefined.

func (*QueryListEncoder) ListAddMap added in v1.11.0

func (e *QueryListEncoder) ListAddMap(fn func(fe MapEncoder))

ListAddMap Is not implemented, query list of map is undefined.

func (*QueryListEncoder) ListAddValue added in v1.11.0

func (e *QueryListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the querystring.

type QueryMapEncoder added in v1.11.0

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

QueryMapEncoder builds a query string.

func (*QueryMapEncoder) MapSetFields added in v1.11.0

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

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

func (*QueryMapEncoder) MapSetList added in v1.11.0

func (e *QueryMapEncoder) MapSetList(k string, fn func(le ListEncoder))

MapSetList executes the passed in callback with a list encoder based on the context of this QueryMapEncoder.

func (*QueryMapEncoder) MapSetMap added in v1.11.0

func (e *QueryMapEncoder) MapSetMap(k string, fn func(me MapEncoder))

MapSetMap sets the query string element with nested maps appending the passed in k to the prefix if one was set.

func (*QueryMapEncoder) MapSetValue added in v1.11.0

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

MapSetValue adds a single value to the query.

type ReadSeekerStream added in v1.11.0

type ReadSeekerStream struct {
	V io.ReadSeeker
}

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

func (ReadSeekerStream) MarshalStream added in v1.11.0

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

MarshalStream returns the wrapped io.ReadSeeker for encoding.

type StreamMarshaler added in v1.11.0

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

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

type StringStream added in v1.11.0

type StringStream string

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

func (StringStream) MarshalStream added in v1.11.0

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

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

type StringValue added in v1.11.0

type StringValue string

StringValue provies encoding of string for AWS protocols.

func (StringValue) MarshalValue added in v1.11.0

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

MarshalValue formats the value into a string for encoding.

func (StringValue) MarshalValueBuf added in v1.11.0

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 added in v1.11.0

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 added in v1.11.0

func (e Target) String() string

type TimeValue added in v1.11.0

type TimeValue struct {
	V      time.Time
	Format string
}

TimeValue provies encoding of time.Time for AWS protocols.

func (TimeValue) MarshalValue added in v1.11.0

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

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

func (TimeValue) MarshalValueBuf added in v1.11.0

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 added in v1.11.0

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.

Directories

Path Synopsis
Package ec2query provides serialization of AWS EC2 requests and responses.
Package ec2query provides serialization of AWS EC2 requests and responses.
jsonutil
Package jsonutil provides JSON serialization of AWS requests and responses.
Package jsonutil provides JSON serialization of AWS requests and responses.
Package jsonrpc provides JSON RPC utilities for serialization of AWS requests and responses.
Package jsonrpc provides JSON RPC utilities for serialization of AWS requests and responses.
Package query provides serialization of AWS query requests, and responses.
Package query provides serialization of AWS query requests, and responses.
Package rest provides RESTful serialization of AWS requests and responses.
Package rest provides RESTful serialization of AWS requests and responses.
Package restjson provides RESTful JSON serialization of AWS requests and responses.
Package restjson provides RESTful JSON serialization of AWS requests and responses.
Package restxml provides RESTful XML serialization of AWS requests and responses.
Package restxml provides RESTful XML serialization of AWS requests and responses.
xml
xmlutil
Package xmlutil provides XML serialization of AWS requests and responses.
Package xmlutil provides XML serialization of AWS requests and responses.

Jump to

Keyboard shortcuts

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