# 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.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaTriggerConfig do
  @moduledoc """
  Configuration detail of a trigger.

  ## Attributes

  *   `alertConfig` (*type:* `list(GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaIntegrationAlertConfig.t)`, *default:* `nil`) - Optional. An alert threshold configuration for the [trigger + client + integration] tuple. If these values are not specified in the trigger config, default values will be populated by the system. Note that there must be exactly one alert threshold configured per [client + trigger + integration] when published.
  *   `cloudSchedulerConfig` (*type:* `GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCloudSchedulerConfig.t`, *default:* `nil`) - Optional. Cloud Scheduler Trigger related metadata
  *   `description` (*type:* `String.t`, *default:* `nil`) - Optional. User-provided description intended to give additional business context about the task.
  *   `errorCatcherId` (*type:* `String.t`, *default:* `nil`) - Optional. Optional Error catcher id of the error catch flow which will be executed when execution error happens in the task
  *   `label` (*type:* `String.t`, *default:* `nil`) - Optional. The user created label for a particular trigger.
  *   `nextTasksExecutionPolicy` (*type:* `String.t`, *default:* `nil`) - Optional. Dictates how next tasks will be executed.
  *   `position` (*type:* `GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCoordinate.t`, *default:* `nil`) - Optional. Informs the front-end application where to draw this error catcher config on the UI.
  *   `properties` (*type:* `map()`, *default:* `nil`) - Optional. Configurable properties of the trigger, not to be confused with integration parameters. E.g. "name" is a property for API triggers and "subscription" is a property for Pub/sub triggers.
  *   `startTasks` (*type:* `list(GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaNextTask.t)`, *default:* `nil`) - Optional. Set of tasks numbers from where the integration execution is started by this trigger. If this is empty, then integration is executed with default start tasks. In the list of start tasks, none of two tasks can have direct ancestor-descendant relationships (i.e. in a same integration execution graph).
  *   `trigger` (*type:* `String.t`, *default:* `nil`) - Optional. Name of the trigger. Example: "API Trigger", "Cloud Pub Sub Trigger" When set will be sent out to monitoring dashabord for tracking purpose.
  *   `triggerId` (*type:* `String.t`, *default:* `nil`) - Optional. The backend trigger ID.
  *   `triggerNumber` (*type:* `String.t`, *default:* `nil`) - Required. A number to uniquely identify each trigger config within the integration on UI.
  *   `triggerType` (*type:* `String.t`, *default:* `nil`) - Optional. Type of trigger
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :alertConfig =>
            list(
              GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaIntegrationAlertConfig.t()
            )
            | nil,
          :cloudSchedulerConfig =>
            GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCloudSchedulerConfig.t()
            | nil,
          :description => String.t() | nil,
          :errorCatcherId => String.t() | nil,
          :label => String.t() | nil,
          :nextTasksExecutionPolicy => String.t() | nil,
          :position =>
            GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCoordinate.t()
            | nil,
          :properties => map() | nil,
          :startTasks =>
            list(GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaNextTask.t())
            | nil,
          :trigger => String.t() | nil,
          :triggerId => String.t() | nil,
          :triggerNumber => String.t() | nil,
          :triggerType => String.t() | nil
        }

  field(:alertConfig,
    as: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaIntegrationAlertConfig,
    type: :list
  )

  field(:cloudSchedulerConfig,
    as: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCloudSchedulerConfig
  )

  field(:description)
  field(:errorCatcherId)
  field(:label)
  field(:nextTasksExecutionPolicy)

  field(:position,
    as: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaCoordinate
  )

  field(:properties, type: :map)

  field(:startTasks,
    as: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaNextTask,
    type: :list
  )

  field(:trigger)
  field(:triggerId)
  field(:triggerNumber)
  field(:triggerType)
end

defimpl Poison.Decoder,
  for: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaTriggerConfig do
  def decode(value, options) do
    GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaTriggerConfig.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.Integrations.V1alpha.Model.GoogleCloudIntegrationsV1alphaTriggerConfig do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
