Documentation ¶
Index ¶
- type GcpConnectionParams
- func NewEmptyGcpConnectionParams() *GcpConnectionParams
- func NewGcpConnectionParams(values map[string]string) *GcpConnectionParams
- func NewGcpConnectionParamsFromConfig(config *cconf.ConfigParams) *GcpConnectionParams
- func NewGcpConnectionParamsFromMaps(configs ...map[string]string) *GcpConnectionParams
- func NewGcpConnectionParamsFromString(line string) *GcpConnectionParams
- func NewGcpConnectionParamsFromTuples(tuples ...any) *GcpConnectionParams
- func (c *GcpConnectionParams) Account() (string, bool)
- func (c *GcpConnectionParams) AuthToken() (string, bool)
- func (c *GcpConnectionParams) Function() (string, bool)
- func (c *GcpConnectionParams) OrgId() (string, bool)
- func (c *GcpConnectionParams) ProjectId() (string, bool)
- func (c *GcpConnectionParams) Protocol() (string, bool)
- func (c *GcpConnectionParams) Region() (string, bool)
- func (c *GcpConnectionParams) SetAccount(value string)
- func (c *GcpConnectionParams) SetAuthToken(value string)
- func (c *GcpConnectionParams) SetFunction(value string)
- func (c *GcpConnectionParams) SetOrgId(value string)
- func (c *GcpConnectionParams) SetProjectId(value string)
- func (c *GcpConnectionParams) SetProtocol(value string)
- func (c *GcpConnectionParams) SetRegion(value string)
- func (c *GcpConnectionParams) SetUri(value string)
- func (c *GcpConnectionParams) Uri() (string, bool)
- func (c *GcpConnectionParams) Validate(ctx context.Context) error
- type GcpConnectionResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GcpConnectionParams ¶
type GcpConnectionParams struct {
*cconf.ConfigParams
}
Contains connection parameters to authenticate against Google and connect to specific Google Cloud Platform.
The class is able to compose and parse Google Platform connection parameters.
Configuration parameters - connections: - uri: full connection uri with specific app and function name - protocol: connection protocol - project_id: is your Google Cloud Platform project ID - region: is the region where your function is deployed - function: is the name of the HTTP function you deployed - org_id: organization name - credentials: - account: the service account name - auth_token: Google-generated ID token or null if using custom auth (IAM)
In addition to standard parameters CredentialParams may contain any number of custom parameters.
see GcpConnectionResolver
Example: connection := connect.NewGcpConnectionParamsFromTuples( "connection.uri", "http://east-my_test_project.cloudfunctions.net/myfunction", "connection.protocol", "http", "connection.region", "east", "connection.function", "myfunction", "connection.project_id", "my_test_project", "credential.auth_token", "1234", ) uri, _ := connection.Uri() // Result: "http://east-my_test_project.cloudfunctions.net/myfunction" region, _ := connection.Region() // Result: "east" protocol, _ := connection.Protocol() // Result: "http" functionName, _ := connection.Function() // Result: "myfunction" projectId, _ := connection.ProjectId() // Result: "my_test_project" authToken, _ := connection.AuthToken() // Result: "1234"
func NewEmptyGcpConnectionParams ¶
func NewEmptyGcpConnectionParams() *GcpConnectionParams
Creates an new instance of the connection parameters.
func NewGcpConnectionParams ¶
func NewGcpConnectionParams(values map[string]string) *GcpConnectionParams
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 NewGcpConnectionParamsFromConfig ¶
func NewGcpConnectionParamsFromConfig(config *cconf.ConfigParams) *GcpConnectionParams
Retrieves GcpConnectionParams from configuration parameters. The values are retrieves from "connection" and "credential" sections. Parameters:
- config configuration parameters
Returns the generated GcpConnectionParams object.
func NewGcpConnectionParamsFromMaps ¶
func NewGcpConnectionParamsFromMaps(configs ...map[string]string) *GcpConnectionParams
Retrieves GcpConnectionParams from multiple configuration parameters. The values are retrieves from "connection" and "credential" sections. Parameters:
- configs a list with configuration parameters
Returns the generated GcpConnectionParams object.
func NewGcpConnectionParamsFromString ¶
func NewGcpConnectionParamsFromString(line string) *GcpConnectionParams
Creates a new GcpConnectionParams 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 GcpConnectionParams object.
func NewGcpConnectionParamsFromTuples ¶
func NewGcpConnectionParamsFromTuples(tuples ...any) *GcpConnectionParams
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 (*GcpConnectionParams) Account ¶
func (c *GcpConnectionParams) Account() (string, bool)
Gets the service account name Returns the account name.
func (*GcpConnectionParams) AuthToken ¶
func (c *GcpConnectionParams) AuthToken() (string, bool)
Gets an ID token with the request to authenticate themselves Returns the ID token.
func (*GcpConnectionParams) Function ¶
func (c *GcpConnectionParams) Function() (string, bool)
Gets the Google function name. Returns the Google function name.
func (*GcpConnectionParams) OrgId ¶
func (c *GcpConnectionParams) OrgId() (string, bool)
Get organization name Returns the organization name.
func (*GcpConnectionParams) ProjectId ¶
func (c *GcpConnectionParams) ProjectId() (string, bool)
Gets the Google Cloud Platform project ID. Returns the project ID.
func (*GcpConnectionParams) Protocol ¶
func (c *GcpConnectionParams) Protocol() (string, bool)
Gets the Google Platform service connection protocol. Returns the Google service connection protocol.
func (*GcpConnectionParams) Region ¶
func (c *GcpConnectionParams) Region() (string, bool)
Gets the region where your function is deployed. Returns the region of deployed function.
func (*GcpConnectionParams) SetAccount ¶
func (c *GcpConnectionParams) SetAccount(value string)
Sets the service account name Parameters:
- value a new account name.
func (*GcpConnectionParams) SetAuthToken ¶
func (c *GcpConnectionParams) SetAuthToken(value string)
Sets an ID token with the request to authenticate themselves Parameters:
- value a new ID token.
func (*GcpConnectionParams) SetFunction ¶
func (c *GcpConnectionParams) SetFunction(value string)
Sets the Google function name. Parameters:
- value a new Google function name.
func (*GcpConnectionParams) SetOrgId ¶
func (c *GcpConnectionParams) SetOrgId(value string)
Sets organization name Parameters:
- value a new organization name.
func (*GcpConnectionParams) SetProjectId ¶
func (c *GcpConnectionParams) SetProjectId(value string)
Sets the Google Cloud Platform project ID. Parameters:
- value a new project ID.
func (*GcpConnectionParams) SetProtocol ¶
func (c *GcpConnectionParams) SetProtocol(value string)
Sets the Google Platform service connection protocol. Parameters:
- value a new Google service connection protocol.
func (*GcpConnectionParams) SetRegion ¶
func (c *GcpConnectionParams) SetRegion(value string)
Sets the region where your function is deployed. Parameters:
- value the region of deployed function.
func (*GcpConnectionParams) SetUri ¶
func (c *GcpConnectionParams) SetUri(value string)
Sets the Google Platform service uri. Parameters:
- value a new Google service uri.
func (*GcpConnectionParams) Uri ¶
func (c *GcpConnectionParams) Uri() (string, bool)
Gets the Google Platform service uri. Returns the Google sevice uri.
type GcpConnectionResolver ¶
type GcpConnectionResolver struct {
// contains filtered or unexported fields
}
Helper class to retrieve Google connection and credential parameters, validate them and compose a GcpConnectionParams value.
Configuration parameters - connections: - uri: full connection uri with specific app and function name - protocol: connection protocol - project_id: is your Google Cloud Platform project ID - region: is the region where your function is deployed - function: is the name of the HTTP function you deployed - org_id: organization name - credentials: - account: the service account name - auth_token: Google-generated ID token or null if using custom auth (IAM) References - *: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://east-my_test_project.cloudfunctions.net/myfunction", "connection.protocol", "http", "connection.region", "east", "connection.function", "myfunction", "connection.project_id", "my_test_project", "credential.auth_token", "1234", ) ctx := context.Background() connectionResolver := connect.NewGcpConnectionResolver() connectionResolver.Configure(ctx, config) connectionResolver.SetReferences(ctx, references) connectionParams, _ := connectionResolver.Resolve("123")
func NewGcpConnectionResolver ¶
func NewGcpConnectionResolver() *GcpConnectionResolver
Creates new instance of GcpConnectionResolver
func (*GcpConnectionResolver) Configure ¶
func (c *GcpConnectionResolver) Configure(ctx context.Context, config *cconf.ConfigParams)
Configure Configures component by passing configuration parameters.
Parameters: - ctx context.Context - config *config.ConfigParams configuration parameters to be set.
func (*GcpConnectionResolver) Resolve ¶
func (c *GcpConnectionResolver) Resolve(ctx context.Context) (*GcpConnectionParams, error)
Resolves connection and credential parameters and generates a single GcpConnectionParams value. Parameters:
- ctx context.Context a context to trace execution through call chain.
Returns GcpConnectionParams value or error.
see IDiscovery (in the Pip.Services components package)
func (*GcpConnectionResolver) SetReferences ¶
func (c *GcpConnectionResolver) SetReferences(ctx context.Context, references refer.IReferences)
SetReferences sets references to dependent components.
Parameters: - ctx context.Context - references refer.IReferences references to locate the component dependencies.