GcpConnectionResolver

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

Implements: IConfigurable, IReferenceable

Description

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_name: is the name of the HTTP function you deployed
  • credentials:
    • auth_token: Google-generated ID token or null if using custom auth

References

  • *:credential-store:*:*:1.0 - (optional) credential stores to resolve credentials.

Fields

_connectionResolver

Connection resolver.

protected _connectionResolver: ConnectionResolver

_credentialResolver

Credential resolver.

protected _credentialResolver: CredentialResolver

Instance methods

configure

Configures a component by passing its configuration parameters.

public configure(config: ConfigParams): void

  • config: ConfigParams - configuration parameters to be set.

resolve

Resolves connection and credential parameters and generates a single GcpConnectionParams value.

public resolve(context: IContext): Promise<GcpConnectionParams>

  • context: IContext - (optional) a context to trace execution through a call chain.
  • returns: Promise<GcpConnectionParams> - receives an GcpConnectionParams value or error.

setReferences

Sets references to dependent components.

public setReferences(references: IReferences): void

  • references: IReferences - references to locate the component’s dependencies.

Examples

let config = ConfigParams.fromTuples(
    'connection.uri', 'http://east-my_test_project.cloudfunctions.net/myfunction',
    'connection.protocol', 'http',
    'connection.region', 'east',
    'connection.function_name', 'myfunction',
    'credential.project_id', 'my_test_project',
    'credential.auth_token', '1234',
);
   
let connectionResolver = new GcpConnectionResolver();
connectionResolver.configure(config);
connectionResolver.setReferences(references);
    
const connectionParams = await connectionResolver.resolve("123");

See also