SubscriberClient

SubscriberClient

The service that an application uses to manipulate subscriptions and to consume messages from a subscription via the Pull method or by establishing a bi-directional stream using the StreamingPull method.

Constructor

new SubscriberClient(optionsopt)

Construct an instance of SubscriberClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. The options accepted by the constructor are described in detail in this document. The common options are:

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean <optional>

Use HTTP fallback mode. In fallback mode, a special browser-compatible transport implementation is used instead of gRPC transport. In browser context (if the window object is defined) the fallback mode is enabled automatically; set options.fallback to false if you need to override this behavior.

Members

apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

acknowledge(request, optionsopt) → {Promise}

Acknowledges the messages associated with the ack_ids in the AcknowledgeRequest. The Pub/Sub system can remove the relevant messages from the subscription.

Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The subscription whose message is being acknowledged. Format is projects/{project}/subscriptions/{sub}.

ackIds Array.<string>

Required. The acknowledgment ID for the messages being acknowledged that was returned by the Pub/Sub system in the Pull response. Must not be empty.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.acknowledge(request);

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

createSnapshot(request, optionsopt) → {Promise}

Creates a snapshot from the requested subscription. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. If the snapshot already exists, returns ALREADY_EXISTS. If the requested subscription doesn't exist, returns NOT_FOUND. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then FAILED_PRECONDITION is returned. See also the Snapshot.expire_time field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. User-provided name for this snapshot. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription. Note that for REST API requests, you must specify a name. See the resource name rules. Format is projects/{project}/snapshots/{snap}.

subscription string

Required. The subscription whose backlog the snapshot retains. Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the subscription. More precisely, this is defined as the messages in the subscription's backlog that are unacknowledged upon the successful completion of the CreateSnapshot request; as well as: (b) Any messages published to the subscription's topic following the successful completion of the CreateSnapshot request. Format is projects/{project}/subscriptions/{sub}.

labels Array.<number>

See Creating and managing labels.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Snapshot. Please see the documentation for more details and examples.
Example
const [response] = await client.createSnapshot(request);

createSubscription(request, optionsopt) → {Promise}

Creates a subscription to a given topic. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names). If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND.

If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the subscription. It must have the format "projects/{project}/subscriptions/{subscription}". {subscription} 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".

topic string

Required. The name of the topic from which this subscription is receiving messages. Format is projects/{project}/topics/{topic}. The value of this field will be _deleted-topic_ if the topic has been deleted.

pushConfig google.pubsub.v1.PushConfig

If push delivery is used with this subscription, this field is used to configure it. An empty pushConfig signifies that the subscriber will pull and ack messages using API methods.

ackDeadlineSeconds number

The approximate amount of time (on a best-effort basis) Pub/Sub waits for the subscriber to acknowledge receipt before resending the message. In the interval after the message is delivered and before it is acknowledged, it is considered to be outstanding. During that time period, the message will not be redelivered (on a best-effort basis).

For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call ModifyAckDeadline with the corresponding ack_id if using non-streaming pull or send the ack_id in a StreamingModifyAckDeadlineRequest if using streaming pull. The minimum custom deadline you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds (10 minutes). If this parameter is 0, a default value of 10 seconds is used.

For push delivery, this value is also used to set the request timeout for the call to the push endpoint.

If the subscriber never acknowledges the message, the Pub/Sub system will eventually redeliver the message.

retainAckedMessages boolean

Indicates whether to retain acknowledged messages. If true, then messages are not expunged from the subscription's backlog, even if they are acknowledged, until they fall out of the message_retention_duration window. This must be true if you would like to [Seek to a timestamp] (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time).

messageRetentionDuration google.protobuf.Duration

How long to retain unacknowledged messages in the subscription's backlog, from the moment a message is published. If retain_acked_messages is true, then this also configures the retention of acknowledged messages, and thus configures how far back in time a Seek can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10 minutes.

labels Array.<number>

See Creating and managing labels.

enableMessageOrdering boolean

If true, messages published with the same ordering_key in PubsubMessage will be delivered to the subscribers in the order in which they are received by the Pub/Sub system. Otherwise, they may be delivered in any order.

