api

package
v0.0.0-...-e7db92f Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptData

func DecryptData(data []byte, passphrase string) ([]byte, error)

func EncryptData

func EncryptData(data []byte, passphrase string) ([]byte, error)

func Hmac

func Hmac(secret []byte, data []byte) []byte

Types

type API

type API struct {

	// The bolt database held by this installation
	Db *bolt.DB

	// Server Configuration
	Config *config.Config

	// A map of queue sizes
	QueueSize map[string]int
	// contains filtered or unexported fields
}

API : Assemble server api object

func NewAPI

func NewAPI(dbName string, c *config.Config) (*API, error)

NewAPI : Create a new API instance

func (*API) Buckets

func (api *API) Buckets(c *gin.Context)

Buckets : List all available top level buckets

Returned responses will be one of: - 200 OK : Message will be a list of bucket names - 500 Error : Message will be the error message

func (*API) Containers

func (api *API) Containers(c *gin.Context)

Containers : The API endpoint method for retrieving the sidebar container set

Returned responses will be one of: - 200 OK : Message will be a list of strings

func (*API) CreateBucket

func (api *API) CreateBucket(c *gin.Context)

CreateBucket : Create a new bucket

POST /bucket

The create request must contain: - bucket - the name of the bucket to create or parent bucket name when creating a child - child - [optional] the name of the child bucket to create

Responses are: - 201 Created - 400 Bad request sent when bucket name is empty - 500 Internal server error

func (*API) Decrypt

func (api *API) Decrypt(c *gin.Context)

Decrypt Decrypts a given string and sends back the plaintext value

INTERNAL Execution only

POST /decrypt

Request parameters: - value - the value to decrypt - token - the validation token to ensure decryption is allowed to take place

Response codes: - 200 OK Message will be the decrypted value - 400 Bad request if value is empty, token is invalid or token matches value - 500 internal server error if value cannot be decoded - Message field may offer further clarification

This function requires both a value and a 'token' to be passed in via context.

token is the encrypted version of the passphrase used to encrypt passwords and should only be available to the flow server.

This is to offer an additional level of security at the browser level to prevent attackers from decrypting a user stored password by accessing the decrypt api endpoint to have the server decrypt the password for them.

func (*API) DeleteBucket

func (api *API) DeleteBucket(c *gin.Context)

DeleteBucket : Deletes a given bucket

DELETE /bucket/:bucket[/:child]

The url parameters must contain: - bucket - the name of the bucket to delete or parent bucket name when deleting a child - child - [optional] the name of the child bucket to create

Responses are: - 202 Accepted - 400 Bad request sent when bucket name is empty - 500 Internal server error

func (*API) DeleteKey

func (api *API) DeleteKey(c *gin.Context)

DeleteKey : Delete a key value pair from a bucket

DELETE /bucket/:bucket[/:child]/:key

URL parameters are: - bucket : The name of the bucket containing the key - child : [optional] The name of a child bucket to manage - key : The key to delete

Returned responses are: - 202 Accepted - 400 Bad Request when bucket or key are empty - 500 Internal server error on failure to delete

func (*API) DestroyFlow

func (api *API) DestroyFlow(c *gin.Context)

DestroyFlow : Destroys all infrastructure for a given flow

POST /destroyflow

Request parameters: - pipeline - The name of the pipeline to trigger

Response codes: - See forwardPost method below

func (*API) Encrypt

func (api *API) Encrypt(c *gin.Context)

Encrypt : Encrypt a message and send back the encrypted value as a base64 encoded string

POST /encrypt

Request parameters - value : the value to encrypt

Response codes 200 OK message will contain encrypted value 400 Bad request if value is empty 500 Internal server error if message cannot be encrypted

func (*API) ExecuteFlow

func (api *API) ExecuteFlow(c *gin.Context)

ExecuteFlow : Executes the current pipeline

POST /execute

Request parameters: - pipeline - The name of the pipeline to trigger

Response codes: - See forwardPost method below

Flow execution is handed off to the flow api to build the infrastructure and begin executing the queue.

This should be a straight pass-through and flow should be responsible for verifying if infrastructure has/has not already been built or the pipeline is already in the process of being executed.

func (*API) FlowStatus

func (api *API) FlowStatus(c *gin.Context)

FlowStatus : Get the status of all items in the current pipeline

