From 73b2b9e005cee7339239cbde1b71c41d0dd0e575 Mon Sep 17 00:00:00 2001 From: Shinichi TAMURA Date: Mon, 12 Aug 2019 18:24:47 +0000 Subject: [PATCH] Add oidcToken field to pubsub subscription Signed-off-by: Modular Magician --- docs/resources/google_pubsub_subscription.md | 2 + .../property/subscription_push_config.rb | 4 ++ .../subscription_push_config_oidc_token.rb | 37 +++++++++++++++++++ libraries/google_pubsub_subscription.rb | 1 + 4 files changed, 44 insertions(+) create mode 100644 libraries/google/pubsub/property/subscription_push_config_oidc_token.rb diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index 1e752a20d..c6aeb7e92 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -32,6 +32,8 @@ Properties that can be accessed from the `google_pubsub_subscription` resource: * `attributes`: Endpoint configuration attributes. Every endpoint has a set of API supported attributes that can be used to control different aspects of the message delivery. The currently supported attribute is x-goog-version, which you can use to change 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 subscriptions.create call, it will default to the version of the API used to make such call. If not present during a subscriptions.modifyPushConfig call, its value will not be changed. subscriptions.get calls will always return a valid version, even if the subscription was created without this attribute. 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. + * `oidc_token`: If specified, Pub/Sub will generate and attach an OIDC JWT token as an Authorization header in the HTTP request for every pushed message. + * `ack_deadline_seconds`: This value is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. After message delivery but before the ack deadline expires and before the message is acknowledged, it is an outstanding message and will not be delivered again during that time (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 subscriptions.modifyAckDeadline with the corresponding ackId if using 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. * `message_retention_duration`: How long to retain unacknowledged messages in the subscription's backlog, from the moment a message is published. If retainAckedMessages is true, then this also configures the retention of acknowledged messages, and thus configures how far back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`). A duration in seconds with up to nine fractional digits, terminated by 's'. Example: `"600.5s"`. diff --git a/libraries/google/pubsub/property/subscription_push_config.rb b/libraries/google/pubsub/property/subscription_push_config.rb index ef547d660..860fe60fb 100644 --- a/libraries/google/pubsub/property/subscription_push_config.rb +++ b/libraries/google/pubsub/property/subscription_push_config.rb @@ -13,6 +13,7 @@ # CONTRIBUTING.md located at the root of this package. # # ---------------------------------------------------------------------------- +require 'google/pubsub/property/subscription_push_config_oidc_token' module GoogleInSpec module Pubsub module Property @@ -21,11 +22,14 @@ class SubscriptionPushConfig attr_reader :attributes + attr_reader :oidc_token + def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier @push_endpoint = args['pushEndpoint'] @attributes = args['attributes'] + @oidc_token = GoogleInSpec::Pubsub::Property::SubscriptionPushConfigOidcToken.new(args['oidcToken'], to_s) end def to_s diff --git a/libraries/google/pubsub/property/subscription_push_config_oidc_token.rb b/libraries/google/pubsub/property/subscription_push_config_oidc_token.rb new file mode 100644 index 000000000..8ac9ab81a --- /dev/null +++ b/libraries/google/pubsub/property/subscription_push_config_oidc_token.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Pubsub + module Property + class SubscriptionPushConfigOidcToken + attr_reader :service_account_email + + attr_reader :audience + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @service_account_email = args['serviceAccountEmail'] + @audience = args['audience'] + end + + def to_s + "#{@parent_identifier} SubscriptionPushConfigOidcToken" + end + end + end + end +end diff --git a/libraries/google_pubsub_subscription.rb b/libraries/google_pubsub_subscription.rb index 6975ba247..b6e015e34 100644 --- a/libraries/google_pubsub_subscription.rb +++ b/libraries/google_pubsub_subscription.rb @@ -16,6 +16,7 @@ require 'gcp_backend' require 'google/pubsub/property/subscription_expiration_policy' require 'google/pubsub/property/subscription_push_config' +require 'google/pubsub/property/subscription_push_config_oidc_token' # A provider to manage Cloud Pub/Sub resources. class Subscription < GcpResourceBase