client

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 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)"
)
View Source
const (
	NativeService       = "service"
	NativeFunctionality = "functionality"
	NativeEnvironment   = "environment"
	NativeTeam          = "team"
)

Native resource type constants.

Variables

This section is empty.

Functions

func IsNativeResource added in v0.2.0

func IsNativeResource(t string) bool

IsNativeResource returns true if the given type name is a built-in Rootly resource type that supports bulk sync (service, functionality, environment, team).

func NativeKnownAttrs added in v0.3.0

func NativeKnownAttrs(resourceType string) map[string]bool

NativeKnownAttrs returns the known writable attributes for a native resource type.

func NativePropertyIDToSlug added in v0.3.0

func NativePropertyIDToSlug(props []NativePropertyInfo) map[string]string

NativePropertyIDToSlug builds a property-UUID-to-slug map for read-back resolution.

func NativePropertyMap added in v0.3.0

func NativePropertyMap(props []NativePropertyInfo) map[string]NativePropertyInfo

NativePropertyMap builds a slug-to-info map from a property list.

func SDKCreatableKind added in v0.3.1

func SDKCreatableKind(kind string) bool

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) BulkDeleteNative added in v0.2.0

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

BulkDeleteNative deletes native resources by external ID in batches.

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) BulkUpsertNative added in v0.2.0

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

BulkUpsertNative upserts native resources in batches. For each entity, fields matching known attributes are set directly on the SDK struct; remaining fields go into the catalog Fields array.

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) EnsureNativeProperty added in v0.3.0

func (c *Client) EnsureNativeProperty(ctx context.Context, resourceType, name, kind, kindCatalogID string) error

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.

func (*Client) ListNativeProperties added in v0.3.0

func (c *Client) ListNativeProperties(ctx context.Context, resourceType string) ([]NativePropertyInfo, error)

func (*Client) ListNativeResources added in v0.2.0

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

ListNativeResources lists all resources of the given native type, paginating through the API until all pages are fetched.

func (*Client) ListNativeResourcesWithProps added in v0.3.0

func (c *Client) ListNativeResourcesWithProps(ctx context.Context, resourceType string, propIDToSlug map[string]string) ([]catalog.LiveEntity, error)

ListNativeResourcesWithProps lists native resources using a pre-fetched property map.

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
	KindCatalogID string
	Multiple      bool
	Required      bool
}

type NativePropertyInfo added in v0.3.0

type NativePropertyInfo struct {
	ID            string
	Name          string
	Slug          string
	Kind          string
	KindCatalogID string
}

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