infocmdb

package
v1.1.1-0...-115938a Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_CI_TYPE   = "ci type"
	TYPE_ATTRIBUTE = "attribute"
	TYPE_RELATION  = "relation"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeGroupParams

type AttributeGroupParams struct {
	Name                     string
	Description              string
	Note                     string
	OrderNumber              int
	ParentAttributeGroupName string
	IsDuplicateAllow         bool
	IsActive                 bool
	UserId                   int
}

type AttributeParams

type AttributeParams struct {
	Name                string
	Description         string
	Note                string
	Hint                string
	AttributeType       AttributeType
	AttributeGroupName  string
	OrderNumber         int
	Column              Columns //values in db enum('1','2')
	IsUnique            bool
	IsNumeric           bool
	IsBold              bool
	IsEvent             bool
	IsUniqueCheck       bool
	IsAutocomplete      bool
	IsMultiselect       Multiselect //values in db enum('0','1','2')
	IsProjectRestricted bool
	Regex               string
	ScriptName          string
	InputMaxlength      int
	TextareaCols        int
	TextareaRows        int
	IsActive            bool
	Historicize         bool
	UserId              int
}

type AttributeType

type AttributeType int
const (
	AT_INPUT AttributeType = iota + 1
	AT_TEXTAREA
	AT_TEXTEDIT
	AT_SELECTFIELD
	AT_CHECKBOX
	AT_RADIO
	AT_DATE
	AT_DATETIME
	AT_ZAHLUNGSMITTEL
	AT_PASSWORD
	AT_LINK
	AT_ATTACHMENT
	AT_SCRIPT
	AT_EXECUTEABLE
	AT_QUERY
	AT_CITYPE
	AT_INFO
	AT_QUERYPERSIST
	AT_CITYPEPERSIST
	AT_FILTER
	AT_SELECTQUERY
	AT_SELECTPOPUP
)

type BindError

type BindError struct {
	Msg       string
	FieldName string
	SrcName   string
	SrcType   string
	SrcValue  string
}

func (*BindError) Error

func (e *BindError) Error() string

type Ci

type Ci struct {
	CiID               int    `json:"ci_id,string"`
	CiTypeID           int    `json:"ci_type_id,string"`
	CiType             string `json:"ci_type"`
	ProjectsAsString   string `json:"project"`
	ProjectIDsAsString string `json:"project_id"`
	Projects           []string
	ProjectIDs         []int
}

type CiAttribute

type CiAttribute struct {
	CiID                 int    `json:"ci_id,string"`
	CiAttributeID        int    `json:"ci_attribute_id,string"`
	AttributeID          int    `json:"attribute_id,string"`
	AttributeName        string `json:"attribute_name"`
	AttributeDescription string `json:"attribute_description"`
	AttributeType        string `json:"attribute_type"`
	Value                string `json:"value"`
	ModifiedAt           string `json:"modified_at"`
}

type CiAttributes

type CiAttributes = []CiAttribute

type CiIds

type CiIds []int

type CiTypeParams

type CiTypeParams struct {
	Name           string
	Description    string
	Note           string
	ParentCiTypeId int
	OrderNumber    int

	DefaultProjectId int

	IsCiAttach        int
	IsAttributeAttach int

	IsActive int
	// contains filtered or unexported fields
}

type Client

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

Client combines connectivity methods for version 1 and 2 of the cmdb

func NewClient

func NewClient() (c *Client)

NewClient returns a new cmdb client

func (*Client) AddCiProjectMapping

func (c *Client) AddCiProjectMapping(ciID int, projectID int, historyID int) (err error)

func (*Client) AttributeBasedRelation

func (c *Client) AttributeBasedRelation(sourceCiId int, attributeName string, ciRelationTypeName string, triggerType string, swapCiColumns bool) (relationCisAdded []int, relationCisRemoved []int, err error)

func (*Client) CiBasedRelation

func (c *Client) CiBasedRelation(srcCiId int, destCiId []int, ciRelationTypeName string, triggerType string, swapCiColumns bool) (relationCisAdded []int, relationCisRemoved []int, err error)

noinspection GoUnusedParameter preserved to remain backwards compatible

