Documentation ¶
Index ¶
- func AddCI(c *gin.Context)
- func AddCIDB(ci CI) (string, error)
- func AddCIMD(c *gin.Context)
- func AddCIMDDB(cimd CIMD) error
- func AddDoc(c *gin.Context)
- func AddDocDB(doc Doc) (string, error)
- func AddHW(c *gin.Context)
- func AddHWDB(hw HW) (string, error)
- func AddLoc(c *gin.Context)
- func AddLocDB(loc Loc) (string, error)
- func AddNetConf(c *gin.Context)
- func AddNetConfDB(netconf Netconf) (string, error)
- func AddNetSeg(c *gin.Context)
- func AddNetSegDB(netseg Netseg) (string, error)
- func AddSW(c *gin.Context)
- func AddSWDB(sw SW) (string, error)
- func AddUser(c *gin.Context)
- func AddUserDB(user User) (string, error)
- func CheckPasswordHash(password, hash string) bool
- func CreateDB(basepath string, passwd string) error
- func CreateRandomString() string
- func CreateUUIDString() (string, error)
- func HashPassword(password string) (string, error)
- func HelloHandler(c *gin.Context)
- func InitDB(dbpath string)
- func MyAuthenticator(c *gin.Context) (interface{}, error)
- func ReadConfig() (string, error)
- func Serv()
- func WriteConfig(dbinstpath string) error
- type CI
- type CIMD
- type Doc
- type HW
- type Loc
- type Netconf
- type Netseg
- type SW
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCI ¶
AddCI godoc @Summary Add a configuration item @Accept json @Produce json @Param CI body CI true "configuration item" @Success 200 {string} string "added configuration item" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addci [post]
func AddCIMD ¶
AddCIMD godoc @Summary Add metadata to an existing configuration item @Accept json @Produce json @Param CIMD body CIMD true "configuration item metadata" @Success 200 {string} string "added configuration item for metadata" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addcimd [post]
func AddDoc ¶
AddDoc godoc @Summary Add document info to an existing configuration item @Accept json @Produce json @Param Doc body Doc true "document data" @Success 200 {string} string "added document data" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/adddoc [post]
func AddHW ¶
AddHW godoc @Summary Add hardware to an existing configuration item @Accept json @Produce json @Param HW body HW true "hardware" @Success 200 {string} string "added hardware info" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addhw [post]
func AddLoc ¶
AddLoc godoc @Summary Add location data @Accept json @Produce json @Param Loc body Loc true "location data" @Success 200 {string} string "added location" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addloc [post]
func AddNetConf ¶
AddNetConf godoc @Summary Add network config to an existing configuration item @Accept json @Produce json @Param Netconf body Netconf true "network configuration" @Success 200 {string} string "added network configuration" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addnetconf [post]
func AddNetConfDB ¶
AddNetConfDB adds network configuration to a configuration item into the netconfigurations table
func AddNetSeg ¶
AddNetSeg godoc @Summary Add network segment info to an existing configuration item @Accept json @Produce json @Param Netseg body Netseg true "net segment configuration" @Success 200 {string} string "added network segment configuration" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addnetseg [post]
func AddNetSegDB ¶
AddNetSegDB adds network segment info to a configuration item into the netsegments table
func AddSW ¶
AddSW godoc @Summary Add software to an existing configuration item @Accept json @Produce json @Param SW body SW true "software" @Success 200 {string} string "added software info" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addsw [post]
func AddUser ¶
AddUser godoc @Summary Add user @Accept json @Produce json @Param User body User true "user" @Success 200 {string} string "added user" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/adduser [post]
func CheckPasswordHash ¶
CheckPasswordHash compares a string to its hash
func CreateRandomString ¶
func CreateRandomString() string
CreateRandomString generates a random string. Used for passwords set at installation time
func CreateUUIDString ¶
CreateUUIDString generates a UUIDv4 string used evereywhere in tinycmdb
func HashPassword ¶
HashPassword generates a bcrypt hash from a string
func HelloHandler ¶
HelloHandler godoc @Summary Show userID and put Hello World in response body when authorized @Accept json @Produce json @Success 200 {string} string "print hello world a user login" @Failure 401 {object} string "401" @Security ApiKeyAuth @Router /auth/hello [get]
func InitDB ¶
func InitDB(dbpath string)
InitDB is an init function that makes a db connection globally available
func MyAuthenticator ¶
MyAuthenticator godoc @Summary Authenticate user @Accept json @Produce json @Param login body login true "username and password" @Success 200 {string} string "login" @Failure 401 {object} string "401" @Router /login [post]
func ReadConfig ¶
ReadConfig reads the default config file that holds the database location
func WriteConfig ¶
WriteConfig writes the default config file that holds the database location
Types ¶
type CI ¶
type CI struct { UUID string `json:"uuid"` Shortname string `json:"shortname"` Longdesc string `json:"longdesc"` CIType string `json:"citype"` Tschg string `json:"tschg"` }
CI type contains info for a root ci entry and maps to the database table cis
type CIMD ¶
type CIMD struct { Manufacturer string `json:"manufacturer"` Serialno string `json:"serialno"` Productiondate string `json:"productiondate"` Purchasedate string `json:"purchasedate"` Activefrom string `json:"activefrom"` Activeto string `json:"activeto"` License string `json:"license"` Tschg string `json:"tschg"` Ciuuid string `json:"ciuuid"` }
CIMD type contains metadata for a root ci entry and maps to the database table cimetadata
type Doc ¶
type Doc struct { UUID string `json:""` Doctype string `json:""` Subject string `json:""` Citxt string `json:""` Scan string `json:""` Tschg string `json:""` Ciuuid string `json:""` }
Doc type is for simple documents and maps to the database table cidocs
type HW ¶
type HW struct { UUID string `json:"uuid"` Cpucount string `json:"cpucount"` Cputype string `json:"cputype"` Cpucores string `json:"cpucores"` Memorysize string `json:"memorysize"` Memorytype string `json:"memorytype"` Storagesize string `json:"storagesize"` Storagetype string `json:"storagetype"` Powerconsumption string `json:"powercons"` Tschg string `json:"tschg"` Ciuuid string `json:"ciuuid"` }
HW type is for hardware and maps to the database table hardware
type Loc ¶
type Loc struct { UUID string `json:"uuid"` Locname string `json:"locname"` Shortdesc string `json:"shortdesc"` Country string `json:"country"` City string `json:"city"` Street string `json:"street"` Number string `json:"number"` Room string `json:"room"` Row string `json:"row"` Shelf string `json:"shelf"` Rack string `json:"rack"` Misc string `json:"misc"` Uri string `json:"uri"` Tschg string `json:"tschg"` Ciuuid string `json:"ciuuid"` }
Loc type is for locations and maps to the database table locations
type Netconf ¶
type Netconf struct { UUID string `json:"uuid"` Ipaddr string `json:"ipaddr"` Macaddr string `json:"macaddr"` Subnet string `json:"subnet"` Gateway string `json:"gateway"` Dns string `json:"dns"` Dhcpd string `json:"dhcpd"` Ciuuid string `json:"ciuuid"` Tschg string `json:"tschg"` Netseguuid string `json:"netseguuid"` }
Netconf type is for network configurations of a configuration item and maps to the database table netconfs
type Netseg ¶
type Netseg struct { UUID string `json:"uuid"` Netname string `json:"netname"` Gateway string `json:"gateway"` Firstaddr string `json:"Firstaddr"` Lastaddr string `json:"Lastaddr"` Tschg string `json:"Tschg"` }
Netseg type is for network segments and maps to the database table netsegments
type SW ¶
type SW struct { UUID string `json:"uuid"` Shortname string `json:"shortname"` Longname string `json:"longname"` Manufacturer string `json:"manufacturer"` Version string `json:"version"` Patchlevel string `json:"patchlevel"` Year string `json:"year"` Platform string `json:"platform"` Tschg string `json:"tschg"` Ciuuid string `json:"ciuuid"` }
SW type is for software and maps to the database table software
type User ¶
type User struct { UUID string `json:"uuid"` Username string `json:"username"` Passwd string `json:"passwd"` Firstname string `json:"firstname"` Middlename string `json:"middlename"` Lastname string `json:"lastname"` Email string `json:"email"` Phone string `json:"phone"` Mobile string `json:"mobile"` Validfrom string `json:"validfrom"` Validto string `json:"validto"` Tschg string `json:"tschg"` }
User type contains info for a single user and maps to the database table users