From 79024dbf0927563e0827cf4d62a8b7697c357083 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Sun, 29 Jan 2017 16:52:23 +0100 Subject: [PATCH] provider/opsgenie: Descriptions for Teams (#11391) * updating the opsgenie dependency * Adding description to an OpsGenie team * Description for Teams * Added tests for an empty description --- .../opsgenie/import_opsgenie_team_test.go | 24 ++++ .../opsgenie/resource_opsgenie_team.go | 22 ++- .../opsgenie/resource_opsgenie_team_test.go | 32 ++++- .../opsgenie/opsgenie-go-sdk/CONTRIBUTING.md | 10 -- .../opsgenie/opsgenie-go-sdk/README.md | 97 ------------- .../opsgenie-go-sdk/alerts/alert_responses.go | 37 +++++ .../opsgenie/opsgenie-go-sdk/alerts/alerts.go | 92 +++++++++++-- .../client/opsgenie_alert_client.go | 128 +++++++++++++++++- .../opsgenie/opsgenie-go-sdk/team/team.go | 2 + .../opsgenie-go-sdk/team/team_responses.go | 1 + vendor/vendor.json | 46 +++---- .../providers/opsgenie/r/team.html.markdown | 3 + 12 files changed, 344 insertions(+), 150 deletions(-) delete mode 100644 vendor/github.com/opsgenie/opsgenie-go-sdk/CONTRIBUTING.md delete mode 100644 vendor/github.com/opsgenie/opsgenie-go-sdk/README.md diff --git a/builtin/providers/opsgenie/import_opsgenie_team_test.go b/builtin/providers/opsgenie/import_opsgenie_team_test.go index 28b654d37..b77a02b03 100644 --- a/builtin/providers/opsgenie/import_opsgenie_team_test.go +++ b/builtin/providers/opsgenie/import_opsgenie_team_test.go @@ -33,6 +33,30 @@ func TestAccOpsGenieTeam_importBasic(t *testing.T) { }) } +func TestAccOpsGenieTeam_importWithEmptyDescription(t *testing.T) { + resourceName := "opsgenie_team.test" + + ri := acctest.RandInt() + config := fmt.Sprintf(testAccOpsGenieTeam_withEmptyDescription, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckOpsGenieTeamDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccOpsGenieTeam_importWithUser(t *testing.T) { resourceName := "opsgenie_team.test" diff --git a/builtin/providers/opsgenie/resource_opsgenie_team.go b/builtin/providers/opsgenie/resource_opsgenie_team.go index 7035c954c..14606fc33 100644 --- a/builtin/providers/opsgenie/resource_opsgenie_team.go +++ b/builtin/providers/opsgenie/resource_opsgenie_team.go @@ -6,9 +6,10 @@ import ( "fmt" "strings" + "regexp" + "github.com/hashicorp/terraform/helper/schema" "github.com/opsgenie/opsgenie-go-sdk/team" - "regexp" ) func resourceOpsGenieTeam() *schema.Resource { @@ -26,6 +27,10 @@ func resourceOpsGenieTeam() *schema.Resource { Required: true, ValidateFunc: validateOpsGenieTeamName, }, + "description": { + Type: schema.TypeString, + Optional: true, + }, "member": { Type: schema.TypeList, Optional: true, @@ -53,10 +58,12 @@ func resourceOpsGenieTeamCreate(d *schema.ResourceData, meta interface{}) error client := meta.(*OpsGenieClient).teams name := d.Get("name").(string) + description := d.Get("description").(string) createRequest := team.CreateTeamRequest{ - Name: name, - Members: expandOpsGenieTeamMembers(d), + Name: name, + Description: description, + Members: expandOpsGenieTeamMembers(d), } log.Printf("[INFO] Creating OpsGenie team '%s'", name) @@ -118,6 +125,7 @@ func resourceOpsGenieTeamRead(d *schema.ResourceData, meta interface{}) error { } d.Set("name", getResponse.Name) + d.Set("description", getResponse.Description) d.Set("member", flattenOpsGenieTeamMembers(getResponse.Members)) return nil @@ -126,11 +134,13 @@ func resourceOpsGenieTeamRead(d *schema.ResourceData, meta interface{}) error { func resourceOpsGenieTeamUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*OpsGenieClient).teams name := d.Get("name").(string) + description := d.Get("description").(string) updateRequest := team.UpdateTeamRequest{ - Id: d.Id(), - Name: name, - Members: expandOpsGenieTeamMembers(d), + Id: d.Id(), + Name: name, + Description: description, + Members: expandOpsGenieTeamMembers(d), } log.Printf("[INFO] Updating OpsGenie team '%s'", name) diff --git a/builtin/providers/opsgenie/resource_opsgenie_team_test.go b/builtin/providers/opsgenie/resource_opsgenie_team_test.go index 31ffe1aab..a357c1eaf 100644 --- a/builtin/providers/opsgenie/resource_opsgenie_team_test.go +++ b/builtin/providers/opsgenie/resource_opsgenie_team_test.go @@ -105,6 +105,25 @@ func TestAccOpsGenieTeam_basic(t *testing.T) { }) } +func TestAccOpsGenieTeam_withEmptyDescription(t *testing.T) { + ri := acctest.RandInt() + config := fmt.Sprintf(testAccOpsGenieTeam_withEmptyDescription, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckOpsGenieTeamDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckOpsGenieTeamExists("opsgenie_team.test"), + ), + }, + }, + }) +} + func TestAccOpsGenieTeam_withUser(t *testing.T) { ri := acctest.RandInt() config := fmt.Sprintf(testAccOpsGenieTeam_withUser, ri, ri) @@ -215,6 +234,13 @@ resource "opsgenie_team" "test" { } ` +var testAccOpsGenieTeam_withEmptyDescription = ` +resource "opsgenie_team" "test" { + name = "acctest%d" + description = "" +} +` + var testAccOpsGenieTeam_withUser = ` resource "opsgenie_user" "test" { username = "acctest-%d@example.tld" @@ -238,7 +264,8 @@ resource "opsgenie_user" "test" { } resource "opsgenie_team" "test" { - name = "acctest%d" + name = "acctest%d" + description = "Some exmaple description" member { username = "${opsgenie_user.test.username}" role = "user" @@ -259,7 +286,8 @@ resource "opsgenie_user" "second" { } resource "opsgenie_team" "test" { - name = "acctest%d" + name = "acctest%d" + description = "Some exmaple description" member { username = "${opsgenie_user.first.username}" } diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/CONTRIBUTING.md b/vendor/github.com/opsgenie/opsgenie-go-sdk/CONTRIBUTING.md deleted file mode 100644 index 55b06ecd0..000000000 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/CONTRIBUTING.md +++ /dev/null @@ -1,10 +0,0 @@ -# How to contribute - -Your contributions are more than welcomed at OpsGenie! You can contribute to OpsGenie Go SDK by submitting a pull request. - -Before pushing your commits, please make sure you followed the steps described below: - -1. Run `go fmt` to format your code. -2. Alternatively you can use [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), it also formats import lines. -3. [golint](https://github.com/golang/lint) your code to detect style mistakes. -4. [govet](http://godoc.org/golang.org/x/tools/cmd/vet) your code to detect suspicious constructs. \ No newline at end of file diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/README.md b/vendor/github.com/opsgenie/opsgenie-go-sdk/README.md deleted file mode 100644 index 9b41bb790..000000000 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# opsgenie-go-sdk -## Aim and Scope -OpsGenie GO SDK aims to access OpsGenie Web API through HTTP calls -from a client application purely written in Go language. - -OpsGenie Go SDK covers *the Alert API*, *the Heartbeat API*, -*the Integration API* and *the Policy API*. Future releases -are subject to be delivered for packing more APIs soon. - -**Documentation:** [![](https://godoc.org/github.com/nathany/looper?status.svg)](http://godoc.org/github.com/opsgenie/opsgenie-go-sdk/client) - -For more information about OpsGenie Go SDK, please refer to [OpsGenie Go API](https://www.opsgenie.com/docs/api-and-client-libraries/opsgenie-go-api) document. - -## Pre-requisites -* The API is built using Go 1.4.2. Some features may not be -available or supported unless you have installed a relevant version of Go. -Please click [https://golang.org/dl/](https://golang.org/dl/) to download and -get more information about installing Go on your computer. -* Make sure you have properly set both `GOROOT` and `GOPATH` -environment variables. - -* Before you can begin, you need to sign up [OpsGenie](http://www.opsgenie.com) if you -don't have a valid account yet. Create an API Integration and get your API key. - -## Installation -To download all packages in the repo with their dependencies, simply run - -`go get github.com/opsgenie/opsgenie-go-sdk/...` - -## Getting Started -One can start using OpsGenie Go SDK by initializing client and making a request. Example shown below demonstrates how to initialize an OpsGenie Alert client and make a create alert request. -``` - package main - - import ( - "fmt" - - alerts "github.com/opsgenie/opsgenie-go-sdk/alerts" - ogcli "github.com/opsgenie/opsgenie-go-sdk/client" - ) - - func main() { - cli := new(ogcli.OpsGenieClient) - cli.SetAPIKey("YOUR_API_KEY") - - alertCli, cliErr := cli.Alert() - - if cliErr != nil { - panic(cliErr) - } - - // create the alert - req := alerts.CreateAlertRequest{Message: "Hello from OpsGenie Go Sdk"} - response, alertErr := alertCli.Create(req) - - if alertErr != nil { - panic(alertErr) - } - - fmt.Printf("message: %s\n", response.Message) - fmt.Printf("alert id: %s\n", response.AlertId) - fmt.Printf("status: %s\n", response.Status) - fmt.Printf("code: %d\n", response.Code) - } -``` -There are many useful sample code snippets under `samples` directory for packages. - -## Handling Zero value problem with 'omitempty' option in Json - -Every golang type has a [zero value](http://golang.org/ref/spec#The_zero_value). -AddHeartbeat and UpdateHeartbeat requests have a boolean "Enabled" field to determine a heartbeat is enabled or disabled. -enabled is not a mandatory field in both requests so, it has "omitempty" flag. - -When JSON is unmarshalling the requests, it omits the fields contains zero value of its type when this option is set. - -The problem starts here: -When you want to set the Enabled field as false, JSON does not unmarshal it because it contains boolean zero value and has option omitempty. -This problem occurs with strings; when you want to reset a heartbeat's description. To set heartbeat's description as empty string, you should make the request with Description :"". -But JSON does not unmarshal it either. - -So, to solve this we followed go-github's solution as mentioned [here](https://willnorris.com/2014/05/go-rest-apis-and-pointers). -We used pointers just for booleans, if you want to set a string's value to empty. please use " ", or "-" as new string value. - -## The Web API - -Please follow the links below for more information and details -about the Web API. - -* [Alert API](https://www.opsgenie.com/docs/web-api/alert-api) -* [Heartbeat API](https://www.opsgenie.com/docs/web-api/heartbeat-api) -* [Integration API](https://www.opsgenie.com/docs/web-api/integration-api) -* [Policy API](https://www.opsgenie.com/docs/web-api/policy-api) - - -## Bug Reporting and Feature Requests - -If you like to report a bug, or a feature request; please open an issue. diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alert_responses.go b/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alert_responses.go index 5ec8c031d..b8f24c5f5 100644 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alert_responses.go +++ b/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alert_responses.go @@ -164,6 +164,43 @@ type GetAlertResponse struct { SystemData map[string]interface{} `json:"systemData"` } +// UnAcknowledgeAlertResponse holds the result data of the UnAcknowledgeAlertRequest +type UnAcknowledgeAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` + Took int `json:"took"` +} + +// SnoozeAlertResponse holds the result data of the SnoozeAlertRequest +type SnoozeAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` +} + +// RemoveTagsAlertResponse holds the result data of the RemoveTagsAlertRequest +type RemoveTagsAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` +} + +// AddDetailsAlertResponse holds the result data of the AddDetailsAlertRequest +type AddDetailsAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` +} + +// RemoveDetailsAlertResponse holds the result data of the RemoveDetailsAlertRequest +type RemoveDetailsAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` +} + +// EscalateToNextAlertResponse holds the result data of the EscalateToNextAlertRequest +type EscalateToNextAlertResponse struct { + Status string `json:"status"` + Code int `json:"code"` +} + //IntegrationType returns extracted "integrationType" data from the retrieved alert' SystemData property. func (res *GetAlertResponse) IntegrationType() string { if val, ok := res.SystemData["integrationType"].(string); ok { diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alerts.go b/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alerts.go index ed254ebd7..08dba44c5 100644 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alerts.go +++ b/vendor/github.com/opsgenie/opsgenie-go-sdk/alerts/alerts.go @@ -172,15 +172,18 @@ type ListAlertRecipientsRequest struct { // ListAlertsRequest provides necessary parameter structure to Retrieve alerts from OpsGenie. type ListAlertsRequest struct { - APIKey string `url:"apiKey,omitempty"` - CreatedAfter uint64 `url:"createdAfter,omitempty"` - CreatedBefore uint64 `url:"createdBefore,omitempty"` - UpdatedAfter uint64 `url:"updatedAfter,omitempty"` - UpdatedBefore uint64 `url:"updatedBefore,omitempty"` - Limit uint64 `url:"limit,omitempty"` - Status string `url:"status,omitempty"` - SortBy string `url:"sortBy,omitempty"` - Order string `url:"order,omitempty"` + APIKey string `url:"apiKey,omitempty"` + CreatedAfter uint64 `url:"createdAfter,omitempty"` + CreatedBefore uint64 `url:"createdBefore,omitempty"` + UpdatedAfter uint64 `url:"updatedAfter,omitempty"` + UpdatedBefore uint64 `url:"updatedBefore,omitempty"` + Limit uint64 `url:"limit,omitempty"` + Status string `url:"status,omitempty"` + SortBy string `url:"sortBy,omitempty"` + Order string `url:"order,omitempty"` + Teams []string `url:"teams,omitempty"` + Tags []string `url:"tags,omitempty"` + TagsOperator string `url:"tagsOperator,omitempty"` } // CountAlertRequest counts the alerts at OpsGenie. @@ -192,8 +195,8 @@ type CountAlertRequest struct { UpdatedBefore uint64 `url:"updatedBefore,omitempty"` Limit uint64 `url:"limit,omitempty"` Status string `url:"status,omitempty"` - Tags []string `json:"tags,omitempty"` - TagsOperator string `url:"tagsoperator,omitempty"` + Tags []string `url:"tags,omitempty"` + TagsOperator string `url:"tagsOperator,omitempty"` } // RenotifyAlertRequest provides necessary parameter structure to Re-notify recipients at OpsGenie. @@ -216,3 +219,70 @@ type TakeOwnershipAlertRequest struct { Note string `json:"note,omitempty"` Source string `json:"source,omitempty"` } + +// UnAcknowledgeAlertRequest provides necessary parameter structure to Unacknowledge an alert at OpsGenie. +type UnAcknowledgeAlertRequest struct { + APIKey string `json:"apiKey,omitempty"` + ID string `json:"id,omitempty"` + Alias string `json:"alias,omitempty"` + User string `json:"user,omitempty"` + Note string `json:"note,omitempty"` + Source string `json:"source,omitempty"` +} + +// SnoozeAlertRequest provides necessary parameter structure to Snooze an alert at OpsGenie. +type SnoozeAlertRequest struct { + APIKey string `json:"apiKey,omitempty"` + ID string `json:"id,omitempty"` + Alias string `json:"alias,omitempty"` + EndDate string `json:"endDate,omitempty"` + User string `json:"user,omitempty"` + Note string `json:"note,omitempty"` + Source string `json:"source,omitempty"` + TimeZone string `json:"timezone,omitempty"` +} + +// RemoveTagsAlertRequest provides necessary parameter structure to Remove Tags from an alert at OpsGenie. +type RemoveTagsAlertRequest struct { + APIKey string `url:"apiKey,omitempty"` + ID string `url:"id,omitempty"` + Alias string `url:"alias,omitempty"` + Tags []string `url:"tags,omitempty"` + User string `url:"user,omitempty"` + Note string `url:"note,omitempty"` + Source string `url:"source,omitempty"` +} + +// AddDetailsAlertRequest provides necessary parameter structure to Add Details to an alert at OpsGenie. +type AddDetailsAlertRequest struct { + APIKey string `json:"apiKey,omitempty"` + ID string `json:"id,omitempty"` + Alias string `json:"alias,omitempty"` + Details map[string]string `json:"details,omitempty"` + User string `json:"user,omitempty"` + Note string `json:"note,omitempty"` + Source string `json:"source,omitempty"` +} + +// RemoveDetailsAlertRequest provides necessary parameter structure to Remove Details from an alert at OpsGenie. +type RemoveDetailsAlertRequest struct { + APIKey string `url:"apiKey,omitempty"` + ID string `url:"id,omitempty"` + Alias string `url:"alias,omitempty"` + Keys []string `url:"keys,omitempty"` + User string `url:"user,omitempty"` + Note string `url:"note,omitempty"` + Source string `url:"source,omitempty"` +} + +// EscalateToNextAlertRequest provides necessary parameter structure to Escalate To Next for and alert at OpsGenie. +type EscalateToNextAlertRequest struct { + APIKey string `json:"apiKey,omitempty"` + ID string `json:"id,omitempty"` + Alias string `json:"alias,omitempty"` + EscalationID string `json:"escalationId,omitempty"` + EscalationName string `json:"escalationName,omitempty"` + User string `json:"user,omitempty"` + Note string `json:"note,omitempty"` + Source string `json:"source,omitempty"` +} \ No newline at end of file diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/client/opsgenie_alert_client.go b/vendor/github.com/opsgenie/opsgenie-go-sdk/client/opsgenie_alert_client.go index f80a66c78..0df735746 100644 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/client/opsgenie_alert_client.go +++ b/vendor/github.com/opsgenie/opsgenie-go-sdk/client/opsgenie_alert_client.go @@ -38,7 +38,13 @@ const ( addTagsAlertURL = "/v1/json/alert/tags" executeActionAlertURL = "/v1/json/alert/executeAction" attachFileAlertURL = "/v1/json/alert/attach" - countAlertURL = "/v1/json/alert/count" + countAlertURL = "/v1/json/alert/count" + unacknowledgeAlertURL = "/v1/json/alert/unacknowledge" + snoozeAlertURL = "/v1/json/alert/snooze" + removeTagsAlertURL = "/v1/json/alert/tags" + addDetailsAlertURL = "/v1/json/alert/details" + removeDetailsAlertURL = "/v1/json/alert/details" + escalateToNextAlertURL = "/v1/json/alert/escalateToNext" ) // OpsGenieAlertClient is the data type to make Alert API requests. @@ -412,6 +418,126 @@ func (cli *OpsGenieAlertClient) ExecuteAction(req alerts.ExecuteActionAlertReque return &executeActionAlertResp, nil } +// UnAcknowledge method unacknowledges an alert at OpsGenie. +func (cli *OpsGenieAlertClient) UnAcknowledge(req alerts.UnAcknowledgeAlertRequest) (*alerts.UnAcknowledgeAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildPostRequest(unacknowledgeAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var unacknowledgeAlertResp alerts.UnAcknowledgeAlertResponse + + if err = resp.Body.FromJsonTo(&unacknowledgeAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &unacknowledgeAlertResp, nil +} + +// Snooze method snoozes an alert at OpsGenie. +func (cli *OpsGenieAlertClient) Snooze(req alerts.SnoozeAlertRequest) (*alerts.SnoozeAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildPostRequest(snoozeAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var snoozeAlertResp alerts.SnoozeAlertResponse + + if err = resp.Body.FromJsonTo(&snoozeAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &snoozeAlertResp, nil +} + +// RemoveTags method removes tags from an alert at OpsGenie. +func (cli *OpsGenieAlertClient) RemoveTags(req alerts.RemoveTagsAlertRequest) (*alerts.RemoveTagsAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildDeleteRequest(removeTagsAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var removeTagsAlertResp alerts.RemoveTagsAlertResponse + + if err = resp.Body.FromJsonTo(&removeTagsAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &removeTagsAlertResp, nil +} + +// AddDetails method adds details to an alert at OpsGenie. +func (cli *OpsGenieAlertClient) AddDetails(req alerts.AddDetailsAlertRequest) (*alerts.AddDetailsAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildPostRequest(addDetailsAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var addDetailsAlertResp alerts.AddDetailsAlertResponse + + if err = resp.Body.FromJsonTo(&addDetailsAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &addDetailsAlertResp, nil +} + +// RemoveDetails method removes details from an alert at OpsGenie. +func (cli *OpsGenieAlertClient) RemoveDetails(req alerts.RemoveDetailsAlertRequest) (*alerts.RemoveDetailsAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildDeleteRequest(removeDetailsAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var removeDetailsAlertResp alerts.RemoveDetailsAlertResponse + + if err = resp.Body.FromJsonTo(&removeDetailsAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &removeDetailsAlertResp, nil +} + +// UnAcknowledge method unacknowledges an alert at OpsGenie. +func (cli *OpsGenieAlertClient) EscalateToNext(req alerts.EscalateToNextAlertRequest) (*alerts.EscalateToNextAlertResponse, error) { + req.APIKey = cli.apiKey + resp, err := cli.sendRequest(cli.buildPostRequest(escalateToNextAlertURL, req)) + + if resp == nil { + return nil, err + } + defer resp.Body.Close() + + var escalateToNextAlertResp alerts.EscalateToNextAlertResponse + + if err = resp.Body.FromJsonTo(&escalateToNextAlertResp); err != nil { + message := "Server response can not be parsed, " + err.Error() + logging.Logger().Warn(message) + return nil, errors.New(message) + } + return &escalateToNextAlertResp, nil +} + // AttachFile method attaches a file to an alert at OpsGenie. func (cli *OpsGenieAlertClient) AttachFile(req alerts.AttachFileAlertRequest) (*alerts.AttachFileAlertResponse, error) { req.APIKey = cli.apiKey diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team.go b/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team.go index 0201a9568..acd664937 100644 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team.go +++ b/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team.go @@ -16,6 +16,7 @@ type Member struct { // CreateTeamRequest provides necessary parameter structure for creating team type CreateTeamRequest struct { APIKey string `json:"apiKey,omitempty"` + Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` Members []Member `json:"members,omitempty"` } @@ -23,6 +24,7 @@ type CreateTeamRequest struct { // UpdateTeamRequest provides necessary parameter structure for updating a team type UpdateTeamRequest struct { APIKey string `json:"apiKey,omitempty"` + Description string `json:"description,omitempty"` Id string `json:"id,omitempty"` Name string `json:"name,omitempty"` Members []Member `json:"members,omitempty"` diff --git a/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team_responses.go b/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team_responses.go index d0ab0ea42..6509f71d3 100644 --- a/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team_responses.go +++ b/vendor/github.com/opsgenie/opsgenie-go-sdk/team/team_responses.go @@ -21,6 +21,7 @@ type DeleteTeamResponse struct { // Get team response structure type GetTeamResponse struct { + Description string `json:"description,omitempty"` Id string `json:"id,omitempty"` Name string `json:"name,omitempty"` Members []Member `json:"members,omitempty"` diff --git a/vendor/vendor.json b/vendor/vendor.json index 94e7feaa8..03d7f6a7b 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -2236,64 +2236,64 @@ "revisionTime": "2013-12-21T20:05:32Z" }, { - "checksumSHA1": "pp5jNDEOaGDzOb1F0ajBNClK8og=", + "checksumSHA1": "0/RftERTKDVmV2jHzq7+vtmAgfk=", "path": "github.com/opsgenie/opsgenie-go-sdk/alerts", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { - "checksumSHA1": "kD80GYnlsh2/LOIAgGgGdULT0HU=", + "checksumSHA1": "hKn7WCXZXfVmwI20A6yoqpe0Mks=", "path": "github.com/opsgenie/opsgenie-go-sdk/client", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "/qEw2SLQwcT3dTbBUaHvyRszM3U=", "path": "github.com/opsgenie/opsgenie-go-sdk/escalation", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "SHhmCqu+9Hh5e0Tyo6NtP+ofAuU=", "path": "github.com/opsgenie/opsgenie-go-sdk/heartbeat", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "Z4UBwcb/EmhF2dSrxJs9r7pI6w8=", "path": "github.com/opsgenie/opsgenie-go-sdk/integration", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "JI6oDq30yyH+Y1C4xfcKWfDMq/A=", "path": "github.com/opsgenie/opsgenie-go-sdk/logging", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "ON63VXFhw2kb9XTDRzN9AgPCmIc=", "path": "github.com/opsgenie/opsgenie-go-sdk/policy", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "xhOHMc+dJEFYhFSGZBGsKV/AYBc=", "path": "github.com/opsgenie/opsgenie-go-sdk/schedule", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { - "checksumSHA1": "cXHPOWaBeihPn4GRQmqPF3qVdwY=", + "checksumSHA1": "TGsrNGsuIejIWfSWoFiWBGdYrFs=", "path": "github.com/opsgenie/opsgenie-go-sdk/team", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "1O5b+oyDYkjze5MVH8YMBV3+FHI=", "path": "github.com/opsgenie/opsgenie-go-sdk/user", - "revision": "82dfcf432a7ebd279d4db97812012bccce4bca89", - "revisionTime": "2016-11-24T11:28:56Z" + "revision": "2654b36ec837f913b546aec27f7717b5ac664cc8", + "revisionTime": "2017-01-24T12:11:56Z" }, { "checksumSHA1": "d1VHczIGt2bhYR0BNkTedIS/9uk=", diff --git a/website/source/docs/providers/opsgenie/r/team.html.markdown b/website/source/docs/providers/opsgenie/r/team.html.markdown index eaefe692e..60d6e5075 100644 --- a/website/source/docs/providers/opsgenie/r/team.html.markdown +++ b/website/source/docs/providers/opsgenie/r/team.html.markdown @@ -26,6 +26,7 @@ resource "opsgenie_user" "second" { resource "opsgenie_team" "test" { name = "example" + description = "This team deals with all the things" member { username = "${opsgenie_user.first.username}" @@ -45,6 +46,8 @@ The following arguments are supported: * `name` - (Required) The name associated with this team. OpsGenie defines that this must not be longer than 100 characters. +* `description` - (Optional) A description for this team. + * `member` - (Optional) A Member block as documented below. `member` supports the following: