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 service integration email filters #31

Merged
merged 2 commits into from Oct 21, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@
*.test
*.iml
coverage.out
.idea*
76 changes: 63 additions & 13 deletions pagerduty/service.go
@@ -1,6 +1,8 @@
package pagerduty

import "fmt"
import (
"fmt"
)

// ServicesService handles the communication with service
// related methods of the PagerDuty API.
Expand Down Expand Up @@ -44,18 +46,66 @@ type IncidentUrgencyRule struct {

// Integration represents a service integration.
type Integration struct {
CreatedAt string `json:"created_at,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
ID string `json:"id,omitempty"`
Integration *Integration `json:"integration,omitempty"`
IntegrationEmail string `json:"integration_email,omitempty"`
IntegrationKey string `json:"integration_key,omitempty"`
Name string `json:"name,omitempty"`
Self string `json:"self,omitempty"`
Service *ServiceReference `json:"service,omitempty"`
Summary string `json:"summary,omitempty"`
Type string `json:"type,omitempty"`
Vendor *VendorReference `json:"vendor,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
EmailIncidentCreation string `json:"email_incident_creation,omitempty"`
EmailFilterMode string `json:"email_filter_mode,omitempty"`
EmailParsers []*EmailParser `json:"email_parsers,omitempty"`
EmailParsingFallback string `json:"email_parsing_fallback,omitempty"`
EmailFilters []*EmailFilter `json:"email_filters,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
ID string `json:"id,omitempty"`
Integration *Integration `json:"integration,omitempty"`
IntegrationEmail string `json:"integration_email,omitempty"`
IntegrationKey string `json:"integration_key,omitempty"`
Name string `json:"name,omitempty"`
Self string `json:"self,omitempty"`
Service *ServiceReference `json:"service,omitempty"`
Summary string `json:"summary,omitempty"`
Type string `json:"type,omitempty"`
Vendor *VendorReference `json:"vendor,omitempty"`
}

// EmailFilter represents a integration email filters
type EmailFilter struct {
BodyMode string `json:"body_mode,omitempty"`
BodyRegex string `json:"body_regex,omitempty"`
FromEmailMode string `json:"from_email_mode,omitempty"`
FromEmailRegex string `json:"from_email_regex,omitempty"`
ID string `json:"id,omitempty"`
SubjectMode string `json:"subject_mode,omitempty"`
SubjectRegex string `json:"subject_regex,omitempty"`
}

// EmailParser represents a integration email parsers
type EmailParser struct {
Action string `json:"action,omitempty"`
ID *int `json:"id,omitempty"`
MatchPredicate *MatchPredicate `json:"match_predicate,omitempty"`
ValueExtractors []*ValueExtractor `json:"value_extractors,omitempty"`
}

// MatchPredicate represents a integration email MatchPredicate
type MatchPredicate struct {
Predicates []*Predicate `json:"children,omitempty"`
Type string `json:"type,omitempty"`
}

// Predicate represents a integration email Predicate
type Predicate struct {
Matcher string `json:"matcher,omitempty"`
Part string `json:"part,omitempty"`
Predicates []*Predicate `json:"children,omitempty"`
Type string `json:"type,omitempty"`
}

// ValueExtractor represents a integration email ValueExtractor
type ValueExtractor struct {
ValueName string `json:"value_name,omitempty"`
Part string `json:"part,omitempty"`
StartsAfter string `json:"starts_after,omitempty"`
EndsBefore string `json:"ends_before,omitempty"`
Type string `json:"type,omitempty"`
Regex string `json:"regex,omitempty"`
}

// Service represents a service.
Expand Down