client

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

View Source
const (

	// AttrOwnerTeam is a service's or functionality's owning team. Desired values
	// are resolved to a team ID before diffing; live values are owner_group_ids.
	AttrOwnerTeam = "owner_team"
)

Known attribute key constants (used in multiple places).

Variables

This section is empty.

Functions

func HasOwnerTeam added in v0.5.0

func HasOwnerTeam(t string) bool

HasOwnerTeam reports whether resources of type t support the owner_team built-in.

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 KnownAttrsWithProps added in v0.5.0

func KnownAttrsWithProps(resourceType string, props []NativePropertyInfo) map[string]bool

KnownAttrsWithProps is NativeKnownAttrs without owner_team when a custom property with that slug exists, so the property keeps syncing as a property.

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.

func (*Client) OwnerTeamIsBuiltin added in v0.5.0

func (c *Client) OwnerTeamIsBuiltin(ctx context.Context, t string) (bool, error)

OwnerTeamIsBuiltin reports whether owner_team sets the owning team on resources of type t, rather than a custom property named owner_team.

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