apiserver

package
v0.0.0-...-d78993e Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func GetAWSSession

func GetAWSSession(region string) (*session.Session, error)

GetAWSSession returns a new AWS credentials session

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

Types

type ApiResponse

type ApiResponse struct {
	Code int32 `json:"code,omitempty"`

	Type string `json:"type,omitempty"`

	Message string `json:"message,omitempty"`
}

type Application

type Application struct {
	ApplicationName string `json:"ApplicationName"`
}

type CloudFormationClient

type CloudFormationClient struct {
	Client *cloudformation.CloudFormation
}

CloudFormationClient the client for the CloudFormation service.

func NewCloudFormationClient

func NewCloudFormationClient(sess *session.Session) (*CloudFormationClient, error)

NewCloudFormationClient gets a CloudFormation client.

func (*CloudFormationClient) GetStack

func (cc *CloudFormationClient) GetStack(stackID string) (*Stack, error)

GetStack returns an Stack struct from a CloudFormation stack name or stack ID. Using stackID is preferrable since it also works with deleted stacks for up to 90 days.

type DynamoClient

type DynamoClient struct {
	Client       *dynamodb.DynamoDB
	Table        string
	PartitionKey string
	SortKey      string
}

DynamoClient the client for a DynamoDB table.

func NewDynamoClient

func NewDynamoClient(sess *session.Session) (*DynamoClient, error)

NewDynamoClient gets a DynamoDB client.

func (*DynamoClient) GetAllStacks

func (dc *DynamoClient) GetAllStacks() ([]*Stack, error)

GetAllStacks scans the table.

func (*DynamoClient) GetStacksByKeys

func (dc *DynamoClient) GetStacksByKeys(partKey string, sortKey string) ([]*Stack, error)

GetStacksByKeys will get all stacks by partition and sort key.

func (*DynamoClient) GetStacksByPartitionKey

func (dc *DynamoClient) GetStacksByPartitionKey(partKey string) ([]*Stack, error)

GetStacksByPartitionKey will get all stacks by partition key.

func (*DynamoClient) PutStack

func (dc *DynamoClient) PutStack(stack Stack) error

PutStack puts a CloudFormation stack to DynamoDB

type EC2Client

type EC2Client struct {
	Client *ec2.EC2
}

EC2Client the client for the EC2 service.

func NewEC2Client

func NewEC2Client(sess *session.Session) (*EC2Client, error)

NewEC2Client gets an EC2 client.

type Instance

type Instance struct {
	ImageId string `json:"ImageId,omitempty"`

	LaunchTime string `json:"LaunchTime,omitempty"`

	InstanceTags []InstanceTag `json:"InstanceTags,omitempty"`

	Application Application `json:"Application,omitempty"`
}

type InstanceTag

type InstanceTag struct {
	TagKey string `json:"tag_key"`

	TagValue string `json:"tag_value"`
}

type QueryResults

type QueryResults struct {
	Stacks []*Stack
	// contains filtered or unexported fields
}

QueryResults results of a DynamoDB query.

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewStacksApiController

func NewStacksApiController(s StacksApiServicer) Router

NewStacksApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type S3Client

type S3Client struct {
	Client *s3.S3
}

S3Client the client for the S3 service.

func NewS3Client

func NewS3Client(sess *session.Session) (*S3Client, error)

NewS3Client gets an S3 client.

type SQSClient

type SQSClient struct {
	Client *sqs.SQS
}

SQSClient the client for the SQS service.

func NewSQSClient

func NewSQSClient(sess *session.Session) (*SQSClient, error)

NewSQSClient gets an SQS client.

func (*SQSClient) DeleteMessage

func (sc *SQSClient) DeleteMessage(receiptHandle string) (output *sqs.DeleteMessageOutput)

DeleteMessage deletes a message from SQS and panics on any errors.

func (*SQSClient) SendMessage

func (sc *SQSClient) SendMessage(input *sqs.SendMessageInput) (output *sqs.SendMessageOutput)

SendMessage sends a message to SQS and panics on any errors.

type SSMClient

type SSMClient struct {
	Client *ssm.SSM
}

SSMClient the client for the SSM service.

func NewSSMClient

func NewSSMClient(sess *session.Session) (*SSMClient, error)

NewSSMClient gets an SSM client.

type Stack

type Stack struct {
	PK string `json:"PK,omitempty"`

	SK string `json:"SK,omitempty"`

	StackName string `json:"StackName,omitempty"`

	StackId string `json:"StackId,omitempty"`

	StackStatus string `json:"StackStatus,omitempty"`

	CreationTime time.Time `json:"CreationTime,omitempty"`

	LastUpdateTime time.Time `json:"LastUpdateTime,omitempty"`

	StackParameters []StackParameter `json:"StackParameters,omitempty"`

	StackResources []StackResource `json:"StackResources,omitempty"`

	StackOutputs []StackOutput `json:"StackOutputs,omitempty"`
}

type StackOutput

type StackOutput struct {
	ExportName string `json:"ExportName,omitempty"`

	OutputKey string `json:"OutputKey"`

	OutputValue string `json:"OutputValue"`
}

type StackParameter

type StackParameter struct {
	ParamKey string `json:"ParamKey"`

	ParamValue string `json:"ParamValue,omitempty"`
}

type StackResource

type StackResource struct {
	LastUpdatedTimestamp time.Time `json:"LastUpdatedTimestamp"`

	LogicalResourceId string `json:"LogicalResourceId"`

	PhysicalResourceId string `json:"PhysicalResourceId"`

	ResourceStatus string `json:"ResourceStatus"`

	ResourceType string `json:"ResourceType"`
}

type StacksApiController

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

A StacksApiController binds http requests to an api service and writes the service results to the http response

func (*StacksApiController) GetStacks

func (c *StacksApiController) GetStacks(w http.ResponseWriter, r *http.Request)

GetStacks - Gets a list of more CloudFormation stacks.

func (*StacksApiController) PutStack

func (c *StacksApiController) PutStack(w http.ResponseWriter, r *http.Request)

PutStack - Puts a CloudFormation stack to DynamoDB.

func (*StacksApiController) Routes

func (c *StacksApiController) Routes() Routes

Routes returns all of the api route for the StacksApiController

type StacksApiRouter

type StacksApiRouter interface {
	GetStacks(http.ResponseWriter, *http.Request)
	PutStack(http.ResponseWriter, *http.Request)
}

StacksApiRouter defines the required methods for binding the api requests to a responses for the StacksApi The StacksApiRouter implementation should parse necessary information from the http request, pass the data to a StacksApiServicer to perform the required actions, then write the service results to the http response.

type StacksApiService

type StacksApiService struct {
	DynamoClient *DynamoClient
}

StacksApiService is a service that implents the logic for the StacksApiServicer This service should implement the business logic for every endpoint for the StacksApi API. Include any external packages or services that will be required by this service.

func (*StacksApiService) GetStacks

func (s *StacksApiService) GetStacks(stackId string) (interface{}, error)

GetStacks - Gets one or more CloudFormation stacks.

func (*StacksApiService) PutStack

func (s *StacksApiService) PutStack(stack Stack) (interface{}, error)

PutStack will save an stack to DynamoDB.

type StacksApiServicer

type StacksApiServicer interface {
	GetStacks(string) (interface{}, error)
	PutStack(Stack) (interface{}, error)
}

StacksApiServicer defines the api actions for the StacksApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewStacksApiService

func NewStacksApiService(dynamoClient *DynamoClient) (StacksApiServicer, error)

NewStacksApiService creates a default api service

Jump to

Keyboard shortcuts

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