func (*Client) CreateAttribute

func (c *Client) CreateAttribute(attributeParams *AttributeParams) (attributeId int, err error)

func (*Client) CreateAttributeGroup

func (c *Client) CreateAttributeGroup(attributeGroupParams *AttributeGroupParams) (attributeGroupId int, err error)

func (*Client) CreateCi

func (c *Client) CreateCi(ciTypeID int, icon string, historyID int) (r CreateCi, err error)

func (*Client) CreateCiRelation

func (c *Client) CreateCiRelation(ciId1 int, ciId2 int, ciRelationTypeName string, direction v2.CiRelationDirection) (err error)

func (*Client) CreateCiType

func (c *Client) CreateCiType(typeParams *CiTypeParams) (typeId int, err error)

func (*Client) DeleteCi

func (c *Client) DeleteCi(ciId int, userId int, message string) (err error)

func (*Client) DeleteCiRelation

func (c *Client) DeleteCiRelation(ciId1 int, ciId2 int, ciRelationTypeName string) (err error)

func (*Client) GetAndBindCi

func (c *Client) GetAndBindCi(ciId int, out interface{}) (err error)

func (*Client) GetAndBindCiByAttributeValue

func (c *Client) GetAndBindCiByAttributeValue(name string, value string, valueType v2.AttributeValueType, out interface{}) (err error)

func (*Client) GetAndBindCiByAttributeValueCi

func (c *Client) GetAndBindCiByAttributeValueCi(name string, value string, out interface{}) (err error)

func (*Client) GetAndBindCiByAttributeValueText

func (c *Client) GetAndBindCiByAttributeValueText(name string, value string, out interface{}) (err error)

func (*Client) GetAndBindListOfCis

func (c *Client) GetAndBindListOfCis(ciIds []int, out interface{}) (err error)

func (*Client) GetAndBindListOfCisOfCiTypeName

func (c *Client) GetAndBindListOfCisOfCiTypeName(ciTypeName string, out interface{}) (err error)

func (*Client) GetAttrDefaultOptionIdByAttrId

func (c *Client) GetAttrDefaultOptionIdByAttrId(attrId int, optionValue string) (attrDefaultOptionId int, err error)

func (*Client) GetAttrDefaultOptionIdByAttrName

func (c *Client) GetAttrDefaultOptionIdByAttrName(attrName string, optionValue string) (attrDefaultOptionId int, err error)

func (*Client) GetAttributeDefaultOption

func (c *Client) GetAttributeDefaultOption(optionId int) (r string, err error)

func (*Client) GetAttributeGroupIdByName

func (c *Client) GetAttributeGroupIdByName(attributeGroupName string) (attGroupId int, err error)

func (*Client) GetAttributeIdByAttributeName

func (c *Client) GetAttributeIdByAttributeName(name string) (attrId int, err error)

func (*Client) GetCi

func (c *Client) GetCi(ciID int) (r Ci, err error)

func (*Client) GetCiAttributeValue

func (c *Client) GetCiAttributeValue(ciId int, attributeName string, valueType v2.AttributeValueType) (r GetCiAttributeValue, err error)

func (*Client) GetCiAttributeValueCi

func (c *Client) GetCiAttributeValueCi(ciId int, attributeName string) (value string, id int, err error)

func (*Client) GetCiAttributeValueDate

func (c *Client) GetCiAttributeValueDate(ciId int, attributeName string) (value string, id int, err error)

func (*Client) GetCiAttributeValueDefault

func (c *Client) GetCiAttributeValueDefault(ciId int, attributeName string) (value string, id int, err error)

func (*Client) GetCiAttributeValueText

func (c *Client) GetCiAttributeValueText(ciId int, attributeName string) (value string, id int, err error)

func (*Client) GetCiAttributes

func (c *Client) GetCiAttributes(ciId int) (ciAttributes CiAttributes, err error)

func (*Client) GetCiIdByAttributeValue

func (c *Client) GetCiIdByAttributeValue(name string, value string, valueType v2.AttributeValueType) (ciId int, err error)

func (*Client) GetCiRelationCount

