client

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURLStr                           = "https://api.rootly.com"
	ListUsersAPIEndpoint                 = "/v1/users"
	ListTeamsAPIEndpoint                 = "/v1/teams"
	GetTeamAPIEndpoint                   = "/v1/teams/%s"
	ListSecretsAPIEndpoint               = "/v1/secrets"
	ListSchedulesAPIEndpoint             = "/v1/schedules"
	GetScheduleAPIEndpoint               = "/v1/schedules/%s"
	ListScheduleRotationsAPIEndpoint     = "/v1/schedules/%s/schedule_rotations"
	ListScheduleRotationUsersAPIEndpoint = "/v1/schedule_rotations/%s/schedule_rotation_users"
	ListScheduleShiftsAPIEndpoint        = "/v1/shifts"
	ResourcesPageSize                    = 200
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAttribute

type BasicAttribute struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Client

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

func NewClient

func NewClient(ctx context.Context, baseURL string, apiKey string, resourcesPageSize int) (*Client, error)

NewClient creates a new Rootly client. Allows for a configurable base URL, API key, and resources page size.

func (*Client) GetScheduleOwnerIDs added in v0.0.2

func (c *Client) GetScheduleOwnerIDs(
	ctx context.Context,
	scheduleID string,
) (*int, []string, error)

GetScheduleOwnerIDs returns an owner user ID and a list of owner team IDs for a given schedule ID.

func (*Client) GetSchedules added in v0.0.2

func (c *Client) GetSchedules(ctx context.Context, pToken string) ([]Schedule, string, error)

GetSchedules fetches the schedules from the Rootly API. It supports pagination using a page token.

func (*Client) GetSecrets added in v0.0.2

func (c *Client) GetSecrets(ctx context.Context, pToken string) ([]Secret, string, error)

GetSecrets fetches the secrets from the Rootly API. It supports pagination using a page token.

func (*Client) GetTeamMemberAndAdminIDs

func (c *Client) GetTeamMemberAndAdminIDs(
	ctx context.Context,
	teamID string,
) ([]int, []int, error)

GetTeamMemberAndAdminIDs returns a list of member user IDs and admin user IDs for a given team ID.

func (*Client) GetTeams

func (c *Client) GetTeams(ctx context.Context, pToken string) ([]Team, string, error)

GetTeams fetches the teams from the Rootly API. It supports pagination using a page token.

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, pToken string) ([]User, string, error)

GetUsers fetches users from the Rootly API. It supports pagination using a page token.

func (*Client) IsTest added in v0.0.7

func (c *Client) IsTest() bool

func (*Client) ListAllScheduleRotationUsers added in v0.0.2

func (c *Client) ListAllScheduleRotationUsers(
	ctx context.Context,
	rotationID string,
) ([]int, error)

ListAllScheduleRotationUsers returns a list of all the member user IDs for a given schedule rotation ID. It uses pagination under the hood to make one or more requests to build the full list.

func (*Client) ListOnCallUsers added in v0.0.2

func (c *Client) ListOnCallUsers(
	ctx context.Context,
	scheduleID string,
) ([]int, error)

ListOnCallUsers returns a list of on-call user IDs for a given schedule ID.

func (*Client) ListScheduleRotationUsers added in v0.0.2

func (c *Client) ListScheduleRotationUsers(
	ctx context.Context,
	rotationID string,
	pToken string,
) ([]int, string, error)

ListScheduleRotationUsers returns a list of user IDs for a given schedule rotation ID. It supports pagination using a page token.

func (*Client) ListScheduleRotations added in v0.0.2

func (c *Client) ListScheduleRotations(
	ctx context.Context,
	scheduleID string,
	pToken string,
) ([]string, string, error)

ListScheduleRotations returns a list of schedule rotation IDs for a given schedule ID. It supports pagination using a page token.

type Links struct {
	Self  string `json:"self"`
	First string `json:"first"`
	Prev  string `json:"prev"`
	Next  string `json:"next"`
	Last  string `json:"last"`
}

type Meta

type Meta struct {
	CurrentPage  int `json:"current_page"`
	NextPage     int `json:"next_page"`
	PreviousPage int `json:"prev_page"`
	TotalPages   int `json:"total_pages"`
	TotalCount   int `json:"total_count"`
}

type ObjectWithoutAttributes added in v0.0.2

type ObjectWithoutAttributes struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

type RootlyError added in v0.0.7

