# 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.CloudDeploy.V1.Model.RepairRolloutRule do
  @moduledoc """
  The `RepairRolloutRule` automation rule will automatically repair a failed `Rollout`.

  ## Attributes

  *   `condition` (*type:* `GoogleApi.CloudDeploy.V1.Model.AutomationRuleCondition.t`, *default:* `nil`) - Output only. Information around the state of the 'Automation' rule.
  *   `id` (*type:* `String.t`, *default:* `nil`) - Required. ID of the rule. This id must be unique in the `Automation` resource to which this rule belongs. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
  *   `jobs` (*type:* `list(String.t)`, *default:* `nil`) - Optional. Jobs to repair. Proceeds only after job name matched any one in the list, or for all jobs if unspecified or empty. The phase that includes the job must match the phase ID specified in `source_phase`. This value must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.
  *   `phases` (*type:* `list(String.t)`, *default:* `nil`) - Optional. Phases within which jobs are subject to automatic repair actions on failure. Proceeds only after phase name matched any one in the list, or for all phases if unspecified. This value must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.
  *   `repairPhases` (*type:* `list(GoogleApi.CloudDeploy.V1.Model.RepairPhaseConfig.t)`, *default:* `nil`) - Required. Defines the types of automatic repair phases for failed jobs.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :condition => GoogleApi.CloudDeploy.V1.Model.AutomationRuleCondition.t() | nil,
          :id => String.t() | nil,
          :jobs => list(String.t()) | nil,
          :phases => list(String.t()) | nil,
          :repairPhases => list(GoogleApi.CloudDeploy.V1.Model.RepairPhaseConfig.t()) | nil
        }

  field(:condition, as: GoogleApi.CloudDeploy.V1.Model.AutomationRuleCondition)
  field(:id)
  field(:jobs, type: :list)
  field(:phases, type: :list)
  field(:repairPhases, as: GoogleApi.CloudDeploy.V1.Model.RepairPhaseConfig, type: :list)
end

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

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