// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: v1/event/event.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

/// sensory.api.event

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 you 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
}

/// Request to create a new usage event
public struct Sensory_Api_V1_Event_PublishUsageEventsRequest {
  // 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.

  /// A list of events to publish
  public var events: [Sensory_Api_V1_Event_UsageEvent] = []

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

public struct Sensory_Api_V1_Event_UsageEvent {
  // 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.

  /// The UTC timestamp
  public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp {
    get {return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp()}
    set {_timestamp = newValue}
  }
  /// Returns true if `timestamp` has been explicitly set.
  public var hasTimestamp: Bool {return self._timestamp != nil}
  /// Clears the value of `timestamp`. Subsequent reads from it will return its default value.
  public mutating func clearTimestamp() {self._timestamp = nil}

  /// The duration of the event in milliseconds
  public var duration: Int64 = 0

  /// UUID representing the unique event
  public var id: String = String()

  /// OAuth ClientID related to the event
  public var clientID: String = String()

  /// Type of event to create
  public var type: Sensory_Api_Common_UsageEventType = .authentication

  /// The specific route (endpoint) that was accessed
  public var route: String = String()

  /// The technologies that were used
  public var technologies: [Sensory_Api_Common_TechnologyType] = []

  /// The models that were used
  public var models: [String] = []

  /// The duration audio processed in milliseconds
  public var audioDurationMs: Int64 = 0

  /// The number of video frames processed
  public var videoFrameCount: Int64 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? = nil
}

/// Response to a publish events request
public struct Sensory_Api_V1_Event_PublishUsageEventsResponse {
  // 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.

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Sensory_Api_V1_Event_PublishUsageEventsRequest: @unchecked Sendable {}
extension Sensory_Api_V1_Event_UsageEvent: @unchecked Sendable {}
extension Sensory_Api_V1_Event_PublishUsageEventsResponse: @unchecked Sendable {}
#endif  // swift(>=5.5) && canImport(_Concurrency)

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

fileprivate let _protobuf_package = "sensory.api.v1.event"

extension Sensory_Api_V1_Event_PublishUsageEventsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".PublishUsageEventsRequest"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "events"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeRepeatedMessageField(value: &self.events) }()
      default: break
      }
    }
  }

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

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

extension Sensory_Api_V1_Event_UsageEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".UsageEvent"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "timestamp"),
    2: .same(proto: "duration"),
    3: .same(proto: "id"),
    4: .same(proto: "clientId"),
    5: .same(proto: "type"),
    6: .same(proto: "route"),
    7: .same(proto: "technologies"),
    8: .same(proto: "models"),
    9: .same(proto: "audioDurationMs"),
    10: .same(proto: "videoFrameCount"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }()
      case 2: try { try decoder.decodeSingularInt64Field(value: &self.duration) }()
      case 3: try { try decoder.decodeSingularStringField(value: &self.id) }()
      case 4: try { try decoder.decodeSingularStringField(value: &self.clientID) }()
      case 5: try { try decoder.decodeSingularEnumField(value: &self.type) }()
      case 6: try { try decoder.decodeSingularStringField(value: &self.route) }()
      case 7: try { try decoder.decodeRepeatedEnumField(value: &self.technologies) }()
      case 8: try { try decoder.decodeRepeatedStringField(value: &self.models) }()
      case 9: try { try decoder.decodeSingularInt64Field(value: &self.audioDurationMs) }()
      case 10: try { try decoder.decodeSingularInt64Field(value: &self.videoFrameCount) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    try { if let v = self._timestamp {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    } }()
    if self.duration != 0 {
      try visitor.visitSingularInt64Field(value: self.duration, fieldNumber: 2)
    }
    if !self.id.isEmpty {
      try visitor.visitSingularStringField(value: self.id, fieldNumber: 3)
    }
    if !self.clientID.isEmpty {
      try visitor.visitSingularStringField(value: self.clientID, fieldNumber: 4)
    }
    if self.type != .authentication {
      try visitor.visitSingularEnumField(value: self.type, fieldNumber: 5)
    }
    if !self.route.isEmpty {
      try visitor.visitSingularStringField(value: self.route, fieldNumber: 6)
    }
    if !self.technologies.isEmpty {
      try visitor.visitPackedEnumField(value: self.technologies, fieldNumber: 7)
    }
    if !self.models.isEmpty {
      try visitor.visitRepeatedStringField(value: self.models, fieldNumber: 8)
    }
    if self.audioDurationMs != 0 {
      try visitor.visitSingularInt64Field(value: self.audioDurationMs, fieldNumber: 9)
    }
    if self.videoFrameCount != 0 {
      try visitor.visitSingularInt64Field(value: self.videoFrameCount, fieldNumber: 10)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Sensory_Api_V1_Event_UsageEvent, rhs: Sensory_Api_V1_Event_UsageEvent) -> Bool {
    if lhs._timestamp != rhs._timestamp {return false}
    if lhs.duration != rhs.duration {return false}
    if lhs.id != rhs.id {return false}
    if lhs.clientID != rhs.clientID {return false}
    if lhs.type != rhs.type {return false}
    if lhs.route != rhs.route {return false}
    if lhs.technologies != rhs.technologies {return false}
    if lhs.models != rhs.models {return false}
    if lhs.audioDurationMs != rhs.audioDurationMs {return false}
    if lhs.videoFrameCount != rhs.videoFrameCount {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

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

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

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

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