Documentation ¶
Overview ¶
Package paramsbuilder provides common parameters used to initialize connectors. Implementor would pick every relevant parameter and use them to compose one unified parameters list. Then methods of format "With<some-property-name>" should be configured to connector needs and exposed to end user via delegation. Most would do delegation only.
Index ¶
- Variables
- func Apply[P ParamAssurance](params P, opts []func(params *P), defaultOpts ...func(params *P)) (output *P, err error)
- func NewCatalogVariables[V substitutions.RegistryValue](registry substitutions.Registry[V]) []catalogreplacer.CatalogVariable
- type AuthClient
- type Client
- func (p *Client) WithApiKeyHeaderClient(ctx context.Context, client *http.Client, provider providers.Provider, ...)
- func (p *Client) WithApiKeyQueryParamClient(ctx context.Context, client *http.Client, provider providers.Provider, ...)
- func (p *Client) WithBasicClient(ctx context.Context, client *http.Client, user, pass string, ...)
- func (p *Client) WithOauthClient(ctx context.Context, client *http.Client, config *oauth2.Config, ...)
- type Metadata
- type Module
- type ParamAssurance
- type Workspace
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingMetadata = errors.New("missing authentication metadata") ErrIncorrectMetadataParamUsage = errors.New("metadata parameter must have required fields") )
var ErrMissingClient = errors.New("http client not set")
var ErrMissingWorkspace = errors.New("missing workspace name")
Functions ¶
func Apply ¶
func Apply[P ParamAssurance](params P, opts []func(params *P), defaultOpts ...func(params *P), ) (output *P, err error)
Apply will apply options to construct a ready to go set of parameters. This is a generalized constructor of parameters used to initialize any connector. To qualify as a parameter one must have data validation laid out.
It is possible to give default options which will be applied first. Any other options supplied by the user may override defaults, as they are applied last and therefore take higher precedence.
func NewCatalogVariables ¶
func NewCatalogVariables[V substitutions.RegistryValue]( registry substitutions.Registry[V], ) []catalogreplacer.CatalogVariable
NewCatalogVariables converts JSON into supported list of Catalog Variables. This enforces type checking.
Types ¶
type AuthClient ¶
type AuthClient struct { // Caller is an HTTP client that knows how to make authenticated requests. // It also knows how to handle authentication and API response errors. Caller *common.HTTPClient }
AuthClient params sets up authenticated proxy HTTP client.
func (*AuthClient) ValidateParams ¶
func (p *AuthClient) ValidateParams() error
func (*AuthClient) WithAuthenticatedClient ¶
func (p *AuthClient) WithAuthenticatedClient(client common.AuthenticatedHTTPClient)
WithAuthenticatedClient sets up an HTTP client that uses your implementation of authentication.
type Client ¶
type Client struct {
AuthClient
}
Client params sets up authenticated proxy HTTP client. There are many types of authentication, where only one must be chosen. Ex: oauth2.
func (*Client) WithApiKeyHeaderClient ¶
func (p *Client) WithApiKeyHeaderClient( ctx context.Context, client *http.Client, provider providers.Provider, apiKey string, opts ...common.HeaderAuthClientOption, )
WithApiKeyHeaderClient option sets up client that utilises API Key authentication. Passed via Header.
func (*Client) WithApiKeyQueryParamClient ¶
func (p *Client) WithApiKeyQueryParamClient( ctx context.Context, client *http.Client, provider providers.Provider, apiKey string, opts ...common.QueryParamAuthClientOption, )
WithApiKeyQueryParamClient option sets up client that utilises API Key authentication. Passed via Query Param.
func (*Client) WithBasicClient ¶
func (p *Client) WithBasicClient( ctx context.Context, client *http.Client, user, pass string, opts ...common.HeaderAuthClientOption, )
WithBasicClient option that sets up client that utilises Basic (username, password) authentication.
type Metadata ¶
type Metadata struct { // Map is a registry of metadata values that are needed for connector to function. Map map[string]string // contains filtered or unexported fields }
Metadata params sets metadata describing authentication information.
func (*Metadata) ValidateParams ¶
type Module ¶
Module represents a sub-product of a provider. This is relevant where there are several APIs for different sub-products, and the APIs are versioned differently or have different ways of constructing URLs and requests for reading/writing.
func (*Module) ValidateParams ¶
func (*Module) WithModule ¶
func (p *Module) WithModule(moduleID common.ModuleID, supported common.Modules, fallbackID common.ModuleID)
WithModule allows API module selection. Connector implementation must provide list of modules that are currently supported. This defines a list of module a user could switch to. Any out of scope module will be ignored. If user supplied unsupported module, then it will use this fallback.
type ParamAssurance ¶
type ParamAssurance interface {
ValidateParams() error
}
ParamAssurance checks that param data is valid Every param instance must implement it.
type Workspace ¶
type Workspace struct {
Name string
}
Workspace params sets up varying workspace name.
func (*Workspace) GetSubstitutionPlan ¶
func (p *Workspace) GetSubstitutionPlan() catalogreplacer.SubstitutionPlan
GetSubstitutionPlan of the workspace describes how to insert its value into string templates. This makes Workspace parameter a catalog variable.