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

/// Message describing the dataset configuration properties. For more
/// information, see [Dataset configuration
/// properties](https://cloud.google.com/storage/docs/insights/datasets#dataset-config).
public struct DatasetConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Identifier. name of resource
  public var name: Swift.String = Swift.String()

  /// Output only. The UTC time at which the dataset configuration was created.
  /// This is auto-populated.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The UTC time at which the dataset configuration was last
  /// updated. This is auto-populated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Labels as key value pairs
  public var labels: [Swift.String: Swift.String] = [:]

  /// Output only. System generated unique identifier for the resource.
  public var uid: Swift.String = Swift.String()

  /// Optional. Organization resource ID that the source projects should belong
  /// to. Projects that do not belong to the provided organization are not
  /// considered when creating the dataset.
  public var organizationNumber: Swift.Int64 = Swift.Int64()

  /// If set to `true`, the request includes all the newly created buckets in the
  /// dataset that meet the inclusion and exclusion rules.
  public var includeNewlyCreatedBuckets: Swift.Bool = Swift.Bool()

  /// Optional. If set to `false`, then all the permission checks must be
  /// successful before the system can start ingesting data. This field can only
  /// be updated before the system ingests data for the first time. Any attempt
  /// to modify the field after data ingestion starts results in an error.
  @available(*, deprecated)
  public var skipVerificationAndIngest: Swift.Bool = Swift.Bool()

  /// Number of days of history that must be retained.
  public var retentionPeriodDays: Swift.Int32 = Swift.Int32()

  /// Details of the linked dataset.
  public var link: DatasetConfig.Link? = nil

  /// Identity used by this `datasetConfig`.
  public var identity: Identity? = nil

  /// Output only. Status of the `datasetConfig`.
  public var status: GoogleRpc.Status? = nil

  /// Output only. State of the `datasetConfig`.
  public var datasetConfigState: DatasetConfig.ConfigState = DatasetConfig.ConfigState()

  /// Optional. A user-provided description for the dataset configuration.
  ///
  /// Maximum length: 256 characters.
  public var description: Swift.String = Swift.String()

  /// Defines the options for providing source identifiers for the dataset.
  public var sourceOptions: OneOf_SourceOptions? = nil

  /// Cloud Storage locations to include or exclude.
  public var cloudStorageLocations: OneOf_CloudStorageLocations? = nil

  /// Cloud Storage buckets to include or exclude.
  public var cloudStorageBuckets: OneOf_CloudStorageBuckets? = nil

  /// Initialize a new instance of `DatasetConfig`.
  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 = DatasetConfig().with { $0.name = ... }
  /// ```
  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 name = "name"
    case createTime = "createTime"
    case updateTime = "updateTime"
    case labels = "labels"
    case uid = "uid"
    case organizationNumber = "organizationNumber"
    case sourceProjects = "sourceProjects"
    case sourceFolders = "sourceFolders"
    case organizationScope = "organizationScope"
    case cloudStorageObjectPath = "cloudStorageObjectPath"
    case includeCloudStorageLocations = "includeCloudStorageLocations"
    case excludeCloudStorageLocations = "excludeCloudStorageLocations"
    case includeCloudStorageBuckets = "includeCloudStorageBuckets"
    case excludeCloudStorageBuckets = "excludeCloudStorageBuckets"
    case includeNewlyCreatedBuckets = "includeNewlyCreatedBuckets"
    case skipVerificationAndIngest = "skipVerificationAndIngest"
    case retentionPeriodDays = "retentionPeriodDays"
    case link = "link"
    case identity = "identity"
    case status = "status"
    case datasetConfigState = "datasetConfigState"
    case description = "description"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.name = try container.decode(Swift.String.self, forKey: .name)
    self.createTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .createTime)
    self.updateTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .updateTime)
    self.labels = try container.decode([Swift.String: Swift.String].self, forKey: .labels)
    self.uid = try container.decode(Swift.String.self, forKey: .uid)
    self.organizationNumber = try container.decode(Swift.Int64.self, forKey: .organizationNumber)
    self.includeNewlyCreatedBuckets = try container.decode(
      Swift.Bool.self, forKey: .includeNewlyCreatedBuckets)
    self.skipVerificationAndIngest = try container.decode(
      Swift.Bool.self, forKey: .skipVerificationAndIngest)
    self.retentionPeriodDays = try container.decode(Swift.Int32.self, forKey: .retentionPeriodDays)
    self.link = try container.decodeIfPresent(DatasetConfig.Link.self, forKey: .link)
    self.identity = try container.decodeIfPresent(Identity.self, forKey: .identity)
    self.status = try container.decodeIfPresent(GoogleRpc.Status.self, forKey: .status)
    self.datasetConfigState = try container.decode(
      DatasetConfig.ConfigState.self, forKey: .datasetConfigState)
    self.description = try container.decode(Swift.String.self, forKey: .description)

    var sourceOptions: OneOf_SourceOptions? = nil
    let sourceOptionsCheckAndSet = {
      if sourceOptions != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'sourceOptions'"))
      }
      sourceOptions = $0
    }
    if let sourceProjects = try container.decodeIfPresent(
      DatasetConfig.SourceProjects?.self, forKey: .sourceProjects)
    {
      try sourceOptionsCheckAndSet(.sourceProjects(sourceProjects))
    }
    if let sourceFolders = try container.decodeIfPresent(
      DatasetConfig.SourceFolders?.self, forKey: .sourceFolders)
    {
      try sourceOptionsCheckAndSet(.sourceFolders(sourceFolders))
    }
    if let organizationScope = try container.decodeIfPresent(
      Swift.Bool.self, forKey: .organizationScope)
    {
      try sourceOptionsCheckAndSet(.organizationScope(organizationScope))
    }
    if let cloudStorageObjectPath = try container.decodeIfPresent(
      Swift.String.self, forKey: .cloudStorageObjectPath)
    {
      try sourceOptionsCheckAndSet(.cloudStorageObjectPath(cloudStorageObjectPath))
    }
    self.sourceOptions = sourceOptions

    var cloudStorageLocations: OneOf_CloudStorageLocations? = nil
    let cloudStorageLocationsCheckAndSet = {
      if cloudStorageLocations != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'cloudStorageLocations'"))
      }
      cloudStorageLocations = $0
    }
    if let includeCloudStorageLocations = try container.decodeIfPresent(
      DatasetConfig.CloudStorageLocations?.self, forKey: .includeCloudStorageLocations)
    {
      try cloudStorageLocationsCheckAndSet(
        .includeCloudStorageLocations(includeCloudStorageLocations))
    }
    if let excludeCloudStorageLocations = try container.decodeIfPresent(
      DatasetConfig.CloudStorageLocations?.self, forKey: .excludeCloudStorageLocations)
    {
      try cloudStorageLocationsCheckAndSet(
        .excludeCloudStorageLocations(excludeCloudStorageLocations))
    }
    self.cloudStorageLocations = cloudStorageLocations

    var cloudStorageBuckets: OneOf_CloudStorageBuckets? = nil
    let cloudStorageBucketsCheckAndSet = {
      if cloudStorageBuckets != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'cloudStorageBuckets'"))
      }
      cloudStorageBuckets = $0
    }
    if let includeCloudStorageBuckets = try container.decodeIfPresent(
      DatasetConfig.CloudStorageBuckets?.self, forKey: .includeCloudStorageBuckets)
    {
      try cloudStorageBucketsCheckAndSet(.includeCloudStorageBuckets(includeCloudStorageBuckets))
    }
    if let excludeCloudStorageBuckets = try container.decodeIfPresent(
      DatasetConfig.CloudStorageBuckets?.self, forKey: .excludeCloudStorageBuckets)
    {
      try cloudStorageBucketsCheckAndSet(.excludeCloudStorageBuckets(excludeCloudStorageBuckets))
    }
    self.cloudStorageBuckets = cloudStorageBuckets
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.name, forKey: .name)
    try container.encode(self.createTime, forKey: .createTime)
    try container.encode(self.updateTime, forKey: .updateTime)
    try container.encode(self.labels, forKey: .labels)
    try container.encode(self.uid, forKey: .uid)
    try container.encode(self.organizationNumber, forKey: .organizationNumber)
    try container.encode(self.includeNewlyCreatedBuckets, forKey: .includeNewlyCreatedBuckets)
    try container.encode(self.skipVerificationAndIngest, forKey: .skipVerificationAndIngest)
    try container.encode(self.retentionPeriodDays, forKey: .retentionPeriodDays)
    try container.encode(self.link, forKey: .link)
    try container.encode(self.identity, forKey: .identity)
    try container.encode(self.status, forKey: .status)
    try container.encode(self.datasetConfigState, forKey: .datasetConfigState)
    try container.encode(self.description, forKey: .description)

    if let choice = self.sourceOptions {
      switch choice {
      case .sourceProjects(let value):
        try container.encode(value, forKey: .sourceProjects)
      case .sourceFolders(let value):
        try container.encode(value, forKey: .sourceFolders)
      case .organizationScope(let value):
        try container.encode(value, forKey: .organizationScope)
      case .cloudStorageObjectPath(let value):
        try container.encode(value, forKey: .cloudStorageObjectPath)
      }
    }

    if let choice = self.cloudStorageLocations {
      switch choice {
      case .includeCloudStorageLocations(let value):
        try container.encode(value, forKey: .includeCloudStorageLocations)
      case .excludeCloudStorageLocations(let value):
        try container.encode(value, forKey: .excludeCloudStorageLocations)
      }
    }

    if let choice = self.cloudStorageBuckets {
      switch choice {
      case .includeCloudStorageBuckets(let value):
        try container.encode(value, forKey: .includeCloudStorageBuckets)
      case .excludeCloudStorageBuckets(let value):
        try container.encode(value, forKey: .excludeCloudStorageBuckets)
      }
    }
  }

  /// Collection of project numbers
  public struct SourceProjects: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    public var projectNumbers: [Swift.Int64] = []

    /// Initialize a new instance of `SourceProjects`.
    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 = SourceProjects().with { $0.projectNumbers = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.SourceProjects"
    }
    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)
    }
  }

  /// Specifies a set of folders to include in the dataset
  public struct SourceFolders: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. The list of folder numbers to include in the dataset.
    public var folderNumbers: [Swift.Int64] = []

    /// Initialize a new instance of `SourceFolders`.
    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 = SourceFolders().with { $0.folderNumbers = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.SourceFolders"
    }
    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)
    }
  }

  /// Collection of Cloud Storage locations.
  public struct CloudStorageLocations: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    public var locations: [Swift.String] = []

    /// Initialize a new instance of `CloudStorageLocations`.
    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 = CloudStorageLocations().with { $0.locations = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.CloudStorageLocations"
    }
    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)
    }
  }

  /// Collection of Cloud Storage buckets.
  public struct CloudStorageBuckets: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    public var cloudStorageBuckets: [DatasetConfig.CloudStorageBuckets.CloudStorageBucket] = []

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

    /// Defines the bucket by its name or a regex pattern to match buckets.
    public struct CloudStorageBucket: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      public var cloudStorageBucket: OneOf_CloudStorageBucket? = nil

      /// Initialize a new instance of `CloudStorageBucket`.
      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 = CloudStorageBucket().with { $0.bucketName = ... }
      /// ```
      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 bucketName = "bucketName"
        case bucketPrefixRegex = "bucketPrefixRegex"
      }

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

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

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

        if let choice = self.cloudStorageBucket {
          switch choice {
          case .bucketName(let value):
            try container.encode(value, forKey: .bucketName)
          case .bucketPrefixRegex(let value):
            try container.encode(value, forKey: .bucketPrefixRegex)
          }
        }
      }

      public enum OneOf_CloudStorageBucket: Codable, Equatable, Sendable {
        /// Cloud Storage bucket name.
        case bucketName(Swift.String)
        /// A regex pattern for bucket names matching the regex. Regex should
        /// follow the syntax specified in `google/re2` on GitHub.
        case bucketPrefixRegex(Swift.String)
      }

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

  /// Defines the details about the linked dataset.
  public struct Link: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. Dataset name for linked dataset.
    public var dataset: Swift.String = Swift.String()

    /// Output only. State of the linked dataset.
    public var linked: Swift.Bool = Swift.Bool()

    /// Initialize a new instance of `Link`.
    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 = Link().with { $0.dataset = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.Link"
    }
    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)
    }
  }

  /// Provides a summary of the bucket level error statistics.
  public struct BucketErrors: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Count of successfully validated buckets.
    public var validatedCount: Swift.Int64 = Swift.Int64()

    /// Optional. Count of buckets with permission denied errors.
    public var permissionDeniedCount: Swift.Int64 = Swift.Int64()

    /// Optional. Subset of bucket names that have permission denied.
    public var permissionDeniedBucketIds: [Swift.String] = []

    /// Optional. Count of buckets that are not subscribed to Storage
    /// Intelligence.
    @available(*, deprecated)
    public var nonManagementHubEntitledCount: Swift.Int64 = Swift.Int64()

    /// Optional. Number of buckets that encountered internal errors during the
    /// validation process. These buckets are automatically retried in subsequent
    /// validation attempts.
    public var internalErrorCount: Swift.Int64 = Swift.Int64()

    /// Optional. Count of buckets that are not subscribed to Storage
    /// Intelligence.
    public var nonStorageIntelligenceEntitledCount: Swift.Int64 = Swift.Int64()

    /// Optional. Subset of bucket names that are not subscribed to Storage
    /// Intelligence.
    public var nonStorageIntelligenceEntitledBucketIds: [Swift.String] = []

    /// Initialize a new instance of `BucketErrors`.
    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 = BucketErrors().with { $0.validatedCount = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.BucketErrors"
    }
    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)
    }
  }

  /// Provides a summary of the project level error statistics.
  public struct ProjectErrors: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Count of successfully validated projects.
    public var validatedCount: Swift.Int64? = nil

    /// Optional. Count of projects which are not in the same organization.
    public var outsideOrgErrorCount: Swift.Int64? = nil

    /// Optional. Subset of project numbers which are not in the same
    /// organization.
    public var outsideOrgProjectNumbers: [Swift.Int64] = []

    /// Optional. Count of projects that are not subscribed to Storage
    /// Intelligence.
    @available(*, deprecated)
    public var nonManagementHubEntitledErrorCount: Swift.Int64? = nil

    /// Optional. Subset of project numbers that are not subscribed to Storage
    /// Intelligence.
    @available(*, deprecated)
    public var nonManagementHubEntitledProjectNumbers: [Swift.Int64] = []

    /// Optional. Count of projects that are not subscribed to Storage
    /// Intelligence.
    public var nonStorageIntelligenceEntitledErrorCount: Swift.Int64? = nil

    /// Optional. Subset of project numbers that are not subscribed to Storage
    /// Intelligence.
    public var nonStorageIntelligenceEntitledProjectNumbers: [Swift.Int64] = []

    /// Optional. Number of projects that encountered internal errors during
    /// validation and are automatically retried.
    public var internalErrorCount: Swift.Int64? = nil

    /// The destination project check result. It indicates whether the project
    /// is in the correct organization or if an internal error occurred during
    /// the check.
    public var destinationProjectCheckResult: OneOf_DestinationProjectCheckResult? = nil

    /// Initialize a new instance of `ProjectErrors`.
    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 = ProjectErrors().with { $0.validatedCount = ... }
    /// ```
    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 validatedCount = "validatedCount"
      case outsideOrgErrorCount = "outsideOrgErrorCount"
      case outsideOrgProjectNumbers = "outsideOrgProjectNumbers"
      case nonManagementHubEntitledErrorCount = "nonManagementHubEntitledErrorCount"
      case nonManagementHubEntitledProjectNumbers = "nonManagementHubEntitledProjectNumbers"
      case nonStorageIntelligenceEntitledErrorCount = "nonStorageIntelligenceEntitledErrorCount"
      case nonStorageIntelligenceEntitledProjectNumbers =
        "nonStorageIntelligenceEntitledProjectNumbers"
      case internalErrorCount = "internalErrorCount"
      case destinationProjectOrgError = "destinationProjectOrgError"
      case destinationProjectCheckHasInternalError = "destinationProjectCheckHasInternalError"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.validatedCount = try container.decodeIfPresent(Swift.Int64.self, forKey: .validatedCount)
      self.outsideOrgErrorCount = try container.decodeIfPresent(
        Swift.Int64.self, forKey: .outsideOrgErrorCount)
      self.outsideOrgProjectNumbers = try container.decode(
        [Swift.Int64].self, forKey: .outsideOrgProjectNumbers)
      self.nonManagementHubEntitledErrorCount = try container.decodeIfPresent(
        Swift.Int64.self, forKey: .nonManagementHubEntitledErrorCount)
      self.nonManagementHubEntitledProjectNumbers = try container.decode(
        [Swift.Int64].self, forKey: .nonManagementHubEntitledProjectNumbers)
      self.nonStorageIntelligenceEntitledErrorCount = try container.decodeIfPresent(
        Swift.Int64.self, forKey: .nonStorageIntelligenceEntitledErrorCount)
      self.nonStorageIntelligenceEntitledProjectNumbers = try container.decode(
        [Swift.Int64].self, forKey: .nonStorageIntelligenceEntitledProjectNumbers)
      self.internalErrorCount = try container.decodeIfPresent(
        Swift.Int64.self, forKey: .internalErrorCount)

      var destinationProjectCheckResult: OneOf_DestinationProjectCheckResult? = nil
      let destinationProjectCheckResultCheckAndSet = {
        if destinationProjectCheckResult != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'destinationProjectCheckResult'"))
        }
        destinationProjectCheckResult = $0
      }
      if let destinationProjectOrgError = try container.decodeIfPresent(
        Swift.Bool.self, forKey: .destinationProjectOrgError)
      {
        try destinationProjectCheckResultCheckAndSet(
          .destinationProjectOrgError(destinationProjectOrgError))
      }
      if let destinationProjectCheckHasInternalError = try container.decodeIfPresent(
        Swift.Bool.self, forKey: .destinationProjectCheckHasInternalError)
      {
        try destinationProjectCheckResultCheckAndSet(
          .destinationProjectCheckHasInternalError(destinationProjectCheckHasInternalError))
      }
      self.destinationProjectCheckResult = destinationProjectCheckResult
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.validatedCount, forKey: .validatedCount)
      try container.encode(self.outsideOrgErrorCount, forKey: .outsideOrgErrorCount)
      try container.encode(self.outsideOrgProjectNumbers, forKey: .outsideOrgProjectNumbers)
      try container.encode(
        self.nonManagementHubEntitledErrorCount, forKey: .nonManagementHubEntitledErrorCount)
      try container.encode(
        self.nonManagementHubEntitledProjectNumbers, forKey: .nonManagementHubEntitledProjectNumbers
      )
      try container.encode(
        self.nonStorageIntelligenceEntitledErrorCount,
        forKey: .nonStorageIntelligenceEntitledErrorCount)
      try container.encode(
        self.nonStorageIntelligenceEntitledProjectNumbers,
        forKey: .nonStorageIntelligenceEntitledProjectNumbers)
      try container.encode(self.internalErrorCount, forKey: .internalErrorCount)

      if let choice = self.destinationProjectCheckResult {
        switch choice {
        case .destinationProjectOrgError(let value):
          try container.encode(value, forKey: .destinationProjectOrgError)
        case .destinationProjectCheckHasInternalError(let value):
          try container.encode(value, forKey: .destinationProjectCheckHasInternalError)
        }
      }
    }

    /// The destination project check result. It indicates whether the project
    /// is in the correct organization or if an internal error occurred during
    /// the check.
    public enum OneOf_DestinationProjectCheckResult: Codable, Equatable, Sendable {
      /// Optional. Indicates if the destination project resides within the same
      /// organization as the source project.
      case destinationProjectOrgError(Swift.Bool)
      /// Optional. Indicates whether the destination project check failed due to
      /// an internal error. If `true`, the system automatically retries the
      /// check.
      case destinationProjectCheckHasInternalError(Swift.Bool)
    }

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

  /// Summary of validation errors that occurred during the verification phase.
  public struct ValidationErrorsBeforeIngestion: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Provides a summary of the bucket level error stats.
    public var bucketErrors: DatasetConfig.BucketErrors? = nil

    /// Optional. Provides a summary of the project level error stats.
    public var projectErrors: DatasetConfig.ProjectErrors? = nil

    /// Initialize a new instance of `ValidationErrorsBeforeIngestion`.
    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 = ValidationErrorsBeforeIngestion().with { $0.bucketErrors = ... }
    /// ```
    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.storageinsights.v1.DatasetConfig.ValidationErrorsBeforeIngestion"
    }
    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)
    }
  }

  /// State of the configuration.
  public enum ConfigState: Codable, Equatable, Sendable {
    /// Unspecified state.
    case unspecified
    /// Active configuration indicates that the configuration is
    /// actively ingesting data.
    case active
    /// In this state, the configuration is being verified for various
    /// permissions.
    case verificationInProgress
    /// Configuration is created and further processing needs to happen.
    case created
    /// Configuration is under processing
    case processing
    /// Encodes an unknown integer value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownIntValue(Int)
    /// Encodes an unknown string value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownStringValue(String)

    public init() {
      self = .unspecified
    }

    /// Returns the integer value associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown string value, this returns `nil`.
    public var intValue: Int? {
      switch self {
      case .unspecified: return 0
      case .active: return 1
      case .verificationInProgress: return 2
      case .created: return 3
      case .processing: return 4
      case .unknownIntValue(let v): return v
      case .unknownStringValue: return nil
      }
    }

    /// Returns the string value (or name) associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
    public var stringValue: Swift.String? {
      switch self {
      case .unspecified: return "CONFIG_STATE_UNSPECIFIED"
      case .active: return "CONFIG_STATE_ACTIVE"
      case .verificationInProgress: return "CONFIG_STATE_VERIFICATION_IN_PROGRESS"
      case .created: return "CONFIG_STATE_CREATED"
      case .processing: return "CONFIG_STATE_PROCESSING"
      case .unknownIntValue: return nil
      case .unknownStringValue(let v): return v
      }
    }

    /// Initialize from a string value.
    ///
    /// If the value is unknown, this initializes to [`unknownStringValue`](doc:ConfigState/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "CONFIG_STATE_UNSPECIFIED": self = .unspecified
      case "CONFIG_STATE_ACTIVE": self = .active
      case "CONFIG_STATE_VERIFICATION_IN_PROGRESS": self = .verificationInProgress
      case "CONFIG_STATE_CREATED": self = .created
      case "CONFIG_STATE_PROCESSING": self = .processing
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:ConfigState/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .active
      case 2: self = .verificationInProgress
      case 3: self = .created
      case 4: self = .processing
      default: self = .unknownIntValue(intValue)
      }
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.singleValueContainer()
      if let v = try? container.decode(Int.self) {
        self.init(intValue: v)
        return
      }
      if let s = try? container.decode(String.self) {
        if let v = Int(s) {
          self.init(intValue: v)
        } else {
          self.init(stringValue: s)
        }
        return
      }
      throw DecodingError.dataCorruptedError(
        in: container, debugDescription: "Expected enum value, must be integer or string.")
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.singleValueContainer()
      switch self {
      case .unspecified: return try container.encode(0)
      case .active: return try container.encode(1)
      case .verificationInProgress: return try container.encode(2)
      case .created: return try container.encode(3)
      case .processing: return try container.encode(4)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  /// Defines the options for providing source identifiers for the dataset.
  public enum OneOf_SourceOptions: Codable, Equatable, Sendable {
    /// Defines the options for providing source projects for the dataset.
    indirect case sourceProjects(DatasetConfig.SourceProjects?)
    /// Defines the options for providing source folders for the dataset.
    indirect case sourceFolders(DatasetConfig.SourceFolders?)
    /// Defines the options for providing a source organization for the dataset.
    case organizationScope(Swift.Bool)
    /// Input only. Cloud Storage object path containing a list of
    /// project or folder numbers to include in the dataset;
    /// it cannot contain a mix of project and folders.
    ///
    /// The object must be a text file where each line has one of the following
    /// entries:
    ///
    /// - Project number, formatted as `projects/{project_number}`, for example,
    /// `projects/1234567890`.
    /// - Folder identifier, formatted as `folders/{folder_number}`, for example,
    /// `folders/9876543210`.
    /// Path must be in the format `gs://{bucket_name}/{object_name}`.
    case cloudStorageObjectPath(Swift.String)
  }

  /// Cloud Storage locations to include or exclude.
  public enum OneOf_CloudStorageLocations: Codable, Equatable, Sendable {
    indirect case includeCloudStorageLocations(DatasetConfig.CloudStorageLocations?)
    indirect case excludeCloudStorageLocations(DatasetConfig.CloudStorageLocations?)
  }

  /// Cloud Storage buckets to include or exclude.
  public enum OneOf_CloudStorageBuckets: Codable, Equatable, Sendable {
    indirect case includeCloudStorageBuckets(DatasetConfig.CloudStorageBuckets?)
    indirect case excludeCloudStorageBuckets(DatasetConfig.CloudStorageBuckets?)
  }

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