# 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.GKEBackup.V1.Model.ResourceSelector do
  @moduledoc """
  Defines a selector to identify a single or a group of resources. Conditions in the selector are optional, but at least one field should be set to a non-empty value. If a condition is not specified, no restrictions will be applied on that dimension. If more than one condition is specified, a resource will be selected if and only if all conditions are met.

  ## Attributes

  *   `groupKind` (*type:* `GoogleApi.GKEBackup.V1.Model.GroupKind.t`, *default:* `nil`) - Optional. Selects resources using their Kubernetes GroupKinds. If specified, only resources of provided GroupKind will be selected.
  *   `labels` (*type:* `map()`, *default:* `nil`) - Optional. Selects resources using Kubernetes [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). If specified, a resource will be selected if and only if the resource has all of the provided labels and all the label values match.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Optional. Selects resources using their resource names. If specified, only resources with the provided name will be selected.
  *   `namespace` (*type:* `String.t`, *default:* `nil`) - Optional. Selects resources using their namespaces. This only applies to namespace scoped resources and cannot be used for selecting cluster scoped resources. If specified, only resources in the provided namespace will be selected. If not specified, the filter will apply to both cluster scoped and namespace scoped resources (e.g. name or label). The [Namespace](https://pkg.go.dev/k8s.io/api/core/v1#Namespace) resource itself will be restored if and only if any resources within the namespace are restored.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :groupKind => GoogleApi.GKEBackup.V1.Model.GroupKind.t() | nil,
          :labels => map() | nil,
          :name => String.t() | nil,
          :namespace => String.t() | nil
        }

  field(:groupKind, as: GoogleApi.GKEBackup.V1.Model.GroupKind)
  field(:labels, type: :map)
  field(:name)
  field(:namespace)
end

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

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