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

/// The different execution states of the Audit Manager service.
public enum OperationState: Codable, Equatable, Sendable {
  /// Unspecified. Invalid state.
  case unspecified
  /// Audit report generation process has not started.
  case notStarted
  /// Audit Manager is currently evaluating the workloads against specific
  /// standard.
  case evaluationInProgress
  /// Audit Manager has completed Evaluation for the workload.
  case evaluationDone
  /// Audit Manager is creating audit report from the evaluated data.
  case evidenceReportGenerationInProgress
  /// Audit Manager has completed generation of the audit report.
  case evidenceReportGenerationDone
  /// Audit Manager is uploading the audit report and evidences to the customer
  /// provided destination.
  case evidenceUploadInProgress
  /// Audit report generation process is completed.
  case done
  /// Audit report generation process has failed.
  case failed
  /// 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 .notStarted: return 10
    case .evaluationInProgress: return 20
    case .evaluationDone: return 21
    case .evidenceReportGenerationInProgress: return 30
    case .evidenceReportGenerationDone: return 31
    case .evidenceUploadInProgress: return 40
    case .done: return 50
    case .failed: return 60
    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 "OPERATION_STATE_UNSPECIFIED"
    case .notStarted: return "OPERATION_STATE_NOT_STARTED"
    case .evaluationInProgress: return "OPERATION_STATE_EVALUATION_IN_PROGRESS"
    case .evaluationDone: return "OPERATION_STATE_EVALUATION_DONE"
    case .evidenceReportGenerationInProgress:
      return "OPERATION_STATE_EVIDENCE_REPORT_GENERATION_IN_PROGRESS"
    case .evidenceReportGenerationDone: return "OPERATION_STATE_EVIDENCE_REPORT_GENERATION_DONE"
    case .evidenceUploadInProgress: return "OPERATION_STATE_EVIDENCE_UPLOAD_IN_PROGRESS"
    case .done: return "OPERATION_STATE_DONE"
    case .failed: return "OPERATION_STATE_FAILED"
    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:OperationState/unknownStringValue(_:)).
  public init(stringValue: Swift.String) {
    switch stringValue {
    case "OPERATION_STATE_UNSPECIFIED": self = .unspecified
    case "OPERATION_STATE_NOT_STARTED": self = .notStarted
    case "OPERATION_STATE_EVALUATION_IN_PROGRESS": self = .evaluationInProgress
    case "OPERATION_STATE_EVALUATION_DONE": self = .evaluationDone
    case "OPERATION_STATE_EVIDENCE_REPORT_GENERATION_IN_PROGRESS":
      self = .evidenceReportGenerationInProgress
    case "OPERATION_STATE_EVIDENCE_REPORT_GENERATION_DONE": self = .evidenceReportGenerationDone
    case "OPERATION_STATE_EVIDENCE_UPLOAD_IN_PROGRESS": self = .evidenceUploadInProgress
    case "OPERATION_STATE_DONE": self = .done
    case "OPERATION_STATE_FAILED": self = .failed
    default: self = .unknownStringValue(stringValue)
    }
  }

  /// Initialize from an integer value.
  ///
  /// If the value is unknown, this initializes to [`unknownIntValue`](doc:OperationState/unknownIntValue(_:)).
  public init(intValue: Int) {
    switch intValue {
    case 0: self = .unspecified
    case 10: self = .notStarted
    case 20: self = .evaluationInProgress
    case 21: self = .evaluationDone
    case 30: self = .evidenceReportGenerationInProgress
    case 31: self = .evidenceReportGenerationDone
    case 40: self = .evidenceUploadInProgress
    case 50: self = .done
    case 60: self = .failed
    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 .notStarted: return try container.encode(10)
    case .evaluationInProgress: return try container.encode(20)
    case .evaluationDone: return try container.encode(21)
    case .evidenceReportGenerationInProgress: return try container.encode(30)
    case .evidenceReportGenerationDone: return try container.encode(31)
    case .evidenceUploadInProgress: return try container.encode(40)
    case .done: return try container.encode(50)
    case .failed: return try container.encode(60)
    case .unknownIntValue(let v): return try container.encode(v)
    case .unknownStringValue(let v): return try container.encode(v)
    }
  }
}
