# 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.V1.Model.EventTrigger do
  @moduledoc """
  Describes EventTrigger, used to request events be sent from another service.

  ## Attributes

  *   `eventType` (*type:* `String.t`, *default:* `nil`) - Required. The type of event to observe. For example: `providers/cloud.storage/eventTypes/object.change` and `providers/cloud.pubsub/eventTypes/topic.publish`. Event types match pattern `providers/*/eventTypes/*.*`. The pattern contains: 1. namespace: For example, `cloud.storage` and `google.firebase.analytics`. 2. resource type: The type of resource on which event occurs. For example, the Google Cloud Storage API includes the type `object`. 3. action: The action that generates the event. For example, action for a Google Cloud Storage Object is 'change'. These parts are lower case.
  *   `failurePolicy` (*type:* `GoogleApi.CloudFunctions.V1.Model.FailurePolicy.t`, *default:* `nil`) - Specifies policy for failed executions.
  *   `resource` (*type:* `String.t`, *default:* `nil`) - Required. The resource(s) from which to observe events, for example, `projects/_/buckets/myBucket`. Not all syntactically correct values are accepted by all services. For example: 1. The authorization model must support it. Google Cloud Functions only allows EventTriggers to be deployed that observe resources in the same project as the `CloudFunction`. 2. The resource type must match the pattern expected for an `event_type`. For example, an `EventTrigger` that has an `event_type` of "google.pubsub.topic.publish" should have a resource that matches Google Cloud Pub/Sub topics. Additionally, some services may support short names when creating an `EventTrigger`. These will always be returned in the normalized "long" format. See each *service's* documentation for supported formats.
  *   `service` (*type:* `String.t`, *default:* `nil`) - The hostname of the service that 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.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :eventType => String.t() | nil,
          :failurePolicy => GoogleApi.CloudFunctions.V1.Model.FailurePolicy.t() | nil,
          :resource => String.t() | nil,
          :service => String.t() | nil
        }

  field(:eventType)
  field(:failurePolicy, as: GoogleApi.CloudFunctions.V1.Model.FailurePolicy)
  field(:resource)
  field(:service)
end

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

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