client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURLStr           = "https://api.rootly.com"
	ListUsersAPIEndpoint = "/v1/users"
	ListTeamsAPIEndpoint = "/v1/teams"
	GetTeamAPIEndpoint   = "/v1/teams/%s"
	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) 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.

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