rest

package
v1.19.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

BindPlane Rest API

Swagger

The Rest API endpoints are documented with gin-swagger.


Generating Documentation:

First make sure you have swag cli installed with make install-tools or install directly with:

go get -u github.com/swaggo/swag/cmd/swag

Generate docs.

make swagger

Viewing Documentation:

Run bindplane server

bindplane serve

By default docs will be at localhost:3001/swagger/index.html

Documentation

Overview

Package rest provides a HTTP API for interacting with BindPlane

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigurationNotSet = errors.New("configuration must be set for kubernetes installation")

ErrConfigurationNotSet is returned when a platform requires an initial configuration but one is not set

View Source
var ErrResourceNotFound = errors.New("resource not found")

ErrResourceNotFound is returned along with 404 responses.

Functions

func AddRestRoutes

func AddRestRoutes(router gin.IRouter, bindplane exposedserver.BindPlane)

AddRestRoutes adds all API routes to the gin HTTP router

func AgentVersion

func AgentVersion(c *gin.Context, bindplane exposedserver.BindPlane)

AgentVersion returns an agent version by name @Summary Get agent version by name @Produce json @Router /agent-versions/{name} [get] @Param name path string true "the name of the agent version" @Success 200 {object} model.AgentVersionResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func AgentVersions

func AgentVersions(c *gin.Context, bindplane exposedserver.BindPlane)

AgentVersions returns a list of agent versions @Summary List agent versions @Produce json @Router /agent-versions [get] @Success 200 {object} model.AgentVersionsResponse @Failure 500 {object} ErrorResponse

func Agents

func Agents(c *gin.Context, bindplane exposedserver.BindPlane)

Agents returns a list of agents @Summary List Agents @Produce json @Router /Agents [get] @Success 200 {object} model.AgentsResponse @Failure 500 {object} ErrorResponse

func ApplyResources

func ApplyResources(c *gin.Context, bindplane exposedserver.BindPlane)

ApplyResources creates, edits, and configures multiple resources @Summary Create, edit, and configure multiple resources. @Description The /apply route will try to parse resources @Description and upsert them into the store. Additionally @Description it will send reconfigure tasks to affected agents. @Produce json @Router /apply [post] @Param resources body []model.AnyResource true "Resources" @Success 200 {object} model.ApplyResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func BindplaneVersion

func BindplaneVersion(c *gin.Context)

BindplaneVersion returns the current bindplane version of the server. @Summary Server version @Description Returns the current bindplane version of the server. @Produce json @Router /version [get] @Success 200 {string} version.Version

func Configuration

func Configuration(c *gin.Context, bindplane exposedserver.BindPlane)

Configuration returns a configuration by name @Summary Get Configuration by name @Produce json @Router /configurations/{name} [get] @Param name path string true "the name of the Configuration" @Success 200 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func Configurations

func Configurations(c *gin.Context, bindplane exposedserver.BindPlane)

Configurations returns a list of configurations @Summary List Configurations @Produce json @Router /Configurations [get] @Success 200 {object} model.ConfigurationsResponse @Failure 500 {object} ErrorResponse

func CopyConfig

func CopyConfig(c *gin.Context, bindplane exposedserver.BindPlane)

CopyConfig duplicates an existing configuration @Summary Duplicate an existing configuration @Produce json @Router /configurations/{name}/copy [post] @Param name path string true "the name of the configuration to duplicate" @Param name body string true "the desired name of the duplicate configuration" @Success 201 "Successful Copy, created" @Failure 404 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 409 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteAgentVersion

