Documentation
¶
Overview ¶
Package example implements the example provider adapter for the example capability.
Package example implements the example provider adapter for the example capability.
Index ¶
- Constants
- func NewPoller() capability.PollingResource
- func Register(app string, svc Service) error
- type Adapter
- func (a *Adapter) CreateItem(ctx context.Context, title string, _ types.KV) (*capability.Host, error)
- func (a *Adapter) DeleteItem(ctx context.Context, id string) error
- func (a *Adapter) GetItem(ctx context.Context, id string) (*capability.Host, error)
- func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)
- func (a *Adapter) ListItems(ctx context.Context, _ *ListQuery) (*capability.ListResult[capability.Host], error)
- func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
- func (a *Adapter) UpdateItem(ctx context.Context, id string, data map[string]any) (*capability.Host, error)
- type ExamplePoller
- func (*ExamplePoller) ContentHash(item any) string
- func (*ExamplePoller) CursorField() string
- func (*ExamplePoller) DefaultInterval() time.Duration
- func (*ExamplePoller) DiffKey(item any) string
- func (p *ExamplePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)
- func (*ExamplePoller) ResourceName() string
- type ExampleWebhook
- type ListQuery
- type Service
Constants ¶
const ( OpList = "list" OpGet = "get" OpCreate = "create" OpUpdate = "update" OpDelete = "delete" OpHealth = "health" )
Operation name constants for the example capability.
Variables ¶
This section is empty.
Functions ¶
func NewPoller ¶
func NewPoller() capability.PollingResource
NewPoller creates an ExamplePoller backed by a default adapter.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements example.Service using the example provider client.
func (*Adapter) CreateItem ¶
func (*Adapter) ListItems ¶
func (a *Adapter) ListItems(ctx context.Context, _ *ListQuery) (*capability.ListResult[capability.Host], error)
func (*Adapter) ListRawEvents ¶
type ExamplePoller ¶
type ExamplePoller struct {
// contains filtered or unexported fields
}
ExamplePoller implements capability.PollingResource for the example provider. It polls the example provider for new and updated items via the example Service.
func NewPollerWithService ¶
func NewPollerWithService(svc Service) *ExamplePoller
NewPollerWithService creates an ExamplePoller with a specific service, useful for testing.
func (*ExamplePoller) ContentHash ¶
func (*ExamplePoller) ContentHash(item any) string
ContentHash returns a SHA256 hash of the item for content-based change detection.
func (*ExamplePoller) CursorField ¶
func (*ExamplePoller) CursorField() string
CursorField returns the field name used for cursor-based pagination.
func (*ExamplePoller) DefaultInterval ¶
func (*ExamplePoller) DefaultInterval() time.Duration
DefaultInterval returns the recommended polling interval.
func (*ExamplePoller) DiffKey ¶
func (*ExamplePoller) DiffKey(item any) string
DiffKey returns the unique identifier for an item, used for change detection.
func (*ExamplePoller) List ¶
func (p *ExamplePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)
List fetches a batch of items from the provider starting after the given cursor.
func (*ExamplePoller) ResourceName ¶
func (*ExamplePoller) ResourceName() string
ResourceName returns the unique name for this polling resource.
type ExampleWebhook ¶
type ExampleWebhook struct {
// contains filtered or unexported fields
}
ExampleWebhook implements capability.WebhookConverter for the example provider. It demonstrates signature verification and payload conversion patterns.
func NewExampleWebhook ¶
func NewExampleWebhook() *ExampleWebhook
NewExampleWebhook creates an ExampleWebhook that reads the HMAC secret from the example provider config at verification time.
func (*ExampleWebhook) Convert ¶
Convert transforms the raw webhook body into one or more DataEvent records.
func (*ExampleWebhook) VerifySignature ¶
func (w *ExampleWebhook) VerifySignature(headers map[string]string, body []byte) error
VerifySignature validates the HMAC-SHA256 signature from the X-Signature header. The secret is read from provider config at verification time via getSecret.
func (*ExampleWebhook) WebhookPath ¶
func (*ExampleWebhook) WebhookPath() string
WebhookPath returns the URL path that receives webhook events from the example provider.
type ListQuery ¶
type ListQuery = capability.ExampleListQuery
ListQuery wraps pagination for listing items.
type Service ¶
type Service interface {
GetItem(ctx context.Context, id string) (*capability.Host, error)
ListItems(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.Host], error)
CreateItem(ctx context.Context, title string, tags types.KV) (*capability.Host, error)
UpdateItem(ctx context.Context, id string, data map[string]any) (*capability.Host, error)
DeleteItem(ctx context.Context, id string) error
HealthCheck(ctx context.Context) (bool, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}
Service defines the example capability contract.
func New ¶
func New() Service
New creates an Adapter using the default provider client (reads config from YAML).
func NewWithClient ¶
func NewWithClient(c client) Service
NewWithClient creates an Adapter with a specific client, useful for testing.