// DO NOT EDIT.
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: github.com/TheThingsNetwork/api/networkserver/networkserver.proto
//
// For information on using the generated types, please see the documenation:
//   https://github.com/apple/swift-protobuf/

// Copyright © 2017 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

struct Networkserver_DevicesRequest {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// Device address from the uplink message
  var devAddr: Data = SwiftProtobuf.Internal.emptyData

  /// Frame counter from the uplink message
  var fCnt: UInt32 = 0

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}
}

struct Networkserver_DevicesResponse {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var results: [Lorawan_Device] = []

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}
}

/// message StatusRequest is used to request the status of this NetworkServer
struct Networkserver_StatusRequest {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}
}

/// message Status is the response to the StatusRequest
struct Networkserver_Status {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var system: Api_SystemStats {
    get {return _storage._system ?? Api_SystemStats()}
    set {_uniqueStorage()._system = newValue}
  }
  /// Returns true if `system` has been explicitly set.
  var hasSystem: Bool {return _storage._system != nil}
  /// Clears the value of `system`. Subsequent reads from it will return its default value.
  mutating func clearSystem() {_uniqueStorage()._system = nil}

  var component: Api_ComponentStats {
    get {return _storage._component ?? Api_ComponentStats()}
    set {_uniqueStorage()._component = newValue}
  }
  /// Returns true if `component` has been explicitly set.
  var hasComponent: Bool {return _storage._component != nil}
  /// Clears the value of `component`. Subsequent reads from it will return its default value.
  mutating func clearComponent() {_uniqueStorage()._component = nil}

  var uplink: Api_Rates {
    get {return _storage._uplink ?? Api_Rates()}
    set {_uniqueStorage()._uplink = newValue}
  }
  /// Returns true if `uplink` has been explicitly set.
  var hasUplink: Bool {return _storage._uplink != nil}
  /// Clears the value of `uplink`. Subsequent reads from it will return its default value.
  mutating func clearUplink() {_uniqueStorage()._uplink = nil}

  var downlink: Api_Rates {
    get {return _storage._downlink ?? Api_Rates()}
    set {_uniqueStorage()._downlink = newValue}
  }
  /// Returns true if `downlink` has been explicitly set.
  var hasDownlink: Bool {return _storage._downlink != nil}
  /// Clears the value of `downlink`. Subsequent reads from it will return its default value.
  mutating func clearDownlink() {_uniqueStorage()._downlink = nil}

  var activations: Api_Rates {
    get {return _storage._activations ?? Api_Rates()}
    set {_uniqueStorage()._activations = newValue}
  }
  /// Returns true if `activations` has been explicitly set.
  var hasActivations: Bool {return _storage._activations != nil}
  /// Clears the value of `activations`. Subsequent reads from it will return its default value.
  mutating func clearActivations() {_uniqueStorage()._activations = nil}

  var devicesPerAddress: Api_Percentiles {
    get {return _storage._devicesPerAddress ?? Api_Percentiles()}
    set {_uniqueStorage()._devicesPerAddress = newValue}
  }
  /// Returns true if `devicesPerAddress` has been explicitly set.
  var hasDevicesPerAddress: Bool {return _storage._devicesPerAddress != nil}
  /// Clears the value of `devicesPerAddress`. Subsequent reads from it will return its default value.
  mutating func clearDevicesPerAddress() {_uniqueStorage()._devicesPerAddress = nil}

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}

  fileprivate var _storage = _StorageClass.defaultInstance
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "networkserver"

extension Networkserver_DevicesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".DevicesRequest"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "dev_addr"),
    2: .standard(proto: "f_cnt"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularBytesField(value: &self.devAddr)
      case 2: try decoder.decodeSingularUInt32Field(value: &self.fCnt)
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.devAddr.isEmpty {
      try visitor.visitSingularBytesField(value: self.devAddr, fieldNumber: 1)
    }
    if self.fCnt != 0 {
      try visitor.visitSingularUInt32Field(value: self.fCnt, fieldNumber: 2)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Networkserver_DevicesRequest, rhs: Networkserver_DevicesRequest) -> Bool {
    if lhs.devAddr != rhs.devAddr {return false}
    if lhs.fCnt != rhs.fCnt {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Networkserver_DevicesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".DevicesResponse"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "results"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeRepeatedMessageField(value: &self.results)
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.results.isEmpty {
      try visitor.visitRepeatedMessageField(value: self.results, fieldNumber: 1)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Networkserver_DevicesResponse, rhs: Networkserver_DevicesResponse) -> Bool {
    if lhs.results != rhs.results {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Networkserver_StatusRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".StatusRequest"
  static let _protobuf_nameMap = SwiftProtobuf._NameMap()

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let _ = try decoder.nextFieldNumber() {
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Networkserver_StatusRequest, rhs: Networkserver_StatusRequest) -> Bool {
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Networkserver_Status: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".Status"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "system"),
    2: .same(proto: "component"),
    11: .same(proto: "uplink"),
    12: .same(proto: "downlink"),
    13: .same(proto: "activations"),
    21: .standard(proto: "devices_per_address"),
  ]

  fileprivate class _StorageClass {
    var _system: Api_SystemStats? = nil
    var _component: Api_ComponentStats? = nil
    var _uplink: Api_Rates? = nil
    var _downlink: Api_Rates? = nil
    var _activations: Api_Rates? = nil
    var _devicesPerAddress: Api_Percentiles? = nil

    static let defaultInstance = _StorageClass()

    private init() {}

    init(copying source: _StorageClass) {
      _system = source._system
      _component = source._component
      _uplink = source._uplink
      _downlink = source._downlink
      _activations = source._activations
      _devicesPerAddress = source._devicesPerAddress
    }
  }

  fileprivate mutating func _uniqueStorage() -> _StorageClass {
    if !isKnownUniquelyReferenced(&_storage) {
      _storage = _StorageClass(copying: _storage)
    }
    return _storage
  }

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    _ = _uniqueStorage()
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      while let fieldNumber = try decoder.nextFieldNumber() {
        switch fieldNumber {
        case 1: try decoder.decodeSingularMessageField(value: &_storage._system)
        case 2: try decoder.decodeSingularMessageField(value: &_storage._component)
        case 11: try decoder.decodeSingularMessageField(value: &_storage._uplink)
        case 12: try decoder.decodeSingularMessageField(value: &_storage._downlink)
        case 13: try decoder.decodeSingularMessageField(value: &_storage._activations)
        case 21: try decoder.decodeSingularMessageField(value: &_storage._devicesPerAddress)
        default: break
        }
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      if let v = _storage._system {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
      }
      if let v = _storage._component {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
      }
      if let v = _storage._uplink {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 11)
      }
      if let v = _storage._downlink {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 12)
      }
      if let v = _storage._activations {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 13)
      }
      if let v = _storage._devicesPerAddress {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 21)
      }
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Networkserver_Status, rhs: Networkserver_Status) -> Bool {
    if lhs._storage !== rhs._storage {
      let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
        let _storage = _args.0
        let rhs_storage = _args.1
        if _storage._system != rhs_storage._system {return false}
        if _storage._component != rhs_storage._component {return false}
        if _storage._uplink != rhs_storage._uplink {return false}
        if _storage._downlink != rhs_storage._downlink {return false}
        if _storage._activations != rhs_storage._activations {return false}
        if _storage._devicesPerAddress != rhs_storage._devicesPerAddress {return false}
        return true
      }
      if !storagesAreEqual {return false}
    }
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
