mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
209
vendor/github.com/PagerDuty/go-pagerduty/LICENSE.txt
generated
vendored
209
vendor/github.com/PagerDuty/go-pagerduty/LICENSE.txt
generated
vendored
@@ -1,14 +1,201 @@
|
||||
Copyright:: Copyright (c) 2016 PagerDuty, Inc.
|
||||
License:: Apache License, Version 2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
1. Definitions.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2017 PagerDuty, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
34
vendor/github.com/PagerDuty/go-pagerduty/README.md
generated
vendored
34
vendor/github.com/PagerDuty/go-pagerduty/README.md
generated
vendored
@@ -5,15 +5,27 @@ go-pagerduty is a CLI and [go](https://golang.org/) client library for the [Page
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
First, download the source code
|
||||
```cli
|
||||
go get github.com/PagerDuty/go-pagerduty
|
||||
```
|
||||
|
||||
Next build the application.
|
||||
```cli
|
||||
cd $GOPATH/src/github.com/PagerDuty/go-pagerduty
|
||||
go build -o $GOPATH/bin/pd command/*
|
||||
```
|
||||
If you do not have the dependencies necessary to build the project, run this in the project root and try again
|
||||
|
||||
```cli
|
||||
go get ./...
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### CLI
|
||||
|
||||
The CLI requires an [authentication token](https://v2.developer.pagerduty.com/docs/authentication), which can be sepcified in `.pd.yml`
|
||||
The CLI requires an [authentication token](https://v2.developer.pagerduty.com/docs/authentication), which can be specified in `.pd.yml`
|
||||
file in the home directory of the user, or passed as a command-line argument.
|
||||
Example of config file:
|
||||
|
||||
@@ -22,12 +34,6 @@ Example of config file:
|
||||
authtoken: fooBar
|
||||
```
|
||||
|
||||
#### Install
|
||||
```cli
|
||||
cd $GOPATH/github.com/PagerDuty/go-pagerduty
|
||||
go build -o $GOPATH/bin/pd command/*
|
||||
```
|
||||
|
||||
#### Commands
|
||||
`pd` command provides a single entrypoint for all the API endpoints, with individual
|
||||
API represented by their own sub commands. For an exhaustive list of sub-commands, try:
|
||||
@@ -57,12 +63,12 @@ var authtoken = "" // Set your auth token here
|
||||
func main() {
|
||||
var opts pagerduty.ListEscalationPoliciesOptions
|
||||
client := pagerduty.NewClient(authtoken)
|
||||
if eps, err := client.ListEscalationPolicies(opts); err != nil {
|
||||
eps, err := client.ListEscalationPolicies(opts)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
for _, p := range eps.EscalationPolicies {
|
||||
fmt.Println(p.Name)
|
||||
}
|
||||
}
|
||||
for _, p := range eps.EscalationPolicies {
|
||||
fmt.Println(p.Name)
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -71,6 +77,8 @@ The PagerDuty API client also exposes its HTTP client as the `HTTPClient` field.
|
||||
If you need to use your own HTTP client, for doing things like defining your own
|
||||
transport settings, you can replace the default HTTP client with your own by
|
||||
simply by setting a new value in the `HTTPClient` field.
|
||||
## License
|
||||
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
10
vendor/github.com/PagerDuty/go-pagerduty/client.go
generated
vendored
10
vendor/github.com/PagerDuty/go-pagerduty/client.go
generated
vendored
@@ -85,7 +85,8 @@ var defaultHTTPClient HTTPClient = newDefaultHTTPClient()
|
||||
|
||||
// Client wraps http client
|
||||
type Client struct {
|
||||
authToken string
|
||||
authToken string
|
||||
apiEndpoint string
|
||||
|
||||
// HTTPClient is the HTTP client used for making requests against the
|
||||
// PagerDuty API. You can use either *http.Client here, or your own
|
||||
@@ -96,8 +97,9 @@ type Client struct {
|
||||
// NewClient creates an API client
|
||||
func NewClient(authToken string) *Client {
|
||||
return &Client{
|
||||
authToken: authToken,
|
||||
HTTPClient: defaultHTTPClient,
|
||||
authToken: authToken,
|
||||
apiEndpoint: apiEndpoint,
|
||||
HTTPClient: defaultHTTPClient,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +132,7 @@ func (c *Client) get(path string) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func (c *Client) do(method, path string, body io.Reader, headers *map[string]string) (*http.Response, error) {
|
||||
endpoint := apiEndpoint + path
|
||||
endpoint := c.apiEndpoint + path
|
||||
req, _ := http.NewRequest(method, endpoint, body)
|
||||
req.Header.Set("Accept", "application/vnd.pagerduty+json;version=2")
|
||||
if headers != nil {
|
||||
|
||||
4
vendor/github.com/PagerDuty/go-pagerduty/escalation_policy.go
generated
vendored
4
vendor/github.com/PagerDuty/go-pagerduty/escalation_policy.go
generated
vendored
@@ -23,9 +23,9 @@ type EscalationPolicy struct {
|
||||
APIObject
|
||||
Name string `json:"name,omitempty"`
|
||||
EscalationRules []EscalationRule `json:"escalation_rules,omitempty"`
|
||||
Services []APIReference `json:"services,omitempty"`
|
||||
Services []APIObject `json:"services,omitempty"`
|
||||
NumLoops uint `json:"num_loops,omitempty"`
|
||||
Teams []APIReference `json:"teams,omitempty"`
|
||||
Teams []APIReference `json:"teams"`
|
||||
Description string `json:"description,omitempty"`
|
||||
RepeatEnabled bool `json:"repeat_enabled,omitempty"`
|
||||
}
|
||||
|
||||
1
vendor/github.com/PagerDuty/go-pagerduty/event_v2.go
generated
vendored
1
vendor/github.com/PagerDuty/go-pagerduty/event_v2.go
generated
vendored
@@ -14,6 +14,7 @@ type V2Event struct {
|
||||
Action string `json:"event_action"`
|
||||
DedupKey string `json:"dedup_key,omitempty"`
|
||||
Images []interface{} `json:"images,omitempty"`
|
||||
Links []interface{} `json:"links,omitempty"`
|
||||
Client string `json:"client,omitempty"`
|
||||
ClientURL string `json:"client_url,omitempty"`
|
||||
Payload *V2Payload `json:"payload,omitempty"`
|
||||
|
||||
141
vendor/github.com/PagerDuty/go-pagerduty/incident.go
generated
vendored
141
vendor/github.com/PagerDuty/go-pagerduty/incident.go
generated
vendored
@@ -7,28 +7,56 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
)
|
||||
|
||||
// Acknowledgement is the data structure of an acknoledgement of an incident.
|
||||
// Acknowledgement is the data structure of an acknowledgement of an incident.
|
||||
type Acknowledgement struct {
|
||||
At string
|
||||
Acknowledger APIObject
|
||||
At string `json:"at,omitempty"`
|
||||
Acknowledger APIObject `json:"acknowledger,omitempty"`
|
||||
}
|
||||
|
||||
// PendingAction is the data structure for any pending actions on an incident.
|
||||
type PendingAction struct {
|
||||
Type string
|
||||
At string
|
||||
Type string `json:"type,omitempty"`
|
||||
At string `json:"at,omitempty"`
|
||||
}
|
||||
|
||||
// Assignment is the data structure for an assignment of an incident
|
||||
type Assignment struct {
|
||||
At string
|
||||
Assignee APIObject
|
||||
At string `json:"at,omitempty"`
|
||||
Assignee APIObject `json:"assignee,omitempty"`
|
||||
}
|
||||
|
||||
// AlertCounts is the data structure holding a summary of the number of alerts by status of an incident.
|
||||
type AlertCounts struct {
|
||||
Triggered uint `json:"triggered,omitempty"`
|
||||
Resolved uint `json:"resolved,omitempty"`
|
||||
All uint `json:"all,omitempty"`
|
||||
}
|
||||
|
||||
// Priority is the data structure describing the priority of an incident.
|
||||
type Priority struct {
|
||||
APIObject
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// Resolve reason is the data structure describing the reason an incident was resolved
|
||||
type ResolveReason struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Incident APIObject `json:"incident"`
|
||||
}
|
||||
|
||||
// IncidentBody is the datastructure containing data describing the incident.
|
||||
type IncidentBody struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Details string `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
// Incident is a normalized, de-duplicated event generated by a PagerDuty integration.
|
||||
type Incident struct {
|
||||
APIObject
|
||||
IncidentNumber uint `json:"incident_number,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
PendingActions []PendingAction `json:"pending_actions,omitempty"`
|
||||
IncidentKey string `json:"incident_key,omitempty"`
|
||||
@@ -40,10 +68,14 @@ type Incident struct {
|
||||
FirstTriggerLogEntry APIObject `json:"first_trigger_log_entry,omitempty"`
|
||||
EscalationPolicy APIObject `json:"escalation_policy,omitempty"`
|
||||
Teams []APIObject `json:"teams,omitempty"`
|
||||
Priority *Priority `json:"priority,omitempty"`
|
||||
Urgency string `json:"urgency,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Priority APIObject `json:"priority,omitempty"`
|
||||
ResolveReason ResolveReason `json:"resolve_reason,omitempty"`
|
||||
AlertCounts AlertCounts `json:"alert_counts,omitempty"`
|
||||
Body IncidentBody `json:"body,omitempty"`
|
||||
IsMergeable bool `json:"is_mergeable,omitempty"`
|
||||
}
|
||||
|
||||
// ListIncidentsResponse is the response structure when calling the ListIncident API endpoint.
|
||||
@@ -83,32 +115,29 @@ func (c *Client) ListIncidents(o ListIncidentsOptions) (*ListIncidentsResponse,
|
||||
return &result, c.decodeJSON(resp, &result)
|
||||
}
|
||||
|
||||
// CreateIncident is the structure POST'd to the incidents endpoint. It wraps a CreateIncidentValue
|
||||
type CreateIncident struct {
|
||||
Incident CreateIncidentOptions `json:"incident"`
|
||||
}
|
||||
|
||||
// createIncidentResponse is returned from the API when creating a response.
|
||||
type createIncidentResponse struct {
|
||||
Incident Incident `json:incident`
|
||||
Incident Incident `json:"incident"`
|
||||
}
|
||||
|
||||
// CreateIncidentOptions is the structure used when POSTing to the CreateIncident API endpoint.
|
||||
type CreateIncidentOptions struct {
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Service APIReference `json:"service"`
|
||||
Priority APIReference `json:"priority"`
|
||||
IncidentKey string `json:"incident_key"`
|
||||
Body APIDetails `json:"body"`
|
||||
EscalationPolicy APIReference `json:"escalation_policy"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Service *APIReference `json:"service"`
|
||||
Priority *APIReference `json:"priority,omitempty"`
|
||||
IncidentKey string `json:"incident_key,omitempty"`
|
||||
Body *APIDetails `json:"body,omitempty"`
|
||||
EscalationPolicy *APIReference `json:"escalation_policy,omitempty"`
|
||||
}
|
||||
|
||||
// CreateIncident creates an incident synchronously without a corresponding event from a monitoring service.
|
||||
func (c *Client) CreateIncident(from string, i *CreateIncident) (*Incident, error) {
|
||||
func (c *Client) CreateIncident(from string, o *CreateIncidentOptions) (*Incident, error) {
|
||||
headers := make(map[string]string)
|
||||
headers["From"] = from
|
||||
resp, e := c.post("/incidents", i, &headers)
|
||||
data := make(map[string]*CreateIncidentOptions)
|
||||
data["incident"] = o
|
||||
resp, e := c.post("/incidents", data, &headers)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
@@ -132,6 +161,16 @@ func (c *Client) ManageIncidents(from string, incidents []Incident) error {
|
||||
return e
|
||||
}
|
||||
|
||||
// MergeIncidents a list of source incidents into a specified incident.
|
||||
func (c *Client) MergeIncidents(from string, id string, incidents []Incident) error {
|
||||
r := make(map[string][]Incident)
|
||||
r["source_incidents"] = incidents
|
||||
headers := make(map[string]string)
|
||||
headers["From"] = from
|
||||
_, e := c.put("/incidents/"+id+"/merge", r, &headers)
|
||||
return e
|
||||
}
|
||||
|
||||
// GetIncident shows detailed information about an incident.
|
||||
func (c *Client) GetIncident(id string) (*Incident, error) {
|
||||
resp, err := c.get("/incidents/" + id)
|
||||
@@ -176,34 +215,43 @@ func (c *Client) ListIncidentNotes(id string) ([]IncidentNote, error) {
|
||||
|
||||
// IncidentAlert is a alert for the specified incident.
|
||||
type IncidentAlert struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
AlertKey string `json:"alert_key,omitempty"`
|
||||
APIObject
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
AlertKey string `json:"alert_key,omitempty"`
|
||||
Service APIObject `json:"service,omitempty"`
|
||||
Body map[string]interface{} `json:"body,omitempty"`
|
||||
Incident APIReference `json:"incident,omitempty"`
|
||||
Suppressed bool `json:"suppressed,omitempty"`
|
||||
Severity string `json:"severity,omitempty"`
|
||||
Integration APIObject `json:"integration,omitempty"`
|
||||
}
|
||||
|
||||
// ListAlertsResponse is the response structure when calling the ListAlert API endpoint.
|
||||
type ListAlertsResponse struct {
|
||||
APIListObject
|
||||
Alerts []IncidentAlert `json:"alerts,omitempty"`
|
||||
}
|
||||
|
||||
// ListIncidentAlerts lists existing alerts for the specified incident.
|
||||
func (c *Client) ListIncidentAlerts(id string) ([]IncidentAlert, error) {
|
||||
resp, err := c.get("/incidents/"+id+"/alerts")
|
||||
func (c *Client) ListIncidentAlerts(id string) (*ListAlertsResponse, error) {
|
||||
resp, err := c.get("/incidents/" + id + "/alerts")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result map[string][]IncidentAlert
|
||||
if err := c.decodeJSON(resp, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
alerts, ok := result["alerts"]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("JSON response does not have alerts field")
|
||||
}
|
||||
return alerts, nil
|
||||
|
||||
var result ListAlertsResponse
|
||||
return &result, c.decodeJSON(resp, &result)
|
||||
}
|
||||
|
||||
// CreateIncidentNote creates a new note for the specified incident.
|
||||
func (c *Client) CreateIncidentNote(id string, note IncidentNote) error {
|
||||
data := make(map[string]IncidentNote)
|
||||
headers := make(map[string]string)
|
||||
headers["From"] = note.User.Summary
|
||||
|
||||
data["note"] = note
|
||||
_, err := c.post("/incidents/"+id+"/notes", data, nil)
|
||||
_, err := c.post("/incidents/"+id+"/notes", data, &headers)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -242,3 +290,18 @@ func (c *Client) ListIncidentLogEntries(id string, o ListIncidentLogEntriesOptio
|
||||
var result ListIncidentLogEntriesResponse
|
||||
return &result, c.decodeJSON(resp, &result)
|
||||
}
|
||||
|
||||
// Alert is a list of all of the alerts that happened to an incident.
|
||||
type Alert struct {
|
||||
APIObject
|
||||
Service APIObject `json:"service,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
AlertKey string `json:"alert_key,omitempty"`
|
||||
Incident APIObject `json:"incident,omitempty"`
|
||||
}
|
||||
|
||||
type ListAlertResponse struct {
|
||||
APIListObject
|
||||
Alerts []Alert `json:"alerts,omitempty"`
|
||||
}
|
||||
|
||||
2
vendor/github.com/PagerDuty/go-pagerduty/log_entry.go
generated
vendored
2
vendor/github.com/PagerDuty/go-pagerduty/log_entry.go
generated
vendored
@@ -68,7 +68,7 @@ func (c *Client) ListLogEntries(o ListLogEntriesOptions) (*ListLogEntryResponse,
|
||||
|
||||
// GetLogEntryOptions is the data structure used when calling the GetLogEntry API endpoint.
|
||||
type GetLogEntryOptions struct {
|
||||
TimeZone string `url:"timezone,omitempty"`
|
||||
TimeZone string `url:"time_zone,omitempty"`
|
||||
Includes []string `url:"include,omitempty,brackets"`
|
||||
}
|
||||
|
||||
|
||||
19
vendor/github.com/PagerDuty/go-pagerduty/maintenance_window.go
generated
vendored
19
vendor/github.com/PagerDuty/go-pagerduty/maintenance_window.go
generated
vendored
@@ -49,14 +49,25 @@ func (c *Client) ListMaintenanceWindows(o ListMaintenanceWindowsOptions) (*ListM
|
||||
return &result, c.decodeJSON(resp, &result)
|
||||
}
|
||||
|
||||
// CreateMaintenanceWindows creates a new maintenance window for the specified services.
|
||||
func (c *Client) CreateMaintenanceWindows(m MaintenanceWindow) (*MaintenanceWindow, error) {
|
||||
// CreateMaintenanceWindow creates a new maintenance window for the specified services.
|
||||
func (c *Client) CreateMaintenanceWindow(from string, o MaintenanceWindow) (*MaintenanceWindow, error) {
|
||||
data := make(map[string]MaintenanceWindow)
|
||||
data["maintenance_window"] = m
|
||||
resp, err := c.post("/maintenance_windows", data, nil)
|
||||
o.Type = "maintenance_window"
|
||||
data["maintenance_window"] = o
|
||||
headers := make(map[string]string)
|
||||
if from != "" {
|
||||
headers["From"] = from
|
||||
}
|
||||
resp, err := c.post("/maintenance_windows", data, &headers)
|
||||
return getMaintenanceWindowFromResponse(c, resp, err)
|
||||
}
|
||||
|
||||
// CreateMaintenanceWindows creates a new maintenance window for the specified services.
|
||||
// Deprecated: Use `CreateMaintenanceWindow` instead.
|
||||
func (c *Client) CreateMaintenanceWindows(o MaintenanceWindow) (*MaintenanceWindow, error) {
|
||||
return c.CreateMaintenanceWindow("", o)
|
||||
}
|
||||
|
||||
// DeleteMaintenanceWindow deletes an existing maintenance window if it's in the future, or ends it if it's currently on-going.
|
||||
func (c *Client) DeleteMaintenanceWindow(id string) error {
|
||||
_, err := c.delete("/maintenance_windows/" + id)
|
||||
|
||||
12
vendor/github.com/PagerDuty/go-pagerduty/on_call.go
generated
vendored
12
vendor/github.com/PagerDuty/go-pagerduty/on_call.go
generated
vendored
@@ -6,12 +6,12 @@ import (
|
||||
|
||||
// OnCall represents a contiguous unit of time for which a user will be on call for a given escalation policy and escalation rule.
|
||||
type OnCall struct {
|
||||
User APIObject `json:"user,omitempty"`
|
||||
Schedule APIObject `json:"schedule,omitempty"`
|
||||
EscalationPolicy APIObject `json:"escalation_policy,omitempty"`
|
||||
EscalationLevel uint `json:"escalation_level,omitempty"`
|
||||
Start string `json:"start,omitempty"`
|
||||
End string `json:"end,omitempty"`
|
||||
User User `json:"user,omitempty"`
|
||||
Schedule Schedule `json:"schedule,omitempty"`
|
||||
EscalationPolicy EscalationPolicy `json:"escalation_policy,omitempty"`
|
||||
EscalationLevel uint `json:"escalation_level,omitempty"`
|
||||
Start string `json:"start,omitempty"`
|
||||
End string `json:"end,omitempty"`
|
||||
}
|
||||
|
||||
// ListOnCallsResponse is the data structure returned from calling the ListOnCalls API endpoint.
|
||||
|
||||
87
vendor/github.com/PagerDuty/go-pagerduty/user.go
generated
vendored
87
vendor/github.com/PagerDuty/go-pagerduty/user.go
generated
vendored
@@ -7,42 +7,51 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
)
|
||||
|
||||
// ContactMethod is a way of contacting the user.
|
||||
type ContactMethod struct {
|
||||
ID string
|
||||
Label string
|
||||
Address string
|
||||
Type string
|
||||
SendShortEmail bool `json:"send_short_email"`
|
||||
}
|
||||
|
||||
// NotificationRule is a rule for notifying the user.
|
||||
type NotificationRule struct {
|
||||
ID string
|
||||
ID string `json:"id"`
|
||||
StartDelayInMinutes uint `json:"start_delay_in_minutes"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ContactMethod ContactMethod `json:"contact_method"`
|
||||
Urgency string
|
||||
Type string
|
||||
Urgency string `json:"urgency"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// User is a member of a PagerDuty account that has the ability to interact with incidents and other data on the account.
|
||||
type User struct {
|
||||
APIObject
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Timezone string `json:"timezone,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
AvatarURL string `json:"avatar_url,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
InvitationSent bool
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Summary string `json:"summary"`
|
||||
Email string `json:"email"`
|
||||
Timezone string `json:"time_zone,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
AvatarURL string `json:"avatar_url,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
InvitationSent bool `json:"invitation_sent,omitempty"`
|
||||
ContactMethods []ContactMethod `json:"contact_methods"`
|
||||
NotificationRules []NotificationRule `json:"notification_rules"`
|
||||
JobTitle string `json:"job_title,omitempty"`
|
||||
Teams []Team
|
||||
}
|
||||
|
||||
// ContactMethod is a way of contacting the user.
|
||||
type ContactMethod struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Summary string `json:"summary"`
|
||||
Self string `json:"self"`
|
||||
Label string `json:"label"`
|
||||
Address string `json:"address"`
|
||||
SendShortEmail bool `json:"send_short_email,omitempty"`
|
||||
SendHTMLEmail bool `json:"send_html_email,omitempty"`
|
||||
Blacklisted bool `json:"blacklisted,omitempty"`
|
||||
CountryCode int `json:"country_code,omitempty"`
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
HTMLUrl string `json:"html_url"`
|
||||
}
|
||||
|
||||
// ListUsersResponse is the data structure returned from calling the ListUsers API endpoint.
|
||||
type ListUsersResponse struct {
|
||||
APIListObject
|
||||
@@ -57,6 +66,12 @@ type ListUsersOptions struct {
|
||||
Includes []string `url:"include,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// ListContactMethodResponse is the data structure returned from calling the GetUserContactMethod API endpoint.
|
||||
type ListContactMethodsResponse struct {
|
||||
APIListObject
|
||||
ContactMethods []ContactMethod `json:"contact_methods"`
|
||||
}
|
||||
|
||||
// GetUserOptions is the data structure used when calling the GetUser API endpoint.
|
||||
type GetUserOptions struct {
|
||||
Includes []string `url:"include,omitempty,brackets"`
|
||||
@@ -123,3 +138,35 @@ func getUserFromResponse(c *Client, resp *http.Response, err error) (*User, erro
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
// ListUserContactMethod fetches contact methods of the existing user.
|
||||
func (c *Client) ListUserContactMethods(userId string) (*ListContactMethodsResponse, error) {
|
||||
resp, err := c.get("/users/" + userId + "/contact_methods")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result ListContactMethodsResponse
|
||||
return &result, c.decodeJSON(resp, &result)
|
||||
}
|
||||
|
||||
// GetContactMethod gets details about a contact method.
|
||||
func (c *Client) GetUserContactMethod(userID, id string) (*ContactMethod, error) {
|
||||
resp, err := c.get("/users/" + userID + "/contact_methods/" + id)
|
||||
return getContactMethodFromResponse(c, resp, err)
|
||||
}
|
||||
|
||||
func getContactMethodFromResponse(c *Client, resp *http.Response, err error) (*ContactMethod, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var target map[string]ContactMethod
|
||||
if dErr := c.decodeJSON(resp, &target); dErr != nil {
|
||||
return nil, fmt.Errorf("Could not decode JSON response: %v", dErr)
|
||||
}
|
||||
rootNode := "contact_method"
|
||||
t, nodeOK := target[rootNode]
|
||||
if !nodeOK {
|
||||
return nil, fmt.Errorf("JSON response does not have %s field", rootNode)
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
21
vendor/github.com/PagerDuty/go-pagerduty/vendor.go
generated
vendored
21
vendor/github.com/PagerDuty/go-pagerduty/vendor.go
generated
vendored
@@ -10,15 +10,18 @@ import (
|
||||
// Vendor represents a specific type of integration. AWS Cloudwatch, Splunk, Datadog, etc are all examples of vendors that can be integrated in PagerDuty by making an integration.
|
||||
type Vendor struct {
|
||||
APIObject
|
||||
Name string `json:"name,omitempty"`
|
||||
LogoURL string `json:"logo_url,omitempty"`
|
||||
LongName string `json:"long_name,omitempty"`
|
||||
WebsiteURL string `json:"website_url,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Connectable bool `json:"connectable,omitempty"`
|
||||
ThumbnailURL string `json:"thumbnail_url,omitempty"`
|
||||
GenericServiceType string `json:"generic_service_type,omitempty"`
|
||||
IntegrationGuideURL string `json:"integration_guide_url,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
LogoURL string `json:"logo_url,omitempty"`
|
||||
LongName string `json:"long_name,omitempty"`
|
||||
WebsiteURL string `json:"website_url,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Connectable bool `json:"connectable,omitempty"`
|
||||
ThumbnailURL string `json:"thumbnail_url,omitempty"`
|
||||
GenericServiceType string `json:"generic_service_type,omitempty"`
|
||||
IntegrationGuideURL string `json:"integration_guide_url,omitempty"`
|
||||
AlertCreationDefault string `json:"alert_creation_default,omitempty"`
|
||||
AlertCreationEditable bool `json:"alert_creation_editable,omitempty"`
|
||||
IsPDCEF bool `json:"is_pd_cef,omitempty"`
|
||||
}
|
||||
|
||||
// ListVendorResponse is the data structure returned from calling the ListVendors API endpoint.
|
||||
|
||||
Reference in New Issue
Block a user