func (c *Client) GetCiRelationCount(ciId1 int, ciId2 int, ciRelationTypeName string) (r int, err error)

func (*Client) GetCiRelationTypeIdByRelationTypeName

func (c *Client) GetCiRelationTypeIdByRelationTypeName(name string) (r int, err error)

func (*Client) GetCiTypeIdByCiTypeName

func (c *Client) GetCiTypeIdByCiTypeName(name string) (r int, err error)

func (*Client) GetCiTypeName

func (c *Client) GetCiTypeName(ciId int) (ciTypeName string, err error)

func (*Client) GetListOfCiIdsByAttributeValue

func (c *Client) GetListOfCiIdsByAttributeValue(name string, value string, valueType v2.AttributeValueType) (ciIds CiIds, err error)

func (*Client) GetListOfCiIdsByCiRelation

func (c *Client) GetListOfCiIdsByCiRelation(ciId int, ciRelationTypeName string, direction v2.CiRelationDirection) (r CiIds, err error)

func (*Client) GetListOfCiIdsOfCiType

func (c *Client) GetListOfCiIdsOfCiType(ciTypeID int) (ciIds CiIds, err error)

func (*Client) GetListOfCiIdsOfCiTypeName

func (c *Client) GetListOfCiIdsOfCiTypeName(ciTypeName string) (ciIds CiIds, err error)

func (*Client) GetListOfCiIdsOfCiTypeV2

func (c *Client) GetListOfCiIdsOfCiTypeV2(ciTypeID int) (ciIds CiIds, err error)

func (*Client) GetListOfRelationsByName

func (c *Client) GetListOfRelationsByName(name string) (relations []Relation, err error)

func (*Client) GetMapOfCiAttributes

func (c *Client) GetMapOfCiAttributes(ciIds []int) (ciIdToAttributesMap map[int]CiAttributes, err error)

func (*Client) GetProjectIdByProjectName

func (c *Client) GetProjectIdByProjectName(name string) (projectID int, err error)

func (*Client) GetRoleIdByName

func (c *Client) GetRoleIdByName(roleName string) (roleId int, err error)

func (*Client) GetWorkflowContext

func (c *Client) GetWorkflowContext(workflowInstanceId int) (workflowContext *v2.WorkflowContext, err error)

func (*Client) LoadConfig

func (c *Client) LoadConfig(path string) (err error)

LoadConfig from file in yaml format

func (*Client) NewAttributeGroupParams

func (c *Client) NewAttributeGroupParams() (params *AttributeGroupParams)

func (*Client) NewAttributeParams

func (c *Client) NewAttributeParams() (params *AttributeParams)

func (*Client) NewCiTypeParams

func (c *Client) NewCiTypeParams() (params *CiTypeParams)

func (*Client) Query

func (c *Client) Query(ws string, out interface{}, params map[string]string) (err error)

Query allows you to call a generic webservice(arg1: ws) with the providing params and a reference to a result. It will take the built in resty function to deserialize the result Return: error

func (*Client) QueryWebservice

func (c *Client) QueryWebservice(ws string, params map[string]string) (resp string, err error)

QueryWebservices allows you to call a generic webservice(arg1: ws) with the providing params Return: json string

func (*Client) SendNotification

func (c *Client) SendNotification(name string, par v1.NotifyParams) (resp v1.NotificationResponse, err error)

func (*Client) SetAttributeRole

func (c *Client) SetAttributeRole(attributeName string, roleName string, permission string) (err error)

func (*Client) SetTypeOfCi

func (c *Client) SetTypeOfCi(ciId int, ciType string) (err error)

func (*Client) UpdateCiAttribute

func (c *Client) UpdateCiAttribute(ci int, ua []v2.UpdateCiAttribute) (err error)

func (*Client) UploadFile

func (c *Client) UploadFile(file interface{}) (uploadId string, err error)

Supported file data types are `string`, `[]byte` and `io.Reader`. The returned uploadId can be used for attachment attributes in the `UpdateCiAttribute` function.

type Columns

type Columns int
const (
	C_ONE Columns = iota + 1
	C_TWO
)

type Config

