# 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.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinition do
  @moduledoc """
  Custom constraint definition. Defines this as a managed constraint.

  ## Attributes

  *   `actionType` (*type:* `String.t`, *default:* `nil`) - Allow or deny type.
  *   `condition` (*type:* `String.t`, *default:* `nil`) - Org policy condition/expression. For example: `resource.instanceName.matches("[production|test]_.*_(\\d)+")` or, `resource.management.auto_upgrade == true` The max length of the condition is 1000 characters.
  *   `methodTypes` (*type:* `list(String.t)`, *default:* `nil`) - All the operations being applied for this constraint.
  *   `parameters` (*type:* `%{optional(String.t) => GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinitionParameter.t}`, *default:* `nil`) - Stores the structure of `Parameters` used by the constraint condition. The key of `map` represents the name of the parameter.
  *   `resourceTypes` (*type:* `list(String.t)`, *default:* `nil`) - The resource instance type on which this policy applies. Format will be of the form : `/` Example: * `compute.googleapis.com/Instance`.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :actionType => String.t() | nil,
          :condition => String.t() | nil,
          :methodTypes => list(String.t()) | nil,
          :parameters =>
            %{
              optional(String.t()) =>
                GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinitionParameter.t()
            }
            | nil,
          :resourceTypes => list(String.t()) | nil
        }

  field(:actionType)
  field(:condition)
  field(:methodTypes, type: :list)

  field(:parameters,
    as:
      GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinitionParameter,
    type: :map
  )

  field(:resourceTypes, type: :list)
end

defimpl Poison.Decoder,
  for: GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinition do
  def decode(value, options) do
    GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinition.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.OrgPolicy.V2.Model.GoogleCloudOrgpolicyV2ConstraintCustomConstraintDefinition do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
