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

  /// The configuration for auto rollout.
  public struct RolloutConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Steps to roll out a flow version. Steps should be sorted by percentage in
    /// ascending order.
    public var rolloutSteps: [RolloutConfig.RolloutStep] = []

    /// The conditions that are used to evaluate the success of a rollout
    /// step. If not specified, all rollout steps will proceed to the next one
    /// unless failure conditions are met. E.g. "containment_rate > 60% AND
    /// callback_rate < 20%". See the [conditions
    /// reference](https://cloud.google.com/dialogflow/cx/docs/reference/condition).
    public var rolloutCondition: Swift.String = Swift.String()

    /// The conditions that are used to evaluate the failure of a rollout
    /// step. If not specified, no rollout steps will fail. E.g. "containment_rate
    /// < 10% OR average_turn_count < 3". See the [conditions
    /// reference](https://cloud.google.com/dialogflow/cx/docs/reference/condition).
    public var failureCondition: Swift.String = Swift.String()

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

    /// A single rollout step with specified traffic allocation.
    public struct RolloutStep: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The name of the rollout step;
      public var displayName: Swift.String = Swift.String()

      /// The percentage of traffic allocated to the flow version of this rollout
      /// step. (0%, 100%].
      public var trafficPercent: Swift.Int32 = Swift.Int32()

      /// The minimum time that this step should last. Should be longer than 1
      /// hour. If not set, the default minimum duration for each step will be 1
      /// hour.
      public var minDuration: GoogleCloudWkt.Duration? = nil

      /// Initialize a new instance of `RolloutStep`.
      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 = RolloutStep().with { $0.displayName = ... }
      /// ```
      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.dialogflow.cx.v3.RolloutConfig.RolloutStep"
      }
      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.dialogflow.cx.v3.RolloutConfig"
    }
    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
