Skip to content

Commit

Permalink
Merge pull request #385 from PagerDuty/issue_315
Browse files Browse the repository at this point in the history
Add support for adding email filters for Generic Email Integrations
  • Loading branch information
theckman committed Nov 16, 2021
2 parents 3f9ba66 + 4bdbceb commit b0b8842
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 192 deletions.
77 changes: 0 additions & 77 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ import (
"github.com/google/go-querystring/query"
)

// Integration is an endpoint (like Nagios, email, or an API call) that generates events, which are normalized and de-duplicated by PagerDuty to create incidents.
type Integration struct {
APIObject
Name string `json:"name,omitempty"`
Service *APIObject `json:"service,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Vendor *APIObject `json:"vendor,omitempty"`
IntegrationKey string `json:"integration_key,omitempty"`
IntegrationEmail string `json:"integration_email,omitempty"`
}

// InlineModel represents when a scheduled action will occur.
type InlineModel struct {
Type string `json:"type,omitempty"`
Expand Down Expand Up @@ -265,72 +254,6 @@ func (c *Client) DeleteServiceWithContext(ctx context.Context, id string) error
return err
}

// CreateIntegration creates a new integration belonging to a service.
//
// Deprecated: Use CreateIntegrationWithContext instead.
func (c *Client) CreateIntegration(id string, i Integration) (*Integration, error) {
return c.CreateIntegrationWithContext(context.Background(), id, i)
}

// CreateIntegrationWithContext creates a new integration belonging to a service.
func (c *Client) CreateIntegrationWithContext(ctx context.Context, id string, i Integration) (*Integration, error) {
d := map[string]Integration{
"integration": i,
}

resp, err := c.post(ctx, "/services/"+id+"/integrations", d, nil)
return getIntegrationFromResponse(c, resp, err)
}

// GetIntegrationOptions is the data structure used when calling the GetIntegration API endpoint.
type GetIntegrationOptions struct {
Includes []string `url:"include,omitempty,brackets"`
}

// GetIntegration gets details about an integration belonging to a service.
//
// Deprecated: Use GetIntegrationWithContext instead.
func (c *Client) GetIntegration(serviceID, integrationID string, o GetIntegrationOptions) (*Integration, error) {
return c.GetIntegrationWithContext(context.Background(), serviceID, integrationID, o)
}

// GetIntegrationWithContext gets details about an integration belonging to a service.
func (c *Client) GetIntegrationWithContext(ctx context.Context, serviceID, integrationID string, o GetIntegrationOptions) (*Integration, error) {
v, err := query.Values(o)
if err != nil {
return nil, err
}

resp, err := c.get(ctx, "/services/"+serviceID+"/integrations/"+integrationID+"?"+v.Encode())
return getIntegrationFromResponse(c, resp, err)
}

// UpdateIntegration updates an integration belonging to a service.
//
// Deprecated: Use UpdateIntegrationWithContext instead.
func (c *Client) UpdateIntegration(serviceID string, i Integration) (*Integration, error) {
return c.UpdateIntegrationWithContext(context.Background(), serviceID, i)
}

// UpdateIntegrationWithContext updates an integration belonging to a service.
func (c *Client) UpdateIntegrationWithContext(ctx context.Context, serviceID string, i Integration) (*Integration, error) {
resp, err := c.put(ctx, "/services/"+serviceID+"/integrations/"+i.ID, i, nil)
return getIntegrationFromResponse(c, resp, err)
}

// DeleteIntegration deletes an existing integration.
//
// Deprecated: Use DeleteIntegrationWithContext instead.
func (c *Client) DeleteIntegration(serviceID string, integrationID string) error {
return c.DeleteIntegrationWithContext(context.Background(), serviceID, integrationID)
}

// DeleteIntegrationWithContext deletes an existing integration.
func (c *Client) DeleteIntegrationWithContext(ctx context.Context, serviceID string, integrationID string) error {
_, err := c.delete(ctx, "/services/"+serviceID+"/integrations/"+integrationID)
return err
}

// ListServiceRulesPaginated gets all rules for a service.
func (c *Client) ListServiceRulesPaginated(ctx context.Context, serviceID string) ([]ServiceRule, error) {
var rules []ServiceRule
Expand Down
Loading

0 comments on commit b0b8842

Please sign in to comment.