feat(protocol): negotiate display and native input
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Code generated by tools/generate.py; DO NOT EDIT.
|
||||
import Foundation
|
||||
public typealias JSONObject = [String: String]
|
||||
public let schemaSHA256 = "a86cbdaf2cfb884e3d98467968007e731ca55c6f6eb6dbd5cd6b95e062a9b058"
|
||||
public let schemaSHA256 = "b2bb0a8ac8ef56dbc0e1443eeb5b3028be9e71ec2f5fd8e73928d71b7cd9340c"
|
||||
public let currentWireVersion = "1"
|
||||
public let nMinus1WireVersion = "0"
|
||||
public let nMinus2WireVersion = "-1"
|
||||
@@ -148,6 +148,8 @@ public struct BrokerSession: Codable, Equatable {
|
||||
public let requestedAt: String
|
||||
public let endedAt: String?
|
||||
public let version: Int64
|
||||
public let requestedDisplayMode: DisplayMode?
|
||||
public let effectiveDisplayMode: DisplayMode?
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id = "id"
|
||||
case principalId = "principal_id"
|
||||
@@ -164,9 +166,11 @@ public struct BrokerSession: Codable, Equatable {
|
||||
case requestedAt = "requested_at"
|
||||
case endedAt = "ended_at"
|
||||
case version = "version"
|
||||
case requestedDisplayMode = "requested_display_mode"
|
||||
case effectiveDisplayMode = "effective_display_mode"
|
||||
}
|
||||
|
||||
public init(id: String, principalId: String, poolId: String, assignmentId: String?, state: String, policySnapshot: AllocationPolicy, reconnectDeadline: String?, outcome: String?, failureCode: String?, cleanupState: String, idempotencyKey: String, correlationId: String, requestedAt: String, endedAt: String?, version: Int64) throws {
|
||||
public init(id: String, principalId: String, poolId: String, assignmentId: String?, state: String, policySnapshot: AllocationPolicy, reconnectDeadline: String?, outcome: String?, failureCode: String?, cleanupState: String, idempotencyKey: String, correlationId: String, requestedAt: String, endedAt: String?, version: Int64, requestedDisplayMode: DisplayMode?, effectiveDisplayMode: DisplayMode?) throws {
|
||||
self.id = id
|
||||
self.principalId = principalId
|
||||
self.poolId = poolId
|
||||
@@ -182,6 +186,8 @@ public struct BrokerSession: Codable, Equatable {
|
||||
self.requestedAt = requestedAt
|
||||
self.endedAt = endedAt
|
||||
self.version = version
|
||||
self.requestedDisplayMode = requestedDisplayMode
|
||||
self.effectiveDisplayMode = effectiveDisplayMode
|
||||
try validate()
|
||||
}
|
||||
|
||||
@@ -189,7 +195,7 @@ public struct BrokerSession: Codable, Equatable {
|
||||
let all = try decoder.container(keyedBy: AnyCodingKey.self)
|
||||
for key in all.allKeys where CodingKeys(stringValue: key.stringValue) == nil { throw ContractValidationError(field: key.stringValue, code: "unknown_field") }
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
try self.init(id: try c.decode(String.self, forKey: .id), principalId: try c.decode(String.self, forKey: .principalId), poolId: try c.decode(String.self, forKey: .poolId), assignmentId: try c.decodeIfPresent(String.self, forKey: .assignmentId), state: try c.decode(String.self, forKey: .state), policySnapshot: try c.decode(AllocationPolicy.self, forKey: .policySnapshot), reconnectDeadline: try c.decodeIfPresent(String.self, forKey: .reconnectDeadline), outcome: try c.decodeIfPresent(String.self, forKey: .outcome), failureCode: try c.decodeIfPresent(String.self, forKey: .failureCode), cleanupState: try c.decode(String.self, forKey: .cleanupState), idempotencyKey: try c.decode(String.self, forKey: .idempotencyKey), correlationId: try c.decode(String.self, forKey: .correlationId), requestedAt: try c.decode(String.self, forKey: .requestedAt), endedAt: try c.decodeIfPresent(String.self, forKey: .endedAt), version: try c.decode(Int64.self, forKey: .version))
|
||||
try self.init(id: try c.decode(String.self, forKey: .id), principalId: try c.decode(String.self, forKey: .principalId), poolId: try c.decode(String.self, forKey: .poolId), assignmentId: try c.decodeIfPresent(String.self, forKey: .assignmentId), state: try c.decode(String.self, forKey: .state), policySnapshot: try c.decode(AllocationPolicy.self, forKey: .policySnapshot), reconnectDeadline: try c.decodeIfPresent(String.self, forKey: .reconnectDeadline), outcome: try c.decodeIfPresent(String.self, forKey: .outcome), failureCode: try c.decodeIfPresent(String.self, forKey: .failureCode), cleanupState: try c.decode(String.self, forKey: .cleanupState), idempotencyKey: try c.decode(String.self, forKey: .idempotencyKey), correlationId: try c.decode(String.self, forKey: .correlationId), requestedAt: try c.decode(String.self, forKey: .requestedAt), endedAt: try c.decodeIfPresent(String.self, forKey: .endedAt), version: try c.decode(Int64.self, forKey: .version), requestedDisplayMode: try c.contains(.requestedDisplayMode) ? c.decode(DisplayMode.self, forKey: .requestedDisplayMode) : nil, effectiveDisplayMode: try c.contains(.effectiveDisplayMode) ? c.decode(DisplayMode.self, forKey: .effectiveDisplayMode) : nil)
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
@@ -235,6 +241,12 @@ public struct BrokerSession: Codable, Equatable {
|
||||
if ISO8601DateFormatter().date(from: value) == nil { throw ContractValidationError(field: "ended_at", code: "invalid_time") }
|
||||
}
|
||||
if self.version < 1 { throw ContractValidationError(field: "version", code: "minimum") }
|
||||
if let value = self.requestedDisplayMode {
|
||||
try value.validate()
|
||||
}
|
||||
if let value = self.effectiveDisplayMode {
|
||||
try value.validate()
|
||||
}
|
||||
}
|
||||
|
||||
public static func decodeJSON(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) }
|
||||
@@ -632,6 +644,43 @@ public struct DeviceRegistrationRequest: Codable, Equatable {
|
||||
public func encodeJSON() throws -> Data { try validate(); return try JSONEncoder().encode(self) }
|
||||
}
|
||||
|
||||
public struct DisplayMode: Codable, Equatable {
|
||||
public let resolutionWidth: Int64
|
||||
public let resolutionHeight: Int64
|
||||
public let fps: Int64
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case resolutionWidth = "resolution_width"
|
||||
case resolutionHeight = "resolution_height"
|
||||
case fps = "fps"
|
||||
}
|
||||
|
||||
public init(resolutionWidth: Int64, resolutionHeight: Int64, fps: Int64) throws {
|
||||
self.resolutionWidth = resolutionWidth
|
||||
self.resolutionHeight = resolutionHeight
|
||||
self.fps = fps
|
||||
try validate()
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let all = try decoder.container(keyedBy: AnyCodingKey.self)
|
||||
for key in all.allKeys where CodingKeys(stringValue: key.stringValue) == nil { throw ContractValidationError(field: key.stringValue, code: "unknown_field") }
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
try self.init(resolutionWidth: try c.decode(Int64.self, forKey: .resolutionWidth), resolutionHeight: try c.decode(Int64.self, forKey: .resolutionHeight), fps: try c.decode(Int64.self, forKey: .fps))
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
if self.resolutionWidth < 320 { throw ContractValidationError(field: "resolution_width", code: "minimum") }
|
||||
if self.resolutionWidth > 16384 { throw ContractValidationError(field: "resolution_width", code: "maximum") }
|
||||
if self.resolutionHeight < 200 { throw ContractValidationError(field: "resolution_height", code: "minimum") }
|
||||
if self.resolutionHeight > 8640 { throw ContractValidationError(field: "resolution_height", code: "maximum") }
|
||||
if self.fps < 1 { throw ContractValidationError(field: "fps", code: "minimum") }
|
||||
if self.fps > 240 { throw ContractValidationError(field: "fps", code: "maximum") }
|
||||
}
|
||||
|
||||
public static func decodeJSON(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) }
|
||||
public func encodeJSON() throws -> Data { try validate(); return try JSONEncoder().encode(self) }
|
||||
}
|
||||
|
||||
public struct EntitledPool: Codable, Equatable {
|
||||
public let poolId: String
|
||||
public let name: String
|
||||
@@ -1414,14 +1463,17 @@ public struct ManifestGateway: Codable, Equatable {
|
||||
public struct ManifestProfile: Codable, Equatable {
|
||||
public let id: String
|
||||
public let bounds: ManifestBounds
|
||||
public let displayMode: DisplayMode?
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id = "id"
|
||||
case bounds = "bounds"
|
||||
case displayMode = "display_mode"
|
||||
}
|
||||
|
||||
public init(id: String, bounds: ManifestBounds) throws {
|
||||
public init(id: String, bounds: ManifestBounds, displayMode: DisplayMode?) throws {
|
||||
self.id = id
|
||||
self.bounds = bounds
|
||||
self.displayMode = displayMode
|
||||
try validate()
|
||||
}
|
||||
|
||||
@@ -1429,7 +1481,7 @@ public struct ManifestProfile: Codable, Equatable {
|
||||
let all = try decoder.container(keyedBy: AnyCodingKey.self)
|
||||
for key in all.allKeys where CodingKeys(stringValue: key.stringValue) == nil { throw ContractValidationError(field: key.stringValue, code: "unknown_field") }
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
try self.init(id: try c.decode(String.self, forKey: .id), bounds: try c.decode(ManifestBounds.self, forKey: .bounds))
|
||||
try self.init(id: try c.decode(String.self, forKey: .id), bounds: try c.decode(ManifestBounds.self, forKey: .bounds), displayMode: try c.contains(.displayMode) ? c.decode(DisplayMode.self, forKey: .displayMode) : nil)
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
@@ -1437,6 +1489,9 @@ public struct ManifestProfile: Codable, Equatable {
|
||||
if !self.id.isEmpty && self.id.utf8.count < 1 { throw ContractValidationError(field: "id", code: "min_length") }
|
||||
if self.id.utf8.count > 128 { throw ContractValidationError(field: "id", code: "max_length") }
|
||||
try self.bounds.validate()
|
||||
if let value = self.displayMode {
|
||||
try value.validate()
|
||||
}
|
||||
}
|
||||
|
||||
public static func decodeJSON(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) }
|
||||
@@ -2132,20 +2187,23 @@ public struct SessionRequest: Codable, Equatable {
|
||||
public let poolId: String
|
||||
public let idempotencyKey: String
|
||||
public let policySnapshot: AllocationPolicy
|
||||
public let requestedDisplayMode: DisplayMode?
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case clientDeviceId = "client_device_id"
|
||||
case deviceKeyId = "device_key_id"
|
||||
case poolId = "pool_id"
|
||||
case idempotencyKey = "idempotency_key"
|
||||
case policySnapshot = "policy_snapshot"
|
||||
case requestedDisplayMode = "requested_display_mode"
|
||||
}
|
||||
|
||||
public init(clientDeviceId: String, deviceKeyId: String, poolId: String, idempotencyKey: String, policySnapshot: AllocationPolicy) throws {
|
||||
public init(clientDeviceId: String, deviceKeyId: String, poolId: String, idempotencyKey: String, policySnapshot: AllocationPolicy, requestedDisplayMode: DisplayMode?) throws {
|
||||
self.clientDeviceId = clientDeviceId
|
||||
self.deviceKeyId = deviceKeyId
|
||||
self.poolId = poolId
|
||||
self.idempotencyKey = idempotencyKey
|
||||
self.policySnapshot = policySnapshot
|
||||
self.requestedDisplayMode = requestedDisplayMode
|
||||
try validate()
|
||||
}
|
||||
|
||||
@@ -2153,7 +2211,7 @@ public struct SessionRequest: Codable, Equatable {
|
||||
let all = try decoder.container(keyedBy: AnyCodingKey.self)
|
||||
for key in all.allKeys where CodingKeys(stringValue: key.stringValue) == nil { throw ContractValidationError(field: key.stringValue, code: "unknown_field") }
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
try self.init(clientDeviceId: try c.decode(String.self, forKey: .clientDeviceId), deviceKeyId: try c.decode(String.self, forKey: .deviceKeyId), poolId: try c.decode(String.self, forKey: .poolId), idempotencyKey: try c.decode(String.self, forKey: .idempotencyKey), policySnapshot: try c.decode(AllocationPolicy.self, forKey: .policySnapshot))
|
||||
try self.init(clientDeviceId: try c.decode(String.self, forKey: .clientDeviceId), deviceKeyId: try c.decode(String.self, forKey: .deviceKeyId), poolId: try c.decode(String.self, forKey: .poolId), idempotencyKey: try c.decode(String.self, forKey: .idempotencyKey), policySnapshot: try c.decode(AllocationPolicy.self, forKey: .policySnapshot), requestedDisplayMode: try c.contains(.requestedDisplayMode) ? c.decode(DisplayMode.self, forKey: .requestedDisplayMode) : nil)
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
@@ -2170,6 +2228,9 @@ public struct SessionRequest: Codable, Equatable {
|
||||
if !self.idempotencyKey.isEmpty && self.idempotencyKey.utf8.count < 1 { throw ContractValidationError(field: "idempotency_key", code: "min_length") }
|
||||
if self.idempotencyKey.utf8.count > 256 { throw ContractValidationError(field: "idempotency_key", code: "max_length") }
|
||||
try self.policySnapshot.validate()
|
||||
if let value = self.requestedDisplayMode {
|
||||
try value.validate()
|
||||
}
|
||||
}
|
||||
|
||||
public static func decodeJSON(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) }
|
||||
|
||||
Reference in New Issue
Block a user