From 6f1797f9554f5a67dc54b39665488ee2809cc344 Mon Sep 17 00:00:00 2001 From: Carlos Gajardo Date: Fri, 12 Jul 2024 16:51:34 -0400 Subject: [PATCH] Add vendor reference [DO NOT MERGE] --- go.mod | 2 + go.sum | 4 +- .../go-pagerduty/automation_action.go | 332 ++++++++++++++++++ .../go-pagerduty/event_orchestration.go | 24 +- vendor/modules.txt | 3 +- 5 files changed, 350 insertions(+), 15 deletions(-) create mode 100644 vendor/github.com/PagerDuty/go-pagerduty/automation_action.go diff --git a/go.mod b/go.mod index 98a5fd37d..7c3428834 100644 --- a/go.mod +++ b/go.mod @@ -76,3 +76,5 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + +replace github.com/PagerDuty/go-pagerduty => github.com/cjgajard/go-pagerduty v0.0.0-20240712203852-d83eacdec105 diff --git a/go.sum b/go.sum index c7794d9a7..2c46ff679 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20240524180345-9b652f07c450 h1:G8EOmgL7i+vO6hYAnjpVbPDqUpPY7ThF6NfasZntop0= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20240524180345-9b652f07c450/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -11,6 +9,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cjgajard/go-pagerduty v0.0.0-20240712203852-d83eacdec105 h1:794KlUOMDDRNJCbSqu8REHBrSY0x4ehJLZg0U1oN2AU= +github.com/cjgajard/go-pagerduty v0.0.0-20240712203852-d83eacdec105/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= diff --git a/vendor/github.com/PagerDuty/go-pagerduty/automation_action.go b/vendor/github.com/PagerDuty/go-pagerduty/automation_action.go new file mode 100644 index 000000000..11e26e173 --- /dev/null +++ b/vendor/github.com/PagerDuty/go-pagerduty/automation_action.go @@ -0,0 +1,332 @@ +package pagerduty + +import ( + "context" + + "github.com/google/go-querystring/query" +) + +type ActionDataReference struct { + Script *string `json:"script,omitempty"` + InvocationCommand *string `json:"invocation_command,omitempty"` + ProcessAutomationJobID *string `json:"process_automation_job_id,omitempty"` + ProcessAutomationJobArguments *string `json:"process_automation_job_arguments,omitempty"` + ProcessAutomationNodeFilter *string `json:"process_automation_node_filter,omitempty"` +} + +type Priviledges struct { + Permissions []string `json:"permissions"` +} + +type AutomationAction struct { + APIObject + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + ActionType string `json:"action_type,omitempty"` + ActionClassification *string `json:"action_classification,omitempty"` + Runner string `json:"runner,omitempty"` + RunnerType string `json:"runner_type,omitempty"` + Services []APIObject `json:"services,omitempty"` + Teams []APIObject `json:"teams,omitempty"` + ActionDataReference *ActionDataReference `json:"action_data_reference,omitempty"` + Priviledges *Priviledges `json:"priviledges,omitempty"` + Metadata interface{} `json:"metadata,omitempty"` + CreationTime string `json:"creation_time,omitempty"` + ModifyTime string `json:"modify_time,omitempty"` + LastRun string `json:"last_run,omitempty"` + LastRunBy *APIObject `json:"last_run_by,omitempty"` +} + +type AutomationActionResponse struct { + Action AutomationAction `json:"action,omitempty"` +} + +type CreateAutomationActionOptions AutomationActionResponse + +func (c *Client) CreateAutomationActionWithContext(ctx context.Context, o CreateAutomationActionOptions) (*AutomationAction, error) { + resp, err := c.post(ctx, "/automation_actions/actions", o, nil) + if err != nil { + return nil, err + } + + var response AutomationActionResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Action, nil +} + +func (c *Client) GetAutomationActionWithContext(ctx context.Context, id string) (*AutomationAction, error) { + resp, err := c.get(ctx, "/automation_actions/actions/"+id, nil) + if err != nil { + return nil, err + } + + var response AutomationActionResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Action, nil +} + +func (c *Client) DeleteAutomationActionWithContext(ctx context.Context, id string) error { + _, err := c.delete(ctx, "/automation_actions/actions/"+id) + return err +} + +type UpdateAutomationActionOptions AutomationActionResponse + +func (c *Client) UpdateAutomationActionWithContext(ctx context.Context, o UpdateAutomationActionOptions) (*AutomationAction, error) { + resp, err := c.put(ctx, "/automation_actions/actions/"+o.Action.ID, o, nil) + if err != nil { + return nil, err + } + + var response AutomationActionResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Action, nil +} + +type AssociateAutomationActionServiceOptions struct { + Service APIReference `json:"service,omitempty"` +} + +type AutomationActionServiceResponse struct { + Service APIObject `json:"service,omitempty"` +} + +func (c *Client) AssociateAutomationActionServiceWithContext(ctx context.Context, id string, o AssociateAutomationActionServiceOptions) (*AutomationActionServiceResponse, error) { + resp, err := c.post(ctx, "/automation_actions/actions/"+id+"/services", o, nil) + if err != nil { + return nil, err + } + + var response AutomationActionServiceResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +func (c *Client) DisassociateAutomationActionServiceWithContext(ctx context.Context, actionID, serviceID string) error { + _, err := c.delete(ctx, "/automation_actions/actions/"+actionID+"/services/"+serviceID) + return err +} + +func (c *Client) GetAutomationActionServiceWithContext(ctx context.Context, actionID, serviceID string) (*AutomationActionServiceResponse, error) { + resp, err := c.get(ctx, "/automation_actions/actions/"+actionID+"/services/"+serviceID, nil) + if err != nil { + return nil, err + } + + var response AutomationActionServiceResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +type AssociateAutomationActionTeamOptions struct { + Team APIReference `json:"team,omitempty"` +} + +type AutomationActionTeamResponse struct { + Team APIObject `json:"team,omitempty"` +} + +func (c *Client) AssociateAutomationActionTeamWithContext(ctx context.Context, id string, o AssociateAutomationActionTeamOptions) (*AutomationActionTeamResponse, error) { + resp, err := c.post(ctx, "/automation_actions/actions/"+id+"/teams", o, nil) + if err != nil { + return nil, err + } + + var response AutomationActionTeamResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +func (c *Client) DisassociateAutomationActionTeamWithContext(ctx context.Context, actionID, teamID string) error { + _, err := c.delete(ctx, "/automation_actions/actions/"+actionID+"/teams/"+teamID) + return err +} + +func (c *Client) GetAutomationActionTeamWithContext(ctx context.Context, actionID, teamID string) (*AutomationActionTeamResponse, error) { + resp, err := c.get(ctx, "/automation_actions/actions/"+actionID+"/teams/"+teamID, nil) + if err != nil { + return nil, err + } + + var response AutomationActionTeamResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +type AutomationActionsRunnerActions struct { + Actions []APIObject `json:"actions,omitempty"` + More bool `json:"more,omitempty"` +} + +type AutomationActionsRunner struct { + APIObject + Secret string `json:"secret,omitempty"` + RunnerType string `json:"runner_type,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + LastSeen string `json:"last_seen,omitempty"` + Status string `json:"status,omitempty"` + CreationTime string `json:"creation_time,omitempty"` + RunbookBaseURI string `json:"runbook_base_uri,omitempty"` + RunbookAPIKey string `json:"runbook_api_key,omitempty"` + Teams []APIObject `json:"teams,omitempty"` + Priviledges *Priviledges `json:"priviledges,omitempty"` + AssociatedActions *AutomationActionsRunnerActions `json:"associated_actions,omitempty"` + Metadata interface{} `json:"metadata,omitempty"` +} + +type AutomationActionsRunnerResponse struct { + Runner AutomationActionsRunner `json:"runner,omitempty"` +} + +func (c *Client) CreateAutomationActionsRunnerWithContext(ctx context.Context, a AutomationActionsRunner) (*AutomationActionsRunner, error) { + d := map[string]AutomationActionsRunner{ + "runner": a, + } + + resp, err := c.post(ctx, "/automation_actions/runners/", d, nil) + if err != nil { + return nil, err + } + + var response AutomationActionsRunnerResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Runner, nil +} + +type ListAutomationActionsRunnersOptions struct { + Cursor string `url:"include,omitempty"` + Limit uint `url:"limit,omitempty"` + Name string `url:"name,omitempty"` + Includes []string `url:"include,brackets,omitempty"` +} + +type ListAutomationActionsRunnersResponse struct { + Runners []AutomationActionsRunner `json:"runners,omitempty"` + Priviledges *Priviledges `json:"priviledges,omitempty"` + cursor + // NextCursor string `json:"next_cursor,omitempty"` + // Limit uint `json:"limit,omitempty"` + cursorHandler +} + +func (c *Client) ListAutomationActionsRunnersWithContext(ctx context.Context, o ListAutomationActionsRunnersOptions) (*ListAutomationActionsRunnersResponse, error) { + v, err := query.Values(o) + if err != nil { + return nil, err + } + + resp, err := c.get(ctx, "/automation_actions/runners?"+v.Encode(), nil) + if err != nil { + return nil, err + } + + var response ListAutomationActionsRunnersResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +func (c *Client) GetAutomationActionsRunnerWithContext(ctx context.Context, id string) (*AutomationActionsRunner, error) { + resp, err := c.get(ctx, "/automation_actions/runners/"+id, nil) + if err != nil { + return nil, err + } + + var response AutomationActionsRunnerResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Runner, nil +} + +func (c *Client) UpdateAutomationActionsRunnerWithContext(ctx context.Context, a AutomationActionsRunner) (*AutomationActionsRunner, error) { + d := map[string]AutomationActionsRunner{ + "runner": a, + } + + resp, err := c.put(ctx, "/automation_actions/runners/"+a.ID, d, nil) + if err != nil { + return nil, err + } + + var response AutomationActionsRunnerResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response.Runner, nil +} + +func (c *Client) DeleteAutomationActionsRunnerWithContext(ctx context.Context, id string) error { + _, err := c.delete(ctx, "/automation_actions/runners/"+id) + return err +} + +type AssociateAutomationActionsRunnerTeamOptions struct { + Team APIReference `json:"team,omitempty"` +} + +type AutomationActionsRunnerTeamResponse struct { + Team APIObject `json:"team,omitempty"` +} + +func (c *Client) AssociateAutomationActionsRunnerTeamWithContext(ctx context.Context, id string, o AssociateAutomationActionsRunnerTeamOptions) (*AutomationActionsRunnerTeamResponse, error) { + resp, err := c.post(ctx, "/automation_actions/runners/"+id+"/teams", o, nil) + if err != nil { + return nil, err + } + + var response AutomationActionsRunnerTeamResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} + +func (c *Client) DisassociateAutomationActionsRunnerTeamWithContext(ctx context.Context, actionID, teamID string) error { + _, err := c.delete(ctx, "/automation_actions/runners/"+actionID+"/teams/"+teamID) + return err +} + +func (c *Client) GetAutomationActionsRunnerTeamWithContext(ctx context.Context, actionID, teamID string) (*AutomationActionsRunnerTeamResponse, error) { + resp, err := c.get(ctx, "/automation_actions/runners/"+actionID+"/teams/"+teamID, nil) + if err != nil { + return nil, err + } + + var response AutomationActionsRunnerTeamResponse + if err := c.decodeJSON(resp, &response); err != nil { + return nil, err + } + + return &response, nil +} diff --git a/vendor/github.com/PagerDuty/go-pagerduty/event_orchestration.go b/vendor/github.com/PagerDuty/go-pagerduty/event_orchestration.go index 7abc60d79..609318fb7 100644 --- a/vendor/github.com/PagerDuty/go-pagerduty/event_orchestration.go +++ b/vendor/github.com/PagerDuty/go-pagerduty/event_orchestration.go @@ -272,17 +272,17 @@ type ServiceOrchestrationRuleCondition struct { // ServiceOrchestrationRuleActions are the actions that will be taken to change the resulting alert and incident. type ServiceOrchestrationRuleActions struct { - RouteTo string `json:"route_to,omitempty"` - Suppress bool `json:"suppress,omitempty"` - Suspend uint `json:"suspend,omitempty"` - Priority string `json:"priority,omitempty"` - Annotate string `json:"annotate,omitempty"` - PagerDutyAutomationActions []*PagerDutyAutomationAction `json:"pagerduty_automation_actions,omitempty"` - AutomationActions []*AutomationAction `json:"automation_actions,omitempty"` - Severity string `json:"severity,omitempty"` - EventAction string `json:"event_action,omitempty"` - Variables []*OrchestrationVariable `json:"variables,omitempty"` - Extractions []*OrchestrationExtraction `json:"extractions,omitempty"` + RouteTo string `json:"route_to,omitempty"` + Suppress bool `json:"suppress,omitempty"` + Suspend uint `json:"suspend,omitempty"` + Priority string `json:"priority,omitempty"` + Annotate string `json:"annotate,omitempty"` + PagerDutyAutomationActions []*PagerDutyAutomationAction `json:"pagerduty_automation_actions,omitempty"` + AutomationActions []*OrchestrationAutomationAction `json:"automation_actions,omitempty"` + Severity string `json:"severity,omitempty"` + EventAction string `json:"event_action,omitempty"` + Variables []*OrchestrationVariable `json:"variables,omitempty"` + Extractions []*OrchestrationExtraction `json:"extractions,omitempty"` } type ServiceOrchestrationActive struct { @@ -451,7 +451,7 @@ type PagerDutyAutomationAction struct { ActionID string `json:"action_id,omitempty"` } -type AutomationAction struct { +type OrchestrationAutomationAction struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` AutoSend bool `json:"auto_send,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 26f324e00..6a9d0a5c6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/PagerDuty/go-pagerduty v1.8.1-0.20240524180345-9b652f07c450 +# github.com/PagerDuty/go-pagerduty v1.8.1-0.20240524180345-9b652f07c450 => github.com/cjgajard/go-pagerduty v0.0.0-20240712203852-d83eacdec105 ## explicit; go 1.19 github.com/PagerDuty/go-pagerduty # github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c @@ -559,3 +559,4 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 +# github.com/PagerDuty/go-pagerduty => github.com/cjgajard/go-pagerduty v0.0.0-20240712203852-d83eacdec105