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
- Variables
- type Auth
- type Data
- type Employee
- type EmployeeDB
- func (e *EmployeeDB) ConnectDB() (*mongo.Client, error)
- func (e *EmployeeDB) CreateEmployee(employee *Employee) error
- func (e *EmployeeDB) DeleteEmployeeByID(id int) error
- func (e *EmployeeDB) GetAllEmployees() ([]*Employee, error)
- func (e *EmployeeDB) GetCollection() (*mongo.Collection, error)
- func (e *EmployeeDB) GetEmployeeByID(id int) (*Employee, error)
- func (e *EmployeeDB) GetMongoCredFromVault() (*SecretData, error)
- func (e *EmployeeDB) RequestValidator(data interface{}) ValidationErrors
- func (e *EmployeeDB) UpdateEmployee(employee *Employee) error
- type RedisCache
- type SecretData
- type Validation
- type ValidationError
- type ValidationErrors
- type Vault
- type VaultData
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 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) 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
type SecretData ¶
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
Click to show internal directories.
Click to hide internal directories.