Documentation
¶
Overview ¶
Package service holds connectionforge's operations: create, get, list, rename, test and disconnect. Each checks authorization through the host's cf.Authorizer and records an audit event.
Index ¶
- Variables
- func NewUUID() string
- type CreateInput
- type Options
- type Service
- func (s *Service) Create(ctx context.Context, in CreateInput) (cf.Connection, error)
- func (s *Service) Disconnect(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
- func (s *Service) Get(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
- func (s *Service) List(ctx context.Context, owner cf.OwnerID, actor cf.Principal, f cf.Filter) ([]cf.Connection, error)
- func (s *Service) Rename(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id, name string) (cf.Connection, error)
- func (s *Service) Test(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidInput = errors.New("service: invalid input")
ErrInvalidInput is returned for input that does not match the provider's manifest.
var ErrNotAudited = errors.New("service: the change was made but its event was not recorded")
ErrNotAudited wraps an audit failure after an operation succeeded: the change was made, and the gap in the trail must be treated as an incident.
Functions ¶
Types ¶
type CreateInput ¶
type CreateInput struct {
Owner cf.OwnerID
Actor cf.Principal
Provider string
AuthMethod string
DisplayName string
// Fields are the method's inputs, by field name.
Fields map[string]cf.Secret
Metadata map[string]string
}
CreateInput is a new connection.
type Options ¶
type Options struct {
Store cf.Store
Broker *broker.Broker
Providers *provider.Registry
Authorizer cf.Authorizer
Auditor cf.Auditor
Clock cf.Clock
// NewID returns a new connection ID. The default is a random UUID.
NewID func() string
}
Options configures a Service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs connection operations.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, in CreateInput) (cf.Connection, error)
Create validates the credential with the provider and, if it is accepted, stores the connection and its sealed credential. A rejected credential stores nothing.
func (*Service) Disconnect ¶
func (s *Service) Disconnect(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
Disconnect destroys a connection's credentials and marks it disconnected. The record stays, so the audit trail and bindings keep their reference.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
Get returns a connection the actor may view.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, owner cf.OwnerID, actor cf.Principal, f cf.Filter) ([]cf.Connection, error)
List returns the owner's connections that the actor may view.
func (*Service) Rename ¶
func (s *Service) Rename(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id, name string) (cf.Connection, error)
Rename changes a connection's display name.
func (*Service) Test ¶
func (s *Service) Test(ctx context.Context, owner cf.OwnerID, actor cf.Principal, id string) (cf.Connection, error)
Test validates a connection's credential with its provider and records the result as health. A permanent failure moves the connection to needs_attention and a success moves it back to connected; a transient failure changes only health. The validation outcome is in the returned connection's health, not in the error.