api

package
v0.0.0-...-37b99e7 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfig

func AddConfig(dal *DAL) gin.HandlerFunc

AddConfig - Create a new configuration and configuration value

func AuthRequired

func AuthRequired(d *DAL) gin.HandlerFunc

AuthRequired is a simple middleware to check the session

func GetConfigByID

func GetConfigByID(dal *DAL) gin.HandlerFunc

GetConfigByID - Retrieve a configuration by configuration ID

func GetConfigs

func GetConfigs(dal *DAL) gin.HandlerFunc

GetConfigs - Get a paginated list of configurations

func GetRecords

func GetRecords(dal *DAL) gin.HandlerFunc

GetRecords - Retrieves an audit log entry

func HostLogin

func HostLogin(dal *DAL) gin.HandlerFunc

HostLogin - Login host with an API key

func HostRegister

func HostRegister(dal *DAL) gin.HandlerFunc

HostRegister - Register host for an API key

func NewRouter

func NewRouter(dal *DAL) *gin.Engine

NewRouter returns a new router.

func PingGet

func PingGet(dal *DAL) gin.HandlerFunc

PingGet - Healthcheck for the API

func UpdateConfigByID

func UpdateConfigByID(dal *DAL) gin.HandlerFunc

UpdateConfigByID - Update a configuration by configuration ID

func ValidateToken

func ValidateToken(dal *DAL, hostID string, token string) (string, bool, error)

ValidateToken ...

Types

type AuditEvent

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

AuditEvent audit event struct for sending messages of service events

func (*AuditEvent) ToByteSlice

func (a *AuditEvent) ToByteSlice() ([]byte, error)

ToByteSlice - converts AuditEvent into a byte slice

type DAL

type DAL struct {
	Cache         *persistence.RedisStore `json:"cache"`
	Config        *svcmodels.Config       `json:"config"`
	Database      db.DBIface              `json:"database"`
	Context       *context.Context        `json:"context"`
	DocumentStore *mongo.Client           `json:"document_store"`
	Logger        *zap.SugaredLogger      `json:"logger"`
	Producer      *kafka.Producer         `json:"producer"`
	APM           *newrelic.Application   `json:"apm"`
	Collection    string                  `json:"collection,omitempty"`
	SessionKey    string                  `json:"session_key"`
	CacheEnabled  bool                    `json:"cache_enabled"`
}

DAL Data Access Layer struct for maintaining and managing data store connections for Stilla

func NewDAL

func NewDAL(ctx *context.Context, sugar *zap.SugaredLogger, apm *newrelic.Application, config *svcmodels.Config, dbConn db.Conn, docStore *mongo.Client, store *persistence.RedisStore, producer *kafka.Producer, collection, sessionKey string) *DAL

NewDAL returns a new DAL

func (*DAL) EmitMessage

func (d *DAL) EmitMessage(messageType, funcName string, body map[string]interface{})

EmitMessage emits a message for the service. Currently only manages AuditEvents

func (*DAL) GetAuditLogs

func (d *DAL) GetAuditLogs(ctx *gin.Context, offset string, limit string, req interface{}) ([]pb.AuditLog, error)

GetAuditLogs returns a pagination list of audit logs

func (*DAL) GetConfig

func (d *DAL) GetConfig(ctx *gin.Context, configID string, hostID string, req interface{}) (models.ConfigResponse, error)

GetConfig returns a Config with the latest version of the ConfigVersion

func (*DAL) GetConfigs

func (d *DAL) GetConfigs(ctx *gin.Context, offset string, limit string, req interface{}) ([]models.ConfigStore, error)

GetConfigs returns a paginated slice of Configs from the document store

func (*DAL) InsertConfig

func (d *DAL) InsertConfig(ctx *gin.Context, configIn models.ConfigIn, req interface{}) (string, bool, error)

InsertConfig insert a configuration object into the document store. This creates a new ConfigVersion object. The ObjectID of the ConfigVersion is then used to update the Config object reference for ConfigVersion

func (*DAL) LoginHost

func (d *DAL) LoginHost(ctx *gin.Context, hostLoginIn models.HostLoginIn, req interface{}) (string, error)

LoginHost uses the API Key of a host and validates it. Creates a new session if the key is valid

func (*DAL) RegisterHost

func (d *DAL) RegisterHost(ctx *gin.Context, hostRegisterIn models.HostRegisterIn, req interface{}) (string, string, error)

RegisterHost registers a host and provides the requestor an API key

func (*DAL) UpdateConfigByID

func (d *DAL) UpdateConfigByID(ctx *gin.Context, configID string, updateConfigIn models.UpdateConfigIn, req interface{}) (interface{}, error)

UpdateConfigByID Updates a configuration by the ID

type HTTPServer

type HTTPServer struct {
	Context context.Context
	Engine  *gin.Engine        `json:"engine",yaml:"engine"`
	Logger  *zap.SugaredLogger `json:"logger",yaml:"logger"`

	DomainName string `json:"domain_name",yaml:"domain_name"`
	Secure     bool   `json:"secure",yaml:"secure"`
	// contains filtered or unexported fields
}

HTTPServer represents a web server

func Get

func Get(ctx context.Context, sugar *zap.SugaredLogger, domainName string, config *models.Config) (*HTTPServer, error)

Get returns a new web server leveraging the service logger

func (*HTTPServer) Run

func (h *HTTPServer) Run() error

Run runs the web server

type HostCache

type HostCache struct {
	Hostname string `json:"hostname"`
}

HostCache cache for host

type MongoQueryResult

type MongoQueryResult struct {
	Result interface{} `json:"result"`
	Error  error       `json:"error"`
}

MongoQueryResult used to manage Mongo query results from channels

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc func(*DAL) gin.HandlerFunc
}

Route is the information for every URI.

type Routes

type Routes []Route

Routes is the list of the generated Route.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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