type RootlyError struct {
	Title  string `json:"title"`
	Status string `json:"status"`
	Code   string `json:"code"`   // optional
	Detail string `json:"detail"` // optional
}

type RootlyErrorResponse added in v0.0.7

type RootlyErrorResponse struct {
	Errors []RootlyError `json:"errors"`
}

RootlyError represents an error response from the Rootly API.

func (*RootlyErrorResponse) Message added in v0.0.7

func (e *RootlyErrorResponse) Message() string

Message implements the uhttp.ErrorResponse interface.

type Schedule added in v0.0.2

type Schedule struct {
	ID         string             `json:"id"`
	Type       string             `json:"type"`
	Attributes ScheduleAttributes `json:"attributes"`
}

type ScheduleAttributes added in v0.0.2

type ScheduleAttributes struct {
	Name          string   `json:"name"`
	Description   string   `json:"description"`
	OwnerUserID   *int     `json:"owner_user_id"`
	OwnerGroupIDs []string `json:"owner_group_ids"`
	UpdatedAt     string   `json:"updated_at"`
	CreatedAt     string   `json:"created_at"`
}

type ScheduleResponse added in v0.0.2

type ScheduleResponse struct {
	Data Schedule `json:"data"`
}

type ScheduleRotationUser added in v0.0.2

type ScheduleRotationUser struct {
	ID         string                         `json:"id"`
	Type       string                         `json:"type"`
	Attributes ScheduleRotationUserAttributes `json:"attributes"`
}

type ScheduleRotationUserAttributes added in v0.0.2

type ScheduleRotationUserAttributes struct {
	UserID int `json:"user_id"`
}

type ScheduleRotationUsersResponse added in v0.0.2

type ScheduleRotationUsersResponse struct {
	Data  []ScheduleRotationUser `json:"data"`
	Links Links                  `json:"links"`
	Meta  Meta                   `json:"meta"`
}

type ScheduleRotationsResponse added in v0.0.2

type ScheduleRotationsResponse struct {
	Data  []ObjectWithoutAttributes `json:"data"`
	Links Links                     `json:"links"`
	Meta  Meta                      `json:"meta"`
}

type ScheduleShiftsResponse added in v0.0.2

type ScheduleShiftsResponse struct {
	// note there's a data object available but don't need it
	Included []ObjectWithoutAttributes `json:"included"`
}

type SchedulesResponse added in v0.0.2

type SchedulesResponse struct {
	Data  []Schedule `json:"data"`
	Links Links      `json:"links"`
	Meta  Meta       `json:"meta"`
}

type Secret added in v0.0.2

type Secret struct {
	ID         string           `json:"id"`
	Type       string           `json:"type"`
	Attributes SecretAttributes `json:"attributes"`
}

type SecretAttributes added in v0.0.2

type SecretAttributes struct {
	Name      string `json:"name"`
	UpdatedAt string `json:"updated_at"`
	CreatedAt string `json:"created_at"`
}

type SecretsResponse added in v0.0.2

type SecretsResponse struct {
	Data  []Secret `json:"data"`
	Links Links    `json:"links"`
	Meta  Meta     `json:"meta"`
}

type Team

type Team struct {
	ID         string         `json:"id"`
	Type       string         `json:"type"`
	Attributes TeamAttributes `json:"attributes"`
}

type TeamAttributes

type TeamAttributes struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	UserIDs     []int  `json:"user_ids"`
	AdminIDs    []int  `json:"admin_ids"`
	UpdatedAt   string `json:"updated_at"`
	CreatedAt   string `json:"created_at"`
}

type TeamResponse

type TeamResponse struct {
	Data Team `json:"data"`
}

type TeamsResponse

type TeamsResponse struct {
	Data  []Team `json:"data"`
	Links Links  `json:"links"`
	Meta  Meta   `json:"meta"`
}

type User

type User struct {
	ID         string         `json:"id"`
	Type       string         `json:"type"`
	Attributes UserAttributes `json:"attributes"`
}

type UserAttributes

type UserAttributes struct {
	Name      string `json:"name"`
	Email     string `json:"email"`
	Phone     string `json:"phone"`
	FullName  string `json:"full_name"`
	SlackID   string `json:"slack_id"`
	UpdatedAt string `json:"updated_at"`
	CreatedAt string `json:"created_at"`
}

type UsersResponse

type UsersResponse struct {
	Data  []User `json:"data"`
	Links Links  `json:"links"`
	Meta  Meta   `json:"meta"`
}

Jump to

Keyboard shortcuts

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