Skip to content

Commit

Permalink
adding retrievemode
Browse files Browse the repository at this point in the history
  • Loading branch information
tpretz committed Oct 8, 2021
1 parent d928d39 commit 189989b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 19 deletions.
10 changes: 5 additions & 5 deletions docs/resources/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ description: |-
- **work_period** (Boolean) Show work period
- **ymax** (String) Y Axis Max
- **ymax_itemid** (String) Y Axis Max ItemId
- **ymax_type** (String) Y Axis Max Type, one of: fixed, item, calculated
- **ymax_type** (String) Y Axis Max Type, one of: calculated, fixed, item
- **ymin** (String) Y Axis Min
- **ymin_itemid** (String) Y Axis Min ItemId
- **ymin_type** (String) Y Axis Min Type, one of: fixed, item, calculated
- **ymin_type** (String) Y Axis Min Type, one of: calculated, fixed, item

<a id="nestedblock--item"></a>
### Nested Schema for `item`
Expand All @@ -49,10 +49,10 @@ Required:
Optional:

- **drawtype** (String) Draw Type, one of: line, filled, bold, dot, dashed, gradient
- **function** (String) Function, one of: average, max, all, last, min
- **function** (String) Function, one of: min, average, max, all, last
- **sortorder** (String) sort order
- **type** (String) Type, one of: simple, sum
- **yaxis_side** (String) Y Axis Side, one of: left, right
- **type** (String) Type, one of: sum, simple
- **yaxis_side** (String) Y Axis Side, one of: right, left

Read-Only:

