protocol

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 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

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 provies 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 provies 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 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 provies 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
}

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 givin 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.

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