# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudFunctions.V2.Model.EventTrigger do
  @moduledoc """
  Describes EventTrigger, used to request events to be sent from another service.

  ## Attributes

  *   `channel` (*type:* `String.t`, *default:* `nil`) - Optional. The name of the channel associated with the trigger in `projects/{project}/locations/{location}/channels/{channel}` format. You must provide a channel to receive events from Eventarc SaaS partners.
  *   `eventFilters` (*type:* `list(GoogleApi.CloudFunctions.V2.Model.EventFilter.t)`, *default:* `nil`) - Criteria used to filter events.
  *   `eventType` (*type:* `String.t`, *default:* `nil`) - Required. The type of event to observe. For example: `google.cloud.audit.log.v1.written` or `google.cloud.pubsub.topic.v1.messagePublished`.
  *   `pubsubTopic` (*type:* `String.t`, *default:* `nil`) - Optional. The name of a Pub/Sub topic in the same project that will be used as the transport topic for the event delivery. Format: `projects/{project}/topics/{topic}`. This is only valid for events of type `google.cloud.pubsub.topic.v1.messagePublished`. The topic provided here will not be deleted at function deletion.
  *   `retryPolicy` (*type:* `String.t`, *default:* `nil`) - Optional. If unset, then defaults to ignoring failures (i.e. not retrying them).
  *   `service` (*type:* `String.t`, *default:* `nil`) - Optional. The hostname of the service that 1st Gen function should be observed. If no string is provided, the default service implementing the API will be used. For example, `storage.googleapis.com` is the default for all event types in the `google.storage` namespace. The field is only applicable to 1st Gen functions.
  *   `serviceAccountEmail` (*type:* `String.t`, *default:* `nil`) - Optional. The email of the trigger's service account. The service account must have permission to invoke Cloud Run services, the permission is `run.routes.invoke`. If empty, defaults to the Compute Engine default service account: `{project_number}-compute@developer.gserviceaccount.com`.
  *   `trigger` (*type:* `String.t`, *default:* `nil`) - Output only. The resource name of the Eventarc trigger. The format of this field is `projects/{project}/locations/{region}/triggers/{trigger}`.
  *   `triggerRegion` (*type:* `String.t`, *default:* `nil`) - The region that the trigger will be in. The trigger will only receive events originating in this region. It can be the same region as the function, a different region or multi-region, or the global region. If not provided, defaults to the same region as the function.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :channel => String.t() | nil,
          :eventFilters => list(GoogleApi.CloudFunctions.V2.Model.EventFilter.t()) | nil,
          :eventType => String.t() | nil,
          :pubsubTopic => String.t() | nil,
          :retryPolicy => String.t() | nil,
          :service => String.t() | nil,
          :serviceAccountEmail => String.t() | nil,
          :trigger => String.t() | nil,
          :triggerRegion => String.t() | nil
        }

  field(:channel)
  field(:eventFilters, as: GoogleApi.CloudFunctions.V2.Model.EventFilter, type: :list)
  field(:eventType)
  field(:pubsubTopic)
  field(:retryPolicy)
  field(:service)
  field(:serviceAccountEmail)
  field(:trigger)
  field(:triggerRegion)
end

defimpl Poison.Decoder, for: GoogleApi.CloudFunctions.V2.Model.EventTrigger do
  def decode(value, options) do
    GoogleApi.CloudFunctions.V2.Model.EventTrigger.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudFunctions.V2.Model.EventTrigger do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
