// 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 PredictionService
  import Foundation
  import GoogleCloudWkt

  /// Response message for [PredictionService.GenerateContent].
  public struct GenerateContentResponse: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. Generated candidates.
    public var candidates: [Candidate] = []

    /// Output only. The model version used to generate the response.
    public var modelVersion: Swift.String = Swift.String()

    /// Output only. Timestamp when the request is made to the server.
    public var createTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. response_id is used to identify each response. It is the
    /// encoding of the event_id.
    public var responseId: Swift.String = Swift.String()

    /// Output only. Content filter results for a prompt sent in the request.
    /// Note: Sent only in the first stream chunk.
    /// Only happens when no candidates were generated due to content violations.
    public var promptFeedback: GenerateContentResponse.PromptFeedback? = nil

    /// Usage metadata about the response(s).
    public var usageMetadata: GenerateContentResponse.UsageMetadata? = nil

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

    /// Content filter results for a prompt sent in the request.
    public struct PromptFeedback: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. Blocked reason.
      public var blockReason: GenerateContentResponse.PromptFeedback.BlockedReason =
        GenerateContentResponse.PromptFeedback.BlockedReason()

      /// Output only. Safety ratings.
      public var safetyRatings: [SafetyRating] = []

      /// Output only. A readable block reason message.
      public var blockReasonMessage: Swift.String = Swift.String()

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

      /// Blocked reason enumeration.
      public enum BlockedReason: Codable, Equatable, Sendable {
        /// Unspecified blocked reason.
        case unspecified
        /// Candidates blocked due to safety.
        case safety
        /// Candidates blocked due to other reason.
        case other
        /// Candidates blocked due to the terms which are included from the
        /// terminology blocklist.
        case blocklist
        /// Candidates blocked due to prohibited content.
        case prohibitedContent
        /// The user prompt was blocked by Model Armor.
        case modelArmor
        /// The user prompt was blocked due to jailbreak.
        case jailbreak
        /// 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 .safety: return 1
          case .other: return 2
          case .blocklist: return 3
          case .prohibitedContent: return 4
          case .modelArmor: return 5
          case .jailbreak: return 6
          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 "BLOCKED_REASON_UNSPECIFIED"
          case .safety: return "SAFETY"
          case .other: return "OTHER"
          case .blocklist: return "BLOCKLIST"
          case .prohibitedContent: return "PROHIBITED_CONTENT"
          case .modelArmor: return "MODEL_ARMOR"
          case .jailbreak: return "JAILBREAK"
          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:BlockedReason/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "BLOCKED_REASON_UNSPECIFIED": self = .unspecified
          case "SAFETY": self = .safety
          case "OTHER": self = .other
          case "BLOCKLIST": self = .blocklist
          case "PROHIBITED_CONTENT": self = .prohibitedContent
          case "MODEL_ARMOR": self = .modelArmor
          case "JAILBREAK": self = .jailbreak
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:BlockedReason/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .safety
          case 2: self = .other
          case 3: self = .blocklist
          case 4: self = .prohibitedContent
          case 5: self = .modelArmor
          case 6: self = .jailbreak
          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 .safety: return try container.encode(1)
          case .other: return try container.encode(2)
          case .blocklist: return try container.encode(3)
          case .prohibitedContent: return try container.encode(4)
          case .modelArmor: return try container.encode(5)
          case .jailbreak: return try container.encode(6)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

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

    /// Usage metadata about response(s).
    public struct UsageMetadata: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Number of tokens in the request. When `cached_content` is set, this is
      /// still the total effective prompt size meaning this includes the number of
      /// tokens in the cached content.
      public var promptTokenCount: Swift.Int32 = Swift.Int32()

      /// Number of tokens in the response(s).
      public var candidatesTokenCount: Swift.Int32 = Swift.Int32()

      /// Output only. Number of tokens present in thoughts output.
      public var thoughtsTokenCount: Swift.Int32 = Swift.Int32()

      /// Total token count for prompt and response candidates.
      public var totalTokenCount: Swift.Int32 = Swift.Int32()

      /// Output only. Number of tokens in the cached part in the input (the cached
      /// content).
      public var cachedContentTokenCount: Swift.Int32 = Swift.Int32()

      /// Output only. List of modalities that were processed in the request input.
      public var promptTokensDetails: [ModalityTokenCount] = []

      /// Output only. List of modalities of the cached content in the request
      /// input.
      public var cacheTokensDetails: [ModalityTokenCount] = []

      /// Output only. List of modalities that were returned in the response.
      public var candidatesTokensDetails: [ModalityTokenCount] = []

      /// Output only. A detailed breakdown by modality of the token counts from
      /// the results of tool executions, which are provided back to the model as
      /// input.
      public var toolUsePromptTokensDetails: [ModalityTokenCount] = []

      /// Output only. The traffic type for this request.
      public var trafficType: GenerateContentResponse.UsageMetadata.TrafficType =
        GenerateContentResponse.UsageMetadata.TrafficType()

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

      /// The type of traffic that this request was processed with, indicating
      /// which quota is consumed.
      public enum TrafficType: Codable, Equatable, Sendable {
        /// Unspecified request traffic type.
        case unspecified
        /// The request was processed using Pay-As-You-Go quota.
        case onDemand
        /// Type for Provisioned Throughput traffic.
        case provisionedThroughput
        /// Type for Priority Pay-As-You-Go traffic.
        case onDemandPriority
        /// Type for Flex traffic.
        case onDemandFlex
        /// 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 .onDemand: return 1
          case .provisionedThroughput: return 2
          case .onDemandPriority: return 3
          case .onDemandFlex: 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 "TRAFFIC_TYPE_UNSPECIFIED"
          case .onDemand: return "ON_DEMAND"
          case .provisionedThroughput: return "PROVISIONED_THROUGHPUT"
          case .onDemandPriority: return "ON_DEMAND_PRIORITY"
          case .onDemandFlex: return "ON_DEMAND_FLEX"
          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:TrafficType/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "TRAFFIC_TYPE_UNSPECIFIED": self = .unspecified
          case "ON_DEMAND": self = .onDemand
          case "ON_DEMAND_PRIORITY": self = .onDemandPriority
          case "ON_DEMAND_FLEX": self = .onDemandFlex
          case "PROVISIONED_THROUGHPUT": self = .provisionedThroughput
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:TrafficType/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .onDemand
          case 2: self = .provisionedThroughput
          case 3: self = .onDemandPriority
          case 4: self = .onDemandFlex
          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 .onDemand: return try container.encode(1)
          case .provisionedThroughput: return try container.encode(2)
          case .onDemandPriority: return try container.encode(3)
          case .onDemandFlex: return try container.encode(4)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

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