connectorbuilder

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 28 Imported by: 340

Documentation

Index

Constants

View Source
const (
	LegacyBatonFeedId = "baton_feed_event"
)

Variables

This section is empty.

Functions

func NewConnector

func NewConnector(ctx context.Context, in interface{}, opts ...Opt) (types.ConnectorServer, error)

NewConnector creates a new ConnectorServer for a new resource.

func WithSyncId added in v0.5.0

func WithSyncId(ss sessions.SessionStore, syncID string) sessions.SessionStore

WithSyncId creates a new SessionStore wrapper that prepends sync ID to all operations.

Types

type AccountManager added in v0.1.15

type AccountManager interface {
	ResourceSyncer
	AccountManagerLimited
}

AccountManager extends ResourceSyncer to add capabilities for managing user accounts.

Implementing this interface indicates the connector supports creating accounts in the external system. A resource type should implement this interface if it represents users or accounts that can be provisioned.

type AccountManagerLimited added in v0.4.12

type AccountManagerLimited interface {
	CreateAccount(ctx context.Context,
		accountInfo *v2.AccountInfo,
		credentialOptions *v2.LocalCredentialOptions) (CreateAccountResponse, []*v2.PlaintextData, annotations.Annotations, error)
	CreateAccountCapabilityDetails(ctx context.Context) (*v2.CredentialDetailsAccountProvisioning, annotations.Annotations, error)
}

type AccountManagerV2 added in v0.6.7

type AccountManagerV2 interface {
	ResourceSyncerV2
	AccountManagerLimited
}

type ActionManager added in v0.6.9

type ActionManager interface {
	// ListActionSchemas returns all action schemas, optionally filtered by resource type.
	// If resourceTypeID is empty, returns all actions (both global and resource-scoped).
	// If resourceTypeID is set, returns only actions for that resource type.
	ListActionSchemas(ctx context.Context, resourceTypeID string) ([]*v2.BatonActionSchema, annotations.Annotations, error)

	// GetActionSchema returns the schema for a specific action by name.
	GetActionSchema(ctx context.Context, name string) (*v2.BatonActionSchema, annotations.Annotations, error)

	// InvokeAction invokes an action. If resourceTypeID is set, invokes a resource-scoped action.
	InvokeAction(
		ctx context.Context,
		name string,
		resourceTypeID string,
		args *structpb.Struct,
	) (string, v2.BatonActionStatus, *structpb.Struct, annotations.Annotations, error)

	// GetActionStatus returns the status of an outstanding action.
	GetActionStatus(ctx context.Context, id string) (v2.BatonActionStatus, string, *structpb.Struct, annotations.Annotations, error)

	// GetTypeRegistry returns a registry for registering resource-scoped actions.
	GetTypeRegistry(ctx context.Context, resourceTypeID string) (actions.ActionRegistry, error)

	// HasActions returns true if there are any registered actions.
	HasActions() bool
}

ActionManager defines the interface for managing actions in the connector builder. This is the internal interface used by the builder for dispatch. The *actions.ActionManager type implements this interface.

type ConnectorBuilder

type ConnectorBuilder interface {
	MetadataProvider
	ValidateProvider
	ResourceSyncers(ctx context.Context) []ResourceSyncer
}

type ConnectorBuilderV2 added in v0.4.12

type ConnectorBuilderV2 interface {
	MetadataProvider
	ValidateProvider
	ResourceSyncers(ctx context.Context) []ResourceSyncerV2
}

type CreateAccountResponse added in v0.1.15

type CreateAccountResponse interface {
	proto.Message
	GetIsCreateAccountResult() bool
}

CreateAccountResponse is a semi-opaque type returned from CreateAccount operations.

This is used to communicate the result of account creation back to Baton.

type CredentialManager added in v0.1.15

type CredentialManager interface {
	ResourceSyncer
	CredentialManagerLimited
}

CredentialManager extends ResourceSyncer to add capabilities for managing credentials. Implementing this interface indicates the connector supports rotating credentials for resources of the associated type. This is commonly used for user accounts or service accounts that have rotatable credentials.

type CredentialManagerLimited added in v0.4.12

type CredentialManagerLimited interface {
	Rotate(ctx context.Context,
		resourceId *v2.ResourceId,
		credentialOptions *v2.LocalCredentialOptions) ([]*v2.PlaintextData, annotations.Annotations, error)
	RotateCapabilityDetails(ctx context.Context) (*v2.CredentialDetailsCredentialRotation, annotations.Annotations, error)
}

type CustomActionManager deprecated added in v0.2.71