Request params - pipeline : The pipeline to get status messages for

Response codes: - 200 OK - Statuses will be the message field in the response - 500 if status cannot be retrieved

func (*API) Get

func (api *API) Get(c *gin.Context)

Get : Get the value for a given key

GET /bucket/:bucket[/:child]/:key

Response codes - 200 OK - Message will be the value - 400 Bad Request if bucket or key is empty - 500 Internal server error if value cannot be retrieved

func (*API) KeyCount

func (api *API) KeyCount(c *gin.Context)

KeyCount : Count keys in a bucket

GET /count/:bucket[/:child]

Response codes: - 200 OK - Message will be the number of keys in the bucket - 400 Bad Request - Bucket name is missing - 404 Page not found - Bucket name is invalid - 500 Internal server error on all other errors

func (*API) PerpetualQueue

func (api *API) PerpetualQueue(c *gin.Context)

PerpetualQueue : Updates the given queue with new event items

INTERNAL - Automatically update the queue with new items

GET /perpetualqueue

Request parameters: - pipeline The pipeline to execute - maxitems The max items to update into the queue

Response codes - 202 Accept - 500 Internal server error

func (*API) PopQueue

func (api *API) PopQueue(c *gin.Context)

PopQueue : Take an item off the queue

INTERNAL used for comms between flow and assemble

GET /queue/:pipeline/:key

func (*API) PrefixScan

func (api *API) PrefixScan(c *gin.Context)

PrefixScan : Scan a bucket and retrieve all contents with keys matching prefix

GET /scan/:bucket[/:child][/:key]

Request parameters - bucket [required] The bucket name to scan - child [optional] The child bucket to scan instead - key [optional] If key is not specified, all contents will be returned

Response codes - 200 OK Messsage will be a map of matching key/value pairs - 400 Bad Request if bucket name is empty - 500 Internal server error if the request fails for any reason

func (*API) Put

func (api *API) Put(c *gin.Context)

Put : create a key/value pair in the boltdb

PUT /bucket

Request parameters: - bucket The bucket to write into - child [optional] the child bucket to write into - key The key to add - value The value to save against the key

Response codes - 204 No content if key successfully stored - 400 Bad request if bucket or key is missing - 500 Internal server error if value cannot be stored

func (*API) StartFlow

func (api *API) StartFlow(c *gin.Context)

StartFlow : Starts the queue to flow information out into the pods

POST /startflow

Request parameters: - pipeline - The name of the pipeline to trigger

Response codes: - See forwardPost method below

func (*API) StopFlow

func (api *API) StopFlow(c *gin.Context)

StopFlow : Stops the queue to prevent flow of information

POST /stopflow

Request parameters: - pipeline - The name of the pipeline to trigger

Response codes: - See forwardPost method below

type GithubResponse

type GithubResponse struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

GithubResponse : Expected information from the Github request

type Lock

type Lock struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Lock : Allow for locking individual queues whilst manipulating them

type QueueItem

type QueueItem struct {

	// The pipeline folder this queue is destined for
	PipelineFolder string `json:"pipelineFolder"`

	// Subfolder is a child of pipeline folder and usually
	// representative of the upstream command being actioned
	SubFolder string `json:"subFolder"`

	// The filename of the queue element
	Filename string `json:"filename"`

	// Event data represented in string format
	Event string `json:"event"`

	// The command to execute
	Command pipeline.Command `json:"command"`
}

QueueItem : Type information about an item on the queue

type Result

type Result struct {

	// HTTP response code
	Code int `json:"code"`

	// HTTP Result string - normally one of OK | Error
	Result string `json:"result"`

	// The request message being returned
	Message interface{} `json:"message"`
}

Result : A server result defines the body wrapper sent back to the client

func NewResult

func NewResult() *Result

NewResult : Create a new result item

type ScanResult

type ScanResult struct {

	// Buckets is a list of child buckets the scanned bucket might contain
	Buckets []string `json:"buckets"`

	// For simplicity on the caller side, send the number of child buckets found
	BucketsLength int `json:"bucketlen"`

	// A map of key:value pairs containing bucket data
	Keys map[string]string `json:"keys"`

	// For simplicity, the number of keys in the bucket
	KeyLen int `json:"keylen"`
}

ScanResult : Return values stored in a bucket

Jump to

Keyboard shortcuts

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