func DeleteAgentVersion(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteAgentVersion deletes an agent version by name @Summary Delete agent version by name @Produce json @Router /agent-versions/{name} [delete] @Param name path string true "the name of the agent version to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteAgents

func DeleteAgents(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteAgents deletes agents by id @Summary delete agents by ids @Produce json @Router /agents [delete] @Param id body []string true "list of agent ids to delete" @Success 200 {object} model.DeleteAgentsResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteConfiguration

func DeleteConfiguration(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteConfiguration deletes a configuration by name @Summary Delete configuration by name @Produce json @Router /configurations/{name} [delete] @Param name path string true "the name of the configuration to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteDestination

func DeleteDestination(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteDestination deletes a destination by name @Summary Delete destination by name @Produce json @Router /destinations/{name} [delete] @Param name path string true "the name of the destination to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteDestinationType

func DeleteDestinationType(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteDestinationType deletes a destination type by name @Summary Delete destination type by name @Produce json @Router /destination-types/{name} [delete] @Param name path string true "the name of the destination type to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteProcessor

func DeleteProcessor(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteProcessor deletes a processor by name @Summary Delete processor by name @Produce json @Router /processors/{name} [delete] @Param name path string true "the name of the processor to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteProcessorType

func DeleteProcessorType(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteProcessorType deletes a processor type by name @Summary Delete processor type by name @Produce json @Router /processor-types/{name} [delete] @Param name path string true "the name of the processor type to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteResources

func DeleteResources(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteResources deletes multiple resources @Summary Delete multiple resources @Description /delete endpoint will try to parse resources @Description and delete them from the store. Additionally @Description it will send reconfigure tasks to affected agents. @Produce json @Router /delete [post] @Param resources body []model.AnyResource true "Resources" @Success 200 {object} model.DeleteResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteSource

func DeleteSource(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteSource deletes a source by name @Summary Delete source by name @Produce json @Router /sources/{name} [delete] @Param name path string true "the name of the source to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DeleteSourceType

func DeleteSourceType(c *gin.Context, bindplane exposedserver.BindPlane)

DeleteSourceType deletes a source type by name @Summary Delete source type by name @Produce json @Router /source-types/{name} [delete] @Param name path string true "the name of the source type to delete" @Success 204 "Successful Delete, no content" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func Destination

func Destination(c *gin.Context, bindplane exposedserver.BindPlane)

Destination returns a destination by name @Summary Get Destination by name @Produce json @Router /destinations/{name} [get] @Param name path string true "the name of the Destination" @Success 200 {object} model.DestinationResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DestinationType

func DestinationType(c *gin.Context, bindplane exposedserver.BindPlane)

DestinationType returns a destination type by name @Summary Get destination type by name @Produce json @Router /destination-types/{name} [get] @Param name path string true "the name of the destination type" @Success 200 {object} model.DestinationTypeResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func DestinationTypes

func DestinationTypes(c *gin.Context, bindplane exposedserver.BindPlane)

DestinationTypes returns a list of destination types @Summary List destination types @Produce json @Router /destination-types [get] @Success 200 {object} model.DestinationTypesResponse @Failure 500 {object} ErrorResponse

func Destinations

func Destinations(c *gin.Context, bindplane exposedserver.BindPlane)

Destinations returns a list of destinations @Summary List Destinations @Produce json @Router /Destinations [get] @Success 200 {object} model.DestinationsResponse @Failure 500 {object} ErrorResponse

func GetAgent

func GetAgent(c *gin.Context, bindplane exposedserver.BindPlane)

GetAgent returns an agent by id @Summary Get agent by id @Produce json @Router /agents/{id} [get] @Param id path string true "the id of the agent" @Success 200 {object} model.AgentResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func GetAgentConfiguration

func GetAgentConfiguration(c *gin.Context, bindplane exposedserver.BindPlane)

GetAgentConfiguration returns an agent's configuration by agent id @Summary Get configuration for a given agent @Produce json @Router /agents/{id}/configuration [get] @Param id path string true "the id of the agent" @Success 200 {object} model.ConfigurationResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func GetAgentLabels

func GetAgentLabels(c *gin.Context, bindplane exposedserver.BindPlane)

GetAgentLabels returns an agent's labels by id @Summary Get agent labels by agent id @Produce json @Router /agents/{id}/labels [get] @Param id path string true "the id of the agent" @Success 200 {object} model.AgentLabelsResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func HandleErrorResponse

func HandleErrorResponse(c *gin.Context, statusCode int, err error)

HandleErrorResponse writes an error response and status code to the gin context

func History

func History(c *gin.Context, bindplane exposedserver.BindPlane)

History returns the history of a resource. @Summary Get the history of a resource @Produce json @Router /{kind}/{name}/history [get] @Param kind path string true "the kind of the resource" @Param name path string true "the name of the resource" @Success 200 {object} model.HistoryResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func LabelAgents

func LabelAgents(c *gin.Context, bindplane exposedserver.BindPlane)

LabelAgents applies labels to agents by id @Summary Bulk apply labels to agents @Produce json @Router /agents/labels [patch] @Param ids body []string true "agent IDs" @Param labels body map[string]string true "labels to apply" @Param labels body boolean false "overwrite labels" @Success 200 {object} model.BulkAgentLabelsResponse

func OkResource

func OkResource(c *gin.Context, resourceIsNil bool, err error) bool

OkResource returns true if there should be an OK response based on the resource and error provided. It will set an error response on the gin.Context if appropriate.

func OkResponse

func OkResponse(c *gin.Context, err error) bool

OkResponse returns true if there should be an OK response based on the error provided. It will set an error response on the gin.Context if appropriate.

func PatchAgentLabels

func PatchAgentLabels(c *gin.Context, bindplane exposedserver.BindPlane)

PatchAgentLabels patches an agent's labels by agent id @Summary Patch agent labels by agent id @Produce json @Router /agents/{id}/labels [patch] @Param id path string true "the id of the agent" @Param overwrite query string false "if true, overwrite any existing labels with the same names" @Param labels body model.AgentLabelsPayload true "Labels to be merged with existing labels, empty values will delete existing labels" @Success 200 {object} model.AgentLabelsResponse @Failure 404 {object} ErrorResponse @Failure 409 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func Processor

func Processor(c *gin.Context, bindplane exposedserver.BindPlane)

Processor returns a processor by name @Summary Get Processor by name @Produce json @Router /processors/{name} [get] @Param name path string true "the name of the Processor" @Success 200 {object} model.ProcessorResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func ProcessorType

func ProcessorType(c *gin.Context, bindplane exposedserver.BindPlane)

ProcessorType returns a processor type by name @Summary Get processor type by name @Produce json @Router /processor-types/{name} [get] @Param name path string true "the name of the processor type" @Success 200 {object} model.ProcessorTypeResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func ProcessorTypes

func ProcessorTypes(c *gin.Context, bindplane exposedserver.BindPlane)

ProcessorTypes returns a list of processor types @Summary List processor types @Produce json @Router /processor-types [get] @Success 200 {object} model.ProcessorTypesResponse @Failure 500 {object} ErrorResponse

func Processors

func Processors(c *gin.Context, bindplane exposedserver.BindPlane)

Processors returns a list of processors @Summary List Processors @Produce json @Router /Processors [get] @Success 200 {object} model.ProcessorsResponse @Failure 500 {object} ErrorResponse

func RestartAgent

func RestartAgent(c *gin.Context, bindplane exposedserver.BindPlane)

RestartAgent restarts an agent by id @Summary TODO restart agent @Produce json @Router /agents/{id}/restart [put] @Param id path string true "the id of the agent"

func Rollout

func Rollout(c *gin.Context, bindplane exposedserver.BindPlane)

Rollout returns the configuration with the provided name. @Summary Get rollout configuration by name @Produce json @Router /rollouts/{name} [get] @Param name path string true "the name of the configuration" @Success 200 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func RolloutPause

func RolloutPause(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutPause pauses a rollout by configuration name. @Summary Pause rollout by configuration name @Produce json @Router /rollouts/{name}/pause [post] @Param name path string true "the name of the configuration" @Success 202 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func RolloutResume

func RolloutResume(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutResume resumes a rollout by configuration name. @Summary Resume rollout by configuration name @Produce json @Router /rollouts/{name}/resume [post] @Param name path string true "the name of the configuration" @Success 202 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func RolloutStart

func RolloutStart(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutStart starts a rollout by configuration name. @Summary Start rollout by configuration name @Produce json @Router /rollouts/{name}/start [post] @Param name path string true "the name of the configuration" @Param options body model.RolloutOptions false "the options for the rollout" @Success 202 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func RolloutStatus

func RolloutStatus(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutStatus returns the status of the configuration rollout with the provided name. @Summary Status of configuration rollout by name @Produce json @Router /rollouts/{name}/status [get] @Param name path string true "the name of the configuration" @Success 202 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func RolloutUpdate

func RolloutUpdate(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutUpdate updates a rollout by configuration name. @Summary Update rollout by configuration name @Produce json @Router /rollouts/{name}/update [post] @Param name path string true "the name of the configuration" @Success 202 {object} model.ConfigurationResponse @Failure 500 {object} ErrorResponse

func Rollouts

func Rollouts(c *gin.Context, bindplane exposedserver.BindPlane)

Rollouts returns all configurations with active rollouts. @Summary Get all rollouts @Produce json @Router /rollouts [get] @Success 200 {object} model.ConfigurationsResponse @Failure 500 {object} ErrorResponse

func RolloutsUpdate

func RolloutsUpdate(c *gin.Context, bindplane exposedserver.BindPlane)

RolloutsUpdate updates all active rollouts. @Summary Update all active rollouts @Produce json @Router /rollouts [post] @Success 202 {object} model.ConfigurationsResponse @Failure 500 {object} ErrorResponse

func Source

func Source(c *gin.Context, bindplane exposedserver.BindPlane)

Source returns a source by name @Summary Get Source by name @Produce json @Router /sources/{name} [get] @Param name path string true "the name of the Source" @Success 200 {object} model.SourceResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func SourceType

func SourceType(c *gin.Context, bindplane exposedserver.BindPlane)

SourceType returns a source type by name @Summary Get source type by name @Produce json @Router /source-types/{name} [get] @Param name path string true "the name of the source type" @Success 200 {object} model.SourceTypeResponse @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func SourceTypes

func SourceTypes(c *gin.Context, bindplane exposedserver.BindPlane)

SourceTypes returns a list of source types @Summary List source types @Produce json @Router /source-types [get] @Success 200 {object} model.SourceTypesResponse @Failure 500 {object} ErrorResponse

func Sources

func Sources(c *gin.Context, bindplane exposedserver.BindPlane)

Sources returns a list of sources @Summary List Sources @Produce json @Router /Sources [get] @Success 200 {object} model.SourcesResponse @Failure 500 {object} ErrorResponse

func SyncAgentVersion

func SyncAgentVersion(c *gin.Context, bindplane exposedserver.BindPlane)

SyncAgentVersion creates an agent-version from the contents of a github release. @Summary Sync Agent Version @Description Create an agent-version from the contents of a github release. @Produce json @Router /agent-versions/{version}/sync [post] @Param version path string true "2.1.1" @Success 200 {object} model.ApplyResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse

func UpgradeAgent

func UpgradeAgent(c *gin.Context, bindplane exposedserver.BindPlane)

UpgradeAgent upgrades an agent to latest version by id @Summary Upgrade agent @Produce json @Router /agents/{id}/version [post] @Param name path string true "the id of the agent" @Param body body model.PostAgentVersionRequest true "request body containing version" @Failure 409 {object} ErrorResponse "If the agent does not support upgrade" @Failure 500 {object} ErrorResponse

func UpgradeAgents

func UpgradeAgents(c *gin.Context, bindplane exposedserver.BindPlane)

UpgradeAgents upgrades agents to latest version by id @Summary Update multiple agents @Router /agents/version [patch] @Param body body model.PatchAgentVersionsRequest true "request body containing ids and version"

Types

type ErrorResponse

type ErrorResponse struct {
	Errors []string `json:"errors"`
}

ErrorResponse TODO(doc)

func NewErrorResponse

func NewErrorResponse(err error) ErrorResponse

NewErrorResponse returns a new ErrorResponse from a given error.

Jump to

Keyboard shortcuts

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