feat(protocol): define gateway control envelopes
This commit is contained in:
+137
-3
@@ -1,7 +1,7 @@
|
||||
// Code generated by tools/generate.py; DO NOT EDIT.
|
||||
import Foundation
|
||||
public typealias JSONObject = [String: String]
|
||||
public let schemaSHA256 = "792abfb9cfe70e79911d499d76c009ab848713278bc240b88576df520580e480"
|
||||
public let schemaSHA256 = "e35414af52d7a097dea05567fdab11f842a42e529fb6cbedd281c48dbf930b17"
|
||||
public let currentWireVersion = "1"
|
||||
public let nMinus1WireVersion = "0"
|
||||
public let nMinus2WireVersion = "-1"
|
||||
@@ -350,6 +350,44 @@ public struct ChannelFrame: Codable, Equatable {
|
||||
public func encodeJSON() throws -> Data { try validate(); return try JSONEncoder().encode(self) }
|
||||
}
|
||||
|
||||
public struct ClipboardPolicy: Codable, Equatable {
|
||||
public let clientToProviderEnabled: Bool
|
||||
public let providerToClientEnabled: Bool
|
||||
public let maxTextBytes: Int64
|
||||
public let maxUpdatesPerMinute: Int64
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case clientToProviderEnabled = "client_to_provider_enabled"
|
||||
case providerToClientEnabled = "provider_to_client_enabled"
|
||||
case maxTextBytes = "max_text_bytes"
|
||||
case maxUpdatesPerMinute = "max_updates_per_minute"
|
||||
}
|
||||
|
||||
public init(clientToProviderEnabled: Bool, providerToClientEnabled: Bool, maxTextBytes: Int64, maxUpdatesPerMinute: Int64) throws {
|
||||
self.clientToProviderEnabled = clientToProviderEnabled
|
||||
self.providerToClientEnabled = providerToClientEnabled
|
||||
self.maxTextBytes = maxTextBytes
|
||||
self.maxUpdatesPerMinute = maxUpdatesPerMinute
|
||||
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(clientToProviderEnabled: try c.decode(Bool.self, forKey: .clientToProviderEnabled), providerToClientEnabled: try c.decode(Bool.self, forKey: .providerToClientEnabled), maxTextBytes: try c.decode(Int64.self, forKey: .maxTextBytes), maxUpdatesPerMinute: try c.decode(Int64.self, forKey: .maxUpdatesPerMinute))
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
if self.maxTextBytes < 1 { throw ContractValidationError(field: "max_text_bytes", code: "minimum") }
|
||||
if self.maxTextBytes > 65536 { throw ContractValidationError(field: "max_text_bytes", code: "maximum") }
|
||||
if self.maxUpdatesPerMinute < 1 { throw ContractValidationError(field: "max_updates_per_minute", code: "minimum") }
|
||||
if self.maxUpdatesPerMinute > 120 { throw ContractValidationError(field: "max_updates_per_minute", 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 ClipboardText: Codable, Equatable {
|
||||
public let text: String
|
||||
public let encoding: String
|
||||
@@ -809,6 +847,95 @@ public struct FieldViolation: Codable, Equatable {
|
||||
public func encodeJSON() throws -> Data { try validate(); return try JSONEncoder().encode(self) }
|
||||
}
|
||||
|
||||
public struct GatewayClipboardAudit: Codable, Equatable {
|
||||
public let version: String
|
||||
public let sessionId: String
|
||||
public let direction: String
|
||||
public let outcome: String
|
||||
public let textBytes: Int64
|
||||
public let reason: String
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case version = "version"
|
||||
case sessionId = "session_id"
|
||||
case direction = "direction"
|
||||
case outcome = "outcome"
|
||||
case textBytes = "text_bytes"
|
||||
case reason = "reason"
|
||||
}
|
||||
|
||||
public init(version: String, sessionId: String, direction: String, outcome: String, textBytes: Int64, reason: String) throws {
|
||||
self.version = version
|
||||
self.sessionId = sessionId
|
||||
self.direction = direction
|
||||
self.outcome = outcome
|
||||
self.textBytes = textBytes
|
||||
self.reason = reason
|
||||
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(version: try c.decode(String.self, forKey: .version), sessionId: try c.decode(String.self, forKey: .sessionId), direction: try c.decode(String.self, forKey: .direction), outcome: try c.decode(String.self, forKey: .outcome), textBytes: try c.decode(Int64.self, forKey: .textBytes), reason: try c.decode(String.self, forKey: .reason))
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
if self.version != "1" { throw ContractValidationError(field: "version", code: "invalid_value") }
|
||||
if self.sessionId.isEmpty { throw ContractValidationError(field: "session_id", code: "required") }
|
||||
if !self.sessionId.isEmpty && self.sessionId.utf8.count < 1 { throw ContractValidationError(field: "session_id", code: "min_length") }
|
||||
if self.sessionId.utf8.count > 128 { throw ContractValidationError(field: "session_id", code: "max_length") }
|
||||
if !["client_to_provider", "provider_to_client"].contains(self.direction) { throw ContractValidationError(field: "direction", code: "invalid_value") }
|
||||
if !["forwarded", "suppressed", "rejected"].contains(self.outcome) { throw ContractValidationError(field: "outcome", code: "invalid_value") }
|
||||
if self.textBytes < 0 { throw ContractValidationError(field: "text_bytes", code: "minimum") }
|
||||
if self.textBytes > 65536 { throw ContractValidationError(field: "text_bytes", code: "maximum") }
|
||||
if !["forwarded", "loop", "policy", "rate", "provider", "malformed"].contains(self.reason) { throw ContractValidationError(field: "reason", code: "invalid_value") }
|
||||
}
|
||||
|
||||
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 GatewayClipboardText: Codable, Equatable {
|
||||
public let direction: String
|
||||
public let text: String
|
||||
public let encoding: String
|
||||
public let loopToken: String
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case direction = "direction"
|
||||
case text = "text"
|
||||
case encoding = "encoding"
|
||||
case loopToken = "loop_token"
|
||||
}
|
||||
|
||||
public init(direction: String, text: String, encoding: String, loopToken: String) throws {
|
||||
self.direction = direction
|
||||
self.text = text
|
||||
self.encoding = encoding
|
||||
self.loopToken = loopToken
|
||||
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(direction: try c.decode(String.self, forKey: .direction), text: try c.decode(String.self, forKey: .text), encoding: try c.decode(String.self, forKey: .encoding), loopToken: try c.decode(String.self, forKey: .loopToken))
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
if !["client_to_provider", "provider_to_client"].contains(self.direction) { throw ContractValidationError(field: "direction", code: "invalid_value") }
|
||||
if self.text.utf8.count > 65536 { throw ContractValidationError(field: "text", code: "max_length") }
|
||||
if self.encoding != "utf-8" { throw ContractValidationError(field: "encoding", code: "invalid_value") }
|
||||
if self.loopToken.isEmpty { throw ContractValidationError(field: "loop_token", code: "required") }
|
||||
if !self.loopToken.isEmpty && self.loopToken.utf8.count < 16 { throw ContractValidationError(field: "loop_token", code: "min_length") }
|
||||
if self.loopToken.utf8.count > 128 { throw ContractValidationError(field: "loop_token", code: "max_length") }
|
||||
}
|
||||
|
||||
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 GatewayDrain: Codable, Equatable {
|
||||
public let version: String
|
||||
public let gatewayId: String
|
||||
@@ -1328,6 +1455,8 @@ public struct ProviderSessionWork: Codable, Equatable {
|
||||
public let clientCertificatePem: String
|
||||
public let clientPrivateKeyPem: String
|
||||
public let serverCertificatePem: String
|
||||
public let clipboardPolicy: ClipboardPolicy
|
||||
public let providerApplicationTerminationAllowed: Bool
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case version = "version"
|
||||
case sessionId = "session_id"
|
||||
@@ -1346,9 +1475,11 @@ public struct ProviderSessionWork: Codable, Equatable {
|
||||
case clientCertificatePem = "client_certificate_pem"
|
||||
case clientPrivateKeyPem = "client_private_key_pem"
|
||||
case serverCertificatePem = "server_certificate_pem"
|
||||
case clipboardPolicy = "clipboard_policy"
|
||||
case providerApplicationTerminationAllowed = "provider_application_termination_allowed"
|
||||
}
|
||||
|
||||
public init(version: String, sessionId: String, gatewayId: String, reconnectSequence: Int64, expiresAt: String, providerProfile: String, providerIdentity: String, policyVersionId: String, applicationId: String, clientId: String, managementHost: String, managementPort: Int64, streamHost: String, streamPort: Int64, clientCertificatePem: String, clientPrivateKeyPem: String, serverCertificatePem: String) throws {
|
||||
public init(version: String, sessionId: String, gatewayId: String, reconnectSequence: Int64, expiresAt: String, providerProfile: String, providerIdentity: String, policyVersionId: String, applicationId: String, clientId: String, managementHost: String, managementPort: Int64, streamHost: String, streamPort: Int64, clientCertificatePem: String, clientPrivateKeyPem: String, serverCertificatePem: String, clipboardPolicy: ClipboardPolicy, providerApplicationTerminationAllowed: Bool) throws {
|
||||
self.version = version
|
||||
self.sessionId = sessionId
|
||||
self.gatewayId = gatewayId
|
||||
@@ -1366,6 +1497,8 @@ public struct ProviderSessionWork: Codable, Equatable {
|
||||
self.clientCertificatePem = clientCertificatePem
|
||||
self.clientPrivateKeyPem = clientPrivateKeyPem
|
||||
self.serverCertificatePem = serverCertificatePem
|
||||
self.clipboardPolicy = clipboardPolicy
|
||||
self.providerApplicationTerminationAllowed = providerApplicationTerminationAllowed
|
||||
try validate()
|
||||
}
|
||||
|
||||
@@ -1373,7 +1506,7 @@ public struct ProviderSessionWork: 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(version: try c.decode(String.self, forKey: .version), sessionId: try c.decode(String.self, forKey: .sessionId), gatewayId: try c.decode(String.self, forKey: .gatewayId), reconnectSequence: try c.decode(Int64.self, forKey: .reconnectSequence), expiresAt: try c.decode(String.self, forKey: .expiresAt), providerProfile: try c.decode(String.self, forKey: .providerProfile), providerIdentity: try c.decode(String.self, forKey: .providerIdentity), policyVersionId: try c.decode(String.self, forKey: .policyVersionId), applicationId: try c.decode(String.self, forKey: .applicationId), clientId: try c.decode(String.self, forKey: .clientId), managementHost: try c.decode(String.self, forKey: .managementHost), managementPort: try c.decode(Int64.self, forKey: .managementPort), streamHost: try c.decode(String.self, forKey: .streamHost), streamPort: try c.decode(Int64.self, forKey: .streamPort), clientCertificatePem: try c.decode(String.self, forKey: .clientCertificatePem), clientPrivateKeyPem: try c.decode(String.self, forKey: .clientPrivateKeyPem), serverCertificatePem: try c.decode(String.self, forKey: .serverCertificatePem))
|
||||
try self.init(version: try c.decode(String.self, forKey: .version), sessionId: try c.decode(String.self, forKey: .sessionId), gatewayId: try c.decode(String.self, forKey: .gatewayId), reconnectSequence: try c.decode(Int64.self, forKey: .reconnectSequence), expiresAt: try c.decode(String.self, forKey: .expiresAt), providerProfile: try c.decode(String.self, forKey: .providerProfile), providerIdentity: try c.decode(String.self, forKey: .providerIdentity), policyVersionId: try c.decode(String.self, forKey: .policyVersionId), applicationId: try c.decode(String.self, forKey: .applicationId), clientId: try c.decode(String.self, forKey: .clientId), managementHost: try c.decode(String.self, forKey: .managementHost), managementPort: try c.decode(Int64.self, forKey: .managementPort), streamHost: try c.decode(String.self, forKey: .streamHost), streamPort: try c.decode(Int64.self, forKey: .streamPort), clientCertificatePem: try c.decode(String.self, forKey: .clientCertificatePem), clientPrivateKeyPem: try c.decode(String.self, forKey: .clientPrivateKeyPem), serverCertificatePem: try c.decode(String.self, forKey: .serverCertificatePem), clipboardPolicy: try c.decode(ClipboardPolicy.self, forKey: .clipboardPolicy), providerApplicationTerminationAllowed: try c.decode(Bool.self, forKey: .providerApplicationTerminationAllowed))
|
||||
}
|
||||
|
||||
public func validate() throws {
|
||||
@@ -1419,6 +1552,7 @@ public struct ProviderSessionWork: Codable, Equatable {
|
||||
if self.serverCertificatePem.isEmpty { throw ContractValidationError(field: "server_certificate_pem", code: "required") }
|
||||
if !self.serverCertificatePem.isEmpty && self.serverCertificatePem.utf8.count < 1 { throw ContractValidationError(field: "server_certificate_pem", code: "min_length") }
|
||||
if self.serverCertificatePem.utf8.count > 32768 { throw ContractValidationError(field: "server_certificate_pem", code: "max_length") }
|
||||
try self.clipboardPolicy.validate()
|
||||
}
|
||||
|
||||
public static func decodeJSON(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) }
|
||||
|
||||
Reference in New Issue
Block a user