feat(protocol): add gateway provider session work
This commit is contained in:
+110
-1
@@ -1,7 +1,7 @@
|
||||
// Code generated by tools/generate.py; DO NOT EDIT.
|
||||
import Foundation
|
||||
public typealias JSONObject = [String: String]
|
||||
public let schemaSHA256 = "6b8631bf2b2aa12b14d0bc4d136af39a632e85b3237dc5614469ba09d93f5fca"
|
||||
public let schemaSHA256 = "c075c6fc472ce858337c3ad6c4b2f4dcfa88446d5471afb46c2f6931cbcf1b1d"
|
||||
public let currentWireVersion = "1"
|
||||
public let nMinus1WireVersion = "0"
|
||||
public let nMinus2WireVersion = "-1"
|
||||
@@ -1310,6 +1310,115 @@ public struct PageInfo: Codable, Equatable {
|
||||
public func encodeJSON() throws -> Data { try validate(); return try JSONEncoder().encode(self) }
|
||||
}
|
||||
|
||||
public struct ProviderSessionWork: Codable, Equatable {
|
||||
public let version: String
|
||||
public let sessionId: String
|
||||
public let gatewayId: String
|
||||
public let reconnectSequence: Int64
|
||||
public let expiresAt: String
|
||||
public let providerProfile: String
|
||||
public let providerIdentity: String
|
||||
public let policyVersionId: String
|
||||
public let applicationId: String
|
||||
public let managementHost: String
|
||||
public let managementPort: Int64
|
||||
public let streamHost: String
|
||||
public let streamPort: Int64
|
||||
public let clientCertificatePem: String
|
||||
public let clientPrivateKeyPem: String
|
||||
public let serverCertificatePem: String
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case version = "version"
|
||||
case sessionId = "session_id"
|
||||
case gatewayId = "gateway_id"
|
||||
case reconnectSequence = "reconnect_sequence"
|
||||
case expiresAt = "expires_at"
|
||||
case providerProfile = "provider_profile"
|
||||
case providerIdentity = "provider_identity"
|
||||
case policyVersionId = "policy_version_id"
|
||||
case applicationId = "application_id"
|
||||
case managementHost = "management_host"
|
||||
case managementPort = "management_port"
|
||||
case streamHost = "stream_host"
|
||||
case streamPort = "stream_port"
|
||||
case clientCertificatePem = "client_certificate_pem"
|
||||
case clientPrivateKeyPem = "client_private_key_pem"
|
||||
case serverCertificatePem = "server_certificate_pem"
|
||||
}
|
||||
|
||||
public init(version: String, sessionId: String, gatewayId: String, reconnectSequence: Int64, expiresAt: String, providerProfile: String, providerIdentity: String, policyVersionId: String, applicationId: String, managementHost: String, managementPort: Int64, streamHost: String, streamPort: Int64, clientCertificatePem: String, clientPrivateKeyPem: String, serverCertificatePem: String) throws {
|
||||
self.version = version
|
||||
self.sessionId = sessionId
|
||||
self.gatewayId = gatewayId
|
||||
self.reconnectSequence = reconnectSequence
|
||||
self.expiresAt = expiresAt
|
||||
self.providerProfile = providerProfile
|
||||
self.providerIdentity = providerIdentity
|
||||
self.policyVersionId = policyVersionId
|
||||
self.applicationId = applicationId
|
||||
self.managementHost = managementHost
|
||||
self.managementPort = managementPort
|
||||
self.streamHost = streamHost
|
||||
self.streamPort = streamPort
|
||||
self.clientCertificatePem = clientCertificatePem
|
||||
self.clientPrivateKeyPem = clientPrivateKeyPem
|
||||
self.serverCertificatePem = serverCertificatePem
|
||||
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), 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), 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))
|
||||
}
|
||||
|
||||
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 self.gatewayId.isEmpty { throw ContractValidationError(field: "gateway_id", code: "required") }
|
||||
if !self.gatewayId.isEmpty && self.gatewayId.utf8.count < 1 { throw ContractValidationError(field: "gateway_id", code: "min_length") }
|
||||
if self.gatewayId.utf8.count > 128 { throw ContractValidationError(field: "gateway_id", code: "max_length") }
|
||||
if self.reconnectSequence < 0 { throw ContractValidationError(field: "reconnect_sequence", code: "minimum") }
|
||||
if self.expiresAt.utf8.count > 64 { throw ContractValidationError(field: "expires_at", code: "max_length") }
|
||||
if ISO8601DateFormatter().date(from: self.expiresAt) == nil { throw ContractValidationError(field: "expires_at", code: "invalid_time") }
|
||||
if self.providerProfile != "apollo" { throw ContractValidationError(field: "provider_profile", code: "invalid_value") }
|
||||
if self.providerIdentity.isEmpty { throw ContractValidationError(field: "provider_identity", code: "required") }
|
||||
if !self.providerIdentity.isEmpty && self.providerIdentity.utf8.count < 1 { throw ContractValidationError(field: "provider_identity", code: "min_length") }
|
||||
if self.providerIdentity.utf8.count > 256 { throw ContractValidationError(field: "provider_identity", code: "max_length") }
|
||||
if self.policyVersionId.isEmpty { throw ContractValidationError(field: "policy_version_id", code: "required") }
|
||||
if !self.policyVersionId.isEmpty && self.policyVersionId.utf8.count < 1 { throw ContractValidationError(field: "policy_version_id", code: "min_length") }
|
||||
if self.policyVersionId.utf8.count > 128 { throw ContractValidationError(field: "policy_version_id", code: "max_length") }
|
||||
if self.applicationId.isEmpty { throw ContractValidationError(field: "application_id", code: "required") }
|
||||
if !self.applicationId.isEmpty && self.applicationId.utf8.count < 1 { throw ContractValidationError(field: "application_id", code: "min_length") }
|
||||
if self.applicationId.utf8.count > 128 { throw ContractValidationError(field: "application_id", code: "max_length") }
|
||||
if self.managementHost.isEmpty { throw ContractValidationError(field: "management_host", code: "required") }
|
||||
if !self.managementHost.isEmpty && self.managementHost.utf8.count < 1 { throw ContractValidationError(field: "management_host", code: "min_length") }
|
||||
if self.managementHost.utf8.count > 256 { throw ContractValidationError(field: "management_host", code: "max_length") }
|
||||
if self.managementPort < 1 { throw ContractValidationError(field: "management_port", code: "minimum") }
|
||||
if self.managementPort > 65535 { throw ContractValidationError(field: "management_port", code: "maximum") }
|
||||
if self.streamHost.isEmpty { throw ContractValidationError(field: "stream_host", code: "required") }
|
||||
if !self.streamHost.isEmpty && self.streamHost.utf8.count < 1 { throw ContractValidationError(field: "stream_host", code: "min_length") }
|
||||
if self.streamHost.utf8.count > 256 { throw ContractValidationError(field: "stream_host", code: "max_length") }
|
||||
if self.streamPort < 1 { throw ContractValidationError(field: "stream_port", code: "minimum") }
|
||||
if self.streamPort > 65535 { throw ContractValidationError(field: "stream_port", code: "maximum") }
|
||||
if self.clientCertificatePem.isEmpty { throw ContractValidationError(field: "client_certificate_pem", code: "required") }
|
||||
if !self.clientCertificatePem.isEmpty && self.clientCertificatePem.utf8.count < 1 { throw ContractValidationError(field: "client_certificate_pem", code: "min_length") }
|
||||
if self.clientCertificatePem.utf8.count > 32768 { throw ContractValidationError(field: "client_certificate_pem", code: "max_length") }
|
||||
if self.clientPrivateKeyPem.isEmpty { throw ContractValidationError(field: "client_private_key_pem", code: "required") }
|
||||
if !self.clientPrivateKeyPem.isEmpty && self.clientPrivateKeyPem.utf8.count < 1 { throw ContractValidationError(field: "client_private_key_pem", code: "min_length") }
|
||||
if self.clientPrivateKeyPem.utf8.count > 32768 { throw ContractValidationError(field: "client_private_key_pem", code: "max_length") }
|
||||
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") }
|
||||
}
|
||||
|
||||
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 ProviderState: Codable, Equatable {
|
||||
public let version: String
|
||||
public let sessionId: String
|
||||
|
||||
Reference in New Issue
Block a user