server

package
v0.0.0-...-936a01b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

Insights operator controller

Directory server

Implementation of HTTP REST API server and its endpoints.

Documentation

Overview

Package server contains implementation of REST API server (HTTPServer) for the Insights Operator controller service.

Index

Constants

This section is empty.

Variables

View Source
var APIPrefix = env.GetEnv("CONTROLLER_PREFIX", "/api/v1/")

APIPrefix is appended before all REST API endpoint addresses

View Source
var Environment = os.Getenv("CONTROLLER_ENV")

Environment CONTROLLER_ENV const for specifying production vs test environment

View Source
var SearchClusterTemplate = utils.MergeMaps(map[string]interface{}{

	"id":   "int~Error reading and decoding cluster ID from query",
	"name": "",
	"":     "oneOfIdOrName~Either cluster ID or name needs to be specified",
}, utils.PaginationTemplate)

SearchClusterTemplate defines validation rules and messages for SearchCluster

Functions

func TryToSendBadRequestServerResponse

func TryToSendBadRequestServerResponse(writer http.ResponseWriter, message string)

TryToSendBadRequestServerResponse function tries to send server response with bad request info.

func TryToSendCreatedServerResponse

func TryToSendCreatedServerResponse(writer http.ResponseWriter, payload map[string]interface{})

TryToSendCreatedServerResponse function tries to send server response with info about created resource.

func TryToSendInternalServerError

func TryToSendInternalServerError(writer http.ResponseWriter, message string)

TryToSendInternalServerError function tries to send server response with internal server error info.

func TryToSendOKServerResponse

func TryToSendOKServerResponse(writer http.ResponseWriter, payload map[string]interface{})

TryToSendOKServerResponse function tries to send server response with bad request info.

func TryToSendResponse

func TryToSendResponse(httpStatus int, writer http.ResponseWriter, payload interface{})

TryToSendResponse function tries to send server response with any payload.

func UnableToSendBadRequestServerResponse

func UnableToSendBadRequestServerResponse(err error)

UnableToSendBadRequestServerResponse function log an error when server response can not be delivered to client.

func UnableToSendCreatedResponse

func UnableToSendCreatedResponse(err error)

UnableToSendCreatedResponse function log an error when server response can not be delivered to client.

func UnableToSendInternalServerErrorResponse

func UnableToSendInternalServerErrorResponse(err error)

UnableToSendInternalServerErrorResponse function log an error when server response can not be delivered to client.

func UnableToSendOKResponse

func UnableToSendOKResponse(err error)

UnableToSendOKResponse function log an error when server response can not be delivered to client.

func UnableToSendServerResponse

func UnableToSendServerResponse(err error)

UnableToSendServerResponse function log an error when server response can not be delivered to client.

Types

type Server

type Server struct {
	Address  string
	UseHTTPS bool
	Storage  storage.Storage
	Splunk   logging.Client
	TLSCert  string
	TLSKey   string

	ClusterQuery *storage.ClusterQuery
}

Server data type represents configuration of server

func (*Server) AckTriggerForCluster

func (s *Server) AckTriggerForCluster(writer http.ResponseWriter, request *http.Request)

AckTriggerForCluster method perform ack for single cluster's trigger

func (*Server) ActivateTrigger

func (s *Server) ActivateTrigger(writer http.ResponseWriter, request *http.Request)

ActivateTrigger method actives single trigger

func (*Server) AddDefaultHeaders

func (s *Server) AddDefaultHeaders(nextHandler http.Handler) http.Handler

AddDefaultHeaders method represents middleware for adding headers that should be in any response

func (*Server) ChangeConfigurationProfile

func (s *Server) ChangeConfigurationProfile(writer http.ResponseWriter, request *http.Request)

ChangeConfigurationProfile method changes configuration profile

func (*Server) DeactivateTrigger

func (s *Server) DeactivateTrigger(writer http.ResponseWriter, request *http.Request)

DeactivateTrigger method deactivates single trigger

func (*Server) DeleteCluster

func (s *Server) DeleteCluster(writer http.ResponseWriter, request *http.Request)

DeleteCluster method deletes a cluster

func (*Server) DeleteClusterByName

func (s *Server) DeleteClusterByName(writer http.ResponseWriter, request *http.Request)

DeleteClusterByName method deletes a cluster

func (*Server) DeleteConfiguration

func (s *Server) DeleteConfiguration(writer http.ResponseWriter, request *http.Request)

DeleteConfiguration method removes single configuration specified by its ID

func (*Server) DeleteConfigurationProfile

func (s *Server) DeleteConfigurationProfile(writer http.ResponseWriter, request *http.Request)

DeleteConfigurationProfile method deletes configuration profile

func (*Server) DeleteTrigger

func (s *Server) DeleteTrigger(writer http.ResponseWriter, request *http.Request)

DeleteTrigger method deletes single trigger

func (*Server) DisableClusterConfiguration

func (s *Server) DisableClusterConfiguration(writer http.ResponseWriter, request *http.Request)

