connect

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureFunctionConnectionParams

type AzureFunctionConnectionParams struct {
	cconf.ConfigParams
}

Contains connection parameters to authenticate against Azure and connect to specific Azure Functions.

The class is able to compose and parse Azure Function connection parameters.

Configuration parameters
	- connections:
	     - uri:           full connection uri with specific app and function name
	     - protocol:      connection protocol
	     - app_name:      alternative app name
	     - function_name: application function name
	- credentials:
	     - auth_code:     authorization code or null if using custom auth

In addition to standard parameters CredentialParams may contain any number of custom parameters.

see AzureConnectionResolver

Example:
	connection := connect.NewAzureFunctionConnectionParamsFromTuples(
		"connection.uri", "http://myapp.azurewebsites.net/api/myfunction",
		"connection.protocol", "http",
		"connection.app_name", "myapp",
		"connection.function_name", "myfunction",
		"connection.auth_code", "code",
	)
	uri, _ := connection.FunctionUri()          	// Result: "http://myapp.azurewebsites.net/api/myfunction"
	protocol, _ := connection.Protocol()        	// Result: "http"
	appName, _ := connection.AppName()    			// Result: "myapp"
	functionName, _ := connection.FunctionName()	// Result: "myfunction"
	authCode, _ := connection.AuthCode()  			// Result: "code"

func NewAzureFunctionConnectionParams

func NewAzureFunctionConnectionParams(values map[string]string) *AzureFunctionConnectionParams

Creates an new instance of the connection parameters. Parameters:

  • values (optional) an object to be converted into key-value pairs to initialize this connection.

func NewAzureFunctionConnectionParamsFromConfig

func NewAzureFunctionConnectionParamsFromConfig(config *cconf.ConfigParams) *AzureFunctionConnectionParams

Retrieves AzureFunctionConnectionParams from configuration parameters. The values are retrieves from "connection" and "credential" sections. Parameters:

  • config configuration parameters

Returns the generated AzureFunctionConnectionParams object.

func NewAzureFunctionConnectionParamsFromMaps

func NewAzureFunctionConnectionParamsFromMaps(configs ...map[string]string) *AzureFunctionConnectionParams

Retrieves AzureFunctionConnectionParams from multiple configuration parameters. The values are retrieves from "connection" and "credential" sections. Parameters:

  • configs a list with configuration parameters

Returns the generated AzureFunctionConnectionParams object.

func NewAzureFunctionConnectionParamsFromString

func NewAzureFunctionConnectionParamsFromString(line string) *AzureFunctionConnectionParams

Creates a new AzureFunctionConnectionParams object filled with key-value pairs serialized as a string. Parameters:

  • line a string with serialized key-value pairs as "key1=value1;key2=value2;..." Example: "Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z"

Returns a new AzureFunctionConnectionParams object.

func NewAzureFunctionConnectionParamsFromTuples

func NewAzureFunctionConnectionParamsFromTuples(tuples ...any) *AzureFunctionConnectionParams

Creates a new ConfigParams object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, ... pairs. Parameters:

  • tuples the tuples to fill a new ConfigParams object.

Returns a new ConfigParams object.

func NewEmptyAzureFunctionConnectionParams

func NewEmptyAzureFunctionConnectionParams() *AzureFunctionConnectionParams

Creates an new instance of the connection parameters.

func (*AzureFunctionConnectionParams) AppName

func (c *AzureFunctionConnectionParams) AppName() (string, bool)

Gets the Azure app name. Returns the Azure app name.

func (*AzureFunctionConnectionParams) AuthCode

func (c *AzureFunctionConnectionParams) AuthCode() (string, bool)

Gets the Azure auth code. Returns the Azure auth code.

func (*AzureFunctionConnectionParams) FunctionName

func (c *AzureFunctionConnectionParams) FunctionName() (string, bool)

Gets the Azure function name. Returns the Azure function name.

