Documentation ¶
Index ¶
- Variables
- type AttributeValueType
- type CiRelationDirection
- type Cmdb
- func (i *Cmdb) CallWebservice(method string, service string, serviceName string, params url.Values, ...) (err error)
- func (i *Cmdb) LoadConfig(config Config)
- func (i *Cmdb) LoadConfigFile(path string) (err error)
- func (i *Cmdb) Login() error
- func (i *Cmdb) LoginWithApiKey(url string, apikey string) error
- func (i *Cmdb) LoginWithUserPass(apiUrl string, username string, password string) error
- func (i *Cmdb) SendNotification(notifyName string, params NotifyParams) (resp NotificationResponse, err error)
- func (i *Cmdb) Webservice(ws string, params url.Values) (r string, err error)
- type Config
- type NotificationResponse
- type NotifyParams
- type ResponseStatus
- type ResultLogin
- type SendNotificationData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailedToCreateInfoCMDB = errors.New("failed to create infocmdb object") ErrNoCredentials = errors.New("must provide credentials") ErrNotImplemented = errors.New("not implemented") ErrNoResult = errors.New("query returned no result") ErrTooManyResults = errors.New("query returned to many results, expected one") ErrWebserviceResponseNotOk = errors.New("webservice response was not ok") )
View Source
var (
ErrLoginFailed = errors.New("login status not ok")
)
Functions ¶
This section is empty.
Types ¶
type AttributeValueType ¶
type AttributeValueType string
const ( ATTRIBUTE_VALUE_TYPE_TEXT AttributeValueType = "value_text" ATTRIBUTE_VALUE_TYPE_DATE AttributeValueType = "value_date" ATTRIBUTE_VALUE_TYPE_DEFAULT AttributeValueType = "value_default" ATTRIBUTE_VALUE_TYPE_CI AttributeValueType = "value_ci" )
type CiRelationDirection ¶
type CiRelationDirection string
const ( CI_RELATION_DIRECTION_ALL CiRelationDirection = "all" CI_RELATION_DIRECTION_DIRECTED_FROM CiRelationDirection = "directed_from" CI_RELATION_DIRECTION_DIRECTED_TO CiRelationDirection = "directed_to" CI_RELATION_DIRECTION_BIDIRECTIONAL CiRelationDirection = "bidirectional" CI_RELATION_DIRECTION_OMNIDIRECTIONAL CiRelationDirection = "omnidirectional" )
type Cmdb ¶
type Cmdb struct { Config Config Cache *cache.Cache }
func (*Cmdb) CallWebservice ¶
func (i *Cmdb) CallWebservice(method string, service string, serviceName string, params url.Values, variable interface{}) (err error)
Example (Post_query) ¶
cmdb := Cmdb{} utilTesting.New().SetValidConfig(&cmdb.Config) params := url.Values{ "argv1": {"1"}, } ret := "" err := cmdb.CallWebservice(http.MethodPost, "query", "int_getListOfCiIdsOfCiType", params, &ret) if err != nil { log.Error(err) return } fmt.Println("Post: ", ret)
Output: Post: {"status":"OK","data":[{"ciid":"1"},{"ciid":"2"}]}
func (*Cmdb) LoadConfig ¶
func (*Cmdb) LoadConfigFile ¶
Example (Fail) ¶
i := Cmdb{} err := i.LoadConfigFile("/test_missing.yml") if err != nil { fmt.Println("loading failed") return } fmt.Printf("Config: %v\n", i.Config) fmt.Printf("BasePath: %s\n", i.Config.CmdbBasePath)
Output: loading failed
func (*Cmdb) Login ¶
Example ¶
cmdb := Cmdb{} utilTesting.New().SetValidConfig(&cmdb.Config) err := cmdb.Login() if err != nil { log.Error(err) return } fmt.Printf("Login ok, ApiKey(len): %d\n", len(cmdb.Config.ApiKey))
Output: Login ok, ApiKey(len): 30
Example (With_ApiKey) ¶
cmdb := Cmdb{} utilTesting.New().SetValidConfig(&cmdb.Config) err := cmdb.Login() if err != nil { log.Error(err) return } fmt.Printf("Login ok, ApiKey(len): %d\n", len(cmdb.Config.ApiKey))
Output: Login ok, ApiKey(len): 30
func (*Cmdb) LoginWithUserPass ¶
func (*Cmdb) SendNotification ¶
func (i *Cmdb) SendNotification(notifyName string, params NotifyParams) (resp NotificationResponse, err error)
func (*Cmdb) Webservice ¶
Webservice queries a given webservice with all params supplied Returns err != nil if query fails
Example (Int_getListOfCiIdsOfCiType) ¶
cmdb := Cmdb{} utilTesting.New().SetValidConfig(&cmdb.Config) err := cmdb.Login() if err != nil { log.Error(err) return } params := url.Values{} params.Add("argv1", "1") ret, err := cmdb.Webservice("int_getListOfCiIdsOfCiType", params) if err != nil { log.Error(err) return } fmt.Printf("Return: %v\n", ret)
Output: Return: {"status":"OK","data":[{"ciid":"1"},{"ciid":"2"}]}
type NotificationResponse ¶
type NotificationResponse struct {
SentTo []SendNotificationData
}
type NotifyParams ¶
type ResponseStatus ¶
type ResponseStatus struct {
Status string `json:"status"`
}
type ResultLogin ¶
type SendNotificationData ¶
Click to show internal directories.
Click to hide internal directories.