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

#if VertexRagDataService
  import Foundation
  import GoogleCloudWkt

  /// The SharePointSources to pass to ImportRagFiles.
  public struct SharePointSources: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The SharePoint sources.
    public var sharePointSources: [SharePointSources.SharePointSource] = []

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

    /// An individual SharePointSource.
    public struct SharePointSource: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The Application ID for the app registered in Microsoft Azure Portal.
      /// The application must also be configured with MS Graph permissions
      /// "Files.ReadAll", "Sites.ReadAll" and BrowserSiteLists.Read.All.
      public var clientId: Swift.String = Swift.String()

      /// The application secret for the app registered in Azure.
      public var clientSecret: ApiAuth.ApiKeyConfig? = nil

      /// Unique identifier of the Azure Active Directory Instance.
      public var tenantId: Swift.String = Swift.String()

      /// The name of the SharePoint site to download from. This can be the site
      /// name or the site id.
      public var sharepointSiteName: Swift.String = Swift.String()

      /// Output only. The SharePoint file id. Output only.
      public var fileId: Swift.String = Swift.String()

      /// The SharePoint folder source. If not provided, uses "root".
      public var folderSource: OneOf_FolderSource? = nil

      /// The SharePoint drive source.
      public var driveSource: OneOf_DriveSource? = nil

      /// Initialize a new instance of `SharePointSource`.
      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 = SharePointSource().with { $0.sharepointFolderPath = ... }
      /// ```
      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 sharepointFolderPath = "sharepointFolderPath"
        case sharepointFolderId = "sharepointFolderId"
        case driveName = "driveName"
        case driveId = "driveId"
        case clientId = "clientId"
        case clientSecret = "clientSecret"
        case tenantId = "tenantId"
        case sharepointSiteName = "sharepointSiteName"
        case fileId = "fileId"
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.clientId = try container.decode(Swift.String.self, forKey: .clientId)
        self.clientSecret = try container.decodeIfPresent(
          ApiAuth.ApiKeyConfig.self, forKey: .clientSecret)
        self.tenantId = try container.decode(Swift.String.self, forKey: .tenantId)
        self.sharepointSiteName = try container.decode(
          Swift.String.self, forKey: .sharepointSiteName)
        self.fileId = try container.decode(Swift.String.self, forKey: .fileId)

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

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

      public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(self.clientId, forKey: .clientId)
        try container.encode(self.clientSecret, forKey: .clientSecret)
        try container.encode(self.tenantId, forKey: .tenantId)
        try container.encode(self.sharepointSiteName, forKey: .sharepointSiteName)
        try container.encode(self.fileId, forKey: .fileId)

        if let choice = self.folderSource {
          switch choice {
          case .sharepointFolderPath(let value):
            try container.encode(value, forKey: .sharepointFolderPath)
          case .sharepointFolderId(let value):
            try container.encode(value, forKey: .sharepointFolderId)
          }
        }

        if let choice = self.driveSource {
          switch choice {
          case .driveName(let value):
            try container.encode(value, forKey: .driveName)
          case .driveId(let value):
            try container.encode(value, forKey: .driveId)
          }
        }
      }

      /// The SharePoint folder source. If not provided, uses "root".
      public enum OneOf_FolderSource: Codable, Equatable, Sendable {
        /// The path of the SharePoint folder to download from.
        case sharepointFolderPath(Swift.String)
        /// The ID of the SharePoint folder to download from.
        case sharepointFolderId(Swift.String)
      }

      /// The SharePoint drive source.
      public enum OneOf_DriveSource: Codable, Equatable, Sendable {
        /// The name of the drive to download from.
        case driveName(Swift.String)
        /// The ID of the drive to download from.
        case driveId(Swift.String)
      }

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