Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for IW triggers team restrictions #150

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pagerduty/event_orchestration_cache_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ type EventOrchestrationCacheVariableConfiguration struct {
}

type EventOrchestrationCacheVariable struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Disabled bool `json:"disabled"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Disabled bool `json:"disabled"`
Conditions []*EventOrchestrationCacheVariableCondition `json:"conditions"`
Configuration *EventOrchestrationCacheVariableConfiguration `json:"configuration,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
CreatedBy *UserReference `json:"created_by,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
UpdatedBy *UserReference `json:"updated_by,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
CreatedBy *UserReference `json:"created_by,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
UpdatedBy *UserReference `json:"updated_by,omitempty"`
}

type EventOrchestrationCacheVariablePayload struct {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (s *EventOrchestrationCacheVariableService) List(ctx context.Context, cache
return v, resp, nil
}

func (s *EventOrchestrationCacheVariableService) Create(ctx context.Context, cacheVariableType string, orchestrationId string, cacheVariable *EventOrchestrationCacheVariable) (*EventOrchestrationCacheVariable, *Response, error) {
func (s *EventOrchestrationCacheVariableService) Create(ctx context.Context, cacheVariableType string, orchestrationId string, cacheVariable *EventOrchestrationCacheVariable) (*EventOrchestrationCacheVariable, *Response, error) {
u := buildEventOrchestrationCacheVariableUrl(cacheVariableType, orchestrationId, "")
v := new(EventOrchestrationCacheVariablePayload)
p := &EventOrchestrationCacheVariablePayload{CacheVariable: cacheVariable}
Expand Down
29 changes: 14 additions & 15 deletions pagerduty/event_orchestration_cache_variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ func TestGlobalEventOrchestrationCacheVariableList(t *testing.T) {
setup()
defer teardown()

oId := "a64f9c87-6adc-4f89-a64c-2fdd8cba4639"
oId := "a64f9c87-6adc-4f89-a64c-2fdd8cba4639"
oType := "global"
url := fmt.Sprintf("%s/%s/cache_variables/", eventOrchestrationBaseUrl, oId)
url := fmt.Sprintf("%s/%s/cache_variables/", eventOrchestrationBaseUrl, oId)

mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -78,8 +78,8 @@ func TestGlobalEventOrchestrationCacheVariableList(t *testing.T) {
want := &ListEventOrchestrationCacheVariablesResponse{
CacheVariables: []*EventOrchestrationCacheVariable{
{
ID: "45be0a94-55b2-4691-b285-7a14478f4fe2",
Name: "example_1",
ID: "45be0a94-55b2-4691-b285-7a14478f4fe2",
Name: "example_1",
Conditions: []*EventOrchestrationCacheVariableCondition{},
Configuration: &EventOrchestrationCacheVariableConfiguration{
Type: "trigger_event_count",
Expand Down Expand Up @@ -234,8 +234,8 @@ func TestGlobalOrchestrationCacheVariableGet(t *testing.T) {
}

want := &EventOrchestrationCacheVariable{
ID: "9aa13ae3-81f3-4456-9abc-79233555fc3f",
Name: "get_example",
ID: "9aa13ae3-81f3-4456-9abc-79233555fc3f",
Name: "get_example",
Conditions: []*EventOrchestrationCacheVariableCondition{
{
Expression: "event.source matches part 'test'",
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestGlobalOrchestrationCacheVariableUpdate(t *testing.T) {
Type: "trigger_event_count",
TTLSeconds: 10,
},
Disabled: true,
Disabled: true,
CreatedAt: "2024-02-12T14:44:58Z",
CreatedBy: &UserReference{
ID: "P8B9WR7",
Expand Down Expand Up @@ -363,9 +363,9 @@ func TestServiceEventOrchestrationCacheVariableList(t *testing.T) {
setup()
defer teardown()

oId := "P3ZQXDF"
oId := "P3ZQXDF"
oType := "service"
url := fmt.Sprintf("%s/services/%s/cache_variables/", eventOrchestrationBaseUrl, oId)
url := fmt.Sprintf("%s/services/%s/cache_variables/", eventOrchestrationBaseUrl, oId)

mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -428,8 +428,8 @@ func TestServiceEventOrchestrationCacheVariableList(t *testing.T) {
want := &ListEventOrchestrationCacheVariablesResponse{
CacheVariables: []*EventOrchestrationCacheVariable{
{
ID: "45be0a94-55b2-4691-b285-7a14478f4fe2",
Name: "example_1",
ID: "45be0a94-55b2-4691-b285-7a14478f4fe2",
Name: "example_1",
Conditions: []*EventOrchestrationCacheVariableCondition{},
Configuration: &EventOrchestrationCacheVariableConfiguration{
Type: "trigger_event_count",
Expand Down Expand Up @@ -584,8 +584,8 @@ func TestServiceOrchestrationCacheVariableGet(t *testing.T) {
}

want := &EventOrchestrationCacheVariable{
ID: "9aa13ae3-81f3-4456-9abc-79233555fc3f",
Name: "get_example",
ID: "9aa13ae3-81f3-4456-9abc-79233555fc3f",
Name: "get_example",
Conditions: []*EventOrchestrationCacheVariableCondition{
{
Expression: "event.source matches part 'test'",
Expand Down Expand Up @@ -670,7 +670,7 @@ func TestServiceOrchestrationCacheVariableUpdate(t *testing.T) {
Type: "trigger_event_count",
TTLSeconds: 10,
},
Disabled: true,
Disabled: true,
CreatedAt: "2024-02-12T14:44:58Z",
CreatedBy: &UserReference{
ID: "P8B9WR7",
Expand Down Expand Up @@ -708,4 +708,3 @@ func TestServiceOrchestrationCacheVariableDelete(t *testing.T) {
t.Fatal(err)
}
}

2 changes: 1 addition & 1 deletion pagerduty/event_orchestration_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type EventOrchestrationPathRuleActions struct {
}

type EventOrchestrationPathIncidentCustomFieldUpdate struct {
ID string `json:"id,omitempty"`
ID string `json:"id,omitempty"`
Value string `json:"value,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/event_orchestration_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ func TestEventOrchestrationPathGlobalUpdate(t *testing.T) {
},
},
},
Label: "Set Impact Start custom field from event",
ID: "yu3bv02m",
Label: "Set Impact Start custom field from event",
ID: "yu3bv02m",
Conditions: []*EventOrchestrationPathRuleCondition{},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pagerduty/incident_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type IncidentWorkflowActionInput struct {

// IncidentWorkflowActionInlineStepsInput represents the configuration for an incident workflow action input with a series of inlined steps as the value
type IncidentWorkflowActionInlineStepsInput struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
Value *IncidentWorkflowActionInlineStepsInputValue `json:"value,omitempty"`
}