expirationPolicy google.pubsub.v1.ExpirationPolicy

A policy that specifies the conditions for this subscription's expiration. A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If expiration_policy is not set, a default policy with ttl of 31 days will be used. The minimum allowed value for expiration_policy.ttl is 1 day.

filter string

An expression written in the Pub/Sub filter language. If non-empty, then only PubsubMessages whose attributes field matches the filter are delivered on this subscription. If empty, then no messages are filtered out.

deadLetterPolicy google.pubsub.v1.DeadLetterPolicy

A policy that specifies the conditions for dead lettering messages in this subscription. If dead_letter_policy is not set, dead lettering is disabled.

The Cloud Pub/Sub service account associated with this subscriptions's parent project (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have permission to Acknowledge() messages on this subscription.

retryPolicy google.pubsub.v1.RetryPolicy

A policy that specifies how Pub/Sub retries message delivery for this subscription.

If not set, the default retry policy is applied. This generally implies that messages will be retried as soon as possible for healthy subscribers. RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded events for a given message.

detached boolean

Indicates whether the subscription is detached from its topic. Detached subscriptions don't receive messages from their topic and don't retain any backlog. Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will not be made.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Subscription. Please see the documentation for more details and examples.
Example
const [response] = await client.createSubscription(request);

deleteSnapshot(request, optionsopt) → {Promise}

Removes an existing snapshot. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
snapshot string

Required. The name of the snapshot to delete. Format is projects/{project}/snapshots/{snap}.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteSnapshot(request);

deleteSubscription(request, optionsopt) → {Promise}

Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The subscription to delete. Format is projects/{project}/subscriptions/{sub}.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteSubscription(request);

getIamPolicy(request, optionsopt, callbackopt) → {Promise}

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

options Object <optional>

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy. This field is only used by Cloud IAM.

This object should have the same structure as GetPolicyOptions

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

getSnapshot(request, optionsopt) → {Promise}

Gets the configuration details of a snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
snapshot string

Required. The name of the snapshot to get. Format is projects/{project}/snapshots/{snap}.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Snapshot. Please see the documentation for more details and examples.
Example
const [response] = await client.getSnapshot(request);

getSubscription(request, optionsopt) → {Promise}

Gets the configuration details of a subscription.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The name of the subscription to get. Format is projects/{project}/subscriptions/{sub}.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Subscription. Please see the documentation for more details and examples.
Example
const [response] = await client.getSubscription(request);

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

listSnapshots(request, optionsopt) → {Promise}

Lists the existing snapshots. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list snapshots. Format is projects/{project-id}.

pageSize number

Maximum number of snapshots to return.

pageToken string

The value returned by the last ListSnapshotsResponse; indicates that this is a continuation of a prior ListSnapshots call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Snapshot. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listSnapshotsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSnapshotsAsync(request, optionsopt) → {Object}

Equivalent to listSnapshots, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list snapshots. Format is projects/{project-id}.

pageSize number

Maximum number of snapshots to return.

pageToken string

The value returned by the last ListSnapshotsResponse; indicates that this is a continuation of a prior ListSnapshots call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Snapshot. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
const iterable = client.listSnapshotsAsync(request);
for await (const response of iterable) {
  // process response
}

listSnapshotsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list snapshots. Format is projects/{project-id}.

pageSize number

Maximum number of snapshots to return.

pageToken string

The value returned by the last ListSnapshotsResponse; indicates that this is a continuation of a prior ListSnapshots call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Snapshot on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listSnapshotsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSubscriptions(request, optionsopt) → {Promise}

Lists matching subscriptions.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list subscriptions. Format is projects/{project-id}.

pageSize number

Maximum number of subscriptions to return.

pageToken string

The value returned by the last ListSubscriptionsResponse; indicates that this is a continuation of a prior ListSubscriptions call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Subscription. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listSubscriptionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSubscriptionsAsync(request, optionsopt) → {Object}

Equivalent to listSubscriptions, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list subscriptions. Format is projects/{project-id}.

pageSize number

