victorops

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	Username  string `json:"username,omitempty"`
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
	SelfUrl   string `json:"_selfUrl,omitempty"`
}

User is a user in the VictorOps org.

type AllContactResponse

type AllContactResponse struct {
	Phones  ContactGroup `json:"phones,omitempty"`
	Emails  ContactGroup `json:"emails,omitempty"`
	Devices ContactGroup `json:"devices,omitempty"`
}

type ApiEscalationPolicy

type ApiEscalationPolicy struct {
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ApiEscalationPolicySchedule

type ApiEscalationPolicySchedule struct {
	Policy    ApiEscalationPolicy `json:"policy,omitempty"`
	Schedule  []ApiOnCallEntry    `json:"schedule,omitempty"`
	Overrides []ApiOnCallOverride `json:"overrides,omitempty"`
}

type ApiOnCallEntry

type ApiOnCallEntry struct {
	OnCallUser         ApiUser         `json:"onCallUser,omitempty"`
	OverrideOnCallUser ApiUser         `json:"overrideOnCallUser,omitempty"`
	OnCallType         string          `json:"onCallType,omitempty"`
	RotationName       string          `json:"rotationName,omitempty"`
	ShiftName          string          `json:"shiftName,omitempty"`
	ShiftRoll          time.Time       `json:"shiftRoll,omitempty"`
	Rolls              []ApiOnCallRoll `json:"rolls,omitempty"`
}

type ApiOnCallNow

type ApiOnCallNow struct {
	EscalationPolicy ApiEscalationPolicy `json:"escalationPolicy,omitempty"`
	Users            []ApiOnCallUser     `json:"users,omitempty"`
}

type ApiOnCallOverride

type ApiOnCallOverride struct {
	OrigOnCallUser     ApiUser             `json:"origOnCallUser,omitempty"`
	OverrideOnCallUser ApiUser             `json:"overrideOnCallUser,omitempty"`
	Start              time.Time           `json:"start,omitempty"`
	End                time.Time           `json:"end,omitempty"`
	Policy             ApiEscalationPolicy `json:"policy,omitempty"`
}

type ApiOnCallRoll

type ApiOnCallRoll struct {
	Start      time.Time `json:"start,omitempty"`
	End        time.Time `json:"end,omitempty"`
	OnCallUser ApiUser   `json:"onCallUser,omitempty"`
	IsRoll     bool      `json:"isRoll,omitempty"`
}

type ApiOnCallUser

type ApiOnCallUser struct {
	OnCallUser ApiUser `json:"onCallUser,omitempty"`
}

type ApiTeam

type ApiTeam struct {
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ApiTeamOnCall

type ApiTeamOnCall struct {
	Team      ApiTeam        `json:"team,omitempty"`
	OnCallNow []ApiOnCallNow `json:"onCallNow,omitempty"`
}

type ApiTeamSchedule

type ApiTeamSchedule struct {
	Team      ApiTeam                       `json:"team,omitempty"`
	Schedules []ApiEscalationPolicySchedule `json:"schedules,omitempty"`
}

type ApiTeamsOnCall

type ApiTeamsOnCall struct {
	TeamsOnCall []ApiTeamOnCall `json:"teamsOnCall,omitempty"`
}

type ApiUser

type ApiUser struct {
	Username string `json:"username,omitempty"`
}

type ApiUserSchedule

type ApiUserSchedule struct {
	Schedules []ApiTeamSchedule `json:"teamSchedules,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the main client for interacting with victorops

func NewClient

func NewClient(apiID string, apiKey string, publicBaseURL string) *Client

NewClient creates a new VictorOps client

func NewConfigurableClient

func NewConfigurableClient(apiID string, apiKey string, publicBaseURL string, httpClient http.Client) *Client

NewConfigurableClient creates a new VictorOps client with ClientArgs struct

func (Client) AckIncidents

func (c Client) AckIncidents(userName string, incidents []int, message string) (*IncidentActionResponse, *RequestDetails, error)

AckIncidents acknowledges a list of incidents

func (Client) AckIncidentsByUser

func (c Client) AckIncidentsByUser(userName string, message string) (*IncidentActionResponse, *RequestDetails, error)

AckIncidentsByUser acknowledges all incidents for the given user

func (Client) AddTeamMember

func (c Client) AddTeamMember(teamID string, username string) (*RequestDetails, error)

AddTeamMember adds a member to a victorops team.

func (Client) CreateContact

func (c Client) CreateContact(username string, contact *Contact) (*Contact, *RequestDetails, error)

CreateContact creates a new contact for a user

func (Client) CreateEscalationPolicy

func (c Client) CreateEscalationPolicy(escalationPolicy *EscalationPolicy) (*EscalationPolicy, *RequestDetails, error)

CreateEscalationPolicy creates a new eslacation policy

func (Client) CreateRoutingKey

func (c Client) CreateRoutingKey(routingKey *RoutingKey) (*RoutingKey, *RequestDetails, error)

CreateRoutingKey creates a routingkey in the victorops organization

func (Client) CreateTeam

func (c Client) CreateTeam(team *Team) (*Team, *RequestDetails, error)

CreateTeam creates a team in the victorops organization

func (Client) CreateUser

func (c Client) CreateUser(user *User) (*User, *RequestDetails, error)

CreateUser creates a user in the victorops organization

func (Client) DeleteContact

func (c Client) DeleteContact(username string, contactExtID string, contactType ContactType) (*RequestDetails, error)

DeleteContact deletes a contact

func (Client) DeleteEscalationPolicy

func (c Client) DeleteEscalationPolicy(escalationPolicyID string) (*RequestDetails, error)

DeleteEscalationPolicy deletes an escalation policy by ID

func (Client) DeleteTeam

func (c Client) DeleteTeam(teamID string) (*RequestDetails, error)

DeleteTeam deletes a team from this victorops org

func (Client) DeleteUser

func (c Client) DeleteUser(username string, replacementUser string) (*RequestDetails, error)

DeleteUser deletes a user from the victorops org

func (Client) GetAllContacts

func (c Client) GetAllContacts(username string) (*AllContactResponse, *RequestDetails, error)

GetAllContacts returns a list of all of the contacts for a user in the victorops org

func (Client) GetAllEscalationPolicies

func (c Client) GetAllEscalationPolicies() (*EscalationPolicyList, *RequestDetails, error)

GetAllEscalationPolicies lists all escalation policies for the org

func (Client) GetAllRoutingKeys

func (c Client) GetAllRoutingKeys() (*RoutingKeyResponseList, *RequestDetails, error)

GetAllRoutingKeys returns a list of all of the routing keys for an account

func (Client) GetAllTeams

func (c Client) GetAllTeams() (*[]Team, *RequestDetails, error)

GetAllTeams returns a list of all team within this victorops organization

func (Client) GetAllUserV2

func (c Client) GetAllUserV2() (*UserListV2, *RequestDetails, error)

GetAllUserV2 returns a list of all of the users in the victorops org

func (Client) GetAllUsers

func (c Client) GetAllUsers() (*UserList, *RequestDetails, error)

GetAllUsers returns a list of all of the users in the victorops org

func (Client) GetApiTeamSchedule

func (c Client) GetApiTeamSchedule(teamSlug string, daysForward int, daysSkip int, step int) (*ApiTeamSchedule, *RequestDetails, error)

func (Client) GetContact

func (c Client) GetContact(username string, contactExtID string, contactType ContactType) (*Contact, *RequestDetails, error)

GetContact gets a contact for a user

func (Client) GetContactByID

func (c Client) GetContactByID(username string, id int, contactType ContactType) (*Contact, *RequestDetails, error)

func (Client) GetEscalationPolicy

func (c Client) GetEscalationPolicy(escalationPolicyID string) (*EscalationPolicy, *RequestDetails, error)

GetEscalationPolicy gets an escalation policy by ID

func (Client) GetHTTPClient

func (c Client) GetHTTPClient() *http.Client

GetHTTPClient returns http client for the purpose of test

func (Client) GetIncident

func (c Client) GetIncident(incidentID int) (*Incident, *RequestDetails, error)

GetIncident returns the details of a specific incident

func (Client) GetIncidents

func (c Client) GetIncidents() (*IncidentResponse, *RequestDetails, error)

GetIncidents gets a list of the currently open, acknowledged and recently resolved incidents

func (Client) GetOnCallCurrent

func (c Client) GetOnCallCurrent() (*ApiTeamsOnCall, *RequestDetails, error)

Get all current on-call personnel

func (Client) GetRoutingKey

func (c Client) GetRoutingKey(keyname string) (*RoutingKeyResponse, *RequestDetails, error)

GetRoutingKey returns a specific routingkey within this victorops organization

func (Client) GetTeam

func (c Client) GetTeam(teamID string) (*Team, *RequestDetails, error)

GetTeam returns a specific team within this victorops organization

func (Client) GetTeamAdmins

func (c Client) GetTeamAdmins(teamID string) (*TeamAdmins, *RequestDetails, error)

GetTeamAdmins returns a list of admins for this team

func (Client) GetTeamMembers

func (c Client) GetTeamMembers(teamID string) (*TeamMembers, *RequestDetails, error)

GetTeamMembers returns a members on a team within this victorops organization

func (Client) GetUser

func (c Client) GetUser(username string) (*User, *RequestDetails, error)

GetUser returns a specific user within this victorops organization

func (Client) GetUserByEmail

func (c Client) GetUserByEmail(email string) (*UserListV2, *RequestDetails, error)

GetUserByEmail returns a list of all of the user(s) in the victorops org that matches the given email

func (Client) GetUserDefaultEmailContactID

func (c Client) GetUserDefaultEmailContactID(username string) (float64, *RequestDetails, error)

GetUserDefaultEmailContactID returns the id of the default email contact for a user TODO: Utilize the contact method methods for this

func (Client) GetUserOnCallSchedule

func (c Client) GetUserOnCallSchedule(userName string, daysForward int, daysSkip int, step int) (*ApiUserSchedule, *RequestDetails, error)

func (Client) IsTeamMember

func (c Client) IsTeamMember(teamID string, username string) (bool, *RequestDetails, error)

IsTeamMember Returns wether or not a user is in a specific victorops team TODO: Maybe we should do this using the v1/user/{username}/teams endpoint instead

func (Client) RemoveTeamMember

func (c Client) RemoveTeamMember(teamID string, username string, replacement string) (*RequestDetails, error)

RemoveTeamMember Removes a member from a victorops team

func (Client) ResolveIncidents

func (c Client) ResolveIncidents(userName string, incidents []int, message string) (*IncidentActionResponse, *RequestDetails, error)

ResolveIncidents resolves a list of incidents

func (Client) ResolveIncidentsByUser

func (c Client) ResolveIncidentsByUser(userName string, message string) (*IncidentActionResponse, *RequestDetails, error)

ResolveIncidentsByUser solves all incidents for the given user

func (Client) String

func (c Client) String() string

func (Client) TakeOnCallForPolicy

func (c Client) TakeOnCallForPolicy(policySlug string, req *TakeRequest) (*TakeResponse, *RequestDetails, error)

func (Client) TakeOnCallForTeam

func (c Client) TakeOnCallForTeam(teamSlug string, req *TakeRequest) (*TakeResponse, *RequestDetails, error)

func (Client) UpdateTeam

func (c Client) UpdateTeam(team *Team) (*Team, *RequestDetails, error)

UpdateTeam updates a victorops user

func (Client) UpdateUser

func (c Client) UpdateUser(user *User) (*User, *RequestDetails, error)

UpdateUser updates a victorops user

type ClientArgs

type ClientArgs struct {
	// contains filtered or unexported fields
}

Client args is used to dynamically pass in parameters when instantiating the Client

type Contact

type Contact struct {
	PhoneNumber string `json:"phone,omitempty"`
	Email       string `json:"email,omitempty"`
	Label       string `json:"label,omitempty"`
	Rank        int    `json:"rank,omitempty"`
	ExtID       string `json:"extId,omitempty"`
	ID          int    `json:"id,omitempty"`
	Value       string `json:"value,omitempty"`
	Verified    string `json:"verified,omitempty"`
}

Contact is a struct to hold the data for a victorops phone or email contact. This has Email and PhoneNumber fields for when making a create request But on querying later, those values are always returned as "value"

func (Contact) Type

func (c Contact) Type() ContactType

type ContactGroup

type ContactGroup struct {
	ContactMethods []Contact `json:"contactMethods"`
}

type ContactType

type ContactType struct {
	// contains filtered or unexported fields
}

func GetContactTypeFromNotificationType

func GetContactTypeFromNotificationType(notificationType string) ContactType

GetContactTypeFromNotificationType returns a ContactType based on the notificationType string returned in notification steps.

type ContactTypes

type ContactTypes struct {
	Phone  ContactType
	Email  ContactType
	Device ContactType
}

Define a ContactType enum that is used internally for endpoint generation Golang doesn't have real enums, so this is a way to mimic it

func GetContactTypes

func GetContactTypes() ContactTypes

type EscalationPolicy

type EscalationPolicy struct {
	Name                       string                  `json:"name"`
	TeamID                     string                  `json:"teamSlug"`
	IgnoreCustomPagingPolicies bool                    `json:"ignoreCustomPagingPolicies"`
	Steps                      []EscalationPolicySteps `json:"steps"`
	ID                         string                  `json:"slug"`
}

EscalationPolicy is a struct to hold an escalation policy

type EscalationPolicyList

type EscalationPolicyList struct {
	Policies []EscalationPolicyListElement `json:"policies"`
}

EscalationPolicyList is a struct to hold the response from the list all escalation policies API call

type EscalationPolicyListDetail

type EscalationPolicyListDetail struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

EscalationPolicyListDetail is a struct to hold the details of a team or policy returned in the list all escalation policies API call

type EscalationPolicyListElement

type EscalationPolicyListElement struct {
	Policy EscalationPolicyListDetail `json:"policy"`
	Team   EscalationPolicyListDetail `json:"team"`
}

EscalationPolicyListElement is a struct to hold a single policy/team combination element returned in the list all escalation policies API call

type EscalationPolicyStepEntry

type EscalationPolicyStepEntry struct {
	ExecutionType string            `json:"executionType"`
	User          map[string]string `json:"user"`
	RotationGroup map[string]string `json:"rotationGroup"`
	Webhook       map[string]string `json:"webhook"`
	Email         map[string]string `json:"email"`
	TargetPolicy  map[string]string `json:"targetPolicy"`
}

EscalationPolicyStepEntry is a struct to store escalation policy step entries

type EscalationPolicySteps

type EscalationPolicySteps struct {
	Timeout int                         `json:"timeout"`
	Entries []EscalationPolicyStepEntry `json:"entries"`
}

EscalationPolicySteps is a struct to store escalation policy steps

type GetAllContactResponse

type GetAllContactResponse struct {
	ContactMethods []Contact `json:"contactMethods,omitempty"`
}

Get a contact via it's internal api ID, but using the public API

type Incident

type Incident struct {
	AlertCount        int           `json:"alertCount,omitempty"`
	CurrentPhase      string        `json:"currentPhase,omitempty"`
	EntityDisplayName string        `json:"entityDisplayName,omitempty"`
	EntityID          string        `json:"entityId,omitempty"`
	EntityState       string        `json:"entityState,omitempty"`
	EntityType        string        `json:"entityType,omitempty"`
	Host              string        `json:"host,omitempty"`
	IncidentNumber    string        `json:"incidentNumber,omitempty"`
	LastAlertID       string        `json:"lastAlertId,omitempty"`
	LastAlertTime     time.Time     `json:"lastAlertTime,omitempty"`
	Service           string        `json:"service,omitempty"`
	StartTime         time.Time     `json:"startTime,omitempty"`
	PagedTeams        []string      `json:"pagedTeams,omitempty"`
	PagedUsers        []string      `json:"pagedUsers,omitempty"`
	PagedPolicies     []PagedPolicy `json:"pagedPolicies,omitempty"`
	Transitions       []Transition  `json:",omitempty"`
}

Incident represents an incident on victorops

type IncidentAction

type IncidentAction struct {
	IncidentNumber string `json:"incidentNumber,omitempty"`
	EntityID       string `json:"entityId,omitempty"`
	CmdAccepted    bool   `json:"cmdAccepted,omitempty"`
	Message        string `json:"message,omitempty"`
}

IncidentAction is the result of the single action on an incident.

type IncidentActionByUserRequest

type IncidentActionByUserRequest struct {
	UserName string `json:"userName,omitempty"`
	Message  string `json:"message,omitempty"`
}

type IncidentActionRequest

type IncidentActionRequest struct {
	UserName      string   `json:"userName,omitempty"`
	IncidentNames []string `json:"incidentNames,omitempty"`
	Message       string   `json:"message,omitempty"`
}

IncidentActionRequest represents the payload for a request to modify the state of an incident

type IncidentActionResponse

type IncidentActionResponse struct {
	Results []IncidentAction `json:"results,omitempty"`
}

IncidentActionResponse represents the payload for a response to a request to modify the state of an incident.

type IncidentResponse

type IncidentResponse struct {
	Incidents []Incident `json:"incidents,omitempty"`
}

IncidentResponse holds just the list of incidents from the api response

type PagedEntity

type PagedEntity struct {
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

PagedEntity holds references for a parsed paged policy or team for an incident

type PagedPolicy

type PagedPolicy struct {
	Policy PagedEntity `json:"policy,omitempty"`
	Team   PagedEntity `json:"team,omitempty"`
}

PagedPolicy to hold references for parsing an incident

type RequestDetails

type RequestDetails struct {
	StatusCode   int
	ResponseBody string
	RequestBody  string
	RawResponse  *http.Response
	RawRequest   *http.Request
}

RequestDetails contains details from the API response

type RoutingKey

type RoutingKey struct {
	RoutingKey string   `json:"routingKey,omitempty"`
	Targets    []string `json:"targets,omitempty"`
}

RoutingKey is a struct to hold the data for a victorops routing key.

type RoutingKeyResponse

type RoutingKeyResponse struct {
	RoutingKey string                      `json:"routingKey,omitempty"`
	Targets    []RoutingKeyResponseTargets `json:"targets,omitempty"`
}

In the request to create a routing key, we supply a list of strings which are target escalaption policy slugs In the response while getting routing keys, we get a different type of result which is a map of values like so: {"policyName":"Moderate Severity","policySlug":"pol-tq09wTVkG7BzuMY0","_teamUrl":"/api-public/v1/team/team-Iei67wjVsD14Pe4O"} So these structs exist to represent read responses rather that create requests.

type RoutingKeyResponseList

type RoutingKeyResponseList struct {
	RoutingKeys []RoutingKeyResponse `json:"routingKeys,omitempty"`
}

type RoutingKeyResponseTargets

type RoutingKeyResponseTargets struct {
	PolicySlug string `json:"policySlug,omitempty"`
}

type TakeRequest

type TakeRequest struct {
	FromUser string `json:"fromUser,omitempty"`
	ToUser   string `json:"toUser,omitempty"`
}

type TakeResponse

type TakeResponse struct {
	Result string `json:"result,omitempty"`
}

type Team

type Team struct {
	Name          string `json:"name,omitempty"`
	Slug          string `json:"slug,omitempty"`
	MemberCount   int    `json:"memberCount,omitempty"`
	Version       int    `json:"version,omitempty"`
	IsDefaultTeam bool   `json:"isDefaultTeam,omitempty"`
	Description   string `json:"description,omitempty"`
}

Team is a struct to hold the data for a victorops Team

type TeamAdmins

type TeamAdmins struct {
	TeamAdmins []Admin `json:"admin,omitempty"`
}

TeamAdmins contains administrators for a team

type TeamMembers

type TeamMembers struct {
	Members []User `json:"members,omitempty"`
}

TeamMembers contains membership details for a team

type Transition

type Transition struct {
	Name     string    `json:",omitempty"`
	At       time.Time `json:",omitempty"`
	Message  string    `json:",omitempty"`
	By       string    `json:",omitempty"`
	Manually bool
	AlertID  string `json:"alertId,omitempty"`
	AlertURL string `json:"alertUrl,omitempty"`
}

Transition represents a state changes of an incident

type User

type User struct {
	FirstName           string `json:"firstName,omitempty"`
	LastName            string `json:"lastName,omitempty"`
	Username            string `json:"username,omitempty"`
	Email               string `json:"email,omitempty"`
	Admin               bool   `json:"admin,omitempty"`
	ExpirationHours     int    `json:"expirationHours,omitempty"`
	CreatedAt           string `json:"createdAt,omitempty"`
	PasswordLastUpdated string `json:"passwordLastUpdated,omitempty"`
	Verified            bool   `json:"verified,omitempty"`
}

User is a user in the VictorOps org.

type UserList

type UserList struct {
	Users [][]User `json:"users"`
}

UserList is a list of Users

type UserListV2

type UserListV2 struct {
	Users []User `json:"users"`
}

UserListV2 is a list of Users for Version 2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL