# 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.EnterpriseCrmEventbusProtoWorkflowAlertConfig do
  @moduledoc """
  Message to be used to configure custom alerting in the {@code EventConfig} protos for an event.

  ## Attributes

  *   `aggregationPeriod` (*type:* `String.t`, *default:* `nil`) - For an EXPECTED_MIN threshold, this aggregation_period must be lesser than 24 hours.
  *   `alertDisabled` (*type:* `boolean()`, *default:* `nil`) - Set to false by default. When set to true, the metrics are not aggregated or pushed to Monarch for this workflow alert.
  *   `alertName` (*type:* `String.t`, *default:* `nil`) - A name to identify this alert. This will be displayed in the alert subject. If set, this name should be unique within the scope of the workflow.
  *   `clientId` (*type:* `String.t`, *default:* `nil`) - Client associated with this alert configuration.
  *   `durationThresholdMs` (*type:* `String.t`, *default:* `nil`) - Should be specified only for *AVERAGE_DURATION and *PERCENTILE_DURATION metrics. This member should be used to specify what duration value the metrics should exceed for the alert to trigger.
  *   `errorEnumList` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t`, *default:* `nil`) - 
  *   `metricType` (*type:* `String.t`, *default:* `nil`) - 
  *   `numAggregationPeriods` (*type:* `integer()`, *default:* `nil`) - For how many contiguous aggregation periods should the expected min or max be violated for the alert to be fired.
  *   `onlyFinalAttempt` (*type:* `boolean()`, *default:* `nil`) - For either events or tasks, depending on the type of alert, count only final attempts, not retries.
  *   `playbookUrl` (*type:* `String.t`, *default:* `nil`) - Link to a playbook for resolving the issue that triggered this alert.
  *   `thresholdType` (*type:* `String.t`, *default:* `nil`) - The threshold type, whether lower(expected_min) or upper(expected_max), for which this alert is being configured. If value falls below expected_min or exceeds expected_max, an alert will be fired.
  *   `thresholdValue` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue.t`, *default:* `nil`) - The metric value, above or below which the alert should be triggered.
  *   `warningEnumList` (*type:* `GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t`, *default:* `nil`) - 
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :aggregationPeriod => String.t() | nil,
          :alertDisabled => boolean() | nil,
          :alertName => String.t() | nil,
          :clientId => String.t() | nil,
          :durationThresholdMs => String.t() | nil,
          :errorEnumList =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t()
            | nil,
          :metricType => String.t() | nil,
          :numAggregationPeriods => integer() | nil,
          :onlyFinalAttempt => boolean() | nil,
          :playbookUrl => String.t() | nil,
          :thresholdType => String.t() | nil,
          :thresholdValue =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue.t()
            | nil,
          :warningEnumList =>
            GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList.t()
            | nil
        }

  field(:aggregationPeriod)
  field(:alertDisabled)
  field(:alertName)
  field(:clientId)
  field(:durationThresholdMs)

  field(:errorEnumList,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList
  )

  field(:metricType)
  field(:numAggregationPeriods)
  field(:onlyFinalAttempt)
  field(:playbookUrl)
  field(:thresholdType)

  field(:thresholdValue,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigThresholdValue
  )

  field(:warningEnumList,
    as:
      GoogleApi.Integrations.V1alpha.Model.EnterpriseCrmEventbusProtoBaseAlertConfigErrorEnumList
  )
end

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

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