Skip to content

Commit

Permalink
Merge pull request #15111 from bednar/notification-endpoint
Browse files Browse the repository at this point in the history
docs(http): update NotificationEndpoint swagger definition to reflect reality
  • Loading branch information
kelwang authored Sep 12, 2019
2 parents 61c75ae + a8ad9e2 commit 63c5311
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
28 changes: 25 additions & 3 deletions http/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5811,7 +5811,7 @@ paths:
$ref: "#/components/schemas/NotificationEndpoint"
responses:
'201':
description: Notification rule created
description: Notification endpoint created
content:
application/json:
schema:
Expand Down Expand Up @@ -9714,7 +9714,7 @@ components:
$ref: "#/components/schemas/Links"
NotificationEndpointBase:
type: object
required: [type]
required: [type, name]
properties:
id:
type: string
Expand Down Expand Up @@ -9742,18 +9742,40 @@ components:
enum: ["active", "inactive"]
labels:
$ref: "#/components/schemas/Labels"
links:
type: object
readOnly: true
example:
self: "/api/v2/notificationEndpoints/1"
labels: "/api/v2/notificationEndpoints/1/labels"
members: "/api/v2/notificationEndpoints/1/members"
owners: "/api/v2/notificationEndpoints/1/owners"
properties:
self:
description: URL for this endpoint
$ref: "#/components/schemas/Link"
labels:
description: URL to retrieve labels for this endpoint
$ref: "#/components/schemas/Link"
members:
description: URL to retrieve members for this endpoint
$ref: "#/components/schemas/Link"
owners:
description: URL to retrieve owners for this endpoint
$ref: "#/components/schemas/Link"
type:
$ref: "#/components/schemas/NotificationEndpointType"
SlackNotificationEndpoint:
type: object
allOf:
- $ref: "#/components/schemas/NotificationEndpointBase"
- type: object
required: [url, token]
properties:
url:
description: specifies the URL of the slack endpoint; either URL or Token should be specified
type: string
token:
description: specifies the api token string; either URL or Token should be specified
type: string
PagerDutyNotificationEndpoint:
type: object
Expand Down
32 changes: 32 additions & 0 deletions notification/endpoint/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ func TestValidEndpoint(t *testing.T) {
Msg: "invalid status",
},
},
{
name: "empty name",
src: &endpoint.PagerDuty{
Base: endpoint.Base{
ID: influxTesting.MustIDBase16(id1),
OrgID: influxTesting.MustIDBase16(id3),
Status: influxdb.Active,
},
ClientURL: "https://events.pagerduty.com/v2/enqueue",
RoutingKey: influxdb.SecretField{Key: id1 + "-routing-key"},
},
err: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "Notification Endpoint Name can't be empty",
},
},
{
name: "empty slack url and token",
src: &endpoint.Slack{
Expand Down Expand Up @@ -188,6 +204,22 @@ func TestJSON(t *testing.T) {
Token: influxdb.SecretField{Key: "token-key-1"},
},
},
{
name: "Slack without token",
src: &endpoint.Slack{
Base: endpoint.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
OrgID: influxTesting.MustIDBase16(id3),
Status: influxdb.Active,
CRUDLog: influxdb.CRUDLog{
CreatedAt: timeGen1.Now(),
UpdatedAt: timeGen2.Now(),
},
},
URL: "https://hooks.slack.com/services/x/y/z",
},
},
{
name: "simple pagerduty",
src: &endpoint.PagerDuty{
Expand Down

0 comments on commit 63c5311

Please sign in to comment.