// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 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
//
//     https://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.

import Foundation
import GoogleCloudWkt

/// 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.
public struct ResourceSelector: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Optional. Selects resources using their Kubernetes GroupKinds. If
  /// specified, only resources of provided GroupKind will be selected.
  public var groupKind: RestoreConfig.GroupKind? = nil

  /// Optional. Selects resources using their resource names. If specified,
  /// only resources with the provided name will be selected.
  public var name: Swift.String = Swift.String()

  /// 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.
  public var namespace: Swift.String = Swift.String()

  /// 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.
  public var labels: [Swift.String: Swift.String] = [:]

  /// Initialize a new instance of `ResourceSelector`.
  public init() {}

  /// Use `config` to return a new instance of this object, with some fields updated.
  ///
  /// Commonly used to initialize the value, for example:
  ///
  /// ```
  /// let value = ResourceSelector().with { $0.groupKind = ... }
  /// ```
  public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
    var copy = self
    try config(&copy)
    return copy
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.gkebackup.v1.ResourceSelector"
  }
  public init(fromAny any: GoogleCloudWkt.`Any`) throws {
    self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
  }
  public func _pack() throws -> GoogleCloudWkt.Struct {
    return try GoogleCloudWkt._slowAnySerialize(message: self)
  }
}
