diff --git a/README.md b/README.md index 568f25b..c6f9a7f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # nxs-go-zabbix -This Go package provides access to Zabbix API v4.4. +This Go package provides access to Zabbix API v5.0. +Also see older versions in other branches. At the time not all Zabbix API methods are implemented, but work in progress. ## Install ``` -go get github.com/nixys/nxs-go-zabbix/v4 +go get github.com/nixys/nxs-go-zabbix/v5 ``` ## Example of usage @@ -23,7 +24,7 @@ import ( "fmt" "os" - "github.com/nixys/nxs-go-zabbix/v4" + "github.com/nixys/nxs-go-zabbix/v5" ) func zabbixLogin(z *zabbix.Context, zbxHost, zbxUsername, zbxPassword string) { diff --git a/action.go b/action.go index 1447303..eccdd96 100644 --- a/action.go +++ b/action.go @@ -59,7 +59,7 @@ const ( // For `ActionOperationMessageObject` field: `DefaultMsg` const ( ActionOperationMessageDefaultMsgFromOperation = 0 - ActionOperationMessageDefaultMsgFromAction = 1 + ActionOperationMessageDefaultMsgFromMediaType = 1 ) // For `ActionOperationConditionObject` field: `ConditionType` @@ -141,18 +141,12 @@ const ( // ActionObject struct is used to store action operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action type ActionObject struct { ActionID int `json:"actionid,omitempty"` EscPeriod int `json:"esc_period"` Eventsource int `json:"eventsource"` Name string `json:"name"` - DefLongdata string `json:"def_longdata,omitempty"` - DefShortdata string `json:"def_shortdata,omitempty"` - RlongData string `json:"r_longdata,omitempty"` - RshortData string `json:"r_shortdata,omitempty"` - AckLongdata string `json:"ack_longdata,omitempty"` - AckShortdata string `json:"ack_shortdata,omitempty"` Status int `json:"status,omitempty"` // has defined consts, see above PauseSuppressed int `json:"pause_suppressed,omitempty"` // has defined consts, see above @@ -164,7 +158,7 @@ type ActionObject struct { // ActionOperationObject struct is used to store action operations // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_operation +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation type ActionOperationObject struct { OperationID int `json:"operationid,omitempty"` OperationType int `json:"operationtype"` // has defined consts, see above @@ -187,26 +181,24 @@ type ActionOperationObject struct { // ActionOperationCommandObject struct is used to store action operation commands // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_operation_command +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_command type ActionOperationCommandObject struct { - OperationID int `json:"operationid,omitempty"` - Command string `json:"command"` - Type int `json:"type"` // has defined consts, see above - AuthType int `json:"authtype,omitempty"` // has defined consts, see above - ExecuteOn int `json:"execute_on,omitempty"` // has defined consts, see above - Password string `json:"password,omitempty"` - Port string `json:"port,omitempty"` - PrivateKey string `json:"privatekey,omitempty"` - PublicKey string `json:"publickey,omitempty"` - ScriptID int `json:"scriptid,omitempty"` - UserName string `json:"username,omitempty"` + Command string `json:"command"` + Type int `json:"type"` // has defined consts, see above + AuthType int `json:"authtype,omitempty"` // has defined consts, see above + ExecuteOn int `json:"execute_on,omitempty"` // has defined consts, see above + Password string `json:"password,omitempty"` + Port string `json:"port,omitempty"` + PrivateKey string `json:"privatekey,omitempty"` + PublicKey string `json:"publickey,omitempty"` + ScriptID int `json:"scriptid,omitempty"` + UserName string `json:"username,omitempty"` } // ActionOperationMessageObject struct is used to store action operation messages // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_operation_message +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_message type ActionOperationMessageObject struct { - OperationID int `json:"operationid,omitempty"` DefaultMsg int `json:"default_msg,omitempty"` // has defined consts, see above MediatypeID int `json:"mediatypeid,omitempty"` Message string `json:"message,omitempty"` @@ -215,7 +207,7 @@ type ActionOperationMessageObject struct { // ActionOperationConditionObject struct is used to store action operation conditions // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_operation_condition +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_operation_condition type ActionOperationConditionObject struct { OpconditionID int `json:"opconditionid,omitempty"` ConditionType int `json:"conditiontype"` // has defined consts, see above @@ -226,7 +218,7 @@ type ActionOperationConditionObject struct { // ActionRecoveryOperationObject struct is used to store action recovery operations // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_recovery_operation +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_recovery_operation type ActionRecoveryOperationObject struct { OperationID int `json:"operationid"` OperationType int `json:"operationtype,omitempty"` // has defined consts, see above @@ -241,7 +233,7 @@ type ActionRecoveryOperationObject struct { // ActionUpdateOperationObject struct is used to store action update operations // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_update_operation +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_update_operation type ActionUpdateOperationObject struct { OperationID int `json:"operationid"` OperationType int `json:"operationtype,omitempty"` // has defined consts, see above @@ -255,7 +247,7 @@ type ActionUpdateOperationObject struct { // ActionFilterObject struct is used to store action filters // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_filter +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_filter type ActionFilterObject struct { Conditions []ActionFilterConditionObject `json:"conditions"` EvalType int `json:"evaltype"` // has defined consts, see above @@ -265,7 +257,7 @@ type ActionFilterObject struct { // ActionFilterConditionObject struct is used to store action filter conditions // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/object#action_filter_condition +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/object#action_filter_condition type ActionFilterConditionObject struct { ConditionID int `json:"conditionid,omitempty"` ConditionType int `json:"conditiontype"` // has defined consts, see above @@ -322,7 +314,7 @@ type ActionOpinventoryObject struct { // ActionGetParams struct is used for action get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/action/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/action/get#parameters type ActionGetParams struct { GetParameters diff --git a/action_test.go b/action_test.go index 557d6ed..aca069c 100644 --- a/action_test.go +++ b/action_test.go @@ -38,12 +38,10 @@ func testActionCreate(t *testing.T, z Context, hostgrpID, usergrpID int) []int { aCreatedIDs, _, err := z.ActionCreate([]ActionObject{ { - Name: testActionName, - Eventsource: 0, - Status: ActionStatusEnabled, - EscPeriod: testActionEscPeriod, - DefShortdata: testActionDefShortdata, - DefLongdata: testActionDefLongdata, + Name: testActionName, + Eventsource: 0, + Status: ActionStatusEnabled, + EscPeriod: testActionEscPeriod, Filter: ActionFilterObject{ EvalType: ActionFilterEvalTypeAndOr, Conditions: []ActionFilterConditionObject{ diff --git a/go.mod b/go.mod index d6e7bab..778278d 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module github.com/nixys/nxs-go-zabbix/v4 +module github.com/nixys/nxs-go-zabbix/v5 -go 1.13 +go 1.14 -require github.com/mitchellh/mapstructure v1.2.2 +require github.com/mitchellh/mapstructure v1.3.0 diff --git a/go.sum b/go.sum index 6526c4b..43df515 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -github.com/mitchellh/mapstructure v1.2.2 h1:dxe5oCinTXiTIcfgmZecdCzPmAJKd46KsCWc35r0TV4= -github.com/mitchellh/mapstructure v1.2.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.3.0 h1:iDwIio/3gk2QtLLEsqU5lInaMzos0hDTz8a6lazSFVw= +github.com/mitchellh/mapstructure v1.3.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= diff --git a/history.go b/history.go index 6dd58dc..55c3a14 100644 --- a/history.go +++ b/history.go @@ -13,7 +13,7 @@ const ( // HistoryFloatObject struct is used to store history float operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/object#float_history +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#float_history type HistoryFloatObject struct { Clock int `json:"clock,omitempty"` ItemID int `json:"itemid,omitempty"` @@ -23,7 +23,7 @@ type HistoryFloatObject struct { // HistoryIntegerObject struct is used to store history integer operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/object#integer_history +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#integer_history type HistoryIntegerObject struct { Clock int `json:"clock,omitempty"` ItemID int `json:"itemid,omitempty"` @@ -33,7 +33,7 @@ type HistoryIntegerObject struct { // HistoryStringObject struct is used to store history string operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/object#string_history +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#string_history type HistoryStringObject struct { Clock int `json:"clock,omitempty"` ItemID int `json:"itemid,omitempty"` @@ -43,7 +43,7 @@ type HistoryStringObject struct { // HistoryTextObject struct is used to store history text operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/object#text_history +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#text_history type HistoryTextObject struct { ID int `json:"id,omitempty"` Clock int `json:"clock,omitempty"` @@ -54,7 +54,7 @@ type HistoryTextObject struct { // HistoryLogObject struct is used to store history log operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/object#log_history +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/object#log_history type HistoryLogObject struct { ID int `json:"id,omitempty"` Clock int `json:"clock,omitempty"` @@ -69,7 +69,7 @@ type HistoryLogObject struct { // HistoryGetParams struct is used for history get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/history/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/history/get#parameters type HistoryGetParams struct { GetParameters diff --git a/history_test.go b/history_test.go index 80684be..2fd47ef 100644 --- a/history_test.go +++ b/history_test.go @@ -5,7 +5,7 @@ import ( ) const ( - testHistoryItemID = "44876" + testHistoryItemID = 45503 testHistoryType = 0 ) @@ -27,7 +27,7 @@ func testHistoryGet(t *testing.T, z Context) []HistoryFloatObject { hObjects, _, err := z.HistoryGet(HistoryGetParams{ History: HistoryObjectTypeFloat, - ItemIDs: []int{44876}, + ItemIDs: []int{testHistoryItemID}, GetParameters: GetParameters{ Limit: 1, }, diff --git a/host.go b/host.go index 51a883f..b7fac43 100644 --- a/host.go +++ b/host.go @@ -107,7 +107,7 @@ const ( // HostObject struct is used to store host operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/host/object#host +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/object#host type HostObject struct { HostID int `json:"hostid,omitempty"` Host string `json:"host,omitempty"` @@ -140,27 +140,26 @@ type HostObject struct { SnmpDisableUntil int `json:"snmp_disable_until,omitempty"` SnmpError string `json:"snmp_error,omitempty"` SnmpErrorsFrom int `json:"snmp_errors_from,omitempty"` - Status int `json:"status,omitempty"` // has defined consts, see above - - TLSConnect int `json:"tls_connect,omitempty"` // has defined consts, see above - TLSAccept int `json:"tls_accept,omitempty"` // has defined consts, see above - TLSIssuer string `json:"tls_issuer,omitempty"` - TLSSubject string `json:"tls_subject,omitempty"` - TLSPSKIdentity string `json:"tls_psk_identity,omitempty"` - TLSPSK string `json:"tls_psk,omitempty"` - - Groups []HostgroupObject `json:"groups,omitempty"` - Interfaces []HostinterfaceObject `json:"interfaces,omitempty"` - Tags []HostTagObject `json:"tags,omitempty"` - Macros []UsermacroObject `json:"macros,omitempty"` - - ParentTemplates []TemplateObject `json:"parentTemplates,omitempty"` // Used to store result for `get` operations - Templates []TemplateObject `json:"templates,omitempty"` // Used for `create` operations + Status int `json:"status,omitempty"` // has defined consts, see above + TLSConnect int `json:"tls_connect,omitempty"` // has defined consts, see above + TLSAccept int `json:"tls_accept,omitempty"` // has defined consts, see above + TLSIssuer string `json:"tls_issuer,omitempty"` + TLSSubject string `json:"tls_subject,omitempty"` + TLSPSKIdentity string `json:"tls_psk_identity,omitempty"` + TLSPSK string `json:"tls_psk,omitempty"` + + Groups []HostgroupObject `json:"groups,omitempty"` + Interfaces []HostinterfaceObject `json:"interfaces,omitempty"` + Tags []HostTagObject `json:"tags,omitempty"` + InheritedTags []HostTagObject `json:"inheritedTags,omitempty"` + Macros []UsermacroObject `json:"macros,omitempty"` + Templates []TemplateObject `json:"templates,omitempty"` // Used for `create` operations + ParentTemplates []TemplateObject `json:"parentTemplates,omitempty"` // Used to store result for `get` operations } // HostTagObject struct is used to store host tag // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/host/object#host_tag +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/object#host_tag type HostTagObject struct { Tag string `json:"tag"` Value string `json:"value,omitempty"` @@ -170,7 +169,7 @@ type HostTagObject struct { // HostGetParams struct is used for host get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/host/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/host/get#parameters type HostGetParams struct { GetParameters @@ -202,24 +201,28 @@ type HostGetParams struct { WithMonitoredTriggers bool `json:"with_monitored_triggers,omitempty"` WithSimpleGraphItems bool `json:"with_simple_graph_items,omitempty"` WithTriggers bool `json:"with_triggers,omitempty"` + WithProblemsSuppressed bool `json:"withProblemsSuppressed,omitempty"` Evaltype int `json:"evaltype,omitempty"` // has defined consts, see above + Severities []int `json:"severities,omitempty"` Tags []HostTagObject `json:"tags,omitempty"` - - SelectGroups SelectQuery `json:"selectGroups,omitempty"` - SelectApplications SelectQuery `json:"selectApplications,omitempty"` - SelectDiscoveries SelectQuery `json:"selectDiscoveries,omitempty"` - SelectDiscoveryRule SelectQuery `json:"selectDiscoveryRule ,omitempty"` - SelectGraphs SelectQuery `json:"selectGraphs,omitempty"` - SelectHostDiscovery SelectQuery `json:"selectHostDiscovery ,omitempty"` - SelectHTTPTests SelectQuery `json:"selectHttpTests,omitempty"` - SelectInterfaces SelectQuery `json:"selectInterfaces,omitempty"` - SelectInventory SelectQuery `json:"selectInventory,omitempty"` - SelectItems SelectQuery `json:"selectItems,omitempty"` + InheritedTags bool `json:"inheritedTags,omitempty"` + + // SelectApplications SelectQuery `json:"selectApplications,omitempty"` // not implemented yet + // SelectDiscoveries SelectQuery `json:"selectDiscoveries,omitempty"` // not implemented yet + // SelectDiscoveryRule SelectQuery `json:"selectDiscoveryRule ,omitempty"` // not implemented yet + // SelectGraphs SelectQuery `json:"selectGraphs,omitempty"` // not implemented yet + SelectGroups SelectQuery `json:"selectGroups,omitempty"` + // SelectHostDiscovery SelectQuery `json:"selectHostDiscovery ,omitempty"` // not implemented yet + // SelectHTTPTests SelectQuery `json:"selectHttpTests,omitempty"` // not implemented yet + SelectInterfaces SelectQuery `json:"selectInterfaces,omitempty"` + // SelectInventory SelectQuery `json:"selectInventory,omitempty"` // not implemented yet + // SelectItems SelectQuery `json:"selectItems,omitempty"` // not implemented yet SelectMacros SelectQuery `json:"selectMacros,omitempty"` SelectParentTemplates SelectQuery `json:"selectParentTemplates,omitempty"` - SelectScreens SelectQuery `json:"selectScreens,omitempty"` - SelectTags SelectQuery `json:"selectTags,omitempty"` - SelectTriggers SelectQuery `json:"selectTriggers,omitempty"` + // SelectScreens SelectQuery `json:"selectScreens,omitempty"` // not implemented yet + SelectTags SelectQuery `json:"selectTags,omitempty"` + SelectInheritedTags SelectQuery `json:"selectInheritedTags,omitempty"` + // SelectTriggers SelectQuery `json:"selectTriggers,omitempty"` // not implemented yet } // Structure to store creation result diff --git a/hostgroup.go b/hostgroup.go index 6ce59b6..9f98c3a 100644 --- a/hostgroup.go +++ b/hostgroup.go @@ -14,7 +14,7 @@ const ( // HostgroupObject struct is used to store hostgroup operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/hostgroup/object +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostgroup/object type HostgroupObject struct { GroupID int `json:"groupid,omitempty"` Name string `json:"name,omitempty"` @@ -27,7 +27,7 @@ type HostgroupObject struct { // HostgroupGetParams struct is used for hostgroup get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/hostgroup/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostgroup/get#parameters type HostgroupGetParams struct { GetParameters diff --git a/hostinterface.go b/hostinterface.go index d5b048c..a5718cf 100644 --- a/hostinterface.go +++ b/hostinterface.go @@ -20,33 +20,75 @@ const ( HostinterfaceUseipIP = 1 ) -// For `HostinterfaceObject` field: `Bulk` +// For `HostinterfaceDetailsTagObject` field: `Bulk` const ( - HostinterfaceBulkDontUse = 0 - HostinterfaceBulkUse = 1 + HostinterfaceDetailsTagBulkDontUse = 0 + HostinterfaceDetailsTagBulkUse = 1 +) + +// For `HostinterfaceDetailsTagObject` field: `Version` +const ( + HostinterfaceDetailsTagVersionSNMPv1 = 1 + HostinterfaceDetailsTagVersionSNMPv2c = 2 + HostinterfaceDetailsTagVersionSNMPv3 = 3 +) + +// For `HostinterfaceDetailsTagObject` field: `SecurityLevel` +const ( + HostinterfaceDetailsTagSecurityLevelNoAuthNoPriv = 0 + HostinterfaceDetailsTagSecurityLevelAuthNoPriv = 1 + HostinterfaceDetailsTagSecurityLevelAuthPriv = 2 +) + +// For `HostinterfaceDetailsTagObject` field: `AuthProtocol` +const ( + HostinterfaceDetailsTagAuthProtocolMD5 = 0 + HostinterfaceDetailsTagAuthProtocolSHA = 1 +) + +// For `HostinterfaceDetailsTagObject` field: `PrivProtocol` +const ( + HostinterfaceDetailsTagPrivProtocolDES = 0 + HostinterfaceDetailsTagPrivProtocolAES = 1 ) // HostinterfaceObject struct is used to store hostinterface operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/hostinterface/object#hostinterface +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object#hostinterface type HostinterfaceObject struct { - InterfaceID int `json:"interfaceid,omitempty"` - DNS string `json:"dns"` - HostID int `json:"hostid,omitempty"` - IP string `json:"ip"` - Main int `json:"main"` // has defined consts, see above - Port string `json:"port"` - Type int `json:"type"` // has defined consts, see above - UseIP int `json:"useip"` // has defined consts, see above - Bulk int `json:"bulk,omitempty"` // has defined consts, see above + InterfaceID int `json:"interfaceid,omitempty"` + DNS string `json:"dns"` + HostID int `json:"hostid,omitempty"` + IP string `json:"ip"` + Main int `json:"main"` // has defined consts, see above + Port string `json:"port"` + Type int `json:"type"` // has defined consts, see above + UseIP int `json:"useip"` // has defined consts, see above + Details []HostinterfaceDetailsTagObject `json:"details,omitempty"` // Items []ItemObject `json:"items,omitempty"` // not implemented yet Hosts []HostObject `json:"hosts,omitempty"` } +// HostinterfaceDetailsTagObject struct is used to store hostinterface details +// +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object#details_tag +type HostinterfaceDetailsTagObject struct { + Version int `json:"version,omitempty"` // has defined consts, see above + Bulk int `json:"bulk,omitempty"` // has defined consts, see above + Community string `json:"community,omitempty"` + SecurityName string `json:"securityname,omitempty"` + SecurityLevel int `json:"securitylevel,omitempty"` // has defined consts, see above + AuthPassPhrase string `json:"authpassphrase,omitempty"` + PrivPassPhrase string `json:"privpassphrase,omitempty"` + AuthProtocol int `json:"authprotocol,omitempty"` // has defined consts, see above + PrivProtocol int `json:"privprotocol,omitempty"` // has defined consts, see above + ContextName string `json:"contextname,omitempty"` +} + // HostinterfaceGetParams struct is used for hostinterface get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/hostinterface/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/get#parameters type HostinterfaceGetParams struct { GetParameters diff --git a/mediatype.go b/mediatype.go index 09c0500..2844278 100644 --- a/mediatype.go +++ b/mediatype.go @@ -27,6 +27,12 @@ const ( MediatypeSMTPVerifyPeerYes = 1 ) +// For `MediatypeObject` field: `SMTPAuthentication` +const ( + MediatypeSMTPAuthenticationNone = 0 + MediatypeSMTPAuthenticationNormalPassword = 1 +) + // For `MediatypeObject` field: `Status` const ( MediatypeStatusEnabled = 0 @@ -51,53 +57,80 @@ const ( MediatypeShowEventMenuYes = 1 ) +// For `MediatypeMessageTemplateObject` field: `EventSource` +const ( + MediatypeMessageTemplateEventSourceTriggers = 0 + MediatypeMessageTemplateEventSourceDiscovery = 1 + MediatypeMessageTemplateEventSourceAutoregistration = 2 + MediatypeMessageTemplateEventSourceInternal = 3 +) + +// For `MediatypeMessageTemplateObject` field: `Recovery` +const ( + MediatypeMessageTemplateRecoveryOperations = 0 + MediatypeMessageTemplateRecoveryRecoveryOperations = 1 + MediatypeMessageTemplateRecoveryUpdateOperations = 2 +) + // MediatypeObject struct is used to store mediatype operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/mediatype/object +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object type MediatypeObject struct { - MediatypeID int `json:"mediatypeid,omitempty"` - Name string `json:"name,omitempty"` - Type int `json:"type,omitempty"` // has defined consts, see above - ExecPath string `json:"exec_path,omitempty"` - GsmModem string `json:"gsm_modem,omitempty"` - Passwd string `json:"passwd,omitempty"` - SMTPEmail string `json:"smtp_email,omitempty"` - SMTPHelo string `json:"smtp_helo,omitempty"` - SMTPServer string `json:"smtp_server,omitempty"` - SMTPPort int `json:"smtp_port,omitempty"` - SMTPSecurity int `json:"smtp_security,omitempty"` // has defined consts, see above - SMTPVerifyHost int `json:"smtp_verify_host,omitempty"` // has defined consts, see above - SMTPVerifyPeer int `json:"smtp_verify_peer,omitempty"` // has defined consts, see above - Status int `json:"status,omitempty"` // has defined consts, see above - Username string `json:"username,omitempty"` - ExecParams string `json:"exec_params,omitempty"` - MaxSessions int `json:"maxsessions,omitempty"` - MaxAttempts int `json:"maxattempts,omitempty"` - AttemptInterval string `json:"attempt_interval,omitempty"` - ContentType int `json:"content_type,omitempty"` // has defined consts, see above - Script string `json:"script,omitempty"` - Timeout string `json:"timeout,omitempty"` - ProcessTags int `json:"process_tags,omitempty"` // has defined consts, see above - ShowEventMenu int `json:"show_event_menu,omitempty"` // has defined consts, see above - EventMenuURL string `json:"event_menu_url,omitempty"` - EventMenuName string `json:"event_menu_name,omitempty"` - Parameters []MediatypeWebhookParametersObject `json:"parameters,omitempty"` - Description string `json:"description,omitempty"` + MediatypeID int `json:"mediatypeid,omitempty"` + Name string `json:"name,omitempty"` + Type int `json:"type,omitempty"` // has defined consts, see above + ExecPath string `json:"exec_path,omitempty"` + GsmModem string `json:"gsm_modem,omitempty"` + Passwd string `json:"passwd,omitempty"` + SMTPEmail string `json:"smtp_email,omitempty"` + SMTPHelo string `json:"smtp_helo,omitempty"` + SMTPServer string `json:"smtp_server,omitempty"` + SMTPPort int `json:"smtp_port,omitempty"` + SMTPSecurity int `json:"smtp_security,omitempty"` // has defined consts, see above + SMTPVerifyHost int `json:"smtp_verify_host,omitempty"` // has defined consts, see above + SMTPVerifyPeer int `json:"smtp_verify_peer,omitempty"` // has defined consts, see above + SMTPAuthentication int `json:"smtp_authentication,omitempty"` // has defined consts, see above + Status int `json:"status,omitempty"` // has defined consts, see above + Username string `json:"username,omitempty"` + ExecParams string `json:"exec_params,omitempty"` + MaxSessions int `json:"maxsessions,omitempty"` + MaxAttempts int `json:"maxattempts,omitempty"` + AttemptInterval string `json:"attempt_interval,omitempty"` + ContentType int `json:"content_type,omitempty"` // has defined consts, see above + Script string `json:"script,omitempty"` + Timeout string `json:"timeout,omitempty"` + ProcessTags int `json:"process_tags,omitempty"` // has defined consts, see above + ShowEventMenu int `json:"show_event_menu,omitempty"` // has defined consts, see above + EventMenuURL string `json:"event_menu_url,omitempty"` + EventMenuName string `json:"event_menu_name,omitempty"` + Parameters []MediatypeWebhookParametersObject `json:"parameters,omitempty"` + Description string `json:"description,omitempty"` + MessageTemplates []MediatypeMessageTemplateObject `json:"message_templates,omitempty"` Users []UserObject `json:"users,omitempty"` } // MediatypeWebhookParametersObject struct is used for mediatypes webhook parameters // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/mediatype/object#webhook_parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object#webhook_parameters type MediatypeWebhookParametersObject struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` } +// MediatypeMessageTemplateObject struct is used for mediatypes message template +// +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/object#message_template +type MediatypeMessageTemplateObject struct { + EventSource int `json:"eventsource"` // has defined consts, see above + Recovery int `json:"recovery"` // has defined consts, see above + Subject string `json:"subject,omitempty"` + Message string `json:"message,omitempty"` +} + // MediatypeGetParams struct is used for mediatype get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/mediatype/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/mediatype/get#parameters type MediatypeGetParams struct { GetParameters @@ -105,7 +138,8 @@ type MediatypeGetParams struct { MediaIDs []int `json:"mediaids,omitempty"` UserIDs []int `json:"userids,omitempty"` - SelectUsers SelectQuery `json:"selectUsers,omitempty"` + SelectMessageTemplates SelectQuery `json:"selectMessageTemplates,omitempty"` + SelectUsers SelectQuery `json:"selectUsers,omitempty"` } // Structure to store creation result diff --git a/mediatype_test.go b/mediatype_test.go index 82bbafb..d015ebe 100644 --- a/mediatype_test.go +++ b/mediatype_test.go @@ -35,6 +35,14 @@ func testMediatypeCreate(t *testing.T, z Context) []int { Description: testMediatypeDescription, Type: MediatypeScript, ExecPath: testMediatypeExecPath, + MessageTemplates: []MediatypeMessageTemplateObject{ + { + EventSource: MediatypeMessageTemplateEventSourceTriggers, + Recovery: MediatypeMessageTemplateRecoveryOperations, + Subject: "SSS", + Message: "MMM", + }, + }, }, }) diff --git a/template.go b/template.go index df3d16f..17eae96 100644 --- a/template.go +++ b/template.go @@ -14,7 +14,7 @@ const ( // TemplateObject struct is used to store template operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/template/object +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/object type TemplateObject struct { TemplateID int `json:"templateid,omitempty"` Host string `json:"host,omitempty"` @@ -31,7 +31,7 @@ type TemplateObject struct { // TemplateTagObject struct is used to store template tag data // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/template/object#template_tag +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/object#template_tag type TemplateTagObject struct { Tag string `json:"tag,omitempty"` Value string `json:"value,omitempty"` @@ -41,7 +41,7 @@ type TemplateTagObject struct { // TemplateGetParams struct is used for template get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/template/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/template/get#parameters type TemplateGetParams struct { GetParameters diff --git a/user.go b/user.go index cc7f604..69f38a2 100644 --- a/user.go +++ b/user.go @@ -28,7 +28,7 @@ const ( // UserObject struct is used to store user operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/user/object +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/object type UserObject struct { UserID int `json:"userid,omitempty"` Alias string `json:"alias,omitempty"` @@ -46,18 +46,21 @@ type UserObject struct { Type int `json:"type,omitempty"` // has defined consts, see above URL string `json:"url,omitempty"` + // used for user.login + UserDataObject + Medias []MediaObject `json:"medias,omitempty"` Mediatypes []MediatypeObject `json:"mediatypes,omitempty"` Usrgrps []UsergroupObject `json:"usrgrps,omitempty"` // used when new user created UserMedias []MediaObject `json:"user_medias,omitempty"` - Passwd string `json:"passwd"` + Passwd string `json:"passwd,omitempty"` } // MediaObject struct is used to store media operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/user/object#media +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/object#media type MediaObject struct { MediaID int `json:"mediaid,omitempty"` MediaTypeID int `json:"mediatypeid,omitempty"` @@ -69,15 +72,26 @@ type MediaObject struct { // UserLoginParams struct is used for login requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/user/login#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/login#parameters type UserLoginParams struct { User string `json:"user"` Password string `json:"password"` + UserData string `json:"userData,omitempty"` +} + +// UserDataObject struct is used to store authenticated user additional info +// +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/login#return_values +type UserDataObject struct { + DebugMode bool `json:"debug_mode,omitempty"` + GUIAccess int `json:"gui_access,omitempty"` + SessionID string `json:"sessionid,omitempty"` + UserIP string `json:"userip,omitempty"` } // UserGetParams struct is used for user get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/user/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/user/get#parameters type UserGetParams struct { GetParameters diff --git a/usergroup.go b/usergroup.go index 1a704e5..1187244 100644 --- a/usergroup.go +++ b/usergroup.go @@ -29,7 +29,7 @@ const ( // UsergroupObject struct is used to store usergroup operations results // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usergroup/object#user_group +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#user_group type UsergroupObject struct { UsrgrpID int `json:"usrgrpid,omitempty"` Name string `json:"name,omitempty"` @@ -47,7 +47,7 @@ type UsergroupObject struct { // UsergroupPermissionObject struct is used to store usergroup permissions // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usergroup/object#permission +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#permission type UsergroupPermissionObject struct { ID int `json:"id"` Permission int `json:"permission"` // has defined consts, see above @@ -55,7 +55,7 @@ type UsergroupPermissionObject struct { // UsergroupTagBasedPermissionObject struct is used to store usergroup tag based permission // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usergroup/object#tag_based_permission +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/object#tag_based_permission type UsergroupTagBasedPermissionObject struct { GroupID int `json:"groupid,omitempty"` Tag string `json:"tag,omitempty"` @@ -64,7 +64,7 @@ type UsergroupTagBasedPermissionObject struct { // UsergroupGetParams struct is used for usergroup get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usergroup/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usergroup/get#parameters type UsergroupGetParams struct { GetParameters diff --git a/usermacro.go b/usermacro.go index 79e3ab7..5fbef3b 100644 --- a/usermacro.go +++ b/usermacro.go @@ -1,12 +1,18 @@ package zabbix +// For `UsermacroObject` field: `Type` +const ( + UsermacroTypeText = 0 + UsermacroTypeSecret = 1 +) + // UsermacroObject struct is used to store hostmacro and globalmacro operations results. // In API docs Global and Host it is a two different object types that are joined in this package // into one object `UsermacroObject` that includes fields form both API objects. // The reason is the some other objects do not separates this types. // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usermacro/object#host_macro -// and https://www.zabbix.com/documentation/4.4/manual/api/reference/usermacro/object#global_macro +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usermacro/object#host_macro +// and https://www.zabbix.com/documentation/5.0/manual/api/reference/usermacro/object#global_macro type UsermacroObject struct { // Gobal macro fields only @@ -19,6 +25,7 @@ type UsermacroObject struct { // Common fields Macro string `json:"macro,omitempty"` Value string `json:"value,omitempty"` + Type int `json:"type,omitempty"` // has defined consts, see above Description string `json:"description,omitempty"` Groups []HostgroupObject `json:"groups,omitempty"` @@ -28,7 +35,7 @@ type UsermacroObject struct { // UsermacroGetParams struct is used for hostmacro get requests // -// see: https://www.zabbix.com/documentation/4.4/manual/api/reference/usermacro/get#parameters +// see: https://www.zabbix.com/documentation/5.0/manual/api/reference/usermacro/get#parameters type UsermacroGetParams struct { GetParameters diff --git a/zabbix.go b/zabbix.go index 2e6fc57..aebb29a 100644 --- a/zabbix.go +++ b/zabbix.go @@ -31,8 +31,9 @@ type Context struct { // GetParameters struct is used as embedded struct for some other structs within package // -// see for details: https://www.zabbix.com/documentation/4.4/manual/api/reference_commentary#common_get_method_parameters +// see for details: https://www.zabbix.com/documentation/5.0/manual/api/reference_commentary#common_get_method_parameters type GetParameters struct { + CountOutput bool `json:"countOutput,omitempty"` Editable bool `json:"editable,omitempty"` ExcludeSearch bool `json:"excludeSearch,omitempty"` Filter map[string]interface{} `json:"filter,omitempty"`