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

/// A data product is a curated collection of data assets, packaged to address
/// specific use cases. It's a way to manage and share data in a more organized,
/// product-like manner.
public struct DataProduct: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Identifier. Resource name of the data product.
  /// Format:
  /// `projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}`.
  public var name: Swift.String = Swift.String()

  /// Output only. System generated unique ID for the data product.
  /// This ID will be different if the data product is deleted and re-created
  /// with the same name.
  public var uid: Swift.String = Swift.String()

  /// Required. User-friendly display name of the data product.
  public var displayName: Swift.String = Swift.String()

  /// Output only. The time at which the data product was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time at which the data product was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Optional. This checksum is computed by the server based on the value of
  /// other fields, and may be sent on update and delete requests to ensure the
  /// client has an up-to-date value before proceeding.
  public var etag: Swift.String = Swift.String()

  /// Optional. User-defined labels for the data product.
  ///
  /// Example:
  ///  ```
  ///  {
  ///    "environment": "production",
  ///    "billing": "marketing-department"
  ///  }
  ///  ```
  public var labels: [Swift.String: Swift.String] = [:]

  /// Optional. Description of the data product.
  public var description: Swift.String = Swift.String()

  /// Optional. Base64 encoded image representing the data product. Max
  /// Size: 3.0MiB Expected image dimensions are 512x512 pixels, however the API
  /// only performs validation on size of the encoded data. Note: For byte
  /// fields, the content of the fields are base64-encoded (which increases the
  /// size of the data by 33-36%) when using JSON on the wire.
  public var icon: Foundation.Data = Foundation.Data()

  /// Required. Emails of the data product owners.
  public var ownerEmails: [Swift.String] = []

  /// Output only. Number of data assets associated with this data product.
  public var assetCount: Swift.Int32 = Swift.Int32()

  /// Optional. Data product access groups by access group id as key.
  /// If data product is used only for packaging data assets, then access groups
  /// may be empty. However, if a data product is used for sharing data assets,
  /// then at least one access group must be specified.
  ///
  /// Example:
  ///  ```
  ///  {
  ///    "analyst": {
  ///      "id": "analyst",
  ///      "displayName": "Analyst",
  ///      "description": "Access group for analysts",
  ///      "principal": {
  ///        "googleGroup": "analysts@example.com"
  ///      }
  ///    }
  ///  }
  ///  ```
  public var accessGroups: [Swift.String: DataProduct.AccessGroup] = [:]

  /// Optional. Configuration for access approval for the data product.
  public var accessApprovalConfig: DataProduct.AccessApprovalConfig? = nil

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

  /// Represents the principal entity associated with an access group, as per
  /// https://cloud.google.com/iam/docs/principals-overview.
  public struct Principal: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Specifies the email of the producer service account, as per
    /// https://cloud.google.com/iam/docs/principals-overview#service-account.
    public var serviceAccount: Swift.String? = nil

    /// The type of the principal entity.
    public var type: OneOf_Type_? = nil

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

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.serviceAccount = try container.decodeIfPresent(
        Swift.String.self, forKey: .serviceAccount)

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

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

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

    /// The type of the principal entity.
    public enum OneOf_Type_: Codable, Equatable, Sendable {
      /// Optional. Email of the Google Group, as per
      /// https://cloud.google.com/iam/docs/principals-overview#google-group.
      case googleGroup(Swift.String)
    }

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

  /// Custom user defined access groups at the data product level. These are used
  /// for granting different levels of access (IAM roles) on the individual data
  /// product's data assets.
  public struct AccessGroup: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Unique identifier of the access group within the data product.
    /// User defined. Eg. "analyst", "developer", etc.
    public var id: Swift.String = Swift.String()

    /// Required. User friendly display name of the access group.
    /// Eg. "Analyst", "Developer", etc.
    public var displayName: Swift.String = Swift.String()

    /// Optional. Description of the access group.
    public var description: Swift.String = Swift.String()

    /// Required. The principal entity associated with this access group.
    public var principal: DataProduct.Principal? = nil

    /// Initialize a new instance of `AccessGroup`.
    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 = AccessGroup().with { $0.id = ... }
    /// ```
    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.dataplex.v1.DataProduct.AccessGroup"
    }
    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)
    }
  }

  /// Configuration for access approval for the data product.
  public struct AccessApprovalConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Specifies the email addresses of users who are potential
    /// approvers and are notified when an access request is made for the data
    /// product. The maximum number of emails allowed is 10.
    public var approverEmails: [Swift.String] = []

    /// Initialize a new instance of `AccessApprovalConfig`.
    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 = AccessApprovalConfig().with { $0.approverEmails = ... }
    /// ```
    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.dataplex.v1.DataProduct.AccessApprovalConfig"
    }
    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.dataplex.v1.DataProduct"
  }
  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)
  }
}