type CustomActionManager interface {
	// ListActionSchemas returns all action schemas, optionally filtered by resource type.
	// If resourceTypeID is empty, returns all actions (both global and resource-scoped).
	// If resourceTypeID is set, returns only actions for that resource type.
	ListActionSchemas(ctx context.Context, resourceTypeID string) ([]*v2.BatonActionSchema, annotations.Annotations, error)

	// GetActionSchema returns the schema for a specific action by name.
	GetActionSchema(ctx context.Context, name string) (*v2.BatonActionSchema, annotations.Annotations, error)

	// InvokeAction invokes an action. If resourceTypeID is set, invokes a resource-scoped action.
	InvokeAction(
		ctx context.Context,
		name string,
		resourceTypeID string,
		args *structpb.Struct,
	) (string, v2.BatonActionStatus, *structpb.Struct, annotations.Annotations, error)

	// GetActionStatus returns the status of an outstanding action.
	GetActionStatus(ctx context.Context, id string) (v2.BatonActionStatus, string, *structpb.Struct, annotations.Annotations, error)
}

Deprecated: CustomActionManager is deprecated. Implement GlobalActionProvider instead, which registers actions directly into the SDK's ActionManager.

This interface allows connectors to define and execute custom actions that can be triggered from Baton. It supports both global actions and resource-scoped actions through the resourceTypeID parameter.

type EventFeed added in v0.3.9

type EventFeed interface {
	EventLister
	EventFeedLimited
}

EventFeed is a single stream of events from the external system.

EventFeedMetadata describes this feed, and a connector can have multiple feeds.

type EventFeedLimited added in v0.4.12

type EventFeedLimited interface {
	EventFeedMetadata(ctx context.Context) *v2.EventFeedMetadata
}

type EventFeedsLimited added in v0.4.12

type EventFeedsLimited interface {
	EventFeeds(ctx context.Context) []EventFeed
}

type EventLister added in v0.3.9

type EventLister interface {
	ListEvents(ctx context.Context, earliestEvent *timestamppb.Timestamp, pToken *pagination.StreamToken) ([]*v2.Event, *pagination.StreamState, annotations.Annotations, error)
}

Compatibility interface lets us handle both EventFeed and EventProvider the same.

type EventProvider deprecated added in v0.1.16

type EventProvider interface {
	ConnectorBuilder
	EventLister
}

Deprecated: This interface is deprecated in favor of EventProviderV2 which supports multiple event feeds. Implementing this interface indicates the connector can provide a single stream of events from the external system, enabling near real-time updates in Baton. New connectors should implement EventProviderV2 instead.

type EventProviderV2 added in v0.3.9

type EventProviderV2 interface {
	ConnectorBuilder
	EventFeedsLimited
}

NewEventProviderV2 is a new interface that allows connectors to provide multiple event feeds.

This is the recommended interface for implementing event feed support in new connectors.

type GlobalActionProvider added in v0.6.9

type GlobalActionProvider interface {
	GlobalActions(ctx context.Context, registry actions.ActionRegistry) error
}

GlobalActionProvider allows connectors to register global (non-resource-scoped) actions. This is the preferred method for registering global actions in new connectors. Implement this interface instead of the deprecated CustomActionManager or RegisterActionManagerLimited.

type GrantProvisioner added in v0.4.12

type GrantProvisioner interface {
	Grant(ctx context.Context, resource *v2.Resource, entitlement *v2.Entitlement) (annotations.Annotations, error)
}

type GrantProvisionerV2 added in v0.4.12

type GrantProvisionerV2 interface {
	Grant(ctx context.Context, resource *v2.Resource, entitlement *v2.Entitlement) ([]*v2.Grant, annotations.Annotations, error)
}

type MetadataProvider added in v0.4.12

type MetadataProvider interface {
	Metadata(ctx context.Context) (*v2.ConnectorMetadata, error)
}

type OldAccountManager added in v0.4.2

type OldAccountManager interface {
	ResourceSyncer
	CreateAccount(ctx context.Context,
		accountInfo *v2.AccountInfo,
		credentialOptions *v2.CredentialOptions) (CreateAccountResponse, []*v2.PlaintextData, annotations.Annotations, error)
}

type OldCredentialManager added in v0.4.2

type OldCredentialManager interface {
	Rotate(ctx context.Context,
		resourceId *v2.ResourceId,
		credentialOptions *v2.CredentialOptions) ([]*v2.PlaintextData, annotations.Annotations, error)
}

type Opt added in v0.1.39

type Opt func(b *builder) error

func WithMetricsHandler added in v0.1.39

func WithMetricsHandler(h metrics.Handler) Opt

func WithSessionStore added in v0.4.12