type Config struct {
	ApiUrl       string `yaml:"apiUrl"`
	ApiUser      string `yaml:"apiUser"`
	ApiPassword  string `yaml:"apiPassword"`
	ApiKey       string
	CmdbBasePath string `yaml:"CmdbBasePath"`
}

Client configuration values. Usually taken from data/configs/workflows/infocmdb.yml

type CreateCi

type CreateCi struct {
	ID        int    `json:"id,string"`
	CiTypeID  int    `json:"ci_type_id,string"`
	Icon      string `json:"icon"`
	HistoryID int    `json:"history_id,string"`
	ValidFrom string `json:"valid_from"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type GetCiAttributeValue

type GetCiAttributeValue struct {
	Data []struct {
		ID    string `json:"id"`
		Value string `json:"v"`
	} `json:"data"`
}

type IntWrapper

type IntWrapper int

func (*IntWrapper) UnmarshalJSON

func (iw *IntWrapper) UnmarshalJSON(b []byte) error

type Multiselect

type Multiselect int
const (
	MS_ZERO Multiselect = iota
	MS_ONE
	MS_TWO
)

type Precondition

type Precondition struct {
	Type PreconditionType
	Name string
}

Single workflow requirement.

type PreconditionType

type PreconditionType string

Type of the precondition that will be tested for existence.

type Preconditions

type Preconditions []Precondition

List of workflow requirements.

type Relation

type Relation struct {
	Id        int
	CiId1     int
	CiId2     int
	Direction v2.CiRelationDirection
}

type Workflow

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

Helper struct that encapsulates everything that is necessary to run or test a workflow.

func NewWorkflow

func NewWorkflow() Workflow

Creates a new workflow with default configuration.

func (Workflow) Run

func (w Workflow) Run(workflowFunc WorkflowFunc)

Executes a workflow.

First a infoCMDB client instance is created and the workflow parameters are parsed. The workflow parameters are decoded from the first process argument if available. Absence of any process argument will lead to a failure. For development/testing an empty json object "{}" can be passed.

If everything is successful the workflow function will be executed with the prepared parameters and client.

Any errors that are returned from the workflow function will be logged and lead to a execution failure. Additionally the workflow will be marked as failed when something is printed to Stderr during execution.

func (*Workflow) SetConfig

func (w *Workflow) SetConfig(config string)

Changes the configuration file used by the infocmdb client.

func (Workflow) TestPreconditions

func (w Workflow) TestPreconditions(t *testing.T, preconditions Preconditions)

Executes an existence check test for every supplied precondition.

type WorkflowFunc

type WorkflowFunc func(params WorkflowParams, cmdb *Client) (err error)

User defined workflow function that can be passed to `workflow.Run`.

type WorkflowParams

type WorkflowParams struct {
	Apikey              string `json:"apikey"`
	TriggerType         string `json:"triggerType"`
	WorkflowItemId      int    `json:"workflow_item_id"`
	WorkflowInstanceId  int    `json:"workflow_instance_id"`
	CiId                int    `json:"ciid"`
	CiAttributeId       int    `json:"ciAttributeId"`
	CiRelationId        int    `json:"ciRelationId"`
	CiProjectId         int    `json:"ciProjectId"`
	FileImportHistoryId int    `json:"fileImportHistoryId"`
	UserId              int    `json:"user_id"`
}

Input parameters to a workflow. These are usually passed encoded as a json string as first process argument. These are supplied to the `WorkflowFunc` of `workflow.Run`.

type WorkflowParamsHelper

type WorkflowParamsHelper struct {
	Apikey              string     `json:"apikey"`
	TriggerType         string     `json:"triggerType"`
	WorkflowItemId      int        `json:"workflow_item_id"`
	WorkflowInstanceId  int        `json:"workflow_instance_id"`
	CiId                IntWrapper `json:"ciid"`
	CiAttributeId       IntWrapper `json:"ciAttributeId"`
	CiRelationId        int        `json:"ciRelationId"`
	CiProjectId         int        `json:"ciProjectId"`
	FileImportHistoryId int        `json:"fileImportHistoryId"`
	UserId              IntWrapper `json:"user_id"`
}

Directories

Path Synopsis
v1
v2

Jump to

Keyboard shortcuts

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