client

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 9 Imported by: 0

README

Rollbar Management API Client

A client for the Rollbar API, providing access to project & team management functionality. Used internally by the Rollbar Terraform provider. Does not provide error reporting functionality. If you want to use Rollbar to collect errors from your application, this is the wrong client.

See rollbar-go for the official Go client for Rollbar, which does provide support for error reporting.

Documentation

Documentation

Documentation

Overview

Package client is a client library for accessing the Rollbar API.

Index

Constants

View Source
const (
	StatusEnabled  = Status("enabled")
	StatusDisabled = Status("disabled")
)

Possible values for status

View Source
const (
	SLACK     string = "slack"
	WEBHOOK   string = "webhook"
	EMAIL     string = "email"
	PAGERDUTY string = "pagerduty"
)
View Source
const (
	ScopeWrite          = Scope("write")
	ScopeRead           = Scope("read")
	ScopePostServerItem = Scope("post_server_item")
	ScopePostClientItem = Scope("post_client_item")
)

Possible values for project access token scope

View Source
const DefaultBaseURL = "https://api.rollbar.com"

DefaultBaseURL is the default base URL for the Rollbar API.

View Source
const Version = "v1.14.0"

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound is returned when the API returns a '404 Not Found' error.

View Source
var ErrUnauthorized = fmt.Errorf("unauthorized")

ErrUnauthorized is returned when the API returns a '401 Unauthorized' error.

View Source
var Integrations = map[string]interface{}{EMAIL: emailIntegrationResponse{}, PAGERDUTY: pagerDutyIntegrationResponse{},
	SLACK: slackIntegrationResponse{}, WEBHOOK: webhookIntegrationResponse{}}

Functions

This section is empty.

Types

type EmailIntegration added in v1.10.0

type EmailIntegration struct {
	ProjectID int64 `model:"project_id" mapstructure:"project_id" json:"project_id"`
	Settings  struct {
		Enabled     bool `model:"enabled" mapstructure:"enabled" json:"enabled"`
		ScrubParams bool `model:"scrub_params" mapstructure:"scrub_params" json:"scrub_params"`
	} `model:"settings" mapstructure:"settings"`
}

type ErrorResult

type ErrorResult struct {
	Err     int
	Message string
}

ErrorResult represents an error result returned by Rollbar API.

func (ErrorResult) Error

func (er ErrorResult) Error() string

type Invitation

type Invitation struct {
	ID           int    `json:"id"`
	FromUserID   int    `json:"from_user_id"`
	TeamID       int    `json:"team_id"`
	ToEmail      string `json:"to_email"`
	Status       string `json:"status"`
	DateCreated  int    `json:"date_created"`
	DateRedeemed int    `json:"date_redeemed"`
}

Invitation represents an invitation for a user to join a Rollbar team.

type Notification added in v1.2.0

type Notification struct {
	ID      int                    `model:"id" mapstructure:"id"`
	Action  string                 `model:"action" mapstructure:"action"`
	Trigger string                 `model:"trigger" mapstructure:"trigger"`
	Channel string                 `model:"channel" mapstructure:"channel"`
	Filters []interface{}          `model:"filters" mapstructure:"filters"`
	Config  map[string]interface{} `model:"config" mapstructure:"config"`
}

type PagerDutyIntegration added in v1.10.0

type PagerDutyIntegration struct {
	ProjectID int64 `model:"project_id" mapstructure:"project_id" json:"project_id"`
	Settings  struct {
		Enabled    bool   `model:"enabled" mapstructure:"enabled" json:"enabled"`
		ServiceKey string `model:"service_key" mapstructure:"service_key" json:"service_key"`
	} `model:"settings" mapstructure:"settings"`
}

type Project

type Project struct {
	ID           int    `model:"id" mapstructure:"id"`
	Name         string `model:"name" mapstructure:"name"`
	AccountID    int    `json:"account_id" model:"account_id" mapstructure:"account_id"`
	DateCreated  int    `json:"date_created" model:"date_created" mapstructure:"date_created"`
	DateModified int    `json:"date_modified" model:"date_modified" mapstructure:"date_modified"`
	Status       string `model:"status" mapstructure:"status"`
}

