api

package
v0.0.0-...-99e5d07 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(n int) string

func InitializeAuthnClient

func InitializeAuthnClient(logger core_logging.ILog) (*core_auth_sdk.Client, error)

func InitializeLoggingEngine

func InitializeLoggingEngine(ctx context.Context) core_logging.ILog

func InitializeMetricsEngine

func InitializeMetricsEngine(serviceName string) *metrics.MetricsEngine

func InitializeTracingEngine

func InitializeTracingEngine(serviceName string) (*core_tracing.TracingEngine, io.Closer)

Types

type ArrayResponse

type ArrayResponse []string

type Config

type Config struct {
	HttpClientTimeout         time.Duration `mapstructure:"http-client-timeout"`
	HttpServerTimeout         time.Duration `mapstructure:"http-server-timeout"`
	HttpServerShutdownTimeout time.Duration `mapstructure:"http-server-shutdown-timeout"`
	BackendURL                []string      `mapstructure:"backend-url"`
	UIMessage                 string        `mapstructure:"ui-message"`
	UIColor                   string        `mapstructure:"ui-color"`
	UIPath                    string        `mapstructure:"ui-path"`
	DataPath                  string        `mapstructure:"data-path"`
	ConfigPath                string        `mapstructure:"config-path"`
	CertPath                  string        `mapstructure:"cert-path"`
	Port                      string        `mapstructure:"port"`
	SecurePort                string        `mapstructure:"secure-port"`
	PortMetrics               int           `mapstructure:"port-metrics"`
	Hostname                  string        `mapstructure:"hostname"`
	H2C                       bool          `mapstructure:"h2c"`
	RandomDelay               bool          `mapstructure:"random-delay"`
	RandomDelayUnit           string        `mapstructure:"random-delay-unit"`
	RandomDelayMin            int           `mapstructure:"random-delay-min"`
	RandomDelayMax            int           `mapstructure:"random-delay-max"`
	RandomError               bool          `mapstructure:"random-error"`
	Unhealthy                 bool          `mapstructure:"unhealthy"`
	Unready                   bool          `mapstructure:"unready"`
	JWTSecret                 string        `mapstructure:"jwt-secret"`
	CacheServer               string        `mapstructure:"cache-server"`
}

type CreateAccountRequest

type CreateAccountRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type CreateAccountResponse

type CreateAccountResponse struct {
	Error error  `json:"error"`
	Id    uint32 `json:"id"`
}

type DeleteAccountRequest

type DeleteAccountRequest struct {
	// id of the account to delete
	// in: query
	// required: true
	Id uint32 `json:"result"`
}

Delete account by id request swagger:parameters deleteAccount

type DeleteAccountResponse

type DeleteAccountResponse struct {
	Error error `json:"error"`
}

DeleteAccountResponse is struct providing errors tied to delete account operations

type GetAccountRequest

type GetAccountRequest struct {
	// id of the account to obtain
	// in: query
	// required: true
	Id uint32 `json:"result"`
}

Get account by id request swagger:parameters getAccount

type GetAccountResponse

type GetAccountResponse struct {
	Account *core_auth_sdk.Account `json:"account"`
	Error   error                  `json:"error"`
}

GetAccountResponse is struct providing errors tied to get account operations

type LockAccountRequest

type LockAccountRequest struct {
	// id of the account to lock
	// in: query
	// required: true
	Id uint32 `json:"result"`
}

Lock account request swagger:parameters lockAccount

type LockAccountResponse

type LockAccountResponse struct {
	Error error `json:"error"`
}

LockAccountResponse is struct providing errors tied to lock account operations

type LoggingMiddleware

type LoggingMiddleware struct {
}

func NewLoggingMiddleware

func NewLoggingMiddleware() *LoggingMiddleware

func (*LoggingMiddleware) Handler

func (m *LoggingMiddleware) Handler(next http.Handler) http.Handler

type LoginAccountRequest

type LoginAccountRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginAccountResponse

type LoginAccountResponse struct {
	Error error  `json:"error"`
	Token string `json:"token"`
}

type MapResponse

type MapResponse map[string]string

type OperationResponseSwagger

type OperationResponseSwagger struct {
	// in: body
	Body struct {
		// error
		// required: true
		// example: error occured while processing request
		Error error `json:"error"`
	}
}

Common operation response swagger:response operationResponse

type PrometheusMiddleware

