Global

Methods

headers() → {string}

Get authenticated HTTP request headers that can be used to authorize a request.

Returns:
Type Description
string

authenticated HTTP request headers.

Source:
Example
// Generates a signed JSON Web Token using a Google API Service Account.
node ./bin/cli.js auth headers

jwt(sub, path) → {string}

Generates a signed JSON Web Token using a Google API Service Account.

Parameters:
Name Type Description
sub string

Subject to set for the JWT.

path string | process.env.GOOGLE_APPLICATION_CREDENTIALS

File systems path for the Service Account JSON credentials file for authorization.

Returns:
Type Description
string

Signed JSON Web Token.

Source:
See:
  • [google.auth.jwt.Credentials] (http://google-auth.readthedocs.io/en/latest/reference/google.auth.jwt.html#google.auth.jwt.Credentials)

  • Why and when to use API keys

Example
// Generates a signed JSON Web Token using a Google API Service Account.
node ./bin/cli.js auth create jwt <path>

module:tracer(serviceName) → {object}

Node Open Telemetry trace provider.

Parameters:
Name Type Description
serviceName string

Name of the service to create traces for.

Returns:
Type Description
object
  • Tracer object.
Source:

tokenId(sub, path) → {Promise.<string>}

Create Google Token Id to authorize Cloud Run and Identity-Aware Proxy (IAP) request.

Parameters:
Name Type Description
sub string

Subject to set for the JWT.

path string

File systems path for the Service Account JSON credentials file for authorization.

Returns:
Type Description
Promise.<string>

Signed Token id for Cloud Run.

Source:
See:
  • [google.auth.jwt.Credentials] (http://google-auth.readthedocs.io/en/latest/reference/google.auth.jwt.html#google.auth.jwt.Credentials)

  • Why and when to use API keys

Example
// Generates a signed JSON Web Token using a Google API Service Account.
node ./bin/cli.js auth createTokenId <url> <audience>

topic(name, accountIdopt, projectIdopt, projectNumopt, roleopt, labelsopt, messageStoragePolicyopt, kmsKeyNameopt) → {Promise.<void>}

Create Google Cloud Platform PubSub Topic.

Parameters:
Name Type Attributes Default Description
name string

The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

accountId string | null <optional>
null

Id (aka name) of a user managed service account to grant Topic permissions.

projectId string | null <optional>
process.env.GCP_PROJECT_ID

String project id of the Topic GCP project.

projectNum string | null <optional>
process.env.GCP_PROJECT_NUM

Numeric project id of the Topic GCP project.

role string | null <optional>
publisher

Name of the PubSub Topic IAM Role to grant to the supplied user managed service account and the Google managed PubSub service account. This is used to grant the service accounts permissions required to forward undeliverable message to dead-letter subscriptions.

labels Object | null <optional>
null

Object with string properties.

messageStoragePolicy Object | null <optional>
{allowedPersistenceRegions: ['us-central1']}

Policy constraining how messages published to the topic may be stored. It is determined when the topic is created based on the policy configured at the project level. It must not be set by the caller in the request to CreateTopic or to UpdateTopic. This field will be populated in the responses for GetTopic, CreateTopic, and UpdateTopic: if not present in the response, then no constraints are in effect. This object should have the same structure as MessageStoragePolicy

Properties
Name Type Attributes Default Description
allowedPersistenceRegions Array.<string> | null <optional>
['us-central1']

The list of GCP region IDs where messages that are published to the topic may be persisted in storage. Messages published by publishers running in non-allowed GCP regions (or running outside of GCP altogether) will be routed for storage in one of the allowed regions. An empty list indicates a misconfiguration at the project or organization level, which will result in all Publish operations failing.

kmsKeyName string | null <optional>
null

The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic. The expected format is projects/* /locations/* /keyRings/* /cryptoKeys/*.

Returns:
Type Description
Promise.<void>
Source:
See:
Example
// create PubSub Topic named "commander-test" in the yeti-dev-edw Google Project
node ./bin/cli.js topic create commander-test storage-notifications yeti-dev-edw 643664262938 publisher