-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IncidentNotes,Tags,GlobalRouter Endpoints
1.change io/ioutil package to io 2.Added Events endpoint 3.Bug fixes in incident, schedules, member, roles services
- Loading branch information
Showing
9 changed files
with
414 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type EventsService service | ||
|
||
type AlertPayload struct { | ||
Message string `json:"message"` | ||
Summary string `json:"summary"` | ||
AlertType string `json:"alert_type"` | ||
Suppressed bool `json:"suppressed,omitempty"` | ||
EntityID string `json:"entity_id"` | ||
Payload interface{} `json:"payload"` // payload map[string]interface{}{"severity": "SEV1"} | ||
} | ||
|
||
type IntegrationObject struct { | ||
Name string `json:"name"` | ||
Summary string `json:"summary"` | ||
Service string `json:"service"` | ||
Team string `json:"team"` | ||
IntegrationKey string `json:"integration_key"` | ||
IsEnabled bool `json:"is_enabled"` | ||
} | ||
|
||
type AlertResponse struct { | ||
UniqueID string `json:"unique_id"` | ||
Message string `json:"message"` | ||
Summary string `json:"summary"` | ||
AlertType string `json:"alert_type"` | ||
Suppressed bool `json:"suppressed"` | ||
EntityID string `json:"entity_id"` | ||
Payload string `json:"payload"` | ||
IntegrationObject IntegrationObject `json:"integration_object"` | ||
Integration string `json:"integration"` | ||
CreationDate string `json:"creation_date"` | ||
} | ||
|
||
func (c *EventsService) SendAlert(integrationKey string, payload *AlertPayload) (*AlertResponse, error) { | ||
path := fmt.Sprintf("/api/events/%s/", integrationKey) | ||
|
||
body, err := c.client.newRequestDo("POST", path, payload) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var i AlertResponse | ||
err = json.Unmarshal(body.BodyBytes, &i) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &i, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type GlobalRouterService service | ||
|
||
type GlobalRouterPayload struct { | ||
UniqueID string `json:"unique_id,omitempty"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
IsEnabled bool `json:"is_enabled,omitempty"` | ||
IntegrationKey string `json:"integration_key,omitempty"` | ||
} | ||
|
||
func (c *GlobalRouterService) CreateGlobalRouter(router *GlobalRouterPayload) (*GlobalRouterPayload, error) { | ||
path := "/api/v2/account/events/router/" | ||
|
||
body, err := c.client.newRequestDo("POST", path, router) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var r GlobalRouterPayload | ||
err = json.Unmarshal(body.BodyBytes, &r) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &r, nil | ||
} | ||
|
||
func (c *GlobalRouterService) UpdateGlobalRouter(id string, router *GlobalRouterPayload) (*GlobalRouterPayload, error) { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/", id) | ||
|
||
body, err := c.client.newRequestDo("PATCH", path, router) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var r GlobalRouterPayload | ||
err = json.Unmarshal(body.BodyBytes, &r) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &r, nil | ||
} | ||
|
||
func (c *GlobalRouterService) GetGlobalRouters() ([]GlobalRouterPayload, error) { | ||
path := "/api/v2/account/events/router/" | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var i []GlobalRouterPayload | ||
err = json.Unmarshal(body.BodyBytes, &i) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return i, nil | ||
} | ||
|
||
func (c *GlobalRouterService) GetGlobalRouter(id string) (*GlobalRouterPayload, error) { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/", id) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var r GlobalRouterPayload | ||
err = json.Unmarshal(body.BodyBytes, &r) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &r, nil | ||
} | ||
|
||
func (c *GlobalRouterService) DeleteGlobalRouter(id string) error { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/", id) | ||
_, err := c.client.newRequestDo("DELETE", path, nil) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type GlobalRoutingRuleAction struct { | ||
UniqueId string `json:"unique_id,omitempty"` | ||
ActionType int `json:"action_type"` | ||
Integration string `json:"integration,omitempty"` | ||
} | ||
|
||
// action := client.GlobalRoutingRuleAction{ ActionType: 1} | ||
|
||
type GlobalRoutingRule struct { | ||
Unique_Id string `json:"unique_id,omitempty"` | ||
Name string `json:"name"` | ||
Position int `json:"position,omitempty"` | ||
RuleJson string `json:"rule_json"` | ||
Actions []GlobalRoutingRuleAction `json:"actions"` // []client.GlobalRoutingRuleAction{action} | ||
} | ||
|
||
func (c *GlobalRouterService) CreateGlobalRoutingRule(routerID string, rule *GlobalRoutingRule) (*GlobalRoutingRule, error) { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/rulesets/", routerID) | ||
body, err := c.client.newRequestDo("POST", path, rule) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s GlobalRoutingRule | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
} | ||
|
||
func (c *GlobalRouterService) GetGlobalRoutingRules(routerID string) ([]GlobalRoutingRule, error) { | ||
|
||
path := fmt.Sprintf("/api/v2/account/events/router/%s/rulesets/", routerID) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s []GlobalRoutingRule | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return s, nil | ||
} | ||
|
||
func (c *GlobalRouterService) GetGlobalRoutingRule(routerID, rulesetID string) (*GlobalRoutingRule, error) { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/rulesets/%s/", routerID, rulesetID) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s GlobalRoutingRule | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
} | ||
|
||
func (c *GlobalRouterService) UpdateGlobalRoutingRule(routerID, rulesetID string, rule *GlobalRoutingRule) (*GlobalRoutingRule, error) { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/rulesets/%s/", routerID, rulesetID) | ||
body, err := c.client.newRequestDo("PUT", path, rule) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s GlobalRoutingRule | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
} | ||
|
||
func (c *GlobalRouterService) DeleteGlobalRoutingRule(routerID, rulesetID string) error { | ||
path := fmt.Sprintf("/api/v2/account/events/router/%s/rulesets/%s/", routerID, rulesetID) | ||
_, err := c.client.newRequestDo("DELETE", path, nil) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.