fixed tests. should fail (#14878)

* fixed tests. should fail

* fixed dd monitor evaluation_delay parameter

* updated go-datadog-api.v2

* updated vendor.json
This commit is contained in:
Roman Laguta 2017-06-05 14:47:15 +03:00 committed by Paul Stack
parent 7823ed8eb8
commit bc83cae0e4
9 changed files with 92 additions and 14 deletions

View File

@ -169,7 +169,7 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
o.SetNewHostDelay(attr.(int))
}
if attr, ok := d.GetOk("evaluation_delay"); ok {
o.SetNewHostDelay(attr.(int))
o.SetEvaluationDelay(attr.(int))
}
if attr, ok := d.GetOk("no_data_timeframe"); ok {
o.NoDataTimeframe = datadog.NoDataTimeframe(attr.(int))
@ -282,7 +282,7 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error
d.Set("thresholds", thresholds)
d.Set("new_host_delay", m.Options.GetNewHostDelay())
d.Set("evaluation_delay", m.Options.GetNewHostDelay())
d.Set("evaluation_delay", m.Options.GetEvaluationDelay())
d.Set("notify_no_data", m.Options.GetNotifyNoData())
d.Set("no_data_timeframe", m.Options.NoDataTimeframe)
d.Set("renotify_interval", m.Options.GetRenotifyInterval())
@ -350,7 +350,7 @@ func resourceDatadogMonitorUpdate(d *schema.ResourceData, meta interface{}) erro
o.SetNewHostDelay(attr.(int))
}
if attr, ok := d.GetOk("evaluation_delay"); ok {
o.SetNewHostDelay(attr.(int))
o.SetEvaluationDelay(attr.(int))
}
if attr, ok := d.GetOk("no_data_timeframe"); ok {
o.NoDataTimeframe = datadog.NoDataTimeframe(attr.(int))

View File

@ -34,7 +34,7 @@ func TestAccDatadogMonitor_Basic(t *testing.T) {
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "new_host_delay", "600"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "evaluation_delay", "600"),
"datadog_monitor.foo", "evaluation_delay", "700"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "renotify_interval", "60"),
resource.TestCheckResourceAttr(
@ -116,7 +116,7 @@ func TestAccDatadogMonitor_Updated(t *testing.T) {
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "new_host_delay", "600"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "evaluation_delay", "600"),
"datadog_monitor.foo", "evaluation_delay", "700"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "renotify_interval", "60"),
resource.TestCheckResourceAttr(
@ -158,7 +158,7 @@ func TestAccDatadogMonitor_Updated(t *testing.T) {
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "new_host_delay", "900"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "evaluation_delay", "900"),
"datadog_monitor.foo", "evaluation_delay", "800"),
resource.TestCheckResourceAttr(
"datadog_monitor.foo", "no_data_timeframe", "20"),
resource.TestCheckResourceAttr(
@ -294,7 +294,7 @@ resource "datadog_monitor" "foo" {
notify_audit = false
timeout_h = 60
new_host_delay = 600
evaluation_delay = 600
evaluation_delay = 700
include_tags = true
require_full_window = true
locked = false
@ -393,7 +393,7 @@ resource "datadog_monitor" "foo" {
notify_no_data = true
new_host_delay = 900
evaluation_delay = 900
evaluation_delay = 800
no_data_timeframe = 20
renotify_interval = 40
escalation_message = "the situation has escalated! @pagerduty"

View File

@ -4,7 +4,7 @@ status](https://travis-ci.org/zorkian/go-datadog-api.svg)](https://travis-ci.org
# Datadog API in Go
**This is the v2.0 version of the API, and has breaking changes. Use the main or v1.0 branch if you need
**This is the v2.0 version of the API, and has breaking changes. Use the v1.0 branch if you need
legacy code to be supported.**
A Go wrapper for the Datadog API. Use this library if you need to interact
@ -115,4 +115,4 @@ make generate
Please see the LICENSE file for the included license information.
Copyright 2017 by authors and contributors.
Copyright 2013-2017 by authors and contributors.

View File

@ -72,7 +72,7 @@ type GraphDefinition struct {
Yaxis Yaxis `json:"yaxis,omitempty"`
// For query value type graphs
Autoscale *bool `json:"austoscale,omitempty"`
Autoscale *bool `json:"autoscale,omitempty"`
TextAlign *string `json:"text_align,omitempty"`
Precision *string `json:"precision,omitempty"`
CustomUnit *string `json:"custom_unit,omitempty"`

View File

@ -3175,6 +3175,37 @@ func (d *Downtime) SetMessage(v string) {
d.Message = &v
}
// GetMonitorId returns the MonitorId field if non-nil, zero value otherwise.
func (d *Downtime) GetMonitorId() int {
if d == nil || d.MonitorId == nil {
return 0
}
return *d.MonitorId
}
// GetOkMonitorId returns a tuple with the MonitorId field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (d *Downtime) GetMonitorIdOk() (int, bool) {
if d == nil || d.MonitorId == nil {
return 0, false
}
return *d.MonitorId, true
}
// HasMonitorId returns a boolean if a field has been set.
func (d *Downtime) HasMonitorId() bool {
if d != nil && d.MonitorId != nil {
return true
}
return false
}
// GetMonitorId allocates a new d.MonitorId and returns the pointer to it.
func (d *Downtime) SetMonitorId(v int) {
d.MonitorId = &v
}
// GetRecurrence returns the Recurrence field if non-nil, zero value otherwise.
func (d *Downtime) GetRecurrence() Recurrence {
if d == nil || d.Recurrence == nil {
@ -7980,6 +8011,37 @@ func (o *Options) SetEscalationMessage(v string) {
o.EscalationMessage = &v
}
// GetEvaluationDelay returns the EvaluationDelay field if non-nil, zero value otherwise.
func (o *Options) GetEvaluationDelay() int {
if o == nil || o.EvaluationDelay == nil {
return 0
}
return *o.EvaluationDelay
}
// GetOkEvaluationDelay returns a tuple with the EvaluationDelay field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (o *Options) GetEvaluationDelayOk() (int, bool) {
if o == nil || o.EvaluationDelay == nil {
return 0, false
}
return *o.EvaluationDelay, true
}
// HasEvaluationDelay returns a boolean if a field has been set.
func (o *Options) HasEvaluationDelay() bool {
if o != nil && o.EvaluationDelay != nil {
return true
}
return false
}
// GetEvaluationDelay allocates a new o.EvaluationDelay and returns the pointer to it.
func (o *Options) SetEvaluationDelay(v int) {
o.EvaluationDelay = &v
}
// GetIncludeTags returns the IncludeTags field if non-nil, zero value otherwise.
func (o *Options) GetIncludeTags() bool {
if o == nil || o.IncludeTags == nil {

View File

@ -26,6 +26,7 @@ type Downtime struct {
Disabled *bool `json:"disabled,omitempty"`
End *int `json:"end,omitempty"`
Id *int `json:"id,omitempty"`
MonitorId *int `json:"monitor_id,omitempty"`
Message *string `json:"message,omitempty"`
Recurrence *Recurrence `json:"recurrence,omitempty"`
Scope []string `json:"scope,omitempty"`

View File

@ -44,6 +44,7 @@ type Options struct {
NotifyNoData *bool `json:"notify_no_data,omitempty"`
RenotifyInterval *int `json:"renotify_interval,omitempty"`
NewHostDelay *int `json:"new_host_delay,omitempty"`
EvaluationDelay *int `json:"evaluation_delay,omitempty"`
Silenced map[string]int `json:"silenced,omitempty"`
TimeoutH *int `json:"timeout_h,omitempty"`
EscalationMessage *string `json:"escalation_message,omitempty"`

View File

@ -110,11 +110,25 @@ func (client *Client) doRequestWithRetries(req *http.Request, maxTime time.Durat
err error
resp *http.Response
bo = backoff.NewExponentialBackOff()
body []byte
)
bo.MaxElapsedTime = maxTime
// Save the body for retries
if req.Body != nil {
body, err = ioutil.ReadAll(req.Body)
if err != nil {
return resp, err
}
}
operation := func() error {
if body != nil {
r := bytes.NewReader(body)
req.Body = ioutil.NopCloser(r)
}
resp, err = client.HttpClient.Do(req)
if err != nil {
return err

6
vendor/vendor.json vendored
View File

@ -3671,10 +3671,10 @@
"revisionTime": "2017-04-07T17:21:22Z"
},
{
"checksumSHA1": "OcJdNALtPXoFOieAZjznhm7ufuU=",
"checksumSHA1": "WI/b3b5dn9P+yWQRHd1gOebLxbw=",
"path": "gopkg.in/zorkian/go-datadog-api.v2",
"revision": "f005bb24262365e93726b94d89e6cd8a26a7455e",
"revisionTime": "2017-02-20T05:26:33Z"
"revision": "7069eb831c018b4c3f224e42edcad7d9ae3bbeea",
"revisionTime": "2017-05-15T05:26:33Z"
},
{
"checksumSHA1": "ULdgobdOiXg/nZoZ/gxfU2DBiOk=",