Project represents a Rollbar project.

type ProjectAccessToken

type ProjectAccessToken struct {
	Name                    string  `mapstructure:"name"`
	ProjectID               int     `json:"project_id" mapstructure:"project_id"`
	AccessToken             string  `json:"access_token" mapstructure:"access_token"`
	Scopes                  []Scope `mapstructure:"scopes"`
	Status                  Status  `mapstructure:"status"`
	RateLimitWindowSize     int     `json:"rate_limit_window_size" mapstructure:"rate_limit_window_size"`
	RateLimitWindowCount    int     `json:"rate_limit_window_count" mapstructure:"rate_limit_window_count"`
	DateCreated             int     `json:"date_created" mapstructure:"date_created"`
	DateModified            int     `json:"date_modified" mapstructure:"date_modified"`
	CurRateLimitWindowCount int     `json:"cur_rate_limit_window_count" mapstructure:"cur_rate_limit_window_count"`
	CurRateLimitWindowStart int     `json:"cur_rate_limit_window_start" mapstructure:"cur_rate_limit_window_start"`
}

ProjectAccessToken represents a Rollbar project access token.

type ProjectAccessTokenCreateArgs

type ProjectAccessTokenCreateArgs struct {
	ProjectID            int     `json:"-"`
	Name                 string  `json:"name"`
	Scopes               []Scope `json:"scopes"`
	Status               Status  `json:"status"`
	RateLimitWindowSize  int     `json:"rate_limit_window_size"`
	RateLimitWindowCount int     `json:"rate_limit_window_count"`
}

ProjectAccessTokenCreateArgs encapsulates arguments for creating a Rollbar project access token.

type ProjectAccessTokenUpdateArgs

type ProjectAccessTokenUpdateArgs struct {
	ProjectID            int    `json:"-"`
	AccessToken          string `json:"-"`
	RateLimitWindowSize  int    `json:"rate_limit_window_size"`
	RateLimitWindowCount int    `json:"rate_limit_window_count"`
}

ProjectAccessTokenUpdateArgs encapsulates the required and optional arguments for creating a Rollbar project access token.

Curently not all attributes can be updated. https://github.com/rollbar/terraform-provider-rollbar/issues/41

type RollbarAPIClient

type RollbarAPIClient struct {
	BaseURL string // Base URL for Rollbar API
	Resty   *resty.Client
	// contains filtered or unexported fields
}

RollbarAPIClient is a client for the Rollbar API.

func NewClient

func NewClient(baseURL, token string) *RollbarAPIClient

NewClient sets up a new Rollbar API client.

func NewTestClient added in v1.14.0

func NewTestClient(baseURL, token string) *RollbarAPIClient

NewTestClient sets up a new Rollbar API test client.

func (*RollbarAPIClient) AssignTeamToProject

func (c *RollbarAPIClient) AssignTeamToProject(teamID, projectID int) error

AssignTeamToProject assigns a Rollbar team to a project.

func (*RollbarAPIClient) AssignUserToTeam

func (c *RollbarAPIClient) AssignUserToTeam(teamID, userID int) error

AssignUserToTeam assigns a user to a Rollbar team.

func (*RollbarAPIClient) CancelInvitation

func (c *RollbarAPIClient) CancelInvitation(id int) (err error)

CancelInvitation cancels a Rollbar team invitation.

func (*RollbarAPIClient) CreateInvitation

func (c *RollbarAPIClient) CreateInvitation(teamID int, email string) (Invitation, error)

CreateInvitation sends a Rollbar team invitation to a user.

func (*RollbarAPIClient) CreateNotification added in v1.2.0

func (c *RollbarAPIClient) CreateNotification(channel string, filters, trigger, config interface{}) (*Notification, error)

CreateNotification creates a new Rollbar notification.

