client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL    = "https://api.rootly.com"
	DefaultAPIPath    = "/v1"
	DefaultMaxRetries = 5
	MaxBatchSize      = 100
	DefaultPageSize   = 250
	UserAgent         = "rootly-catalog-sync/0.1.0 (+https://github.com/rootlyhq/rootly-catalog-sync)"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkError

type BulkError struct {
	Index      int    `json:"index"`
	ExternalID string `json:"external_id"`
	Errors     any    `json:"errors"`
}

type BulkResult

type BulkResult struct {
	Succeeded           int
	DeletedExternalIDs  []string
	NotFoundExternalIDs []string
	Errors              []BulkError
}

type CatalogInfo

type CatalogInfo struct {
	ID   string
	Name string
	Slug string
}

type CatalogSpec

type CatalogSpec struct {
	Name        string
	Description string
	ExternalID  string
}

type Client

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

func New

func New(apiKey string, opts ...Option) *Client

func (*Client) BulkDelete

func (c *Client) BulkDelete(ctx context.Context, catalogID string, externalIDs []string) (*BulkResult, error)

BulkDelete deletes entities by external ID in batches of MaxBatchSize.

func (*Client) BulkUpsert

func (c *Client) BulkUpsert(ctx context.Context, catalogID string, ents []catalog.DesiredEntity) (*BulkResult, error)

BulkUpsert creates or updates entities in batches of MaxBatchSize.

func (*Client) EnsureCatalog

func (c *Client) EnsureCatalog(ctx context.Context, spec CatalogSpec) (string, error)

EnsureCatalog finds a catalog by name or creates it, returning the catalog ID.

func (*Client) EnsureFields

func (c *Client) EnsureFields(ctx context.Context, catalogID string, fields []FieldSpec) error

EnsureFields ensures all desired fields exist on a catalog, creating any that are missing.

func (*Client) ListCatalogs

func (c *Client) ListCatalogs(ctx context.Context) ([]CatalogInfo, error)

ListCatalogs returns all catalogs, paginating with page[number].

func (*Client) ListEntities

func (c *Client) ListEntities(ctx context.Context, catalogID string) ([]catalog.LiveEntity, error)

ListEntities returns all entities for a catalog, using page-based pagination. It also fetches catalog fields to resolve property IDs to field names.

type ClientInterface

type ClientInterface interface {
	ListEntities(ctx context.Context, catalogID string) ([]catalog.LiveEntity, error)
	BulkUpsert(ctx context.Context, catalogID string, ents []catalog.DesiredEntity) (*BulkResult, error)
	BulkDelete(ctx context.Context, catalogID string, externalIDs []string) (*BulkResult, error)
	EnsureCatalog(ctx context.Context, spec CatalogSpec) (string, error)
	EnsureFields(ctx context.Context, catalogID string, fields []FieldSpec) error
	ListCatalogs(ctx context.Context) ([]CatalogInfo, error)
}

type FieldSpec

type FieldSpec struct {
	Name       string
	Kind       string
	ExternalID string
	Slug       string
	Multiple   bool
	Required   bool
}

type Option

type Option func(*Client)

func WithAPIPath

func WithAPIPath(p string) Option

func WithBaseURL

func WithBaseURL(u string) Option

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

func WithMaxRetries

func WithMaxRetries(n int) Option

Jump to

Keyboard shortcuts

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