awsquery

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package awsquery provides parsers and encoders for the AWS query-protocol wire format used by EC2, Auto-Scaling, STS, and several other services.

The query protocol is a POST (or GET) with form-encoded parameters where lists are flattened with dotted indices:

Action=RunInstances&ImageId=ami-123&InstanceType=t2.micro
  &SecurityGroupId.1=sg-a&SecurityGroupId.2=sg-b
  &TagSpecification.1.ResourceType=instance
  &TagSpecification.1.Tag.1.Key=Name
  &TagSpecification.1.Tag.1.Value=my-box
  &Filter.1.Name=instance-state-name&Filter.1.Value.1=running

Responses are XML envelopes carrying a RequestId and a service-specific payload under a top-level <ActionResponse> element.

Index

Constants

View Source
const Namespace = "http://ec2.amazonaws.com/doc/2016-11-15/"

Namespace is the XML namespace for AWS EC2 responses.

View Source
const RequestID = "00000000-0000-0000-0000-000000000000"

RequestID is the stub request id embedded in every response. Real AWS uses UUIDs; any well-formed value satisfies SDK clients.

Variables

This section is empty.

Functions

func CollectIndices

func CollectIndices(form url.Values, prefix string) []int

CollectIndices returns the unique ascending N values for which any form key starts with "<prefix>.N" or "<prefix>.N.*". Exposed so sibling packages parsing deeply-nested AWS wire structures can reuse the same logic.

func FlatTags

func FlatTags(form url.Values, prefix string) map[string]string

FlatTags parses the simpler Tag.N.Key / Tag.N.Value form used by APIs such as CreateTags on an existing resource. The prefix is typically "Tag".

func ListStrings

func ListStrings(form url.Values, prefix string) []string

ListStrings collects values of a flattened string list from form parameters. For prefix "SecurityGroupId" it returns values for keys "SecurityGroupId.1", "SecurityGroupId.2", ... in index order.

func WriteXMLError

func WriteXMLError(w http.ResponseWriter, status int, code, message string)

WriteXMLError writes an AWS-style XML error response.

func WriteXMLResponse

func WriteXMLResponse(w http.ResponseWriter, v any)

WriteXMLResponse marshals a pre-built response envelope to the client. The caller's struct is expected to carry an XMLName of "<Action>Response" and an xmlns attr (see examples in server/aws/ec2). This function only handles the HTTP preamble so every op has a uniform response path.

Types

type Error

type Error struct {
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

Error is one error entry.

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name `xml:"Response"`
	RequestID string   `xml:"RequestID"`
	Errors    []Error  `xml:"Errors>Error"`
}

ErrorResponse is the AWS-style XML error body.

type Filter

type Filter struct {
	Name   string
	Values []string
}

Filter is one entry parsed from a Filter.N parameter group.

func Filters

func Filters(form url.Values) []Filter

Filters parses Filter.N.Name / Filter.N.Value.M groups into []Filter.

type TagSpec

type TagSpec struct {
	ResourceType string
	Tags         map[string]string
}

TagSpec is one entry parsed from a TagSpecification.N parameter group.

func TagSpecs

func TagSpecs(form url.Values) []TagSpec

TagSpecs parses TagSpecification.N.ResourceType plus TagSpecification.N.Tag.M.Key / TagSpecification.N.Tag.M.Value groups.

Jump to

Keyboard shortcuts

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