func (*RollbarAPIClient) CreateProject

func (c *RollbarAPIClient) CreateProject(name string) (*Project, error)

CreateProject creates a new Rollbar project.

func (*RollbarAPIClient) CreateProjectAccessToken

func (c *RollbarAPIClient) CreateProjectAccessToken(args ProjectAccessTokenCreateArgs) (ProjectAccessToken, error)

CreateProjectAccessToken creates a Rollbar project access token.

func (c *RollbarAPIClient) CreateServiceLink(name, template string) (*ServiceLink, error)

CreateServiceLink creates a new Rollbar service_link.

func (*RollbarAPIClient) CreateTeam

func (c *RollbarAPIClient) CreateTeam(name, level string) (Team, error)

CreateTeam creates a new Rollbar team.

func (*RollbarAPIClient) DeleteInvitation

func (c *RollbarAPIClient) DeleteInvitation(id int) (err error)

DeleteInvitation is an alias for CancelInvitation.

func (*RollbarAPIClient) DeleteNotification added in v1.2.0

func (c *RollbarAPIClient) DeleteNotification(notificationID int, channel string) error

DeleteNotification deletes a Rollbar notification. If no matching notification is found, returns error ErrNotFound.

func (*RollbarAPIClient) DeleteProject

func (c *RollbarAPIClient) DeleteProject(projectID int) error

DeleteProject deletes a Rollbar project. If no matching project is found, returns error ErrNotFound.

func (*RollbarAPIClient) DeleteProjectAccessToken

func (c *RollbarAPIClient) DeleteProjectAccessToken(projectID int, token string) error

DeleteProjectAccessToken deletes a Rollbar project access token.

func (c *RollbarAPIClient) DeleteServiceLink(id int) error

DeleteServiceLink deletes a Rollbar service_link. If no matching service link is found, returns error ErrNotFound.

func (*RollbarAPIClient) DeleteTeam

func (c *RollbarAPIClient) DeleteTeam(id int) error

DeleteTeam deletes a Rollbar team. If no matching team is found, returns error ErrNotFound.

func (*RollbarAPIClient) FindInvitations

func (c *RollbarAPIClient) FindInvitations(email string) (invs []Invitation, err error)

FindInvitations finds all Rollbar team invitations for a given email.

func (*RollbarAPIClient) FindPendingInvitations

func (c *RollbarAPIClient) FindPendingInvitations(email string) ([]Invitation, error)

FindPendingInvitations finds pending Rollbar team invitations for the given email.

func (*RollbarAPIClient) FindProjectTeamIDs

func (c *RollbarAPIClient) FindProjectTeamIDs(projectID int) ([]int, error)

FindProjectTeamIDs finds IDs of all teams assigned to the project. Caution: this is a potentially slow operation that makes multiple calls to the API. https://github.com/rollbar/terraform-provider-rollbar/issues/104

func (*RollbarAPIClient) FindTeamID

func (c *RollbarAPIClient) FindTeamID(name string) (int, error)

FindTeamID finds the ID for a team.

func (*RollbarAPIClient) FindUserID

func (c *RollbarAPIClient) FindUserID(email string) (int, error)

FindUserID finds the user ID for a given email.

func (*RollbarAPIClient) IsUserAssignedToTeam added in v1.5.0

func (c *RollbarAPIClient) IsUserAssignedToTeam(teamID, userID int) (bool, error)

IsUserAssignedToTeam checks if a user is assigned to a Rollbar team.

func (*RollbarAPIClient) ListAllInvitationsPerEmail added in v1.13.0

func (c *RollbarAPIClient) ListAllInvitationsPerEmail(email string) (invs []Invitation, err error)

ListAllInvitationsPerEmail lists all invitations for all Rollbar teams.

func (*RollbarAPIClient) ListCustomTeams

func (c *RollbarAPIClient) ListCustomTeams() ([]Team, error)

ListCustomTeams lists all custom defined teams, excluding system teams "Everyone" and "Owners". FIXME: This function needs a better name.