Expand Down
5 changes: 3 additions & 2 deletions docs/resources/item_http.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ description: |-
- **id** (String) The ID of this resource.
- **interfaceid** (String) Host Interface ID
- **password** (String, Sensitive) Authentication Password
- **post_type** (String) HTTP post type, one of: json, xml, raw
- **post_type** (String) HTTP post type, one of: raw, json, xml
- **posts** (String) POST data to send in request
- **preprocessor** (Block List) (see [below for nested schema](#nestedblock--preprocessor))
- **proxy** (String) HTTP proxy connection string
- **request_method** (String) HTTP request method, one of: put, head, get, post
- **request_method** (String) HTTP request method, one of: head, get, post, put
- **retrieve_mode** (String) HTTP retrieve mode, one of: body, headers, both
- **status_codes** (String) http status code
- **tag** (Block Set) (see [below for nested schema](#nestedblock--tag))
- **timeout** (String) http request timeout
Expand Down
5 changes: 3 additions & 2 deletions docs/resources/lld_http.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ description: |-
- **lifetime** (String) LLD Stale Item Lifetime
- **macro** (Block Set) (see [below for nested schema](#nestedblock--macro))
- **password** (String, Sensitive) Authentication Password
- **post_type** (String) HTTP post type, one of: json, xml, raw
- **post_type** (String) HTTP post type, one of: raw, json, xml
- **posts** (String) POST data to send in request
- **preprocessor** (Block List) (see [below for nested schema](#nestedblock--preprocessor))
- **proxy** (String) HTTP proxy connection string
- **request_method** (String) HTTP request method, one of: put, head, get, post
- **request_method** (String) HTTP request method, one of: head, get, post, put
- **retrieve_mode** (String) HTTP retrieve mode, one of: body, headers, both
- **status_codes** (String) http status code
- **timeout** (String) http request timeout
- **username** (String) Authentication Username
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/proto_graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ description: |-
- **work_period** (Boolean) Show work period
- **ymax** (String) Y Axis Max
- **ymax_itemid** (String) Y Axis Max ItemId
- **ymax_type** (String) Y Axis Max Type, one of: fixed, item, calculated
- **ymax_type** (String) Y Axis Max Type, one of: calculated, fixed, item
- **ymin** (String) Y Axis Min
- **ymin_itemid** (String) Y Axis Min ItemId
- **ymin_type** (String) Y Axis Min Type, one of: fixed, item, calculated
- **ymin_type** (String) Y Axis Min Type, one of: calculated, fixed, item

<a id="nestedblock--item"></a>
### Nested Schema for `item`
Expand All @@ -49,10 +49,10 @@ Required:
Optional:

- **drawtype** (String) Draw Type, one of: line, filled, bold, dot, dashed, gradient
- **function** (String) Function, one of: average, max, all, last, min
- **function** (String) Function, one of: min, average, max, all, last
- **sortorder** (String) sort order
- **type** (String) Type, one of: simple, sum
- **yaxis_side** (String) Y Axis Side, one of: left, right
- **type** (String) Type, one of: sum, simple
- **yaxis_side** (String) Y Axis Side, one of: right, left

Read-Only:

Expand Down
5 changes: 3 additions & 2 deletions docs/resources/proto_item_http.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ description: |-
- **id** (String) The ID of this resource.
- **interfaceid** (String) Host Interface ID
- **password** (String, Sensitive) Authentication Password
- **post_type** (String) HTTP post type, one of: json, xml, raw
- **post_type** (String) HTTP post type, one of: raw, json, xml
- **posts** (String) POST data to send in request
- **preprocessor** (Block List) (see [below for nested schema](#nestedblock--preprocessor))
- **proxy** (String) HTTP proxy connection string
- **request_method** (String) HTTP request method, one of: put, head, get, post
- **request_method** (String) HTTP request method, one of: head, get, post, put
- **retrieve_mode** (String) HTTP retrieve mode, one of: body, headers, both
- **status_codes** (String) http status code
- **tag** (Block Set) (see [below for nested schema](#nestedblock--tag))
- **timeout** (String) http request timeout
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/proto_trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ description: |-
- **id** (String) The ID of this resource.
- **manual_close** (Boolean) Manual resolution
- **multiple** (Boolean) generate multiple events
- **priority** (String) Trigger Priority level, one of: high, disaster, not_classified, info, warn, average
- **priority** (String) Trigger Priority level, one of: not_classified, info, warn, average, high, disaster
- **recovery_expression** (String) use recovery expression (recovery_none must not be true)
- **recovery_none** (Boolean) set recovery mode to none
- **tag** (Block Set) (see [below for nested schema](#nestedblock--tag))
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ description: |-
- **id** (String) The ID of this resource.
- **manual_close** (Boolean) Manual resolution
- **multiple** (Boolean) generate multiple events
- **priority** (String) Trigger Priority level, one of: high, disaster, not_classified, info, warn, average
- **priority** (String) Trigger Priority level, one of: not_classified, info, warn, average, high, disaster
- **recovery_expression** (String) use recovery expression (recovery_none must not be true)
- **recovery_none** (Boolean) set recovery mode to none
- **tag** (Block Set) (see [below for nested schema](#nestedblock--tag))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.11
require (
github.com/hashicorp/terraform v0.12.23
github.com/hashicorp/terraform-plugin-sdk v1.7.0
github.com/tpretz/go-zabbix-api v0.11.0
github.com/tpretz/go-zabbix-api v0.12.0
)

//replace github.com/tpretz/go-zabbix-api => ../go-zabbix-api
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ github.com/tpretz/go-zabbix-api v0.10.0 h1:QhWFisul6PA+GaeqPPnGrpl0rQa/6kgaGxMjw
github.com/tpretz/go-zabbix-api v0.10.0/go.mod h1:VIcrGoUyHSl91glPiOPIViL2rrmfVBZHG/IkbGnL7II=
github.com/tpretz/go-zabbix-api v0.11.0 h1:aJLBuRS/FeLuQq83IgdOx6g5PQaowO86zfRuxuZFJlY=
github.com/tpretz/go-zabbix-api v0.11.0/go.mod h1:VIcrGoUyHSl91glPiOPIViL2rrmfVBZHG/IkbGnL7II=
github.com/tpretz/go-zabbix-api v0.12.0 h1:l9u3jyfxkaV3RQrV+N9SEoM8Qfhn4TBv17GPWJgxWWI=
github.com/tpretz/go-zabbix-api v0.12.0/go.mod h1:VIcrGoUyHSl91glPiOPIViL2rrmfVBZHG/IkbGnL7II=
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
Expand Down
15 changes: 15 additions & 0 deletions provider/resource_http_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ var _ = func() bool {
HTTP_POSTTYPE_REV[v] = k
HTTP_POSTTYPE_ARR = append(HTTP_POSTTYPE_ARR, k)
}
for k, v := range HTTP_RETRIEVEMODE {
HTTP_RETRIEVEMODE_REV[v] = k
HTTP_RETRIEVEMODE_ARR = append(HTTP_RETRIEVEMODE_ARR, k)
}
for k, v := range HTTP_AUTHTYPE {
HTTP_AUTHTYPE_REV[v] = k
HTTP_AUTHTYPE_ARR = append(HTTP_AUTHTYPE_ARR, k)
Expand Down Expand Up @@ -90,6 +94,13 @@ var schemaHttp = map[string]*schema.Schema{
ValidateFunc: validation.StringInSlice(HTTP_POSTTYPE_ARR, false),
Default: "body",
},
"retrieve_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "HTTP retrieve mode, one of: " + strings.Join(HTTP_RETRIEVEMODE_ARR, ", "),
ValidateFunc: validation.StringInSlice(HTTP_RETRIEVEMODE_ARR, false),
Default: "body",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -212,6 +223,7 @@ func itemHttpModFunc(d *schema.ResourceData, m interface{}, item *zabbix.Item) {
item.Delay = d.Get("delay").(string)
item.RequestMethod = HTTP_METHODS[d.Get("request_method").(string)]
item.PostType = HTTP_POSTTYPE[d.Get("post_type").(string)]
item.RetrieveMode = HTTP_RETRIEVEMODE[d.Get("retrieve_mode").(string)]
item.AuthType = HTTP_AUTHTYPE[d.Get("auth_type").(string)]
item.Username = d.Get("username").(string)
item.Proxy = d.Get("proxy").(string)
Expand All @@ -237,6 +249,7 @@ func lldHttpModFunc(d *schema.ResourceData, m interface{}, item *zabbix.LLDRule)
item.Url = d.Get("url").(string)
item.RequestMethod = HTTP_METHODS[d.Get("request_method").(string)]
item.PostType = HTTP_POSTTYPE[d.Get("post_type").(string)]
item.RetrieveMode = HTTP_RETRIEVEMODE[d.Get("retrieve_mode").(string)]
item.AuthType = HTTP_AUTHTYPE[d.Get("auth_type").(string)]
item.Username = d.Get("username").(string)
item.Proxy = d.Get("proxy").(string)
Expand Down Expand Up @@ -265,6 +278,7 @@ func itemHttpReadFunc(d *schema.ResourceData, m interface{}, item *zabbix.Item)
d.Set("delay", item.Delay)
d.Set("request_method", HTTP_METHODS_REV[item.RequestMethod])
d.Set("post_type", HTTP_POSTTYPE_REV[item.PostType])
d.Set("retrieve_mode", HTTP_RETRIEVEMODE_REV[item.RetrieveMode])
d.Set("auth_type", HTTP_AUTHTYPE_REV[item.AuthType])
d.Set("username", item.Username)
d.Set("proxy", item.Proxy)
Expand All @@ -281,6 +295,7 @@ func lldHttpReadFunc(d *schema.ResourceData, m interface{}, item *zabbix.LLDRule
d.Set("url", item.Url)
d.Set("request_method", HTTP_METHODS_REV[item.RequestMethod])
d.Set("post_type", HTTP_POSTTYPE_REV[item.PostType])
d.Set("retrieve_mode", HTTP_RETRIEVEMODE_REV[item.RetrieveMode])
d.Set("auth_type", HTTP_AUTHTYPE_REV[item.AuthType])
d.Set("username", item.Username)
d.Set("proxy", item.Proxy)
Expand Down

0 comments on commit 189989b

Please sign in to comment.