protocol

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 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 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 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 IsNotSetError

func IsNotSetError(err error) bool

IsNotSetError will return true if the error is of ErrValueNotSet

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 v0.3.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 v0.3.0

type BoolValue bool

BoolValue provies encoding of bool for AWS protocols.

func (BoolValue) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (BoolValue) MarshalValueBuf added in v0.3.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 v0.3.0

type BytesStream []byte

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

func (BytesStream) MarshalStream added in v0.3.0

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

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

type BytesValue added in v0.3.0

type BytesValue string

BytesValue provies encoding of string for AWS protocols.

func (BytesValue) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (BytesValue) MarshalValueBuf added in v0.3.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.

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 added in v0.3.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 v0.3.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 FieldEncoder added in v0.3.0

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 added in v0.3.0

type FieldMarshaler interface {
	MarshalFields(FieldEncoder) error
}

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

type FieldMarshalerFunc added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

type Float64Value float64

Float64Value provies encoding of float64 for AWS protocols.

func (Float64Value) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (Float64Value) MarshalValueBuf added in v0.3.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 v0.3.0

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

HeaderListEncoder will encode list values nested into a header key.

func (*HeaderListEncoder) End added in v0.3.0

func (e *HeaderListEncoder) End()

End does nothing for header list encodings.

func (*HeaderListEncoder) List added in v0.3.0

func (e *HeaderListEncoder) List() ListEncoder

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

func (*HeaderListEncoder) ListAddFields added in v0.3.0

func (e *HeaderListEncoder) ListAddFields(m FieldMarshaler)

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

func (*HeaderListEncoder) ListAddValue added in v0.3.0

func (e *HeaderListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the header.

func (*HeaderListEncoder) Map added in v0.3.0

func (e *HeaderListEncoder) Map() MapEncoder

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

func (*HeaderListEncoder) Start added in v0.3.0

func (e *HeaderListEncoder) Start()

Start does nothing for header list encodings.

type HeaderMapEncoder added in v0.3.0

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

HeaderMapEncoder builds a map valu

func (*HeaderMapEncoder) End added in v0.3.0

func (e *HeaderMapEncoder) End()

End does nothing for header encodings.

func (*HeaderMapEncoder) List added in v0.3.0

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 added in v0.3.0

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

func (*HeaderMapEncoder) MapSetFields added in v0.3.0

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

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

func (*HeaderMapEncoder) MapSetValue added in v0.3.0

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

MapSetValue adds a single value to the header.

func (*HeaderMapEncoder) Start added in v0.3.0

func (e *HeaderMapEncoder) Start()

Start does nothing for header encodings.

type Int64Value added in v0.3.0

type Int64Value int64

Int64Value provies encoding of int64 for AWS protocols.

func (Int64Value) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (Int64Value) MarshalValueBuf added in v0.3.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 v0.3.0

type JSONValue struct {
	V          aws.JSONValue
	EscapeMode EscapeMode
}

JSONValue provies encoding of aws.JSONValues for AWS protocols.

func (JSONValue) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (JSONValue) MarshalValueBuf added in v0.3.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 ListEncoder added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

type MapMarshaler interface {
	MarshalValues(enc MapEncoder) error
}

MapMarshaler is a marshaler for map encoders.

type MarshalListValues added in v0.3.0

type MarshalListValues interface {
	MarshalValues(enc ListEncoder) error
}

MarshalListValues is a marshaler for list encoders.

type Metadata added in v0.3.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 v0.3.0

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

PathReplace replaces path elements using field buffers

func NewPathReplace added in v0.3.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 v0.3.0

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

Encode returns an unescaped path, and escaped path.

func (*PathReplace) ReplaceElement added in v0.3.0

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

ReplaceElement replaces a single element in the path string.

type QueryListEncoder added in v0.3.0

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

QueryListEncoder will encode list values nested into a query key.

func (*QueryListEncoder) End added in v0.3.0

func (e *QueryListEncoder) End()

End does nothing for the query protocol.

func (*QueryListEncoder) List added in v0.3.0

func (e *QueryListEncoder) List() ListEncoder

List will return a new QueryListEncoder.

func (*QueryListEncoder) ListAddFields added in v0.3.0

func (e *QueryListEncoder) ListAddFields(m FieldMarshaler)

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

func (*QueryListEncoder) ListAddValue added in v0.3.0

func (e *QueryListEncoder) ListAddValue(v ValueMarshaler)

ListAddValue encodes an individual list value into the querystring.

func (*QueryListEncoder) Map added in v0.3.0

func (e *QueryListEncoder) Map() MapEncoder

Map will return a new QueryMapEncoder.

func (*QueryListEncoder) Start added in v0.3.0

func (e *QueryListEncoder) Start()

Start does nothing for the query protocol.

type QueryMapEncoder added in v0.3.0

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

QueryMapEncoder builds a query string.

func (*QueryMapEncoder) End added in v0.3.0

func (e *QueryMapEncoder) End()

End does nothing.

func (*QueryMapEncoder) List added in v0.3.0

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

List will return a new QueryListEncoder.

func (*QueryMapEncoder) Map added in v0.3.0

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

Map will return a new QueryMapEncoder.

func (*QueryMapEncoder) MapSetFields added in v0.3.0

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

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

func (*QueryMapEncoder) MapSetValue added in v0.3.0

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

MapSetValue adds a single value to the query.

func (*QueryMapEncoder) Start added in v0.3.0

func (e *QueryMapEncoder) Start()

Start does nothing.

type QuotedValue added in v0.3.0

type QuotedValue struct {
	ValueMarshaler
}

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

type ReadSeekerStream added in v0.3.0

type ReadSeekerStream struct {
	V io.ReadSeeker
}

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

func (ReadSeekerStream) MarshalStream added in v0.3.0

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

MarshalStream returns the wrapped io.ReadSeeker for encoding.

type StreamMarshaler added in v0.3.0

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

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

type StringStream added in v0.3.0

type StringStream string

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

func (StringStream) MarshalStream added in v0.3.0

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

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

type StringValue added in v0.3.0

type StringValue string

StringValue provies encoding of string for AWS protocols.

func (StringValue) MarshalValue added in v0.3.0

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

MarshalValue formats the value into a string for encoding.

func (StringValue) MarshalValueBuf added in v0.3.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 v0.3.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 v0.3.0

func (e Target) String() string

type TimeValue added in v0.3.0

type TimeValue struct {
	V      time.Time
	Format string
}

TimeValue provies encoding of time.Time for AWS protocols.

func (TimeValue) MarshalValue added in v0.3.0

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

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

func (TimeValue) MarshalValueBuf added in v0.3.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 v0.3.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