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

/// Diagnostics information about interconnect, contains detailed and current
/// technical information about Google's side of the connection.
public struct InterconnectDiagnostics: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The MAC address of the Interconnect's bundle interface.
  public var macAddress: Swift.String = Swift.String()

  /// A list of LinkLayerAddress, describing the ip address and corresponding
  /// link-layer address of the neighbors for this interconnect.
  public var linkLayerAddresses: [LinkLayerAddress] = []

  /// A list of LinkStatus objects, used to describe the status for each link on
  /// the Interconnect.
  public var links: [InterconnectDiagnostics.LinkStatus] = []

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

  /// Describing the status for each link on the Interconnect.
  public struct LinkStatus: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The unique ID for this link assigned during turn up by Google.
    public var circuitId: Swift.String = Swift.String()

    /// Describing the state of a LACP link.
    public var lacpStatus: InterconnectDiagnostics.LinkLACPStatus? = nil

    /// A list of LinkLLDPStatus objects, used to describe LLDP status of each
    /// peer for each link on the Interconnect.
    public var lldpStatuses: [InterconnectDiagnostics.LinkLLDPStatus] = []

    /// Packet counts specific statistics for this link.
    public var packetCounts: InterconnectDiagnostics.PacketCounts? = nil

    /// Initialize a new instance of `LinkStatus`.
    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 = LinkStatus().with { $0.circuitId = ... }
    /// ```
    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.edgenetwork.v1.InterconnectDiagnostics.LinkStatus"
    }
    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)
    }
  }

  /// Containing a collection of interface-related statistics objects.
  public struct PacketCounts: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The number of packets that are delivered.
    public var inboundUnicast: Swift.Int64 = Swift.Int64()

    /// The number of inbound packets that contained errors.
    public var inboundErrors: Swift.Int64 = Swift.Int64()

    /// The number of inbound packets that were chosen to be discarded even
    /// though no errors had been detected to prevent their being deliverable.
    public var inboundDiscards: Swift.Int64 = Swift.Int64()

    /// The total number of packets that are requested be transmitted.
    public var outboundUnicast: Swift.Int64 = Swift.Int64()

    /// The number of outbound packets that could not be transmitted because of
    /// errors.
    public var outboundErrors: Swift.Int64 = Swift.Int64()

    /// The number of outbound packets that were chosen to be discarded even
    /// though no errors had been detected to prevent their being transmitted.
    public var outboundDiscards: Swift.Int64 = Swift.Int64()

    /// Initialize a new instance of `PacketCounts`.
    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 = PacketCounts().with { $0.inboundUnicast = ... }
    /// ```
    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.edgenetwork.v1.InterconnectDiagnostics.PacketCounts"
    }
    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)
    }
  }

  /// Describing the status of a LACP link.
  public struct LinkLACPStatus: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The state of a LACP link.
    public var state: InterconnectDiagnostics.LinkLACPStatus.State = InterconnectDiagnostics
      .LinkLACPStatus.State()

    /// System ID of the port on Google's side of the LACP exchange.
    public var googleSystemId: Swift.String = Swift.String()

    /// System ID of the port on the neighbor's side of the LACP exchange.
    public var neighborSystemId: Swift.String = Swift.String()

    /// A true value indicates that the participant will allow the link to be
    /// used as part of the aggregate.
    /// A false value indicates the link should be used as an individual link.
    public var aggregatable: Swift.Bool = Swift.Bool()

    /// If true, the participant is collecting incoming frames on the link,
    /// otherwise false
    public var collecting: Swift.Bool = Swift.Bool()

    /// When true, the participant is distributing outgoing frames; when false,
    /// distribution is disabled
    public var distributing: Swift.Bool = Swift.Bool()

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

    /// State enum for LACP link.
    public enum State: Codable, Equatable, Sendable {
      /// The default state indicating state is in unknown state.
      case unknown
      /// The link is configured and active within the bundle.
      case active
      /// The link is not configured within the bundle, this means the rest of
      /// the object should be empty.
      case detached
      /// 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 = .unknown
      }

      /// 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 .unknown: return 0
        case .active: return 1
        case .detached: 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 .unknown: return "UNKNOWN"
        case .active: return "ACTIVE"
        case .detached: return "DETACHED"
        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:State/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "UNKNOWN": self = .unknown
        case "ACTIVE": self = .active
        case "DETACHED": self = .detached
        default: self = .unknownStringValue(stringValue)
        }
      }

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

  /// Describing a LLDP link.
  public struct LinkLLDPStatus: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The peer system's administratively assigned name.
    public var peerSystemName: Swift.String = Swift.String()

    /// The textual description of the network entity of LLDP peer.
    public var peerSystemDescription: Swift.String = Swift.String()

    /// The peer chassis component of the endpoint identifier associated with the
    /// transmitting LLDP agent.
    public var peerChassisId: Swift.String = Swift.String()

    /// The format and source of the peer chassis identifier string.
    public var peerChassisIdType: Swift.String = Swift.String()

    /// The port component of the endpoint identifier associated with the
    /// transmitting LLDP agent. If the specified port is an IEEE 802.3 Repeater
    /// port, then this TLV is optional.
    public var peerPortId: Swift.String = Swift.String()

    /// The format and source of the peer port identifier string.
    public var peerPortIdType: Swift.String = Swift.String()

    /// Initialize a new instance of `LinkLLDPStatus`.
    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 = LinkLLDPStatus().with { $0.peerSystemName = ... }
    /// ```
    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.edgenetwork.v1.InterconnectDiagnostics.LinkLLDPStatus"
    }
    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.edgenetwork.v1.InterconnectDiagnostics"
  }
  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)
  }
}