Maximum number of subscriptions to return.

pageToken string

The value returned by the last ListSubscriptionsResponse; indicates that this is a continuation of a prior ListSubscriptions call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Subscription. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
const iterable = client.listSubscriptionsAsync(request);
for await (const response of iterable) {
  // process response
}

listSubscriptionsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
project string

Required. The name of the project in which to list subscriptions. Format is projects/{project-id}.

pageSize number

Maximum number of subscriptions to return.

pageToken string

The value returned by the last ListSubscriptionsResponse; indicates that this is a continuation of a prior ListSubscriptions call, and that the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Subscription on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listSubscriptionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchProjectFromProjectName(projectName) → {string}

Parse the project from Project resource.

Parameters:
Name Type Description
projectName string

A fully-qualified path representing Project resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromProjectTopicName(projectTopicName) → {string}

Parse the project from ProjectTopic resource.

Parameters:
Name Type Description
projectTopicName string

A fully-qualified path representing project_topic resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromSchemaName(schemaName) → {string}

Parse the project from Schema resource.

Parameters:
Name Type Description
schemaName string

A fully-qualified path representing Schema resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromSnapshotName(snapshotName) → {string}

Parse the project from Snapshot resource.

Parameters:
Name Type Description
snapshotName string

A fully-qualified path representing Snapshot resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromSubscriptionName(subscriptionName) → {string}

Parse the project from Subscription resource.

Parameters:
Name Type Description
subscriptionName string

A fully-qualified path representing Subscription resource.

Returns:
Type Description
string

A string representing the project.

matchSchemaFromSchemaName(schemaName) → {string}

Parse the schema from Schema resource.

Parameters:
Name Type Description
schemaName string

A fully-qualified path representing Schema resource.

Returns:
Type Description
string

A string representing the schema.

matchSnapshotFromSnapshotName(snapshotName) → {string}

Parse the snapshot from Snapshot resource.

Parameters:
Name Type Description
snapshotName string

A fully-qualified path representing Snapshot resource.

Returns:
Type Description
string

A string representing the snapshot.

matchSubscriptionFromSubscriptionName(subscriptionName) → {string}

Parse the subscription from Subscription resource.

Parameters:
Name Type Description
subscriptionName string

A fully-qualified path representing Subscription resource.

Returns:
Type Description
string

A string representing the subscription.

matchTopicFromProjectTopicName(projectTopicName) → {string}

Parse the topic from ProjectTopic resource.

Parameters:
Name Type Description
projectTopicName string

A fully-qualified path representing project_topic resource.

Returns:
Type Description
string

A string representing the topic.

modifyAckDeadline(request, optionsopt) → {Promise}

Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level ackDeadlineSeconds used for subsequent messages.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The name of the subscription. Format is projects/{project}/subscriptions/{sub}.

ackIds Array.<string>

Required. List of acknowledgment IDs.

ackDeadlineSeconds number

Required. The new ack deadline with respect to the time this request was sent to the Pub/Sub system. For example, if the value is 10, the new ack deadline will expire 10 seconds after the ModifyAckDeadline call was made. Specifying zero might immediately make the message available for delivery to another subscriber client. This typically results in an increase in the rate of message redeliveries (that is, duplicates). The minimum deadline you can specify is 0 seconds. The maximum deadline you can specify is 600 seconds (10 minutes).

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.modifyAckDeadline(request);

modifyPushConfig(request, optionsopt) → {Promise}

Modifies the PushConfig for a specified subscription.

This may be used to change a push subscription to a pull one (signified by an empty PushConfig) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the PushConfig.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The name of the subscription. Format is projects/{project}/subscriptions/{sub}.

pushConfig google.pubsub.v1.PushConfig

Required. The push configuration for future deliveries.

An empty pushConfig indicates that the Pub/Sub system should stop pushing messages from the given subscription and allow messages to be pulled and acknowledged - effectively pausing the subscription if Pull or StreamingPull is not called.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.modifyPushConfig(request);

projectPath(project) → {string}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project string
Returns:
Type Description
string

Resource name string.