func WithSessionStore(ss sessions.SessionStore) Opt

func WithTicketingEnabled added in v0.2.7

func WithTicketingEnabled() Opt

type RegisterActionManager deprecated added in v0.2.71

type RegisterActionManager interface {
	ConnectorBuilder
	RegisterActionManagerLimited
}

Deprecated: RegisterActionManager is deprecated. Implement GlobalActionProvider instead.

RegisterActionManager extends ConnectorBuilder to add capabilities for registering custom actions. It provides a mechanism to register a CustomActionManager with the connector.

type RegisterActionManagerLimited deprecated added in v0.4.12

type RegisterActionManagerLimited interface {
	RegisterActionManager(ctx context.Context) (CustomActionManager, error)
}

Deprecated: RegisterActionManagerLimited is deprecated. Implement GlobalActionProvider instead.

type ResourceActionProvider added in v0.6.9

type ResourceActionProvider interface {
	// ResourceActions returns the schemas and handlers for all resource actions
	// supported by this resource type.
	ResourceActions(ctx context.Context, registry actions.ActionRegistry) error
}

ResourceActionProvider is an interface that resource builders can implement to provide resource-scoped actions for their resource type.

type ResourceCreator added in v0.4.10

type ResourceCreator interface {
	Create(ctx context.Context, resource *v2.Resource) (*v2.Resource, annotations.Annotations, error)
}

type ResourceDeleter added in v0.2.84

type ResourceDeleter interface {
	ResourceSyncer
	ResourceDeleterLimited
}

ResourceDeleter extends ResourceSyncer to add capabilities for deleting resources.

Implementing this interface indicates the connector supports deleting resources of the associated resource type.

type ResourceDeleterLimited added in v0.4.12

type ResourceDeleterLimited interface {
	Delete(ctx context.Context, resourceId *v2.ResourceId) (annotations.Annotations, error)
}

type ResourceDeleterV2 added in v0.3.46

type ResourceDeleterV2 interface {
	ResourceSyncer
	ResourceDeleterV2Limited
}

ResourceDeleterV2 extends ResourceSyncer to add capabilities for deleting resources.

This is the recommended interface for implementing resource deletion operations in new connectors. It differs from ResourceDeleter by having the resource, not just the id.

type ResourceDeleterV2Limited added in v0.4.12

type ResourceDeleterV2Limited interface {
	Delete(ctx context.Context, resourceId *v2.ResourceId, parentResourceID *v2.ResourceId) (annotations.Annotations, error)
}

type ResourceManager added in v0.1.15

type ResourceManager interface {
	ResourceSyncer
	ResourceManagerLimited
}

ResourceManager extends ResourceSyncer to add capabilities for creating resources.

Implementing this interface indicates the connector supports creating and deleting resources of the associated resource type. A ResourceManager automatically provides ResourceDeleter functionality.

type ResourceManagerLimited added in v0.4.12

type ResourceManagerLimited interface {
	ResourceCreator
	ResourceDeleterLimited
}

type ResourceManagerV2 added in v0.3.46

type ResourceManagerV2 interface {
	ResourceSyncer
	ResourceManagerV2Limited
}

ResourceManagerV2 extends ResourceSyncer to add capabilities for creating resources.

This is the recommended interface for implementing resource creation operations in new connectors.

type ResourceManagerV2Limited added in v0.4.12

type ResourceManagerV2Limited interface {
	ResourceCreator
	ResourceDeleterV2Limited
}

type ResourceProvisioner added in v0.0.30

type ResourceProvisioner interface {
	ResourceSyncer
	ResourceProvisionerLimited
}

ResourceProvisioner extends ResourceSyncer to add capabilities for granting and revoking access.

Note: ResourceProvisionerV2 is preferred for new connectors as it provides enhanced grant capabilities.

Implementing this interface indicates the connector supports provisioning operations for the associated resource type.

type ResourceProvisionerLimited added in v0.4.12

type ResourceProvisionerLimited interface {
	RevokeProvisioner
	GrantProvisioner
}

type ResourceProvisionerV2 added in v0.1.13

type ResourceProvisionerV2 interface {
	ResourceSyncer
	ResourceProvisionerV2Limited
}

ResourceProvisionerV2 extends ResourceSyncer to add capabilities for granting and revoking access with enhanced functionality compared to ResourceProvisioner.

This is the recommended interface for implementing provisioning operations in new connectors. It differs from ResourceProvisioner by returning a list of grants from the Grant method.

type ResourceProvisionerV2Limited added in v0.4.12

type ResourceProvisionerV2Limited interface {
	RevokeProvisioner
	GrantProvisionerV2
}

