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

/// Wrapper containing Entry and information about Tags
/// that should and should not be attached to it.
public struct TaggedEntry: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Optional. Tags that should be ingested into the Data Catalog.
  /// Caller should populate template name, column and fields.
  public var presentTags: [Tag] = []

  /// Optional. Tags that should be deleted from the Data Catalog.
  /// Caller should populate template name and column only.
  public var absentTags: [Tag] = []

  /// Required. Entry to be ingested.
  public var entry: OneOf_Entry? = nil

  /// Initialize a new instance of `TaggedEntry`.
  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 = TaggedEntry().with { $0.v1Entry = ... }
  /// ```
  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 v1Entry = "v1Entry"
    case presentTags = "presentTags"
    case absentTags = "absentTags"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.presentTags = try container.decode([Tag].self, forKey: .presentTags)
    self.absentTags = try container.decode([Tag].self, forKey: .absentTags)

    var entry: OneOf_Entry? = nil
    let entryCheckAndSet = {
      if entry != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'entry'"))
      }
      entry = $0
    }
    if let v1Entry = try container.decodeIfPresent(Entry?.self, forKey: .v1Entry) {
      try entryCheckAndSet(.v1Entry(v1Entry))
    }
    self.entry = entry
  }

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

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

  /// Required. Entry to be ingested.
  public enum OneOf_Entry: Codable, Equatable, Sendable {
    /// Non-encrypted Data Catalog v1 Entry.
    indirect case v1Entry(Entry?)
  }

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