projectTopicPath(project, topic) → {string}

Return a fully-qualified projectTopic resource name string.

Parameters:
Name Type Description
project string
topic string
Returns:
Type Description
string

Resource name string.

pull(request, optionsopt) → {Promise}

Pulls messages from the server. The server may return UNAVAILABLE if there are too many concurrent pull requests pending for the given subscription.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
subscription string

Required. The subscription from which messages should be pulled. Format is projects/{project}/subscriptions/{sub}.

returnImmediately boolean <optional>

Optional. If this field set to true, the system will respond immediately even if it there are no messages available to return in the Pull response. Otherwise, the system may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages. Warning: setting this field to true is discouraged because it adversely impacts the performance of Pull operations. We recommend that users do not set this field.

maxMessages number

Required. The maximum number of messages to return for this request. Must be a positive integer. The Pub/Sub system may return fewer than the number specified.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing PullResponse. Please see the documentation for more details and examples.
Example
const [response] = await client.pull(request);

schemaPath(project, schema) → {string}

Return a fully-qualified schema resource name string.

Parameters:
Name Type Description
project string
schema string
Returns:
Type Description
string

Resource name string.

seek(request, optionsopt) → {Promise}

Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription string

Required. The subscription to affect.

time google.protobuf.Timestamp

The time to seek to. Messages retained in the subscription that were published before this time are marked as acknowledged, and messages retained in the subscription that were published after this time are marked as unacknowledged. Note that this operation affects only those messages retained in the subscription (configured by the combination of message_retention_duration and retain_acked_messages). For example, if time corresponds to a point before the message retention window (or to a point before the system's notion of the subscription creation time), only retained messages will be marked as unacknowledged, and already-expunged messages will not be restored.

snapshot string

The snapshot to seek to. The snapshot's topic must be the same as that of the provided subscription. Format is projects/{project}/snapshots/{snap}.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing SeekResponse. Please see the documentation for more details and examples.
Example
const [response] = await client.seek(request);

setIamPolicy(request, optionsopt, callbackopt) → {Promise}

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions Array.<string>

The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

snapshotPath(project, snapshot) → {string}

Return a fully-qualified snapshot resource name string.

Parameters:
Name Type Description
project string
snapshot string
Returns:
Type Description
string

Resource name string.

streamingPull(optionsopt) → {Stream}

Establishes a stream with the server, which sends messages down to the client. The client streams acknowledgements and ack deadline modifications back to the server. The server will close the stream and return the status on any error. The server may close the stream with status UNAVAILABLE to reassign server-side resources, in which case, the client should re-establish the stream. Flow control can be achieved by configuring the underlying RPC channel.

Parameters:
Name Type Attributes Description
options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which is both readable and writable. It accepts objects representing StreamingPullRequest for write() method, and will emit objects representing StreamingPullResponse on 'data' event asynchronously. Please see the documentation for more details and examples.

Example
const stream = client.streamingPull();
stream.on('data', (response) => { ... });
stream.on('end', () => { ... });
stream.write(request);
stream.end();

subscriptionPath(project, subscription) → {string}

Return a fully-qualified subscription resource name string.

Parameters:
Name Type Description
project string
subscription string
Returns:
Type Description
string

Resource name string.

testIamPermissions(request, optionsopt, callbackopt) → {Promise}

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions Array.<string>

The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

updateSnapshot(request, optionsopt) → {Promise}

Updates an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
snapshot google.pubsub.v1.Snapshot

Required. The updated snapshot object.

updateMask google.protobuf.FieldMask

Required. Indicates which fields in the provided snapshot to update. Must be specified and non-empty.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Snapshot. Please see the documentation for more details and examples.
Example
const [response] = await client.updateSnapshot(request);

updateSubscription(request, optionsopt) → {Promise}

Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
subscription google.pubsub.v1.Subscription

Required. The updated subscription object.

updateMask google.protobuf.FieldMask

Required. Indicates which fields in the provided subscription to update. Must be specified and non-empty.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Subscription. Please see the documentation for more details and examples.
Example
const [response] = await client.updateSubscription(request);