Class: Google::Cloud::PubSub::Subscription::PushConfig
- Inherits:
-
Object
- Object
- Google::Cloud::PubSub::Subscription::PushConfig
- Defined in:
- lib/google/cloud/pubsub/subscription/push_config.rb
Overview
Configuration for a push delivery endpoint.
Defined Under Namespace
Classes: OidcToken
Instance Method Summary collapse
-
#authentication ⇒ OidcToken?
The authentication method used by push endpoints to verify the source of push requests.
-
#authentication=(new_auth) ⇒ Object
Sets the authentication method used by push endpoints to verify the source of push requests.
-
#endpoint ⇒ String
A URL locating the endpoint to which messages should be pushed.
-
#endpoint=(new_endpoint) ⇒ Object
Sets the URL locating the endpoint to which messages should be pushed.
-
#initialize(endpoint: nil, email: nil, audience: nil) ⇒ PushConfig
constructor
Creates a new push configuration.
-
#oidc_token? ⇒ Boolean
Checks whether authentication is an OidcToken.
-
#set_oidc_token(email, audience) ⇒ Object
Sets the authentication method to use an OidcToken.
-
#version ⇒ String
The format of the pushed message.
-
#version=(new_version) ⇒ Object
Sets the format of the pushed message.
Constructor Details
#initialize(endpoint: nil, email: nil, audience: nil) ⇒ PushConfig
Creates a new push configuration.
71 72 73 74 75 76 77 78 79 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 71 def initialize endpoint: nil, email: nil, audience: nil @grpc = Google::Cloud::PubSub::V1::PushConfig.new self.endpoint = endpoint unless endpoint.nil? raise ArgumentError, "audience provided without email. Authentication is invalid" if audience && !email set_oidc_token email, audience if email end |
Instance Method Details
#authentication ⇒ OidcToken?
The authentication method used by push endpoints to verify the source of push requests.
104 105 106 107 108 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 104 def authentication return nil unless @grpc.authentication_method == :oidc_token OidcToken.from_grpc @grpc.oidc_token end |
#authentication=(new_auth) ⇒ Object
Sets the authentication method used by push endpoints to verify the source of push requests.
114 115 116 117 118 119 120 121 122 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 114 def authentication= new_auth if new_auth.nil? @grpc.oidc_token = nil else raise ArgumentError unless new_auth.is_a? OidcToken @grpc.oidc_token = new_auth.to_grpc end end |
#endpoint ⇒ String
A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use
https://example.com/push
.
86 87 88 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 86 def endpoint @grpc.push_endpoint end |
#endpoint=(new_endpoint) ⇒ Object
Sets the URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might
use https://example.com/push
.
95 96 97 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 95 def endpoint= new_endpoint @grpc.push_endpoint = String new_endpoint end |
#oidc_token? ⇒ Boolean
Checks whether authentication is an OidcToken.
128 129 130 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 128 def oidc_token? authentication.is_a? OidcToken end |
#set_oidc_token(email, audience) ⇒ Object
Sets the authentication method to use an OidcToken.
137 138 139 140 141 142 143 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 137 def set_oidc_token email, audience oidc_token = OidcToken.new.tap do |token| token.email = email token.audience = audience end self.authentication = oidc_token end |
#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
orv1beta2
: uses the push format defined in the v1 Pub/Sub API.
161 162 163 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 161 def version @grpc.attributes["x-goog-version"] end |
#version=(new_version) ⇒ Object
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
orv1beta2
: uses the push format defined in the v1 Pub/Sub API.
176 177 178 179 180 181 182 |
# File 'lib/google/cloud/pubsub/subscription/push_config.rb', line 176 def version= new_version if new_version.nil? @grpc.attributes.delete "x-goog-version" else @grpc.attributes["x-goog-version"] = new_version end end |