type PrometheusMiddleware struct {
	Histogram *core_metrics.HistogramVec
	Counter   *core_metrics.CounterVec
}

func NewPrometheusMiddleware

func NewPrometheusMiddleware(m *metrics.CoreMetrics) *PrometheusMiddleware

func (*PrometheusMiddleware) Handler

func (p *PrometheusMiddleware) Handler(next http.Handler) http.Handler

Metrics godoc @Summary Prometheus metrics @Description returns HTTP requests duration and Go runtime metrics @Tags Kubernetes @Produce plain @Router /metrics [get] @Success 200 {string} string "OK"

type RandomDelayMiddleware

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

func NewRandomDelayMiddleware

func NewRandomDelayMiddleware(minDelay, maxDelay int, delayUnit string) *RandomDelayMiddleware

func (*RandomDelayMiddleware) Handler

func (m *RandomDelayMiddleware) Handler(next http.Handler) http.Handler

type RuntimeResponse

type RuntimeResponse struct {
	Hostname     string `json:"hostname"`
	Version      string `json:"version"`
	Revision     string `json:"revision"`
	Color        string `json:"color"`
	Message      string `json:"message"`
	GOOS         string `json:"goos"`
	GOARCH       string `json:"goarch"`
	Runtime      string `json:"runtime"`
	NumGoroutine string `json:"num_goroutine"`
	NumCPU       string `json:"num_cpu"`
}

type Server

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

func NewMockServer

func NewMockServer() *Server

func NewServer

func NewServer(config *Config,
	client *core_auth_sdk.Client, logging core_logging.ILog, serviceMetrics *metrics.CoreMetrics,
	metricsEngineConf *core_metrics.CoreMetricsEngine, tracer *core_tracing.TracingEngine) (*Server,
	error)

func (*Server) ArchiveAccountIfErrorsOccur

func (s *Server) ArchiveAccountIfErrorsOccur(ctx context.Context, err error, authnID int, parentSpan opentracing.Span)

func (*Server) DecodeRequestAndInstrument

func (s *Server) DecodeRequestAndInstrument(ctx context.Context, w http.ResponseWriter, r *http.Request, obj interface{},
	operationType string) error

func (*Server) ErrorResponse

func (s *Server) ErrorResponse(w http.ResponseWriter, r *http.Request, error string, code int)

func (*Server) ExtractIdOperationAndInstrument

func (s *Server) ExtractIdOperationAndInstrument(ctx context.Context, r *http.Request, operation string) (uint32, error)

ExtractIdOperationAndInstrument extracts an account id from a request and increments the necessary metrics

func (*Server) IsNotAuthenticated

func (s *Server) IsNotAuthenticated(w http.ResponseWriter, r *http.Request) bool

func (*Server) JSONResponse

func (s *Server) JSONResponse(w http.ResponseWriter, r *http.Request, result interface{})

func (*Server) JSONResponseCode

func (s *Server) JSONResponseCode(w http.ResponseWriter, r *http.Request, result interface{}, responseCode int)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(stopCh <-chan struct{})

func (*Server) RemoteOperationAndInstrument

func (s *Server) RemoteOperationAndInstrument(ctx context.Context, f func() error, operationType string, took *time.Duration) error

func (*Server) RemoteOperationAndInstrumentWithResult

func (s *Server) RemoteOperationAndInstrumentWithResult(
	ctx context.Context,
	f func() (interface{}, error),
	operationType string,
	took *time.Duration) (interface{}, error)

type UnLockAccountRequest

type UnLockAccountRequest struct {
	// id of the account to unlock
	// in: query
	// required: true
	Id uint32 `json:"result"`
}

UnLock account request swagger:parameters unlockAccount

type UnLockAccountResponse

type UnLockAccountResponse struct {
	Error error `json:"error"`
}

UnLockAccountResponse is struct providing errors tied to Unlock account operations

type UpdateAccountRequest

type UpdateAccountRequest struct {
	Email string
}

type UpdateAccountRequestSwagger

type UpdateAccountRequestSwagger struct {
	// user account to update
	// in: body
	Body struct {
		// Email to update
		// required: true
		Email string `json:"email"`
	}
	// id of account to update
	// in: query
	AccountId uint32
}

Update account request swagger:parameters updateAccount

type UpdateAccountResponse

type UpdateAccountResponse struct {
	Error error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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