api

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package api provides a framework for scraping the AWS API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeConfig

func DecodeConfig(input interface{}, output interface{}) error

func FirstError added in v0.1.7

func FirstError(errors ...error) error

func SendRecords

func SendRecords(ctx context.Context, ch chan<- *Record, name string, s Source) error

Types

type Config

type Config struct {
	Action string                 `json:"action"`
	Config map[string]interface{} `json:"config"`
}

type Endpoint

type Endpoint map[string]RequestBuilder

Endpoint is a collection of RequestBuilders.

func (*Endpoint) Filter

func (e *Endpoint) Filter(pattern string) Endpoint

Filter returns an endpoint with subset of RequestBuilders.

func (*Endpoint) New

func (e *Endpoint) New(action string, config interface{}) ([]Request, error)

New allows Endpoint to act as a RequestBuilder, with wildcard support on action.

func (*Endpoint) Resolve

func (e *Endpoint) Resolve(m *Manifest) ([]Request, error)

Resolve translates a configuration manifest into requests.

type Manifest

type Manifest struct {
	Include   []string  `json:"include"`   // Include is a list of actions
	Exclude   []string  `json:"exclude"`   // Exclude is a list of actions
	Overrides []*Config `json:"overrides"` // Overrides are key value pairs of configuration data.
}

Manifest describes desired actions and any necessary configuration overrides.

type Record

type Record struct {
	Timestamp *int64      `json:"timestamp,omitempty"` // Optional nanosecond timestamp.
	Action    string      `json:"action"`              // Action performed. Naming should match IAM policy.
	ID        *string     `json:"id,omitempty"`        // ID of resource contained in Data. Optional
	Data      interface{} `json:"data"`
}

Record is submitted as an observation.

type Recorder

type Recorder interface {
	ReadFrom(context.Context, <-chan *Record) error
}

type RecorderFunc

type RecorderFunc func(context.Context, <-chan *Record) error

Recorder reads from Record channel, does stuff.

func (RecorderFunc) ReadFrom

func (r RecorderFunc) ReadFrom(ctx context.Context, ch <-chan *Record) error

type Request

type Request func(context.Context, chan<- *Record) error

Request runs synchronously, publishing Records to a channel.

type RequestBuilder

type RequestBuilder interface {
	New(action string, config interface{}) ([]Request, error)
}

RequestBuilder translates a requested action and config into requests. A given action can translate into multiple requests in a variety of cases: - the action is wildcarded (e.g. Describe*) - the action spawns multiple sub-requests (e.g. DescribeLogStream needs to be run for every LogGroup).

type Runner

type Runner struct {
	Requests              []Request
	Recorder              Recorder
	BufferSize            int
	MaxConcurrentRequests int
	MaxRecords            int
	ConcurrentRecorders   int
	RequestTimeout        *time.Duration
	Logger                *logr.Logger
}

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

type Service

type Service interface {
	New(p client.ConfigProvider, opts ...*aws.Config) Endpoint
}

Service (e.g. RDS, IAM, S3) provides the means of creating an Endpoint The client and config options provided end up determining region.

type ServiceFunc

type ServiceFunc func(p client.ConfigProvider, opts ...*aws.Config) Endpoint

ServiceFunc implements Service.

func (ServiceFunc) New

func (s ServiceFunc) New(p client.ConfigProvider, opts ...*aws.Config) Endpoint

type Source

type Source interface {
	Records() []*Record
}

Directories

Path Synopsis
Package apitest provides utilities to test api
Package apitest provides utilities to test api

Jump to

Keyboard shortcuts

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