Skip to content

Commit

Permalink
fix Trigger and TriggerPrototype struct
Browse files Browse the repository at this point in the history
  • Loading branch information
hkobayash committed Dec 1, 2023
1 parent a2fbd82 commit ca6e1c9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
8 changes: 7 additions & 1 deletion trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Trigger struct {

Priority SeverityType `json:"priority,string"`
Status StatusType `json:"status,string"`
Dependencies Triggers `json:"dependencies,omitempty"`
Dependencies TriggerIDs `json:"dependencies,omitempty"`
Functions TriggerFunctions `json:"functions,omitempty"`
// Items contained by the trigger in the items property.
ContainedItems Items `json:"items,omitempty"`
Expand All @@ -73,6 +73,12 @@ type Trigger struct {
// Triggers is an array of Trigger
type Triggers []Trigger

type TriggerID struct {
TriggerID string `json:"triggerid"`
}

type TriggerIDs []TriggerID

// TriggersGet Wrapper for trigger.get
// https://www.zabbix.com/documentation/3.2/manual/api/reference/trigger/get
func (api *API) TriggersGet(params Params) (res Triggers, err error) {
Expand Down
36 changes: 21 additions & 15 deletions trigger_prototype.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package zabbix
// TriggerPrototype represent Zabbix trigger prototype object
// https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/object
type TriggerPrototype struct {
TriggerID string `json:"triggerid,omitempty"` // Readonly
Description string `json:"description"` // Reqired
Expression string `json:"expression"` // Required
Commemts string `json:"comments,omitempty"`
Priority SeverityType `json:"priority,omitempty,string"`
Status StatusType `json:"status,omitempty,string"`
TemplateID string `json:"templateid,omitempty"` // Readonly
Type int `json:"type,omitempty,string"`
URL string `json:"url,omitempty"`
RecoveryMode int `json:"recovery_mode,omitempty,string"`
RecoveryExpression string `json:"recovery_expression,omitempty"`
CorrelationMode int `json:"correlation_mode,omitempty,string"`
CorrelationTag string `json:"correlation_tag,omitempty"`
ManualClose int `json:"manual_close,omitempty,string"`
Dependencies TriggerPrototypes `json:"dependencies,omitempty"`
TriggerID string `json:"triggerid,omitempty"` // Readonly
Description string `json:"description"` // Required
Expression string `json:"expression"` // Required
Commemts string `json:"comments,omitempty"`
Priority SeverityType `json:"priority,omitempty,string"`
Status StatusType `json:"status,omitempty,string"`
TemplateID string `json:"templateid,omitempty"` // Readonly
Type int `json:"type,omitempty,string"`
URL string `json:"url,omitempty"`
RecoveryMode int `json:"recovery_mode,omitempty,string"`
RecoveryExpression string `json:"recovery_expression,omitempty"`
CorrelationMode int `json:"correlation_mode,omitempty,string"`
CorrelationTag string `json:"correlation_tag,omitempty"`
ManualClose int `json:"manual_close,omitempty,string"`
Dependencies TriggerPrototypeIDs `json:"dependencies,omitempty"`

Functions TriggerFunctions `json:"functions,omitempty"`
// Return the hosts that the trigger prototype belongs to in the hosts property.
Expand All @@ -27,6 +27,12 @@ type TriggerPrototype struct {
// TriggerPrototypes is an array of TriggerPrototype
type TriggerPrototypes []TriggerPrototype

type TriggerPrototypeID struct {
TriggerID string `json:"triggerid"`
}

type TriggerPrototypeIDs []TriggerPrototypeID

// TriggerPrototypesGet Wrapper for trigger.get
// https://www.zabbix.com/documentation/3.2/manual/api/reference/triggerprototype/get
func (api *API) TriggerPrototypesGet(params Params) (res TriggerPrototypes, err error) {
Expand Down

0 comments on commit ca6e1c9

Please sign in to comment.