func (*RollbarAPIClient) ListInvitations

func (c *RollbarAPIClient) ListInvitations(teamID int) (invs []Invitation, err error)

ListInvitations lists all invitations for a Rollbar team.

func (*RollbarAPIClient) ListNotifications added in v1.8.0

func (c *RollbarAPIClient) ListNotifications(channel string) ([]Notification, error)

func (*RollbarAPIClient) ListPendingInvitations

func (c *RollbarAPIClient) ListPendingInvitations(teamID int) ([]Invitation, error)

ListPendingInvitations lists a Rollbar team's pending invitations.

func (*RollbarAPIClient) ListProjectAccessTokens

func (c *RollbarAPIClient) ListProjectAccessTokens(projectID int) ([]ProjectAccessToken, error)

ListProjectAccessTokens lists the Rollbar project access tokens for the specified Rollbar project.

func (*RollbarAPIClient) ListProjects

func (c *RollbarAPIClient) ListProjects() ([]Project, error)

ListProjects lists all Rollbar projects.

func (c *RollbarAPIClient) ListSerivceLinks() ([]ServiceLink, error)

func (*RollbarAPIClient) ListTeams

func (c *RollbarAPIClient) ListTeams() ([]Team, error)

ListTeams lists all Rollbar teams.

func (*RollbarAPIClient) ListTestUsers added in v1.13.0

func (c *RollbarAPIClient) ListTestUsers() (users []User, err error)

ListTestUsers is used only for testing purposes

func (*RollbarAPIClient) ListUserCustomTeams

func (c *RollbarAPIClient) ListUserCustomTeams(userID int) (teams []Team, err error)

ListUserCustomTeams lists a Rollbar user's custom defined teams, excluding system teams "Everyone" and "Owners".

func (*RollbarAPIClient) ListUserTeams

func (c *RollbarAPIClient) ListUserTeams(userID int) (teams []Team, err error)

ListUserTeams lists a Rollbar user's teams.

func (*RollbarAPIClient) ListUsers

func (c *RollbarAPIClient) ListUsers(email string) (users []User, err error)

ListUsers lists all Rollbar users.

func (*RollbarAPIClient) ReadIntegration added in v1.6.0

func (c *RollbarAPIClient) ReadIntegration(integration string) (interface{}, error)

ReadIntegration reads a Rollbar integration from the API. If no matching integration is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadInvitation

func (c *RollbarAPIClient) ReadInvitation(inviteID int) (inv Invitation, err error)

ReadInvitation reads a Rollbar team invitation from the API.

func (*RollbarAPIClient) ReadNotification added in v1.2.0

func (c *RollbarAPIClient) ReadNotification(notificationID int, channel string) (*Notification, error)

ReadNotification reads a Rollbar notification from the API. If no matching notification is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadProject

func (c *RollbarAPIClient) ReadProject(projectID int) (*Project, error)

ReadProject a Rollbar project from the API. If no matching project is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadProjectAccessToken

func (c *RollbarAPIClient) ReadProjectAccessToken(projectID int, token string) (ProjectAccessToken, error)

ReadProjectAccessToken reads a Rollbar project access token from the API. It returns the first token that matches `name`. If no matching token is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadProjectAccessTokenByName

func (c *RollbarAPIClient) ReadProjectAccessTokenByName(projectID int, name string) (ProjectAccessToken, error)

ReadProjectAccessTokenByName reads a Rollbar project access token from the API. It returns the first token that matches `name`. If no matching token is found, returns error ErrNotFound.

func (c *RollbarAPIClient) ReadServiceLink(id int) (*ServiceLink, error)

ReadServiceLink reads a Rollbar service link from the API. If no matching service link is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadTeam

func (c *RollbarAPIClient) ReadTeam(id int) (Team, error)

ReadTeam reads a Rollbar team from the API. If no matching team is found, returns error ErrNotFound.

func (*RollbarAPIClient) ReadUser

