api

package
v0.0.0-...-7379bb1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(e *echo.Echo, s *Server)

RegisterHandlers registers all the API handlers.

Types

type Info

type Info struct {
	ID   string `json:"id"`
	User string `json:"user"`
	Role Role   `json:"role"`
}

Info is the API info of a user.

type KeyStore

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

KeyStore persists the API keys.

func NewKeyStore

func NewKeyStore(path string) (*KeyStore, error)

NewKeyStore creates a new API key store.

func (*KeyStore) Add

func (s *KeyStore) Add(apiKey string, info Info) error

Add adds an API key to the store.

func (*KeyStore) All

func (s *KeyStore) All() ([]Info, error)

All returns all API keys in the store.

func (*KeyStore) Delete

func (s *KeyStore) Delete(apiKey string) (bool, error)

Delete deletes an API key. The first return value indicates if the key was deleted.

func (*KeyStore) Get

func (s *KeyStore) Get(apiKey string) (*Info, error)

Get reads the info associated with the user. If the API key does not exist, the returned info is nil.

type Role

type Role int

Role is the role of a user.

const (
	UnknownRole Role = iota
	ConfigReader
	ConfigWriter
	Admin
)

All roles.

func (Role) MarshalText

func (r Role) MarshalText() ([]byte, error)

func (Role) String

func (r Role) String() string

func (*Role) UnmarshalText

func (r *Role) UnmarshalText(b []byte) error

type Server

type Server struct {
	LogLevel *zap.AtomicLevel
	TimeZone *timeserver.TimeZone
	KeyStore *KeyStore
	Logger   *zap.Logger
	JWTKey   []byte
}

Server implements the configuration API.

func (*Server) AdminDeleteKey

func (s *Server) AdminDeleteKey(ctx echo.Context, apiKeyID string) error

AdminDeleteKey deletes an API key.

func (*Server) AdminGetKey

func (s *Server) AdminGetKey(ctx echo.Context, apiKeyID string) error

AdminGetKey serves a single API key info.

func (*Server) AdminGetKeys

func (s *Server) AdminGetKeys(ctx echo.Context) error

AdminGetKeys serves a list of a API key infos.

func (*Server) AdminSetKey

func (s *Server) AdminSetKey(ctx echo.Context) error

AdminSetKey sets a API key.

func (*Server) GetLogLevel

func (s *Server) GetLogLevel(ctx echo.Context) error

GetLogLevel wraps the zap log level handler

func (*Server) GetTimeZone

func (s *Server) GetTimeZone(ctx echo.Context) error

GetTimeZone serves the currently configured time zone.

func (*Server) GetToken

func (s *Server) GetToken(ctx echo.Context, params gen.GetTokenParams) error

GetToken issues a token.

func (*Server) SetLogLevel

func (s *Server) SetLogLevel(ctx echo.Context) error

SetLogLevel wraps the zap log level handler

func (*Server) SetTimeZone

func (s *Server) SetTimeZone(ctx echo.Context) error

SetTimeZone sets the time zone.

Directories

Path Synopsis
Package gen provides primitives to interact the openapi HTTP API.
Package gen provides primitives to interact the openapi HTTP API.

Jump to

Keyboard shortcuts

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