// 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

/// Request message to subscribe the Audit Manager service for given resource.
public struct EnrollResourceRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. The resource to be enrolled to the audit manager. Scope format
  /// should be resource_type/resource_identifier Eg:
  /// projects/{project}/locations/{location},
  /// folders/{folder}/locations/{location}
  /// organizations/{organization}/locations/{location}
  public var scope: Swift.String = Swift.String()

  /// Required. List of destination among which customer can choose to upload
  /// their reports during the audit process. While enrolling at a
  /// organization/folder level, customer can choose Cloud storage bucket in any
  /// project. If the audit is triggered at project level using the service agent
  /// at organization/folder level, all the destination options associated with
  /// respective organization/folder level service agent will be available to
  /// auditing projects.
  public var destinations: [EnrollResourceRequest.EligibleDestination] = []

  /// Initialize a new instance of `EnrollResourceRequest`.
  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 = EnrollResourceRequest().with { $0.scope = ... }
  /// ```
  public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
    var copy = self
    try config(&copy)
    return copy
  }

  /// The destination details where the audit report must be uploaded.
  public struct EligibleDestination: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The options for the report destination location.
    public var eligibleDestinations: OneOf_EligibleDestinations? = nil

    /// Initialize a new instance of `EligibleDestination`.
    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 = EligibleDestination().with { $0.eligibleGcsBucket = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    private enum CodingKeys: Swift.String, CodingKey {
      case eligibleGcsBucket = "eligibleGcsBucket"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)

      var eligibleDestinations: OneOf_EligibleDestinations? = nil
      let eligibleDestinationsCheckAndSet = {
        if eligibleDestinations != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'eligibleDestinations'"))
        }
        eligibleDestinations = $0
      }
      if let eligibleGcsBucket = try container.decodeIfPresent(
        Swift.String.self, forKey: .eligibleGcsBucket)
      {
        try eligibleDestinationsCheckAndSet(.eligibleGcsBucket(eligibleGcsBucket))
      }
      self.eligibleDestinations = eligibleDestinations
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)

      if let choice = self.eligibleDestinations {
        switch choice {
        case .eligibleGcsBucket(let value):
          try container.encode(value, forKey: .eligibleGcsBucket)
        }
      }
    }

    /// The options for the report destination location.
    public enum OneOf_EligibleDestinations: Codable, Equatable, Sendable {
      /// The Cloud Storage bucket location where the audit report and evidences
      /// can be uploaded during the `GenerateAuditReport` API call.
      case eligibleGcsBucket(Swift.String)
    }

    public static var _anyTypeUrl: Swift.String {
      return
        "type.googleapis.com/google.cloud.auditmanager.v1.EnrollResourceRequest.EligibleDestination"
    }
    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)
    }
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.auditmanager.v1.EnrollResourceRequest"
  }
  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)
  }
}