func (c *RollbarAPIClient) ReadUser(id int) (user User, err error)

ReadUser reads a Rollbar user from the API.

func (*RollbarAPIClient) RemoveTeamFromProject

func (c *RollbarAPIClient) RemoveTeamFromProject(teamID, projectID int) error

RemoveTeamFromProject removes a Rollbar team from a project.

func (*RollbarAPIClient) RemoveUserFromTeam

func (c *RollbarAPIClient) RemoveUserFromTeam(userID, teamID int) error

RemoveUserFromTeam removes a user from a Rollbar team.

func (*RollbarAPIClient) SetHeaderDataSource added in v1.14.0

func (c *RollbarAPIClient) SetHeaderDataSource(header string)

func (*RollbarAPIClient) SetHeaderResource added in v1.14.0

func (c *RollbarAPIClient) SetHeaderResource(header string)

func (*RollbarAPIClient) UpdateIntegration added in v1.6.0

func (c *RollbarAPIClient) UpdateIntegration(integration string, bodyMap map[string]interface{}) (interface{}, error)

UpdateIntegration updates a new Rollbar integration.

func (*RollbarAPIClient) UpdateNotification added in v1.2.0

func (c *RollbarAPIClient) UpdateNotification(notificationID int, channel string, filters, trigger, config interface{}) (*Notification, error)

UpdateNotification updates a Rollbar notification.

func (*RollbarAPIClient) UpdateProjectAccessToken

func (c *RollbarAPIClient) UpdateProjectAccessToken(args ProjectAccessTokenUpdateArgs) error

UpdateProjectAccessToken updates a Rollbar project access token.

func (*RollbarAPIClient) UpdateProjectTeams

func (c *RollbarAPIClient) UpdateProjectTeams(projectID int, teamIDs []int) error

UpdateProjectTeams updates the Rollbar teams assigned to a project, assigning and removing teams as necessary. Caution: this is a potentially slow operation that makes multiple calls to the API. https://github.com/rollbar/terraform-provider-rollbar/issues/104

func (c *RollbarAPIClient) UpdateServiceLink(id int, name, template string) (*ServiceLink, error)

UpdateServiceLink updates a Rollbar service link.

type Scope

type Scope string

Scope represents the scope of a Rollbar project access token.

type ServiceLink struct {
	ID       int    `model:"id" mapstructure:"id"`
	Name     string `model:"name" mapstructure:"name"`
	Template string `model:"template" mapstructure:"template"`
}

type SlackIntegration added in v1.6.0

type SlackIntegration struct {
	ProjectID int64 `model:"project_id" mapstructure:"project_id" json:"project_id"`
	Settings  struct {
		Channel            string `model:"channel" mapstructure:"channel" json:"channel"`
		Enabled            bool   `model:"enabled" mapstructure:"enabled" json:"enabled"`
		ShowMessageButtons bool   `model:"show_message_buttons" mapstructure:"show_message_buttons" json:"show_message_buttons"`
		ServiceAccountID   string `model:"service_account_id" mapstructure:"service_account_id" json:"service_account_id"`
	} `model:"settings" mapstructure:"settings"`
}

type Status

type Status string

Status represents the enabled or disabled status of an entity.

type Team

type Team struct {
	ID          int
	AccountID   int `json:"account_id"`
	Name        string
	AccessLevel string `json:"access_level"`
}

Team represents a Rollbar team.

type User

type User struct {
	Username string `json:"username"`
	ID       int    `json:"id"`
	Email    string `json:"email"`
}

User represents a Rollbar user.

type WebhookIntegration added in v1.7.0

type WebhookIntegration struct {
	ProjectID int64 `model:"project_id" mapstructure:"project_id" json:"project_id"`
	Settings  struct {
		Enabled bool   `model:"enabled" mapstructure:"enabled" json:"enabled"`
		URL     string `model:"url" mapstructure:"url" json:"url"`
	} `model:"settings" mapstructure:"settings"`
}

Jump to

Keyboard shortcuts

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