database

package
v0.0.0-...-28e7d11 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package classification of Employee API

Documentation for Employee API

Schemes: http
BasePath: /api
Version: 1.0.0

Consumes:
 - application/json

Produces:
 - application/json

Index

Constants

View Source
const (
	VAULT_AUTH_LOGIN  = "auth/kubernetes/login"
	VAULT_SECRET_DATA = "secret/data/webapp/config"
	VAULT_ROLE        = "webapp"

	MONGODB_CONNECTION_STRING = "mongodb://mongod-0.mongodb-service.default.svc.cluster.local"
	MONGODB_DATABASE          = "records"
	MONGODB_COLLECTION        = "employees"

	MONGODB_COLLECTION_ID         = "id"
	MONGODB_COLLECTION_NAME       = "name"
	MONGODB_COLLECTION_EMAIL      = "email"
	MONGODB_COLLECTION_COMPANY    = "company"
	MONGODB_COLLECTION_OCCUPATION = "occupation"
	MONGODB_COLLECTION_SALARY     = "salary"
)
View Source
const (
	LOCAL_ADDR  = "172.17.0.2:31594"
	SERVER_ADDR = "redis.default.svc.cluster.local:6379"
)

Variables

View Source
var EmployeeAlreadyExists = fmt.Errorf("Employee already exists")
View Source
var ErrEmployeeNotFound = fmt.Errorf("Employee not found")

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Client_Token string
}

type Data

type Data struct {
	Data SecretData
}

type Employee

type Employee struct {
	ID         int    `json:"id" validate:"required,gt=99"`
	Name       string `json:"name" validate:"required"`
	Email      string `json:"email" validate:"required,email"`
	Company    string `json:"company" validate:"required"`
	Occupation string `json:"occupation" validate:"required"`
	Salary     string `json:"salary" validate:"required"`
}

Employee Schema structure

type EmployeeDB

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

func InitializeDBManager

func InitializeDBManager(log hclog.Logger) *EmployeeDB

func (*EmployeeDB) ConnectDB

func (e *EmployeeDB) ConnectDB() (*mongo.Client, error)

func (*EmployeeDB) CreateEmployee

func (e *EmployeeDB) CreateEmployee(employee *Employee) error

CreateEmployee method

func (*EmployeeDB) DeleteEmployeeByID

func (e *EmployeeDB) DeleteEmployeeByID(id int) error

DeleteEmployeeByID

func (*EmployeeDB) GetAllEmployees

func (e *EmployeeDB) GetAllEmployees() ([]*Employee, error)

GetAllEmployees method

func (*EmployeeDB) GetCollection

func (e *EmployeeDB) GetCollection() (*mongo.Collection, error)

func (*EmployeeDB) GetEmployeeByID

func (e *EmployeeDB) GetEmployeeByID(id int) (*Employee, error)

GetEmployeeByID method

func (*EmployeeDB) GetMongoCredFromVault

func (e *EmployeeDB) GetMongoCredFromVault() (*SecretData, error)

GetMongoCredFromVault

func (*EmployeeDB) RequestValidator

func (e *EmployeeDB) RequestValidator(data interface{}) ValidationErrors

func (*EmployeeDB) UpdateEmployee

func (e *EmployeeDB) UpdateEmployee(employee *Employee) error

UpdateEmployee

type RedisCache

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

func InitializeCacheClient

func InitializeCacheClient() (*RedisCache, error)

func (*RedisCache) Del

func (c *RedisCache) Del(key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(key string) (*Employee, error)

func (*RedisCache) Set

func (c *RedisCache) Set(key string, value *Employee) error

type SecretData

type SecretData struct {
	Username string
	Password string
}

type Validation

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

type ValidationError

type ValidationError struct {
	validator.FieldError
}

func (ValidationError) Error

func (v ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func Validate

func Validate(data interface{}) ValidationErrors

func (ValidationErrors) Errors

func (v ValidationErrors) Errors() []string

type Vault

type Vault struct {
	Auth Auth
}

type VaultData

type VaultData struct {
	Data Data
}

Jump to

Keyboard shortcuts

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