common

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package common is to handle REST API for common funcitonalities

Package common is to handle REST API for common funcitonalities

Package common is to handle REST API for common funcitonalities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RestCheckHTTPVersion added in v0.7.7

func RestCheckHTTPVersion(c echo.Context) error

RestCheckHTTPVersion godoc @ID CheckHTTPVersion @Summary Check HTTP version of incoming request @Description Checks and logs the HTTP version of the incoming request to the server console. @Tags [Admin] API Request Management @Accept json @Produce json @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /httpVersion [get]

func RestCheckNs

func RestCheckNs(c echo.Context) error

func RestDelAllNs

func RestDelAllNs(c echo.Context) error

RestDelAllNs godoc @ID DelAllNs @Summary Delete all namespaces @Description Delete all namespaces @Tags [Admin] System Configuration @Accept json @Produce json @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Router /ns [delete]

func RestDelNs

func RestDelNs(c echo.Context) error

RestDelNs godoc @ID DelNs @Summary Delete namespace @Description Delete namespace @Tags [Admin] System Configuration @Accept json @Produce json @Param nsId path string true "Namespace ID" default(default) @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Router /ns/{nsId} [delete]

func RestDeleteAllRequests added in v0.7.13

func RestDeleteAllRequests(c echo.Context) error

RestDeleteAllRequests godoc @ID DeleteAllRequests @Summary Delete all requests' details @Description Delete details of all requests @Tags [Admin] API Request Management @Accept json @Produce json @Success 200 {object} model.SimpleMsg @Router /requests [delete]

func RestDeleteObject added in v0.3.3

func RestDeleteObject(c echo.Context) error

func RestDeleteObject is a rest api wrapper for DeleteObject. RestDeleteObject godoc @ID DeleteObject @Summary Delete an object @Description Delete an object @Tags [Admin] System Management @Accept json @Produce json @Param key query string true "delete object value by key" @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /object [delete]

func RestDeleteObjects added in v0.3.3

func RestDeleteObjects(c echo.Context) error

func RestDeleteObjects is a rest api wrapper for DeleteObjects. RestDeleteObjects godoc @ID DeleteObjects @Summary Delete child objects along with the given object @Description Delete child objects along with the given object @Tags [Admin] System Management @Accept json @Produce json @Param key query string true "Delete child objects based on the given key string" @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /objects [delete]

func RestDeleteRequest added in v0.7.13

func RestDeleteRequest(c echo.Context) error

RestDeleteRequest godoc @ID DeleteRequest @Summary Delete a specific request's details @Description Delete details of a specific request @Tags [Admin] API Request Management @Accept json @Produce json @Param reqId path string true "Request ID to delete" @Success 200 {object} model.SimpleMsg @Router /request/{reqId} [delete]

func RestForwardAnyReqToAny added in v0.8.1

func RestForwardAnyReqToAny(c echo.Context) error