DisableClusterConfiguration method disables cluster configuration

func (*Server) DisableConfiguration

func (s *Server) DisableConfiguration(writer http.ResponseWriter, request *http.Request)

DisableConfiguration method disables single configuration

func (*Server) EnableClusterConfiguration

func (s *Server) EnableClusterConfiguration(writer http.ResponseWriter, request *http.Request)

EnableClusterConfiguration method enables cluster configuration

func (*Server) EnableConfiguration

func (s *Server) EnableConfiguration(writer http.ResponseWriter, request *http.Request)

EnableConfiguration method enables single configuration

func (*Server) EnableOrDisableConfiguration

func (s *Server) EnableOrDisableConfiguration(writer http.ResponseWriter, request *http.Request, active string)

EnableOrDisableConfiguration method enables or disables single cluster configuration

func (*Server) GetActiveTriggersForCluster

func (s *Server) GetActiveTriggersForCluster(writer http.ResponseWriter, request *http.Request)

GetActiveTriggersForCluster method returns list of triggers for single cluster

func (*Server) GetAllConfigurations

func (s *Server) GetAllConfigurations(writer http.ResponseWriter, request *http.Request)

GetAllConfigurations method reads and returns list of all configurations

func (*Server) GetAllTriggers

func (s *Server) GetAllTriggers(writer http.ResponseWriter, request *http.Request)

GetAllTriggers method returns list of all triggers

func (*Server) GetClusterByID

func (s *Server) GetClusterByID(writer http.ResponseWriter, request *http.Request)

GetClusterByID method reads cluster specified by its ID and return it to a client.

func (*Server) GetClusterConfiguration

func (s *Server) GetClusterConfiguration(writer http.ResponseWriter, request *http.Request)

GetClusterConfiguration method returns list of configuration for single cluster

func (*Server) GetClusterTriggers

func (s *Server) GetClusterTriggers(writer http.ResponseWriter, request *http.Request)

GetClusterTriggers method returns list of triggers for single cluster

func (*Server) GetClusters

func (s *Server) GetClusters(writer http.ResponseWriter, request *http.Request)

GetClusters method reads list of all clusters from database and return it to a client.

func (*Server) GetConfiguration

func (s *Server) GetConfiguration(writer http.ResponseWriter, request *http.Request)

GetConfiguration method returns single configuration by id

func (*Server) GetConfigurationProfile

func (s *Server) GetConfigurationProfile(writer http.ResponseWriter, request *http.Request)

GetConfigurationProfile method reads profile specified by its ID

func (*Server) GetTrigger

func (s *Server) GetTrigger(writer http.ResponseWriter, request *http.Request)

GetTrigger method returns single trigger by id

func (*Server) Initialize

func (s *Server) Initialize()

Initialize perform the server initialization

func (*Server) JWTAuthentication

func (s *Server) JWTAuthentication(next http.Handler) http.Handler

JWTAuthentication middleware for checking auth rights

func (*Server) ListConfigurationProfiles

func (s *Server) ListConfigurationProfiles(writer http.ResponseWriter, request *http.Request)

ListConfigurationProfiles method reads list of configuration profiles.

func (*Server) LogRequest

func (s *Server) LogRequest(nextHandler http.Handler) http.Handler

LogRequest method represents middleware for loging requests

func (*Server) MainEndpoint

func (s *Server) MainEndpoint(writer http.ResponseWriter, request *http.Request)

MainEndpoint method is handler for the main endpoint of REST API server

func (*Server) NewCluster

func (s *Server) NewCluster(writer http.ResponseWriter, request *http.Request)

NewCluster method creates a record with new cluster in a database. The updated list of all clusters is returned to client.

func (*Server) NewClusterConfiguration

func (s *Server) NewClusterConfiguration(writer http.ResponseWriter, request *http.Request)

NewClusterConfiguration method creates configuration for single cluster

func (*Server) NewConfigurationProfile

func (s *Server) NewConfigurationProfile(writer http.ResponseWriter, request *http.Request)

NewConfigurationProfile method creates new configuration profile

func (*Server) ReadConfigurationForOperator

func (s *Server) ReadConfigurationForOperator(writer http.ResponseWriter, request *http.Request)

ReadConfigurationForOperator method reads configuration for the operator.

func (*Server) RegisterCluster

func (s *Server) RegisterCluster(writer http.ResponseWriter, request *http.Request)

RegisterCluster method registers new cluster.

func (*Server) RegisterClusterTrigger

func (s *Server) RegisterClusterTrigger(writer http.ResponseWriter, request *http.Request)

RegisterClusterTrigger method registers new trigger for cluster

func (*Server) SearchCluster

func (s *Server) SearchCluster(writer http.ResponseWriter, request *http.Request)

SearchCluster method searchs for a cluster specified by its ID or name.

type Token

type Token struct {
	Login string
	jwt.StandardClaims
}

Token JWT claims struct

Jump to

Keyboard shortcuts

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