client

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: MIT Imports: 7 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.

Status

Tests Coverage Status Code Quality Analysis Maintainability Test Coverage Go Report Card

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 (
	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.

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.

Functions

This section is empty.

Types

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 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.

Currently 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
}

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 (*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) 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 (*RollbarAPIClient) CreateTeam

func (c *RollbarAPIClient) CreateTeam(name string, 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) 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 (*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. Note this method is quite inefficient, as it must read all invitations for all teams.

func (*RollbarAPIClient) FindPendingInvitations

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

FindPendingInvitations finds pending Rollbar team invitations for the given email.

func (*RollbarAPIClient) FindProject added in v1.1.0

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

FindProject finds the Rollbar project with a given name.

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. WARNING: this is a potentially slow call. Don't repeat it unnecessarily.

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) 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 (*RollbarAPIClient) ListTeamProjectIDs

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

ListTeamProjectIDs lists IDs of all Rollbar projects to which a given team is assigned.

func (*RollbarAPIClient) ListTeams

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

ListTeams lists all Rollbar teams.

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() (users []User, err error)

ListUsers lists all Rollbar users.

func (*RollbarAPIClient) ReadInvitation

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

ReadInvitation reads a Rollbar team invitation from the API.

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 (*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) 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

type Scope

type Scope string

Scope represents the scope of a Rollbar project access token.

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.

Jump to

Keyboard shortcuts

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