Cloud Pub/Sub API - Class Google::Cloud::PubSub::Subscription::PushConfig (v2.17.0)

Reference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::Subscription::PushConfig.

Configuration for a push delivery endpoint.

Inherits

  • Object

Examples

Create a push config:

require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new
topic = pubsub.topic "my-topic"

push_config = Google::Cloud::PubSub::Subscription::PushConfig.new endpoint: "http://example.net/callback"
push_config.set_oidc_token "service-account@example.net", "audience-header-value"

sub = topic.subscribe "my-subscription", push_config: push_config

Read a push config:

require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new

sub = pubsub.subscription "my-topic-sub"
sub.push_config.endpoint #=> "http://example.com/callback"
sub.push_config.authentication.email #=> "user@example.com"
sub.push_config.authentication.audience #=> "client-12345"

Update a push config:

require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new
sub = pubsub.subscription "my-subscription"

sub.push_config do |pc|
  pc.endpoint = "http://example.net/callback"
  pc.set_oidc_token "user@example.net", "client-67890"
end

Methods

#authentication

def authentication() -> OidcToken, nil

The authentication method used by push endpoints to verify the source of push requests.

Returns
  • (OidcToken, nil) — An OIDC JWT token if specified, nil otherwise.

#authentication=

def authentication=(new_auth)

Sets the authentication method used by push endpoints to verify the source of push requests.

Parameter
  • new_auth (OidcToken, nil) — An authentication value.

#endpoint

def endpoint() -> String

A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use https://example.com/push.

Returns
  • (String)

#endpoint=

def endpoint=(new_endpoint)

Sets the URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use https://example.com/push.

Parameter
  • new_endpoint (String, nil) — New URL value

#initialize

def initialize(endpoint: nil, email: nil, audience: nil) -> PushConfig

Creates a new push configuration.

Parameters
  • endpoint (String) (defaults to: nil) — A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use https://example.com/push.
  • email (String) (defaults to: nil) — The service account email to be used for generating the OIDC token. The caller must have the iam.serviceAccounts.actAs permission for the service account.
  • audience (String) (defaults to: nil) — The audience to be used when generating OIDC token. The audience claim identifies the recipients that the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values (array) for the audience field is not supported. More info about the OIDC JWT token audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the endpoint URL will be used.
Returns
Raises
  • (ArgumentError)

#oidc_token?

def oidc_token?() -> Boolean

Checks whether authentication is an OidcToken.

Returns
  • (Boolean)

#set_oidc_token

def set_oidc_token(email, audience)

Sets the authentication method to use an OidcToken.

Parameters
  • email (String) — Service account email.
  • audience (String) — Audience to be used.

#version

def version() -> String

The format of the pushed message. This attribute indicates the version of the data expected by the endpoint. This controls the shape of the pushed message (i.e., its fields and metadata). The endpoint version is based on the version of the Pub/Sub API.

If not present during the Subscription creation, it will default to the version of the API used to make such call.

The possible values for this attribute are:

  • v1beta1: uses the push format defined in the v1beta1 Pub/Sub API.
  • v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API.
Returns
  • (String)

#version=

def version=(new_version)

Sets the format of the pushed message.

The possible values for this attribute are:

  • v1beta1: uses the push format defined in the v1beta1 Pub/Sub API.
  • v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API.
Parameter
  • new_version (String, nil) — The new version value.