# 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.Eventarc.V1beta1.Model.Trigger do
  @moduledoc """
  A representation of the trigger resource.

  ## Attributes

  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The creation time.
  *   `destination` (*type:* `GoogleApi.Eventarc.V1beta1.Model.Destination.t`, *default:* `nil`) - Required. Destination specifies where the events should be sent to.
  *   `etag` (*type:* `String.t`, *default:* `nil`) - Output only. This checksum is computed by the server based on the value of other fields, and may be sent only on create requests to ensure the client has an up-to-date value before proceeding.
  *   `labels` (*type:* `map()`, *default:* `nil`) - Optional. User labels attached to the triggers that can be used to group resources.
  *   `matchingCriteria` (*type:* `list(GoogleApi.Eventarc.V1beta1.Model.MatchingCriteria.t)`, *default:* `nil`) - Required. Unordered list. The criteria by which events are filtered. Only events that match with this criteria will be sent to the destination.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Required. The resource name of the trigger. Must be unique within the location on the project and must in `projects/{project}/locations/{location}/triggers/{trigger}` format.
  *   `serviceAccount` (*type:* `String.t`, *default:* `nil`) - Optional. The IAM service account email associated with the trigger. The service account represents the identity of the trigger. The principal who calls this API must have `iam.serviceAccounts.actAs` permission in the service account. See https://cloud.google.com/iam/docs/understanding-service-accounts?hl=en#sa_common for more information. For Cloud Run destinations, this service account is used to generate identity tokens when invoking the service. See https://cloud.google.com/run/docs/triggering/pubsub-push#create-service-account for information on how to invoke authenticated Cloud Run services. In order to create Audit Log triggers, the service account should also have 'eventarc.events.receiveAuditLogV1Written' permission.
  *   `transport` (*type:* `GoogleApi.Eventarc.V1beta1.Model.Transport.t`, *default:* `nil`) - Output only. In order to deliver messages, Eventarc may use other Google Cloud products as transport intermediary. This field contains a reference to that transport intermediary. This information can be used for debugging purposes.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The last-modified time.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :createTime => DateTime.t() | nil,
          :destination => GoogleApi.Eventarc.V1beta1.Model.Destination.t() | nil,
          :etag => String.t() | nil,
          :labels => map() | nil,
          :matchingCriteria => list(GoogleApi.Eventarc.V1beta1.Model.MatchingCriteria.t()) | nil,
          :name => String.t() | nil,
          :serviceAccount => String.t() | nil,
          :transport => GoogleApi.Eventarc.V1beta1.Model.Transport.t() | nil,
          :updateTime => DateTime.t() | nil
        }

  field(:createTime, as: DateTime)
  field(:destination, as: GoogleApi.Eventarc.V1beta1.Model.Destination)
  field(:etag)
  field(:labels, type: :map)
  field(:matchingCriteria, as: GoogleApi.Eventarc.V1beta1.Model.MatchingCriteria, type: :list)
  field(:name)
  field(:serviceAccount)
  field(:transport, as: GoogleApi.Eventarc.V1beta1.Model.Transport)
  field(:updateTime, as: DateTime)
end

defimpl Poison.Decoder, for: GoogleApi.Eventarc.V1beta1.Model.Trigger do
  def decode(value, options) do
    GoogleApi.Eventarc.V1beta1.Model.Trigger.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Eventarc.V1beta1.Model.Trigger do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