type ResourceSyncer

type ResourceSyncer interface {
	ResourceType
	List(ctx context.Context, parentResourceID *v2.ResourceId, pToken *pagination.Token) ([]*v2.Resource, string, annotations.Annotations, error)
	Entitlements(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Entitlement, string, annotations.Annotations, error)
	Grants(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Grant, string, annotations.Annotations, error)
}

type ResourceSyncerLimited added in v0.4.12

type ResourceSyncerLimited interface {
	List(ctx context.Context, parentResourceID *v2.ResourceId, pToken *pagination.Token) ([]*v2.Resource, string, annotations.Annotations, error)
	Entitlements(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Entitlement, string, annotations.Annotations, error)
	Grants(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Grant, string, annotations.Annotations, error)
}

type ResourceSyncerV2 added in v0.4.12

type ResourceSyncerV2 interface {
	ResourceType
	ResourceSyncerV2Limited
}

type ResourceSyncerV2Limited added in v0.4.12

type ResourceSyncerV2Limited interface {
	List(ctx context.Context, parentResourceID *v2.ResourceId, opts resource.SyncOpAttrs) ([]*v2.Resource, *resource.SyncOpResults, error)
	Entitlements(ctx context.Context, resource *v2.Resource, opts resource.SyncOpAttrs) ([]*v2.Entitlement, *resource.SyncOpResults, error)
	Grants(ctx context.Context, resource *v2.Resource, opts resource.SyncOpAttrs) ([]*v2.Grant, *resource.SyncOpResults, error)
}

type ResourceTargetedSyncer added in v0.2.99

type ResourceTargetedSyncer interface {
	ResourceSyncer
	ResourceTargetedSyncerLimited
}

ResourceTargetedSyncer extends ResourceSyncer to add capabilities for directly syncing an individual resource

Implementing this interface indicates the connector supports calling "get" on a resource of the associated resource type.

type ResourceTargetedSyncerLimited added in v0.4.12

type ResourceTargetedSyncerLimited interface {
	Get(ctx context.Context, resourceId *v2.ResourceId, parentResourceId *v2.ResourceId) (*v2.Resource, annotations.Annotations, error)
}

type ResourceType added in v0.4.12

type ResourceType interface {
	ResourceType(ctx context.Context) *v2.ResourceType
}

type RevokeProvisioner added in v0.4.10

type RevokeProvisioner interface {
	Revoke(ctx context.Context, grant *v2.Grant) (annotations.Annotations, error)
}

type SessionStoreWithSyncID added in v0.5.0

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

SessionStoreWithSyncID wraps a SessionStore to automatically inject sync ID into all operations.

func (*SessionStoreWithSyncID) Clear added in v0.5.0

func (*SessionStoreWithSyncID) Delete added in v0.5.0

func (*SessionStoreWithSyncID) Get added in v0.5.0

func (*SessionStoreWithSyncID) GetAll added in v0.5.0

func (w *SessionStoreWithSyncID) GetAll(ctx context.Context, pageToken string, opt ...sessions.SessionStoreOption) (map[string][]byte, string, error)

func (*SessionStoreWithSyncID) GetMany added in v0.5.0

func (w *SessionStoreWithSyncID) GetMany(ctx context.Context, keys []string, opt ...sessions.SessionStoreOption) (map[string][]byte, []string, error)

func (*SessionStoreWithSyncID) Set added in v0.5.0

func (*SessionStoreWithSyncID) SetMany added in v0.5.0

func (w *SessionStoreWithSyncID) SetMany(ctx context.Context, values map[string][]byte, opt ...sessions.SessionStoreOption) error

type StaticEntitlementSyncer added in v0.5.21

type StaticEntitlementSyncer interface {
	StaticEntitlements(ctx context.Context, pToken *pagination.Token) ([]*v2.Entitlement, string, annotations.Annotations, error)
}

type StaticEntitlementSyncerV2 added in v0.5.21

type StaticEntitlementSyncerV2 interface {
	StaticEntitlements(ctx context.Context, opts resource.SyncOpAttrs) ([]*v2.Entitlement, *resource.SyncOpResults, error)
}

type TicketManager added in v0.1.36

type TicketManager interface {
	ConnectorBuilder
	TicketManagerLimited
}

TicketManager extends ConnectorBuilder to add capabilities for ticket management.

Implementing this interface indicates the connector can integrate with an external ticketing system, allowing Baton to create and track tickets in that system.

type ValidateProvider added in v0.4.12

type ValidateProvider interface {
	Validate(ctx context.Context) (annotations.Annotations, error)
}

Jump to

Keyboard shortcuts

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