Expand Down
30 changes: 15 additions & 15 deletions pagerduty/incident_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ func TestIncidentWorkflowGet(t *testing.T) {
},
InlineStepsInputs: []*IncidentWorkflowActionInlineStepsInput{
{
Name: "Example inline_steps_input",
Name: "Example inline_steps_input",
Value: &IncidentWorkflowActionInlineStepsInputValue{
Steps: []*IncidentWorkflowActionInlineStep{
{
Name: "Inline Step 1",
Name: "Inline Step 1",
Configuration: &IncidentWorkflowActionConfiguration{
ActionID: "example/action/v1",
ActionID: "example/action/v1",
Inputs: []*IncidentWorkflowActionInput{
{
Name: "Example input",
Expand Down Expand Up @@ -487,13 +487,13 @@ func TestIncidentWorkflowCreate(t *testing.T) {
},
InlineStepsInputs: []*IncidentWorkflowActionInlineStepsInput{
{
Name: "Example inline_steps_input",
Name: "Example inline_steps_input",
Value: &IncidentWorkflowActionInlineStepsInputValue{
Steps: []*IncidentWorkflowActionInlineStep{
{
Name: "Inline Step 1",
Name: "Inline Step 1",
Configuration: &IncidentWorkflowActionConfiguration{
ActionID: "example/action/v1",
ActionID: "example/action/v1",
Inputs: []*IncidentWorkflowActionInput{
{
Name: "Example input",
Expand Down Expand Up @@ -552,13 +552,13 @@ func TestIncidentWorkflowCreate(t *testing.T) {
},
InlineStepsInputs: []*IncidentWorkflowActionInlineStepsInput{
{
Name: "Example inline_steps_input",
Name: "Example inline_steps_input",
Value: &IncidentWorkflowActionInlineStepsInputValue{
Steps: []*IncidentWorkflowActionInlineStep{
{
Name: "Inline Step 1",
Name: "Inline Step 1",
Configuration: &IncidentWorkflowActionConfiguration{
ActionID: "example/action/v1",
ActionID: "example/action/v1",
Inputs: []*IncidentWorkflowActionInput{
{
Name: "Example input",
Expand Down Expand Up @@ -720,13 +720,13 @@ func TestIncidentWorkflowUpdate(t *testing.T) {
},
InlineStepsInputs: []*IncidentWorkflowActionInlineStepsInput{
{
Name: "Example inline_steps_input",
Name: "Example inline_steps_input",
Value: &IncidentWorkflowActionInlineStepsInputValue{
Steps: []*IncidentWorkflowActionInlineStep{
{
Name: "Inline Step 1 Updated Name",
Name: "Inline Step 1 Updated Name",
Configuration: &IncidentWorkflowActionConfiguration{
ActionID: "example/action/v1",
ActionID: "example/action/v1",
Inputs: []*IncidentWorkflowActionInput{
{
Name: "Example input",
Expand Down Expand Up @@ -785,13 +785,13 @@ func TestIncidentWorkflowUpdate(t *testing.T) {
},
InlineStepsInputs: []*IncidentWorkflowActionInlineStepsInput{
{
Name: "Example inline_steps_input",
Name: "Example inline_steps_input",
Value: &IncidentWorkflowActionInlineStepsInputValue{
Steps: []*IncidentWorkflowActionInlineStep{
{
Name: "Inline Step 1 Updated Name",
Name: "Inline Step 1 Updated Name",
Configuration: &IncidentWorkflowActionConfiguration{
ActionID: "example/action/v1",
ActionID: "example/action/v1",
Inputs: []*IncidentWorkflowActionInput{
{
Name: "Example input",
Expand Down
20 changes: 13 additions & 7 deletions pagerduty/incident_workflow_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ type IncidentWorkflowTriggerService service

// IncidentWorkflowTrigger represents an incident workflow.
type IncidentWorkflowTrigger struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
TriggerType IncidentWorkflowTriggerType `json:"trigger_type,omitempty"`
Workflow *IncidentWorkflow `json:"workflow,omitempty"`
Services []*ServiceReference `json:"services,omitempty"`
Condition *string `json:"condition,omitempty"`
SubscribedToAllServices bool `json:"is_subscribed_to_all_services,omitempty"`
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
TriggerType IncidentWorkflowTriggerType `json:"trigger_type,omitempty"`
Workflow *IncidentWorkflow `json:"workflow,omitempty"`
Services []*ServiceReference `json:"services,omitempty"`
Condition *string `json:"condition,omitempty"`
SubscribedToAllServices bool `json:"is_subscribed_to_all_services,omitempty"`
Permissions *IncidentWorkflowTriggerPermissions `json:"permissions,omitempty"`
}

type IncidentWorkflowTriggerPermissions struct {
Restricted bool `json:"restricted"`
TeamID string `json:"team_id,omitempty"`
}

// ListIncidentWorkflowTriggerResponse represents a list response of incident workflow triggers.
Expand Down
4 changes: 4 additions & 0 deletions pagerduty/incident_workflow_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ func TestIncidentWorkflowTriggerGet(t *testing.T) {
},
},
Condition: &cond,
Permissions: &IncidentWorkflowTriggerPermissions{
Restricted: true,
TeamID: "PDEJ7MP",
},
}

if !reflect.DeepEqual(resp, want) {
Expand Down
Loading