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

/// An app serves as a top-level container for a group of agents, including the
/// root agent and its sub-agents, along with their associated configurations.
/// These agents work together to achieve specific goals within the app's
/// context.
public struct App: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Identifier. The unique identifier of the app.
  /// Format: `projects/{project}/locations/{location}/apps/{app}`
  public var name: Swift.String = Swift.String()

  /// Required. Display name of the app.
  public var displayName: Swift.String = Swift.String()

  /// Optional. Human-readable description of the app.
  public var description: Swift.String = Swift.String()

  /// Optional. Whether the app is pinned in the app list.
  public var pinned: Swift.Bool = Swift.Bool()

  /// Optional. The root agent is the entry point of the app.
  /// Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
  public var rootAgent: Swift.String = Swift.String()

  /// Optional. Language settings of the app.
  public var languageSettings: LanguageSettings? = nil

  /// Optional. TimeZone settings of the app.
  public var timeZoneSettings: TimeZoneSettings? = nil

  /// Optional. Audio processing configuration of the app.
  public var audioProcessingConfig: AudioProcessingConfig? = nil

  /// Optional. Logging settings of the app.
  public var loggingSettings: LoggingSettings? = nil

  /// Optional. Error handling settings of the app.
  public var errorHandlingSettings: ErrorHandlingSettings? = nil

  /// Optional. The default LLM model settings for the app.
  /// Individual resources (e.g. agents, guardrails) can override these
  /// configurations as needed.
  public var modelSettings: ModelSettings? = nil

  /// Optional. The tool execution mode for the app. If not provided, will
  /// default to PARALLEL.
  public var toolExecutionMode: App.ToolExecutionMode = App.ToolExecutionMode()

  /// Optional. The evaluation thresholds for the app.
  public var evaluationMetricsThresholds: EvaluationMetricsThresholds? = nil

  /// Optional. The declarations of the variables.
  public var variableDeclarations: [App.VariableDeclaration] = []

  /// Output only. The declarations of predefined variables for the app.
  public var predefinedVariableDeclarations: [App.VariableDeclaration] = []

  /// Optional. Instructions for all the agents in the app.
  /// You can use this instruction to set up a stable identity or personality
  /// across all the agents.
  public var globalInstruction: Swift.String = Swift.String()

  /// Optional. List of guardrails for the app.
  /// Format:
  /// `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}`
  public var guardrails: [Swift.String] = []

  /// Optional. The data store settings for the app.
  public var dataStoreSettings: DataStoreSettings? = nil

  /// Optional. The default channel profile used by the app.
  public var defaultChannelProfile: ChannelProfile? = nil

  /// Optional. Metadata about the app. This field can be used to store
  /// additional information relevant to the app's details or intended usages.
  public var metadata: [Swift.String: Swift.String] = [:]

  /// Output only. Timestamp when the app was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. Timestamp when the app was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. Etag used to ensure the object hasn't changed during a
  /// read-modify-write operation. If the etag is empty, the update will
  /// overwrite any concurrent changes.
  public var etag: Swift.String = Swift.String()

  /// Output only. Number of deployments in the app.
  public var deploymentCount: Swift.Int32 = Swift.Int32()

  /// Optional. The default client certificate settings for the app.
  public var clientCertificateSettings: ClientCertificateSettings? = nil

  /// Optional. VPC-SC settings for the app.
  public var vpcScSettings: VpcScSettings? = nil

  /// Optional. Indicates whether the app is locked for changes. If the app is
  /// locked, modifications to the app resources will be rejected.
  public var locked: Swift.Bool = Swift.Bool()

  /// Output only. Misconfigurations or warnings in the app.
  public var validationErrors: [Swift.String] = []

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

  /// Defines the structure and metadata for a variable.
  public struct VariableDeclaration: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. The name of the variable. The name must start with a letter or
    /// underscore and contain only letters, numbers, or underscores.
    public var name: Swift.String = Swift.String()

    /// Required. The description of the variable.
    public var description: Swift.String = Swift.String()

    /// Required. The schema of the variable.
    public var schema: Schema? = nil

    /// Initialize a new instance of `VariableDeclaration`.
    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 = VariableDeclaration().with { $0.name = ... }
    /// ```
    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.ces.v1.App.VariableDeclaration"
    }
    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 tool execution behavior if there are **multiple** tools being
  /// selected by the agent **at the same time**.
  public enum ToolExecutionMode: Codable, Equatable, Sendable {
    /// Unspecified tool execution mode. Default to PARALLEL.
    case unspecified
    /// If there are multiple tools being selected, they will be executed in
    /// parallel, with the same
    /// [ToolContext](https://google.github.io/adk-docs/context/#the-different-types-of-context).
    case parallel
    /// If there are multiple tools being selected, they will be executed
    /// sequentially. The next tool will only be executed after the previous tool
    /// completes and it can see updated
    /// [ToolContext](https://google.github.io/adk-docs/context/#the-different-types-of-context)
    /// from the previous tool.
    case sequential
    /// 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 .parallel: return 1
      case .sequential: return 2
      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 "TOOL_EXECUTION_MODE_UNSPECIFIED"
      case .parallel: return "PARALLEL"
      case .sequential: return "SEQUENTIAL"
      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:ToolExecutionMode/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "TOOL_EXECUTION_MODE_UNSPECIFIED": self = .unspecified
      case "PARALLEL": self = .parallel
      case "SEQUENTIAL": self = .sequential
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:ToolExecutionMode/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .parallel
      case 2: self = .sequential
      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 .parallel: return try container.encode(1)
      case .sequential: return try container.encode(2)
      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.ces.v1.App"
  }
  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)
  }
}