RestForwardAnyReqToAny godoc @ID ForwardAnyReqToAny @Summary Forward any (GET) request to CB-Spider @Description Forward any (GET) request to CB-Spider @Tags [Admin] API Request Management @Accept json @Produce json @Param path path string true "Internal call path to CB-Spider (path without /spider/ prefix) - see [https://documenter.getpostman.com/view/24786935/2s9Ykq8Lpf#231eec23-b0ab-4966-83ce-a0ef92ead7bc] for more details"" default(vmspec) @Param Request body interface{} false "Request body (various formats) - see [https://documenter.getpostman.com/view/24786935/2s9Ykq8Lpf#231eec23-b0ab-4966-83ce-a0ef92ead7bc] for more details" @Success 200 {object} map[string]interface{} @Router /forward/{path} [post]

func RestGetAllConfig

func RestGetAllConfig(c echo.Context) error

RestGetAllConfig godoc @ID GetAllConfig @Summary List all configs @Description List all configs @Tags [Admin] System Configuration @Accept json @Produce json @Success 200 {object} RestGetAllConfigResponse @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /config [get]

func RestGetAllNs

func RestGetAllNs(c echo.Context) error

RestGetAllNs godoc @ID GetAllNs @Summary List all namespaces or namespaces' ID @Description List all namespaces or namespaces' ID @Tags [Admin] System Configuration @Accept json @Produce json @Param option query string false "Option" Enums(id) @Success 200 {object} JSONResult{[DEFAULT]=RestGetAllNsResponse,[ID]=model.IdList} "Different return structures by the given option param" @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /ns [get]

func RestGetAllRequests added in v0.7.13

func RestGetAllRequests(c echo.Context) error

RestGetAllRequests godoc @ID GetAllRequests @Summary Get all requests @Description Get details of all requests with optional filters. @Tags [Admin] API Request Management @Accept json @Produce json @Param status query string false "Filter by request status (Handling, Error, Success)" @Param method query string false "Filter by HTTP method (GET, POST, etc.)" @Param url query string false "Filter by request URL" @Param time query string false "Filter by time in minutes from now (to get recent requests)" @Param savefile query string false "Option to save the results to a file (set 'true' to activate)" @Success 200 {object} map[string][]common.RequestDetails @Router /requests [get]

func RestGetCloudInfo added in v0.8.7

func RestGetCloudInfo(c echo.Context) error

RestGetCloudInfo func is a rest api wrapper for CloudInfo. RestGetCloudInfo godoc @ID GetCloudInfo @Summary Get cloud information @Description Get cloud information @Tags [Admin] Multi-Cloud Information @Accept json @Produce json @Success 200 {object} model.CloudInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /cloudInfo [get]

func RestGetConfig

func RestGetConfig(c echo.Context) error

RestGetConfig godoc @ID GetConfig @Summary Get config @Description Get config @Tags [Admin] System Configuration @Accept json @Produce json @Param configId path string true "Config ID" @Success 200 {object} model.ConfigInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /config/{configId} [get]

func RestGetConnConfig

func RestGetConnConfig(c echo.Context) error

RestGetConnConfig func is a rest api wrapper for GetConnConfig. RestGetConnConfig godoc @ID GetConnConfig @Summary Get registered ConnConfig info @Description Get registered ConnConfig info @Tags [Admin] Credential Management @Accept json @Produce json @Param connConfigName path string true "Name of connection config (cloud config)" @Success 200 {object} model.ConnConfig @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /connConfig/{connConfigName} [get]

func RestGetConnConfigList

func RestGetConnConfigList(c echo.Context) error

RestGetConnConfigList func is a rest api wrapper for GetConnConfigList. RestGetConnConfigList godoc @ID GetConnConfigList @Summary List all registered ConnConfig @Description List all registered ConnConfig @Tags [Admin] Credential Management @Accept json @Produce json @Param filterCredentialHolder query string false "filter objects by Credential Holder" default() @Param filterVerified query boolean false "filter verified connections only" Enums(true, false) default(true) @Param filterRegionRepresentative query boolean false "filter connections with the representative region only" Enums(true, false) default(false) @Success 200 {object} model.ConnConfigList @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /connConfig [get]

func RestGetK8sClusterInfo added in v0.8.14

func RestGetK8sClusterInfo(c echo.Context) error

RestGetK8sClusterInfo func is a rest api wrapper for K8sClsuterInfo. RestGetK8sClusterInfo godoc @ID GetK8sClusterInfo @Summary Get kubernetes cluster information @Description Get kubernetes cluster information @Tags [Kubernetes] Cluster Management @Accept json @Produce json @Success 200 {object} model.K8sClusterInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /k8sClusterInfo [get]

func RestGetNs

func RestGetNs(c echo.Context) error

RestGetNs godoc @ID GetNs @Summary Get namespace @Description Get namespace @Tags [Admin] System Configuration @Accept json @Produce json @Param nsId path string true "Namespace ID" default(default) @Success 200 {object} model.NsInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /ns/{nsId} [get]

func RestGetObject added in v0.3.3

func RestGetObject(c echo.Context) error

func RestGetObject is a rest api wrapper for GetObject. RestGetObject godoc @ID GetObject @Summary Get value of an object @Description Get value of an object @Tags [Admin] System Management @Accept json @Produce json @Param key query string true "get object value by key" @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /object [get]

func RestGetObjects added in v0.3.3

func RestGetObjects(c echo.Context) error

func RestGetObjects is a rest api wrapper for GetObjectList. RestGetObjects godoc @ID GetObjects @Summary List all objects for a given key @Description List all objects for a given key @Tags [Admin] System Management @Accept json @Produce json @Param key query string true "retrieve objects by key" @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /objects [get]

func RestGetProviderList added in v0.8.9

func RestGetProviderList(c echo.Context) error

RestGetProviderList func is a rest api wrapper for GetProviderList. RestGetProviderList godoc @ID GetProviderList @Summary List all registered Providers @Description List all registered Providers @Tags [Admin] Multi-Cloud Information @Accept json @Produce json @Success 200 {object} model.IdList @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /provider [get]

func RestGetPublicKeyForCredentialEncryption added in v0.9.7

func RestGetPublicKeyForCredentialEncryption(c echo.Context) error

RestGetPublicKeyForCredentialEncryption godoc @ID GetPublicKeyForCredentialEncryption @Summary Get RSA Public Key for Credential Encryption @Description Generates an RSA key pair using a 4096-bit key size with the RSA algorithm. The public key is generated using the RSA algorithm with OAEP padding and SHA-256 as the hash function. This key is used to encrypt an AES key that will be used for hybrid encryption of credentials. @Tags [Admin] Credential Management @Accept json @Produce json @Success 200 {object} model.PublicKeyResponse @Failure 500 {object} model.SimpleMsg @Router /credential/publicKey [get]

func RestGetReadyz added in v0.8.8

func RestGetReadyz(c echo.Context) error

RestGetReadyz func is for checking CB-Tumblebug server is ready. @ID GetReadyz RestGetReadyz godoc @Summary Check Tumblebug is ready @Description Check Tumblebug is ready @Tags [Admin] System Management @Accept json @Produce json @Success 200 {object} model.SimpleMsg @Failure 503 {object} model.SimpleMsg @Router /readyz [get]

func RestGetRegion

func RestGetRegion(c echo.Context) error

RestGetRegion func is a rest api wrapper for GetRegion. RestGetRegion godoc @ID GetRegion @Summary Get registered region info @Description Get registered region info @Tags [Admin] Multi-Cloud Information @Accept json @Produce json @Param providerName path string true "Name of the CSP to retrieve" @Param regionName path string true "Name of region to retrieve" @Success 200 {object} model.RegionDetail @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /provider/{providerName}/region/{regionName} [get]

func RestGetRegionListFromCsp added in v0.9.10

func RestGetRegionListFromCsp(c echo.Context) error

RestGetRegionListFromCsp func is a rest api wrapper for RetrieveRegionListFromCsp. RestGetRegionListFromCsp godoc @ID RetrieveRegionListFromCsp @Summary RetrieveR all region lists from CSPs @Description RetrieveR all region lists from CSPs @Tags [Admin] Multi-Cloud Information @Accept json @Produce json @Success 200 {object} model.RetrievedRegionList @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /regionFromCsp [get]

func RestGetRegions added in v0.9.10

func RestGetRegions(c echo.Context) error

RestGetRegions func is a rest api wrapper for GetRegion. RestGetRegions godoc @ID GetRegions @Summary Get registered region info @Description Get registered region info @Tags [Admin] Multi-Cloud Information @Accept json @Produce json @Param providerName path string true "Name of the CSP to retrieve" @Success 200 {object} model.RegionList @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /provider/{providerName}/region [get]

func RestGetRequest added in v0.7.13

func RestGetRequest(c echo.Context) error

RestGetRequest godoc @ID GetRequest @Summary Get request details @Description Get details of a specific request @Tags [Admin] API Request Management @Accept json @Produce json @Param reqId path string true "Request ID acquired from X-Request-ID header" @Success 200 {object} common.RequestDetails @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /request/{reqId} [get]

func RestInitAllConfig added in v0.3.9

func RestInitAllConfig(c echo.Context) error

RestInitAllConfig godoc @ID InitAllConfig @Summary Init all configs @Description Init all configs @Tags [Admin] System Configuration @Accept json @Produce json @Success 200 {object} model.SimpleMsg @Failure 404 {object} model.SimpleMsg @Router /config [delete]

func RestInitConfig added in v0.3.9

func RestInitConfig(c echo.Context) error

RestInitConfig godoc @ID InitConfig @Summary Init config @Description Init config @Tags [Admin] System Configuration @Accept json @Produce json @Param configId path string true "Config ID" @Success 200 {object} model.ConfigInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /config/{configId} [delete]

func RestInspectResources added in v0.3.6

func RestInspectResources(c echo.Context) error

RestInspectResources godoc @ID InspectResources @Summary Inspect Resources (vNet, securityGroup, sshKey, vm) registered in CB-Tumblebug, CB-Spider, CSP @Description Inspect Resources (vNet, securityGroup, sshKey, vm) registered in CB-Tumblebug, CB-Spider, CSP @Tags [Admin] System Management @Accept json @Produce json @Param connectionName body RestInspectResourcesRequest true "Specify connectionName and resource type" @Success 200 {object} model.InspectResource @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /inspectResources [post]

func RestInspectResourcesOverview added in v0.5.4

func RestInspectResourcesOverview(c echo.Context) error

RestInspectResourcesOverview godoc @ID InspectResourcesOverview @Summary Inspect Resources Overview (vNet, securityGroup, sshKey, vm) registered in CB-Tumblebug and CSP for all connections @Description Inspect Resources Overview (vNet, securityGroup, sshKey, vm) registered in CB-Tumblebug and CSP for all connections @Tags [Admin] System Management @Accept json @Produce json @Success 200 {object} model.InspectResourceAllResult @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /inspectResourcesOverview [get]

func RestPostConfig

func RestPostConfig(c echo.Context) error

RestPostConfig godoc @ID PostConfig @Summary Create or Update config @Description Create or Update config (TB_SPIDER_REST_URL, TB_DRAGONFLY_REST_URL, ...) @Tags [Admin] System Configuration @Accept json @Produce json @Param config body model.ConfigReq true "Key and Value for configuration" @Success 200 {object} model.ConfigInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /config [post]

func RestPostNs

func RestPostNs(c echo.Context) error

RestPostNs godoc @ID PostNs @Summary Create namespace @Description Create namespace @Tags [Admin] System Configuration @Accept json @Produce json @Param nsReq body model.NsReq true "Details for a new namespace" @Success 200 {object} model.NsInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /ns [post]

func RestPutNs

func RestPutNs(c echo.Context) error

RestPutNs godoc @ID PutNs @Summary Update namespace @Description Update namespace @Tags [Admin] System Configuration @Accept json @Produce json @Param nsId path string true "Namespace ID" default(default) @Param namespace body model.NsReq true "Details to update existing namespace" @Success 200 {object} model.NsInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /ns/{nsId} [put]

func RestRegisterCredential added in v0.8.8

func RestRegisterCredential(c echo.Context) error

RestRegisterCredential is a REST API handler for registering credentials. @ID RegisterCredential @Summary Register Credential Information @Description This API registers credential information using hybrid encryption. The process involves compressing and encrypting sensitive data with AES-256, encrypting the AES key with a 4096-bit RSA public key (retrieved via `GET /credential/publicKey`), and using OAEP padding with SHA-256. All values, including the AES key, must be base64 encoded before sending, and the public key token ID must be included in the request. @Tags [Admin] Credential Management @Accept json @Produce json @Param CredentialReq body model.CredentialReq true "Credential request info" @Success 200 {object} model.CredentialInfo @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /credential [post]

func RestRegisterCspNativeResources added in v0.5.3

func RestRegisterCspNativeResources(c echo.Context) error

RestRegisterCspNativeResources godoc @ID RegisterCspNativeResources @Summary Register CSP Native Resources (vNet, securityGroup, sshKey, vm) to CB-Tumblebug @Description Register CSP Native Resources (vNet, securityGroup, sshKey, vm) to CB-Tumblebug @Tags [Admin] System Management @Accept json @Produce json @Param Request body RestRegisterCspNativeResourcesRequest true "Specify connectionName, NS Id, and MCI Name"" @Param option query string false "Option to specify resourceType" Enums(onlyVm, exceptVm) @Param mciFlag query string false "Flag to show VMs in a collective MCI form (y,n)" Enums(y, n) default(y) @Success 200 {object} model.RegisterResourceResult @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /registerCspResources [post]

func RestRegisterCspNativeResourcesAll added in v0.5.3

func RestRegisterCspNativeResourcesAll(c echo.Context) error

RestRegisterCspNativeResourcesAll godoc @ID RegisterCspNativeResourcesAll @Summary Register CSP Native Resources (vNet, securityGroup, sshKey, vm) from all Clouds to CB-Tumblebug @Description Register CSP Native Resources (vNet, securityGroup, sshKey, vm) from all Clouds to CB-Tumblebug @Tags [Admin] System Management @Accept json @Produce json @Param Request body RestRegisterCspNativeResourcesRequestAll true "Specify NS Id and MCI Name" @Param option query string false "Option to specify resourceType" Enums(onlyVm, exceptVm) @Param mciFlag query string false "Flag to show VMs in a collective MCI form (y,n)" Enums(y, n) default(y) @Success 200 {object} model.RegisterResourceAllResult @Failure 404 {object} model.SimpleMsg @Failure 500 {object} model.SimpleMsg @Router /registerCspResourcesAll [post]

func Send

func Send(c echo.Context, httpCode int, json interface{}) error

func SendExistence

func SendExistence(c echo.Context, httpCode int, existence bool) error

func SendMessage

func SendMessage(c echo.Context, httpCode int, msg string) error

func Validate

func Validate(c echo.Context, params []string) error

Types

type Existence

type Existence struct {
	Exists bool `json:"exists"`
}

type JSONResult added in v0.3.11

type JSONResult struct {
}

JSONResult's data field will be overridden by the specific type

type ObjectList added in v0.3.3

type ObjectList struct {
	Object []string `json:"object"`
}

ObjectList struct consists of object IDs

type RestGetAllConfigResponse

type RestGetAllConfigResponse struct {
	//Name string     `json:"name"`
	Config []model.ConfigInfo `json:"config"`
}

Response structure for RestGetAllConfig

type RestGetAllNsResponse

type RestGetAllNsResponse struct {
	//Name string     `json:"name"`
	Ns []model.NsInfo `json:"ns"`
}

Response structure for RestGetAllNs

type RestInspectResourcesRequest added in v0.3.6

type RestInspectResourcesRequest struct {
	ConnectionName string `json:"connectionName" example:"aws-ap-southeast-1"`
	ResourceType   string `json:"resourceType" example:"vNet" enums:"vNet,securityGroup,sshKey,vm"`
}

Request struct for RestInspectResources

type RestRegisterCspNativeResourcesRequest added in v0.5.3

type RestRegisterCspNativeResourcesRequest struct {
	ConnectionName string `json:"connectionName" example:"aws-ap-southeast-1"`
	NsId           string `json:"nsId" example:"default"`
	MciName        string `json:"mciName" example:"csp"`
}

Request struct for RestRegisterCspNativeResources

type RestRegisterCspNativeResourcesRequestAll added in v0.5.3

type RestRegisterCspNativeResourcesRequestAll struct {
	NsId    string `json:"nsId" example:"default"`
	MciName string `json:"mciName" example:"csp"`
}

Request struct for RestRegisterCspNativeResources

type Status

type Status struct {
	Message string `json:"message"`
}

type TbConnectionName added in v0.3.7

type TbConnectionName struct {
	ConnectionName string `json:"connectionName"`
}

Directories

Path Synopsis
Package label is to handle label selector for resources
Package label is to handle label selector for resources

Jump to

Keyboard shortcuts

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