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

/// A control.
public struct Control: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Output only. The control identifier used to fetch the findings. This is
  /// same as the control report name.
  public var id: Swift.String = Swift.String()

  /// Output only. Display name of the control.
  public var displayName: Swift.String = Swift.String()

  /// Output only. Group where the control belongs. E.g. Access Control.
  public var family: Control.Family = Control.Family()

  /// Output only. Regulatory Family of the control E.g. Access Control
  public var controlFamily: ControlFamily? = nil

  /// Output only. Regulatory control ask of the control
  public var description: Swift.String = Swift.String()

  /// Output only. The type of responsibility for implementing this control. It
  /// can be google, customer or shared.
  public var responsibilityType: Swift.String = Swift.String()

  /// Output only. Description of the google responsibility for implementing this
  /// control.
  public var googleResponsibilityDescription: Swift.String = Swift.String()

  /// Output only. Implementation of the google responsibility for implementing
  /// this control.
  public var googleResponsibilityImplementation: Swift.String = Swift.String()

  /// Output only. Description of the customer responsibility for implementing
  /// this control.
  public var customerResponsibilityDescription: Swift.String = Swift.String()

  /// Output only. Implementation of the customer responsibility for implementing
  /// this control.
  public var customerResponsibilityImplementation: Swift.String = Swift.String()

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

  /// The family of the control. For example, Access Control.
  public enum Family: Codable, Equatable, Sendable {
    /// Unspecified. Invalid state.
    case unspecified
    /// Access Control
    case ac
    /// Awareness and Training
    case at
    /// Audit and Accountability
    case au
    /// Certification, Accreditation and Security Assessments
    case ca
    /// Configuration Management
    case cm
    /// Contingency Planning
    case cp
    /// Identification and Authentication
    case ia
    /// Incident Response
    case ir
    /// Maintenance
    case ma
    /// Media Protection
    case mp
    /// Physical and Environmental Protection
    case pe
    /// Security Planning
    case pl
    /// Personnel Security
    case ps
    /// Risk Assessment
    case ra
    /// System Services and Acquisition
    case sa
    /// System and Communications Protection
    case sc
    /// System and Information Integrity
    case si
    /// Supply Chain Risk Management
    case sr
    /// 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 .ac: return 1
      case .at: return 2
      case .au: return 3
      case .ca: return 4
      case .cm: return 5
      case .cp: return 6
      case .ia: return 7
      case .ir: return 8
      case .ma: return 9
      case .mp: return 10
      case .pe: return 11
      case .pl: return 12
      case .ps: return 13
      case .ra: return 14
      case .sa: return 15
      case .sc: return 16
      case .si: return 17
      case .sr: return 18
      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 "FAMILY_UNSPECIFIED"
      case .ac: return "AC"
      case .at: return "AT"
      case .au: return "AU"
      case .ca: return "CA"
      case .cm: return "CM"
      case .cp: return "CP"
      case .ia: return "IA"
      case .ir: return "IR"
      case .ma: return "MA"
      case .mp: return "MP"
      case .pe: return "PE"
      case .pl: return "PL"
      case .ps: return "PS"
      case .ra: return "RA"
      case .sa: return "SA"
      case .sc: return "SC"
      case .si: return "SI"
      case .sr: return "SR"
      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:Family/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "FAMILY_UNSPECIFIED": self = .unspecified
      case "AC": self = .ac
      case "AT": self = .at
      case "AU": self = .au
      case "CA": self = .ca
      case "CM": self = .cm
      case "CP": self = .cp
      case "IA": self = .ia
      case "IR": self = .ir
      case "MA": self = .ma
      case "MP": self = .mp
      case "PE": self = .pe
      case "PL": self = .pl
      case "PS": self = .ps
      case "RA": self = .ra
      case "SA": self = .sa
      case "SC": self = .sc
      case "SI": self = .si
      case "SR": self = .sr
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Family/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .ac
      case 2: self = .at
      case 3: self = .au
      case 4: self = .ca
      case 5: self = .cm
      case 6: self = .cp
      case 7: self = .ia
      case 8: self = .ir
      case 9: self = .ma
      case 10: self = .mp
      case 11: self = .pe
      case 12: self = .pl
      case 13: self = .ps
      case 14: self = .ra
      case 15: self = .sa
      case 16: self = .sc
      case 17: self = .si
      case 18: self = .sr
      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 .ac: return try container.encode(1)
      case .at: return try container.encode(2)
      case .au: return try container.encode(3)
      case .ca: return try container.encode(4)
      case .cm: return try container.encode(5)
      case .cp: return try container.encode(6)
      case .ia: return try container.encode(7)
      case .ir: return try container.encode(8)
      case .ma: return try container.encode(9)
      case .mp: return try container.encode(10)
      case .pe: return try container.encode(11)
      case .pl: return try container.encode(12)
      case .ps: return try container.encode(13)
      case .ra: return try container.encode(14)
      case .sa: return try container.encode(15)
      case .sc: return try container.encode(16)
      case .si: return try container.encode(17)
      case .sr: return try container.encode(18)
      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.auditmanager.v1.Control"
  }
  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)
  }
}
