Skip to content

Commit

Permalink
Changes by code-review.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlamug committed Aug 14, 2017
1 parent 0fa79ee commit ec49053
Show file tree
Hide file tree
Showing 45 changed files with 294 additions and 197 deletions.
6 changes: 3 additions & 3 deletions _samples/notificationsv2/notification_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ func main() {
notificationCli, _ := cli.NotificationV2()

identifier := &notificationv2.Identifier{
UserID: "1f3328df-cb1f-4d0b-8588-f00ed6824b11",
UserID: "0",
}

criteria := notificationv2.Criteria{
Type: notificationv2.MatchAllConditionsType,
Conditions: []notificationv2.Condition{
{
Field: "extra-properties",
Field: notificationv2.ExtraPropertiesField,
Key: "system",
Not: true,
Operation: "equals",
Operation: notificationv2.EqualsConditionOperation,
ExpectedValue: "mysql",
},
},
Expand Down
4 changes: 2 additions & 2 deletions _samples/notificationsv2/notification_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func main() {

response, err := notificationCli.Delete(notificationv2.DeleteNotificationRequest{
Identifier: &notificationv2.Identifier{
UserID: "4ca72bed-c1a9-40f8-a140-44cc957bf31a",
RuleID: "88c00129-6e68-40c5-a812-757dc140018d",
UserID: "0",
RuleID: "0",
},
})

Expand Down
4 changes: 2 additions & 2 deletions _samples/notificationsv2/notification_disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func main() {

response, err := notificationCli.Disable(notificationv2.DisableNotificationRequest{
Identifier: &notificationv2.Identifier{
UserID: "4ca72bed-c1a9-40f8-a140-44cc957bf31a",
RuleID: "ee0de42b-20e2-4ded-bc89-59614c4cd552",
UserID: "0",
RuleID: "0",
},
})

Expand Down
4 changes: 2 additions & 2 deletions _samples/notificationsv2/notification_enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func main() {

response, err := notificationCli.Enable(notificationv2.EnableNotificationRequest{
Identifier: &notificationv2.Identifier{
UserID: "4ca72bed-c1a9-40f8-a140-44cc957bf31a",
RuleID: "ee0de42b-20e2-4ded-bc89-59614c4cd552",
UserID: "0",
RuleID: "0",
},
})

Expand Down
8 changes: 4 additions & 4 deletions _samples/notificationsv2/notification_get.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
"fmt"
"encoding/json"
"fmt"

"github.com/opsgenie/opsgenie-go-sdk/_samples/constants"
ogcli "github.com/opsgenie/opsgenie-go-sdk/client"
"github.com/opsgenie/opsgenie-go-sdk/notificationv2"
"github.com/opsgenie/opsgenie-go-sdk/_samples/constants"
)

func main() {
Expand All @@ -17,8 +17,8 @@ func main() {

response, err := notificationCli.Get(notificationv2.GetNotificationRequest{
Identifier: &notificationv2.Identifier{
UserID: "4ca72bed-c1a9-40f8-a140-44cc957bf31a",
RuleID: "15212908-31cd-4d32-9c30-10bb22cb0008",
UserID: "0",
RuleID: "0",
},
})

Expand Down
2 changes: 1 addition & 1 deletion _samples/notificationsv2/notification_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {

response, err := notificationCli.List(notificationv2.ListNotificationRequest{
Identifier: &notificationv2.Identifier{
UserID: "4ca72bed-c1a9-40f8-a140-44cc957bf31a",
UserID: "0",
},
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions _samples/notificationsv2/notification_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func main() {
notificationCli, _ := cli.NotificationV2()

identifier := &notificationv2.Identifier{
UserID: "1f3328df-cb1f-4d0b-8588-f00ed6824b11",
RuleID: "4fad3584-62cd-49d6-bc4f-c20457645211",
UserID: "0",
RuleID: "0",
}

criteria := notificationv2.Criteria{
Expand Down
2 changes: 1 addition & 1 deletion _samples/usersv2/user_escalation_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
userCli, _ := cli.UserV2()

request := userv2.ListUserEscalationsRequest{
Identifier: &userv2.Identifier{UserName: "22275390-e95b-47df-8c13-6edc469c0b26"},
Identifier: &userv2.Identifier{UserName: "0"},
}

response, err := userCli.ListEscalations(request)
Expand Down
2 changes: 1 addition & 1 deletion _samples/usersv2/user_forwarding_rule_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
userCli, _ := cli.UserV2()

request := userv2.ListUserForwardingRulesRequest{
Identifier: &userv2.Identifier{UserName: "22275390-e95b-47df-8c13-6edc469c0b26"},
Identifier: &userv2.Identifier{UserName: "0"},
}

response, err := userCli.ListForwardingRules(request)
Expand Down
2 changes: 1 addition & 1 deletion _samples/usersv2/user_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {

request := userv2.GetUserRequest{
Identifier: &userv2.Identifier{
ID: "1b4d54a9-7f07-44ef-9995-b2c0b1adc674",
ID: "0",
Expand: userv2.ContactExpandableField,
},
}
Expand Down
3 changes: 1 addition & 2 deletions _samples/usersv2/user_schedule_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import (
func main() {
cli := new(ogcli.OpsGenieClient)
cli.SetAPIKey(constants.APIKey)
cli.SetAPIKey("bdd67d0e-92c6-47b5-87cf-f2a9940629e2")

userCli, _ := cli.UserV2()

request := userv2.ListUserSchedulesRequest{
Identifier: &userv2.Identifier{UserName: "22275390-e95b-47df-8c13-6edc469c0b26"},
Identifier: &userv2.Identifier{UserName: "0"},
}

response, err := userCli.ListSchedules(request)
Expand Down
3 changes: 1 addition & 2 deletions _samples/usersv2/user_team_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import (
func main() {
cli := new(ogcli.OpsGenieClient)
cli.SetAPIKey(constants.APIKey)
cli.SetAPIKey("bdd67d0e-92c6-47b5-87cf-f2a9940629e2")

userCli, _ := cli.UserV2()

request := userv2.ListUserTeamsRequest{
Identifier: &userv2.Identifier{UserName: "22275390-e95b-47df-8c13-6edc469c0b26"},
Identifier: &userv2.Identifier{UserName: "0"},
}

response, err := userCli.ListTeams(request)
Expand Down
2 changes: 1 addition & 1 deletion _samples/usersv2/user_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {

request := userv2.UpdateUserRequest{
Identifier: &userv2.Identifier{
ID: "1b4d54a9-7f07-44ef-9995-b2c0b1adc674",
ID: "0",
Expand: userv2.ContactExpandableField,
},
FullName: "Lex Luthor",
Expand Down
4 changes: 2 additions & 2 deletions client/opsgenie_user_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package client
import (
"errors"

"github.com/opsgenie/opsgenie-go-sdk/user"
"github.com/opsgenie/opsgenie-go-sdk/logging"
"github.com/opsgenie/opsgenie-go-sdk/user"
)

const (
userURL = "/v1/json/user"
userURL = "/v1/json/user"
)

// OpsGenieUserClient is the data type to make User API requests.
Expand Down
12 changes: 11 additions & 1 deletion notificationv2/action_result.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package notificationv2

const (
// The list of action results.
EnabledResult = "Enabled"
DisableResult = "Disabled"
DeletedResult = "Deleted"
)

// ActionResult contains result of action with notification rule.
type ActionResult struct {
Result string `json:"result"`
Result Result `json:"result"`
}

// Result contains string status of notification action result.
type Result string
16 changes: 16 additions & 0 deletions notificationv2/action_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package notificationv2

const (
// Types of action that notification rule will have after creating. It is used to create an alert.
CreateAlertActionType = "create-alert"
AcknowledgedAlertActionType = "acknowledged-alert"
ClosedAlertActionType = "closed-alert"
AssignedAlertActionType = "assigned-alert"
AddNoteActionType = "add-note"
ScheduleStartActionType = "schedule-start"
ScheduleEndActionType = "schedule-end"
IncomingCallRoutingActionType = "incoming-call-routing"
)

// ActionType is the type of notification action. Instead of
type ActionType string
11 changes: 11 additions & 0 deletions notificationv2/condition_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package notificationv2

const (
// The list of matches which are used for creating criteria of notification.
MatchAllType = "match-all"
MatchAnyConditionsType = "match-any-condition"
MatchAllConditionsType = "match-all-conditions"
)

// ConditionType is a type of matching of alert fields, which is used for building criteria of notification.
type ConditionType string
66 changes: 0 additions & 66 deletions notificationv2/constants.go

This file was deleted.

20 changes: 10 additions & 10 deletions notificationv2/create_notification_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ package notificationv2
type CreateNotificationRequest struct {
*Identifier
ApiKey string
Name string `json:"name"`
ActionType string `json:"actionType"`
Criteria Criteria `json:"criteria"`
NotificationTime []string `json:"notificationTime"`
TimeRestriction *TimeRestriction `json:"timeRestriction"`
Schedules []Schedule `json:"schedules"`
Order int `json:"order"`
Steps []Step `json:"steps"`
Repeat Repeat `json:"repeat"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
ActionType ActionType `json:"actionType"`
Criteria Criteria `json:"criteria"`
NotificationTime []NotificationTime `json:"notificationTime"`
TimeRestriction *TimeRestriction `json:"timeRestriction"`
Schedules []Schedule `json:"schedules"`
Order int `json:"order"`
Steps []Step `json:"steps"`
Repeat Repeat `json:"repeat"`
Enabled bool `json:"enabled"`
}

// GetApiKey returns api key.
Expand Down
16 changes: 8 additions & 8 deletions notificationv2/criteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package notificationv2
// Criteria defines the conditions that will be checked before applying notification rules and type of the operations
// that will be applied on these conditions.
type Criteria struct {
Type string `json:"type"`
Conditions []Condition `json:"conditions"`
Type ConditionType `json:"type"`
Conditions []Condition `json:"conditions"`
}

// Condition defines the conditions that will be checked before applying notification rules.
type Condition struct {
Field string `json:"field"`
Key string `json:"key"`
Not bool `json:"not"`
Operation string `json:"operation"`
ExpectedValue string `json:"expectedValue"`
Order int `json:"order"`
Field Field `json:"field"`
Key string `json:"key"`
Not bool `json:"not"`
Operation Operation `json:"operation"`
ExpectedValue string `json:"expectedValue"`
Order int `json:"order"`
}
15 changes: 15 additions & 0 deletions notificationv2/day.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package notificationv2

const (
// The list of week days. These strings are used for generate time restrictions.
Monday = "monday"
Tuesday = "tuesday"
Wednesday = "wednesday"
Thursday = "thursday"
Friday = "friday"
Saturday = "saturday"
Sunday = "sunday"
)

// Day is the text representation of day name of week.
type Day string
17 changes: 17 additions & 0 deletions notificationv2/field.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package notificationv2

const (
// The list of fields, which are used for build filter of alerts.
ActionsField = "actions"
AliasField = "alias"
DescriptionField = "description"
EntityField = "entity"
MessageField = "message"
RecipientsField = "recipients"
SourceField = "source"
TeamsField = "teams"
ExtraPropertiesField = "extra-properties"
)

// Field is the name of alert field, which is used to build filter of alerts.
type Field string
Loading

0 comments on commit ec49053

Please sign in to comment.