func (*AzureFunctionConnectionParams) FunctionUri

func (c *AzureFunctionConnectionParams) FunctionUri() (string, bool)

Gets the Azure Platform service uri. Returns the Azure sevice uri.

func (*AzureFunctionConnectionParams) Protocol

func (c *AzureFunctionConnectionParams) Protocol() (string, bool)

Gets the Azure Platform service connection protocol. Returns the Azure service connection protocol.

func (*AzureFunctionConnectionParams) SetAppName

func (c *AzureFunctionConnectionParams) SetAppName(value string)

Sets the Azure app name. Parameters:

  • value the Azure app name.

func (*AzureFunctionConnectionParams) SetAuthCode

func (c *AzureFunctionConnectionParams) SetAuthCode(value string)

Sets the Azure auth code. Parameters:

  • value the Azure auth code.

func (*AzureFunctionConnectionParams) SetFunctionName

func (c *AzureFunctionConnectionParams) SetFunctionName(value string)

Sets the Azure function name. Parameters:

  • value the Azure function name.

func (*AzureFunctionConnectionParams) SetFunctionUri

func (c *AzureFunctionConnectionParams) SetFunctionUri(value string)

Sets the Azure Platform service uri. Parameters:

  • value a new Azure service uri.

func (*AzureFunctionConnectionParams) SetProtocol

func (c *AzureFunctionConnectionParams) SetProtocol(value string)

Sets the Azure Platform service connection protocol. Parameters:

  • value a new Azure service connection protocol.

func (*AzureFunctionConnectionParams) Validate

func (c *AzureFunctionConnectionParams) Validate(correlationId string) error

Validates this connection parameters Parameters:

  • correlationId (optional) transaction id to trace execution through call chain.

type AzureFunctionConnectionResolver

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

Helper class to retrieve Google connection and credential parameters, validate them and compose a AzureFunctionConnectionParams value.

Configuration parameters
	- connections:
	     - uri:           full connection uri with specific app and function name
	     - protocol:      connection protocol
	     - app_name:      alternative app name
	     - function_name: application function name
	- credentials:
	     - auth_code:     authorization code or null if using custom auth

References
	- *:discovery:*:*:1.0			(optional) IDiscovery services to resolve connections
	- *:credential-store:*:*:1.0	(optional) Credential stores to resolve credentials

see ConnectionParams (in the Pip.Services components package)

Example:
	config := config.NewConfigParamsFromTuples(
		"connection.uri", "http://myapp.azurewebsites.net/api/myfunction",
		"connection.app_name", "myapp",
		"connection.function_name", "myfunction",
		"credential.auth_code", "XXXXXXXXXX",
	)
	ctx := context.Background()
	connectionResolver := connect.NewAzureConnectionResolver()
	connectionResolver.Configure(ctx, config)
	connectionResolver.SetReferences(ctx, references)

	connectionParams, _ := connectionResolver.Resolve("123")

func NewAzureFunctionConnectionResolver

func NewAzureFunctionConnectionResolver() *AzureFunctionConnectionResolver

Creates new instance of AzureFunctionConnectionResolver

func (*AzureFunctionConnectionResolver) Configure

Configure Configures component by passing configuration parameters.

Parameters:
	- ctx context.Context
	- config *config.ConfigParams configuration parameters to be set.

func (*AzureFunctionConnectionResolver) Resolve

Resolves connection and credential parameters and generates a single AzureConnectionParams value. Parameters:

  • correlationId (optional) transaction id to trace execution through call chain.

Returns AzureConnectionParams value and error

func (*AzureFunctionConnectionResolver) SetReferences

func (c *AzureFunctionConnectionResolver) SetReferences(ctx context.Context, references crefer.IReferences)

SetReferences sets references to dependent components.

Parameters:
	- ctx context.Context
	- references refer.IReferences references to locate the component dependencies.

Jump to

Keyboard shortcuts

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