1516 lines
87 KiB
Rust
1516 lines
87 KiB
Rust
// Code generated by tools/generate.py; DO NOT EDIT.
|
|
#![allow(non_snake_case)]
|
|
pub const SCHEMA_SHA256: &str = "c075c6fc472ce858337c3ad6c4b2f4dcfa88446d5471afb46c2f6931cbcf1b1d";
|
|
pub const CURRENT_WIRE_VERSION: &str = "1";
|
|
pub const N_MINUS_1_WIRE_VERSION: &str = "0";
|
|
pub const N_MINUS_2_WIRE_VERSION: &str = "-1";
|
|
pub type JsonObject = std::collections::BTreeMap<String, String>;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ValidationError { pub field: &'static str, pub code: &'static str }
|
|
impl ValidationError { pub const fn new(field: &'static str, code: &'static str) -> Self { Self { field, code } } }
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct AllocationPolicy {
|
|
minimumKbps: i64,
|
|
targetKbps: i64,
|
|
maximumKbps: i64,
|
|
tier: String,
|
|
audience: String,
|
|
protocol: String,
|
|
protocolVersion: i64,
|
|
grantTtlSeconds: i64,
|
|
reservationLeaseSeconds: i64,
|
|
}
|
|
|
|
impl AllocationPolicy {
|
|
pub fn new(minimumKbps: i64, targetKbps: i64, maximumKbps: i64, tier: String, audience: String, protocol: String, protocolVersion: i64, grantTtlSeconds: i64, reservationLeaseSeconds: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { minimumKbps, targetKbps, maximumKbps, tier, audience, protocol, protocolVersion, grantTtlSeconds, reservationLeaseSeconds };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.minimumKbps < 1 { return Err(ValidationError::new("minimum_kbps", "minimum")); }
|
|
if self.minimumKbps > 100000000 { return Err(ValidationError::new("minimum_kbps", "maximum")); }
|
|
if self.targetKbps < 1 { return Err(ValidationError::new("target_kbps", "minimum")); }
|
|
if self.targetKbps > 100000000 { return Err(ValidationError::new("target_kbps", "maximum")); }
|
|
if self.maximumKbps < 1 { return Err(ValidationError::new("maximum_kbps", "minimum")); }
|
|
if self.maximumKbps > 100000000 { return Err(ValidationError::new("maximum_kbps", "maximum")); }
|
|
if self.tier != "standard" && self.tier != "priority" && self.tier != "premium" { return Err(ValidationError::new("tier", "invalid_value")); }
|
|
if self.audience.is_empty() { return Err(ValidationError::new("audience", "required")); }
|
|
if !self.audience.is_empty() && self.audience.len() < 1 { return Err(ValidationError::new("audience", "min_length")); }
|
|
if self.audience.len() > 256 { return Err(ValidationError::new("audience", "max_length")); }
|
|
if self.protocol.is_empty() { return Err(ValidationError::new("protocol", "required")); }
|
|
if !self.protocol.is_empty() && self.protocol.len() < 1 { return Err(ValidationError::new("protocol", "min_length")); }
|
|
if self.protocol.len() > 64 { return Err(ValidationError::new("protocol", "max_length")); }
|
|
if self.protocolVersion < 1 { return Err(ValidationError::new("protocol_version", "minimum")); }
|
|
if self.protocolVersion > 100 { return Err(ValidationError::new("protocol_version", "maximum")); }
|
|
if self.grantTtlSeconds < 5 { return Err(ValidationError::new("grant_ttl_seconds", "minimum")); }
|
|
if self.grantTtlSeconds > 300 { return Err(ValidationError::new("grant_ttl_seconds", "maximum")); }
|
|
if self.reservationLeaseSeconds < 5 { return Err(ValidationError::new("reservation_lease_seconds", "minimum")); }
|
|
if self.reservationLeaseSeconds > 3600 { return Err(ValidationError::new("reservation_lease_seconds", "maximum")); }
|
|
if self.minimumKbps > self.targetKbps || self.targetKbps > self.maximumKbps { return Err(ValidationError::new("bounds", "invalid_order")); }
|
|
Ok(())
|
|
}
|
|
pub fn minimumKbps(&self) -> &i64 { &self.minimumKbps }
|
|
pub fn targetKbps(&self) -> &i64 { &self.targetKbps }
|
|
pub fn maximumKbps(&self) -> &i64 { &self.maximumKbps }
|
|
pub fn tier(&self) -> &String { &self.tier }
|
|
pub fn audience(&self) -> &String { &self.audience }
|
|
pub fn protocol(&self) -> &String { &self.protocol }
|
|
pub fn protocolVersion(&self) -> &i64 { &self.protocolVersion }
|
|
pub fn grantTtlSeconds(&self) -> &i64 { &self.grantTtlSeconds }
|
|
pub fn reservationLeaseSeconds(&self) -> &i64 { &self.reservationLeaseSeconds }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct AssignedDesktop {
|
|
assignmentId: String,
|
|
poolId: String,
|
|
name: String,
|
|
availability: String,
|
|
}
|
|
|
|
impl AssignedDesktop {
|
|
pub fn new(assignmentId: String, poolId: String, name: String, availability: String) -> Result<Self, ValidationError> {
|
|
let value = Self { assignmentId, poolId, name, availability };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.assignmentId.is_empty() { return Err(ValidationError::new("assignment_id", "required")); }
|
|
if !self.assignmentId.is_empty() && self.assignmentId.len() < 1 { return Err(ValidationError::new("assignment_id", "min_length")); }
|
|
if self.assignmentId.len() > 128 { return Err(ValidationError::new("assignment_id", "max_length")); }
|
|
if self.poolId.is_empty() { return Err(ValidationError::new("pool_id", "required")); }
|
|
if !self.poolId.is_empty() && self.poolId.len() < 1 { return Err(ValidationError::new("pool_id", "min_length")); }
|
|
if self.poolId.len() > 128 { return Err(ValidationError::new("pool_id", "max_length")); }
|
|
if self.name.is_empty() { return Err(ValidationError::new("name", "required")); }
|
|
if !self.name.is_empty() && self.name.len() < 1 { return Err(ValidationError::new("name", "min_length")); }
|
|
if self.name.len() > 256 { return Err(ValidationError::new("name", "max_length")); }
|
|
if self.availability.is_empty() { return Err(ValidationError::new("availability", "required")); }
|
|
if !self.availability.is_empty() && self.availability.len() < 1 { return Err(ValidationError::new("availability", "min_length")); }
|
|
if self.availability.len() > 64 { return Err(ValidationError::new("availability", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn assignmentId(&self) -> &String { &self.assignmentId }
|
|
pub fn poolId(&self) -> &String { &self.poolId }
|
|
pub fn name(&self) -> &String { &self.name }
|
|
pub fn availability(&self) -> &String { &self.availability }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct BrokerSession {
|
|
id: String,
|
|
principalId: String,
|
|
poolId: String,
|
|
assignmentId: Option<String>,
|
|
state: String,
|
|
policySnapshot: AllocationPolicy,
|
|
reconnectDeadline: Option<String>,
|
|
outcome: Option<String>,
|
|
failureCode: Option<String>,
|
|
cleanupState: String,
|
|
idempotencyKey: String,
|
|
correlationId: String,
|
|
requestedAt: String,
|
|
endedAt: Option<String>,
|
|
version: i64,
|
|
}
|
|
|
|
impl BrokerSession {
|
|
pub fn new(id: String, principalId: String, poolId: String, assignmentId: Option<String>, state: String, policySnapshot: AllocationPolicy, reconnectDeadline: Option<String>, outcome: Option<String>, failureCode: Option<String>, cleanupState: String, idempotencyKey: String, correlationId: String, requestedAt: String, endedAt: Option<String>, version: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { id, principalId, poolId, assignmentId, state, policySnapshot, reconnectDeadline, outcome, failureCode, cleanupState, idempotencyKey, correlationId, requestedAt, endedAt, version };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.id.is_empty() { return Err(ValidationError::new("id", "required")); }
|
|
if !self.id.is_empty() && self.id.len() < 1 { return Err(ValidationError::new("id", "min_length")); }
|
|
if self.id.len() > 128 { return Err(ValidationError::new("id", "max_length")); }
|
|
if self.principalId.is_empty() { return Err(ValidationError::new("principal_id", "required")); }
|
|
if !self.principalId.is_empty() && self.principalId.len() < 1 { return Err(ValidationError::new("principal_id", "min_length")); }
|
|
if self.principalId.len() > 128 { return Err(ValidationError::new("principal_id", "max_length")); }
|
|
if self.poolId.is_empty() { return Err(ValidationError::new("pool_id", "required")); }
|
|
if !self.poolId.is_empty() && self.poolId.len() < 1 { return Err(ValidationError::new("pool_id", "min_length")); }
|
|
if self.poolId.len() > 128 { return Err(ValidationError::new("pool_id", "max_length")); }
|
|
if let Some(value) = &self.assignmentId {
|
|
if value.len() > 128 { return Err(ValidationError::new("assignment_id", "max_length")); }
|
|
}
|
|
if self.state.is_empty() { return Err(ValidationError::new("state", "required")); }
|
|
if !self.state.is_empty() && self.state.len() < 1 { return Err(ValidationError::new("state", "min_length")); }
|
|
if self.state.len() > 64 { return Err(ValidationError::new("state", "max_length")); }
|
|
self.policySnapshot.validate().map_err(|_| ValidationError::new("policy_snapshot", "invalid_object"))?;
|
|
if let Some(value) = &self.reconnectDeadline {
|
|
if value.len() > 64 { return Err(ValidationError::new("reconnect_deadline", "max_length")); }
|
|
}
|
|
if let Some(value) = &self.outcome {
|
|
if value.len() > 64 { return Err(ValidationError::new("outcome", "max_length")); }
|
|
}
|
|
if let Some(value) = &self.failureCode {
|
|
if value.len() > 128 { return Err(ValidationError::new("failure_code", "max_length")); }
|
|
}
|
|
if self.cleanupState.is_empty() { return Err(ValidationError::new("cleanup_state", "required")); }
|
|
if !self.cleanupState.is_empty() && self.cleanupState.len() < 1 { return Err(ValidationError::new("cleanup_state", "min_length")); }
|
|
if self.cleanupState.len() > 64 { return Err(ValidationError::new("cleanup_state", "max_length")); }
|
|
if self.idempotencyKey.is_empty() { return Err(ValidationError::new("idempotency_key", "required")); }
|
|
if !self.idempotencyKey.is_empty() && self.idempotencyKey.len() < 1 { return Err(ValidationError::new("idempotency_key", "min_length")); }
|
|
if self.idempotencyKey.len() > 256 { return Err(ValidationError::new("idempotency_key", "max_length")); }
|
|
if self.correlationId.is_empty() { return Err(ValidationError::new("correlation_id", "required")); }
|
|
if !self.correlationId.is_empty() && self.correlationId.len() < 1 { return Err(ValidationError::new("correlation_id", "min_length")); }
|
|
if self.correlationId.len() > 128 { return Err(ValidationError::new("correlation_id", "max_length")); }
|
|
if self.requestedAt.len() > 64 { return Err(ValidationError::new("requested_at", "max_length")); }
|
|
if let Some(value) = &self.endedAt {
|
|
if value.len() > 64 { return Err(ValidationError::new("ended_at", "max_length")); }
|
|
}
|
|
if self.version < 1 { return Err(ValidationError::new("version", "minimum")); }
|
|
Ok(())
|
|
}
|
|
pub fn id(&self) -> &String { &self.id }
|
|
pub fn principalId(&self) -> &String { &self.principalId }
|
|
pub fn poolId(&self) -> &String { &self.poolId }
|
|
pub fn assignmentId(&self) -> &Option<String> { &self.assignmentId }
|
|
pub fn state(&self) -> &String { &self.state }
|
|
pub fn policySnapshot(&self) -> &AllocationPolicy { &self.policySnapshot }
|
|
pub fn reconnectDeadline(&self) -> &Option<String> { &self.reconnectDeadline }
|
|
pub fn outcome(&self) -> &Option<String> { &self.outcome }
|
|
pub fn failureCode(&self) -> &Option<String> { &self.failureCode }
|
|
pub fn cleanupState(&self) -> &String { &self.cleanupState }
|
|
pub fn idempotencyKey(&self) -> &String { &self.idempotencyKey }
|
|
pub fn correlationId(&self) -> &String { &self.correlationId }
|
|
pub fn requestedAt(&self) -> &String { &self.requestedAt }
|
|
pub fn endedAt(&self) -> &Option<String> { &self.endedAt }
|
|
pub fn version(&self) -> &i64 { &self.version }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct CapabilityProfile {
|
|
transport: String,
|
|
framing: String,
|
|
media: String,
|
|
audio: String,
|
|
sourceRateControl: String,
|
|
clientDecode: String,
|
|
}
|
|
|
|
impl CapabilityProfile {
|
|
pub fn new(transport: String, framing: String, media: String, audio: String, sourceRateControl: String, clientDecode: String) -> Result<Self, ValidationError> {
|
|
let value = Self { transport, framing, media, audio, sourceRateControl, clientDecode };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.transport.is_empty() { return Err(ValidationError::new("transport", "required")); }
|
|
if !self.transport.is_empty() && self.transport.len() < 1 { return Err(ValidationError::new("transport", "min_length")); }
|
|
if self.transport.len() > 64 { return Err(ValidationError::new("transport", "max_length")); }
|
|
if self.framing.is_empty() { return Err(ValidationError::new("framing", "required")); }
|
|
if !self.framing.is_empty() && self.framing.len() < 1 { return Err(ValidationError::new("framing", "min_length")); }
|
|
if self.framing.len() > 64 { return Err(ValidationError::new("framing", "max_length")); }
|
|
if self.media.is_empty() { return Err(ValidationError::new("media", "required")); }
|
|
if !self.media.is_empty() && self.media.len() < 1 { return Err(ValidationError::new("media", "min_length")); }
|
|
if self.media.len() > 64 { return Err(ValidationError::new("media", "max_length")); }
|
|
if self.audio.is_empty() { return Err(ValidationError::new("audio", "required")); }
|
|
if !self.audio.is_empty() && self.audio.len() < 1 { return Err(ValidationError::new("audio", "min_length")); }
|
|
if self.audio.len() > 64 { return Err(ValidationError::new("audio", "max_length")); }
|
|
if self.sourceRateControl.is_empty() { return Err(ValidationError::new("source_rate_control", "required")); }
|
|
if !self.sourceRateControl.is_empty() && self.sourceRateControl.len() < 1 { return Err(ValidationError::new("source_rate_control", "min_length")); }
|
|
if self.sourceRateControl.len() > 64 { return Err(ValidationError::new("source_rate_control", "max_length")); }
|
|
if self.clientDecode.is_empty() { return Err(ValidationError::new("client_decode", "required")); }
|
|
if !self.clientDecode.is_empty() && self.clientDecode.len() < 1 { return Err(ValidationError::new("client_decode", "min_length")); }
|
|
if self.clientDecode.len() > 64 { return Err(ValidationError::new("client_decode", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn transport(&self) -> &String { &self.transport }
|
|
pub fn framing(&self) -> &String { &self.framing }
|
|
pub fn media(&self) -> &String { &self.media }
|
|
pub fn audio(&self) -> &String { &self.audio }
|
|
pub fn sourceRateControl(&self) -> &String { &self.sourceRateControl }
|
|
pub fn clientDecode(&self) -> &String { &self.clientDecode }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ChannelFrame {
|
|
version: String,
|
|
flowId: String,
|
|
sequence: i64,
|
|
flags: i64,
|
|
fragmentIndex: i64,
|
|
fragmentCount: i64,
|
|
timestampMs: i64,
|
|
payload: String,
|
|
}
|
|
|
|
impl ChannelFrame {
|
|
pub fn new(version: String, flowId: String, sequence: i64, flags: i64, fragmentIndex: i64, fragmentCount: i64, timestampMs: i64, payload: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, flowId, sequence, flags, fragmentIndex, fragmentCount, timestampMs, payload };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.flowId.is_empty() { return Err(ValidationError::new("flow_id", "required")); }
|
|
if !self.flowId.is_empty() && self.flowId.len() < 1 { return Err(ValidationError::new("flow_id", "min_length")); }
|
|
if self.flowId.len() > 64 { return Err(ValidationError::new("flow_id", "max_length")); }
|
|
if self.sequence < 0 { return Err(ValidationError::new("sequence", "minimum")); }
|
|
if self.flags < 0 { return Err(ValidationError::new("flags", "minimum")); }
|
|
if self.flags > 255 { return Err(ValidationError::new("flags", "maximum")); }
|
|
if self.fragmentIndex < 0 { return Err(ValidationError::new("fragment_index", "minimum")); }
|
|
if self.fragmentIndex > 15 { return Err(ValidationError::new("fragment_index", "maximum")); }
|
|
if self.fragmentCount < 1 { return Err(ValidationError::new("fragment_count", "minimum")); }
|
|
if self.fragmentCount > 16 { return Err(ValidationError::new("fragment_count", "maximum")); }
|
|
if self.timestampMs < 0 { return Err(ValidationError::new("timestamp_ms", "minimum")); }
|
|
if self.payload.len() > 87384 { return Err(ValidationError::new("payload", "max_length")); }
|
|
if self.fragmentIndex >= self.fragmentCount { return Err(ValidationError::new("fragment_index", "invalid_order")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn flowId(&self) -> &String { &self.flowId }
|
|
pub fn sequence(&self) -> &i64 { &self.sequence }
|
|
pub fn flags(&self) -> &i64 { &self.flags }
|
|
pub fn fragmentIndex(&self) -> &i64 { &self.fragmentIndex }
|
|
pub fn fragmentCount(&self) -> &i64 { &self.fragmentCount }
|
|
pub fn timestampMs(&self) -> &i64 { &self.timestampMs }
|
|
pub fn payload(&self) -> &String { &self.payload }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ClipboardText {
|
|
text: String,
|
|
encoding: String,
|
|
}
|
|
|
|
impl ClipboardText {
|
|
pub fn new(text: String, encoding: String) -> Result<Self, ValidationError> {
|
|
let value = Self { text, encoding };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.text.len() > 65536 { return Err(ValidationError::new("text", "max_length")); }
|
|
if self.encoding != "utf-8" { return Err(ValidationError::new("encoding", "invalid_value")); }
|
|
Ok(())
|
|
}
|
|
pub fn text(&self) -> &String { &self.text }
|
|
pub fn encoding(&self) -> &String { &self.encoding }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ConnectionManifest {
|
|
version: String,
|
|
purpose: String,
|
|
sessionId: String,
|
|
reconnectSequence: i64,
|
|
gateway: ManifestGateway,
|
|
tunnel: ManifestTunnel,
|
|
profile: ManifestProfile,
|
|
grant: GrantReference,
|
|
correlationId: String,
|
|
}
|
|
|
|
impl ConnectionManifest {
|
|
pub fn new(version: String, purpose: String, sessionId: String, reconnectSequence: i64, gateway: ManifestGateway, tunnel: ManifestTunnel, profile: ManifestProfile, grant: GrantReference, correlationId: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, purpose, sessionId, reconnectSequence, gateway, tunnel, profile, grant, correlationId };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.purpose != "launch" && self.purpose != "reconnect" { return Err(ValidationError::new("purpose", "invalid_value")); }
|
|
if self.sessionId.is_empty() { return Err(ValidationError::new("session_id", "required")); }
|
|
if !self.sessionId.is_empty() && self.sessionId.len() < 1 { return Err(ValidationError::new("session_id", "min_length")); }
|
|
if self.sessionId.len() > 128 { return Err(ValidationError::new("session_id", "max_length")); }
|
|
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
|
self.gateway.validate().map_err(|_| ValidationError::new("gateway", "invalid_object"))?;
|
|
self.tunnel.validate().map_err(|_| ValidationError::new("tunnel", "invalid_object"))?;
|
|
self.profile.validate().map_err(|_| ValidationError::new("profile", "invalid_object"))?;
|
|
self.grant.validate().map_err(|_| ValidationError::new("grant", "invalid_object"))?;
|
|
if self.correlationId.is_empty() { return Err(ValidationError::new("correlation_id", "required")); }
|
|
if !self.correlationId.is_empty() && self.correlationId.len() < 1 { return Err(ValidationError::new("correlation_id", "min_length")); }
|
|
if self.correlationId.len() > 128 { return Err(ValidationError::new("correlation_id", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn purpose(&self) -> &String { &self.purpose }
|
|
pub fn sessionId(&self) -> &String { &self.sessionId }
|
|
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
|
pub fn gateway(&self) -> &ManifestGateway { &self.gateway }
|
|
pub fn tunnel(&self) -> &ManifestTunnel { &self.tunnel }
|
|
pub fn profile(&self) -> &ManifestProfile { &self.profile }
|
|
pub fn grant(&self) -> &GrantReference { &self.grant }
|
|
pub fn correlationId(&self) -> &String { &self.correlationId }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct DeviceChallenge {
|
|
deviceId: String,
|
|
serverId: String,
|
|
principalId: String,
|
|
challenge: String,
|
|
expiresAt: String,
|
|
algorithm: String,
|
|
signatureFormat: String,
|
|
}
|
|
|
|
impl DeviceChallenge {
|
|
pub fn new(deviceId: String, serverId: String, principalId: String, challenge: String, expiresAt: String, algorithm: String, signatureFormat: String) -> Result<Self, ValidationError> {
|
|
let value = Self { deviceId, serverId, principalId, challenge, expiresAt, algorithm, signatureFormat };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.deviceId.is_empty() { return Err(ValidationError::new("device_id", "required")); }
|
|
if !self.deviceId.is_empty() && self.deviceId.len() < 1 { return Err(ValidationError::new("device_id", "min_length")); }
|
|
if self.deviceId.len() > 128 { return Err(ValidationError::new("device_id", "max_length")); }
|
|
if self.serverId.is_empty() { return Err(ValidationError::new("server_id", "required")); }
|
|
if !self.serverId.is_empty() && self.serverId.len() < 1 { return Err(ValidationError::new("server_id", "min_length")); }
|
|
if self.serverId.len() > 128 { return Err(ValidationError::new("server_id", "max_length")); }
|
|
if self.principalId.is_empty() { return Err(ValidationError::new("principal_id", "required")); }
|
|
if !self.principalId.is_empty() && self.principalId.len() < 1 { return Err(ValidationError::new("principal_id", "min_length")); }
|
|
if self.principalId.len() > 128 { return Err(ValidationError::new("principal_id", "max_length")); }
|
|
if self.challenge.is_empty() { return Err(ValidationError::new("challenge", "required")); }
|
|
if !self.challenge.is_empty() && self.challenge.len() < 1 { return Err(ValidationError::new("challenge", "min_length")); }
|
|
if self.challenge.len() > 256 { return Err(ValidationError::new("challenge", "max_length")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
if self.algorithm != "ed25519" { return Err(ValidationError::new("algorithm", "invalid_value")); }
|
|
if self.signatureFormat != "ed25519-domain-separated-v1" { return Err(ValidationError::new("signature_format", "invalid_value")); }
|
|
Ok(())
|
|
}
|
|
pub fn deviceId(&self) -> &String { &self.deviceId }
|
|
pub fn serverId(&self) -> &String { &self.serverId }
|
|
pub fn principalId(&self) -> &String { &self.principalId }
|
|
pub fn challenge(&self) -> &String { &self.challenge }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
pub fn algorithm(&self) -> &String { &self.algorithm }
|
|
pub fn signatureFormat(&self) -> &String { &self.signatureFormat }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct DeviceProofRequest {
|
|
challenge: String,
|
|
signature: String,
|
|
}
|
|
|
|
impl DeviceProofRequest {
|
|
pub fn new(challenge: String, signature: String) -> Result<Self, ValidationError> {
|
|
let value = Self { challenge, signature };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.challenge.is_empty() { return Err(ValidationError::new("challenge", "required")); }
|
|
if !self.challenge.is_empty() && self.challenge.len() < 1 { return Err(ValidationError::new("challenge", "min_length")); }
|
|
if self.challenge.len() > 256 { return Err(ValidationError::new("challenge", "max_length")); }
|
|
if self.signature.is_empty() { return Err(ValidationError::new("signature", "required")); }
|
|
if !self.signature.is_empty() && self.signature.len() < 1 { return Err(ValidationError::new("signature", "min_length")); }
|
|
if self.signature.len() > 256 { return Err(ValidationError::new("signature", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn challenge(&self) -> &String { &self.challenge }
|
|
pub fn signature(&self) -> &String { &self.signature }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct DeviceRegistrationRequest {
|
|
name: String,
|
|
platform: String,
|
|
deviceSubject: String,
|
|
algorithm: String,
|
|
publicKey: String,
|
|
}
|
|
|
|
impl DeviceRegistrationRequest {
|
|
pub fn new(name: String, platform: String, deviceSubject: String, algorithm: String, publicKey: String) -> Result<Self, ValidationError> {
|
|
let value = Self { name, platform, deviceSubject, algorithm, publicKey };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.name.is_empty() { return Err(ValidationError::new("name", "required")); }
|
|
if !self.name.is_empty() && self.name.len() < 1 { return Err(ValidationError::new("name", "min_length")); }
|
|
if self.name.len() > 128 { return Err(ValidationError::new("name", "max_length")); }
|
|
if self.platform.is_empty() { return Err(ValidationError::new("platform", "required")); }
|
|
if !self.platform.is_empty() && self.platform.len() < 1 { return Err(ValidationError::new("platform", "min_length")); }
|
|
if self.platform.len() > 64 { return Err(ValidationError::new("platform", "max_length")); }
|
|
if self.deviceSubject.is_empty() { return Err(ValidationError::new("device_subject", "required")); }
|
|
if !self.deviceSubject.is_empty() && self.deviceSubject.len() < 1 { return Err(ValidationError::new("device_subject", "min_length")); }
|
|
if self.deviceSubject.len() > 256 { return Err(ValidationError::new("device_subject", "max_length")); }
|
|
if self.algorithm != "ed25519" { return Err(ValidationError::new("algorithm", "invalid_value")); }
|
|
if self.publicKey.is_empty() { return Err(ValidationError::new("public_key", "required")); }
|
|
if !self.publicKey.is_empty() && self.publicKey.len() < 1 { return Err(ValidationError::new("public_key", "min_length")); }
|
|
if self.publicKey.len() > 256 { return Err(ValidationError::new("public_key", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn name(&self) -> &String { &self.name }
|
|
pub fn platform(&self) -> &String { &self.platform }
|
|
pub fn deviceSubject(&self) -> &String { &self.deviceSubject }
|
|
pub fn algorithm(&self) -> &String { &self.algorithm }
|
|
pub fn publicKey(&self) -> &String { &self.publicKey }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct EntitledPool {
|
|
poolId: String,
|
|
name: String,
|
|
assignmentState: String,
|
|
}
|
|
|
|
impl EntitledPool {
|
|
pub fn new(poolId: String, name: String, assignmentState: String) -> Result<Self, ValidationError> {
|
|
let value = Self { poolId, name, assignmentState };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.poolId.is_empty() { return Err(ValidationError::new("pool_id", "required")); }
|
|
if !self.poolId.is_empty() && self.poolId.len() < 1 { return Err(ValidationError::new("pool_id", "min_length")); }
|
|
if self.poolId.len() > 128 { return Err(ValidationError::new("pool_id", "max_length")); }
|
|
if self.name.is_empty() { return Err(ValidationError::new("name", "required")); }
|
|
if !self.name.is_empty() && self.name.len() < 1 { return Err(ValidationError::new("name", "min_length")); }
|
|
if self.name.len() > 256 { return Err(ValidationError::new("name", "max_length")); }
|
|
if self.assignmentState.is_empty() { return Err(ValidationError::new("assignment_state", "required")); }
|
|
if !self.assignmentState.is_empty() && self.assignmentState.len() < 1 { return Err(ValidationError::new("assignment_state", "min_length")); }
|
|
if self.assignmentState.len() > 64 { return Err(ValidationError::new("assignment_state", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn poolId(&self) -> &String { &self.poolId }
|
|
pub fn name(&self) -> &String { &self.name }
|
|
pub fn assignmentState(&self) -> &String { &self.assignmentState }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ErrorEnvelope {
|
|
status: bool,
|
|
error: String,
|
|
code: String,
|
|
message: String,
|
|
resolution: String,
|
|
requestId: String,
|
|
violations: Vec<FieldViolation>,
|
|
}
|
|
|
|
impl ErrorEnvelope {
|
|
pub fn new(status: bool, error: String, code: String, message: String, resolution: String, requestId: String, violations: Vec<FieldViolation>) -> Result<Self, ValidationError> {
|
|
let value = Self { status, error, code, message, resolution, requestId, violations };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.error.is_empty() { return Err(ValidationError::new("error", "required")); }
|
|
if !self.error.is_empty() && self.error.len() < 1 { return Err(ValidationError::new("error", "min_length")); }
|
|
if self.error.len() > 512 { return Err(ValidationError::new("error", "max_length")); }
|
|
if self.code.is_empty() { return Err(ValidationError::new("code", "required")); }
|
|
if !self.code.is_empty() && self.code.len() < 1 { return Err(ValidationError::new("code", "min_length")); }
|
|
if self.code.len() > 128 { return Err(ValidationError::new("code", "max_length")); }
|
|
if self.message.is_empty() { return Err(ValidationError::new("message", "required")); }
|
|
if !self.message.is_empty() && self.message.len() < 1 { return Err(ValidationError::new("message", "min_length")); }
|
|
if self.message.len() > 512 { return Err(ValidationError::new("message", "max_length")); }
|
|
if self.resolution.is_empty() { return Err(ValidationError::new("resolution", "required")); }
|
|
if !self.resolution.is_empty() && self.resolution.len() < 1 { return Err(ValidationError::new("resolution", "min_length")); }
|
|
if self.resolution.len() > 128 { return Err(ValidationError::new("resolution", "max_length")); }
|
|
if self.requestId.is_empty() { return Err(ValidationError::new("request_id", "required")); }
|
|
if !self.requestId.is_empty() && self.requestId.len() < 1 { return Err(ValidationError::new("request_id", "min_length")); }
|
|
if self.requestId.len() > 128 { return Err(ValidationError::new("request_id", "max_length")); }
|
|
if self.violations.len() > 16 { return Err(ValidationError::new("violations", "max_items")); }
|
|
for item in self.violations.iter() { item.validate().map_err(|_| ValidationError::new("violations", "invalid_item"))?; }
|
|
Ok(())
|
|
}
|
|
pub fn status(&self) -> &bool { &self.status }
|
|
pub fn error(&self) -> &String { &self.error }
|
|
pub fn code(&self) -> &String { &self.code }
|
|
pub fn message(&self) -> &String { &self.message }
|
|
pub fn resolution(&self) -> &String { &self.resolution }
|
|
pub fn requestId(&self) -> &String { &self.requestId }
|
|
pub fn violations(&self) -> &Vec<FieldViolation> { &self.violations }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct EventEnvelope {
|
|
eventId: String,
|
|
sequence: i64,
|
|
typeValue: String,
|
|
version: i64,
|
|
resource: ResourceLink,
|
|
occurredAt: String,
|
|
correlationId: String,
|
|
payload: JsonObject,
|
|
}
|
|
|
|
impl EventEnvelope {
|
|
pub fn new(eventId: String, sequence: i64, typeValue: String, version: i64, resource: ResourceLink, occurredAt: String, correlationId: String, payload: JsonObject) -> Result<Self, ValidationError> {
|
|
let value = Self { eventId, sequence, typeValue, version, resource, occurredAt, correlationId, payload };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.eventId.is_empty() { return Err(ValidationError::new("event_id", "required")); }
|
|
if !self.eventId.is_empty() && self.eventId.len() < 1 { return Err(ValidationError::new("event_id", "min_length")); }
|
|
if self.eventId.len() > 128 { return Err(ValidationError::new("event_id", "max_length")); }
|
|
if self.sequence < 1 { return Err(ValidationError::new("sequence", "minimum")); }
|
|
if self.typeValue.is_empty() { return Err(ValidationError::new("type", "required")); }
|
|
if !self.typeValue.is_empty() && self.typeValue.len() < 1 { return Err(ValidationError::new("type", "min_length")); }
|
|
if self.typeValue.len() > 128 { return Err(ValidationError::new("type", "max_length")); }
|
|
if self.version < 1 { return Err(ValidationError::new("version", "minimum")); }
|
|
self.resource.validate().map_err(|_| ValidationError::new("resource", "invalid_object"))?;
|
|
if self.occurredAt.len() > 64 { return Err(ValidationError::new("occurred_at", "max_length")); }
|
|
if self.correlationId.is_empty() { return Err(ValidationError::new("correlation_id", "required")); }
|
|
if !self.correlationId.is_empty() && self.correlationId.len() < 1 { return Err(ValidationError::new("correlation_id", "min_length")); }
|
|
if self.correlationId.len() > 128 { return Err(ValidationError::new("correlation_id", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn eventId(&self) -> &String { &self.eventId }
|
|
pub fn sequence(&self) -> &i64 { &self.sequence }
|
|
pub fn typeValue(&self) -> &String { &self.typeValue }
|
|
pub fn version(&self) -> &i64 { &self.version }
|
|
pub fn resource(&self) -> &ResourceLink { &self.resource }
|
|
pub fn occurredAt(&self) -> &String { &self.occurredAt }
|
|
pub fn correlationId(&self) -> &String { &self.correlationId }
|
|
pub fn payload(&self) -> &JsonObject { &self.payload }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct EventResume {
|
|
cursor: String,
|
|
lastSequence: i64,
|
|
}
|
|
|
|
impl EventResume {
|
|
pub fn new(cursor: String, lastSequence: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { cursor, lastSequence };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.cursor.len() > 512 { return Err(ValidationError::new("cursor", "max_length")); }
|
|
if self.lastSequence < 0 { return Err(ValidationError::new("last_sequence", "minimum")); }
|
|
Ok(())
|
|
}
|
|
pub fn cursor(&self) -> &String { &self.cursor }
|
|
pub fn lastSequence(&self) -> &i64 { &self.lastSequence }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct FieldViolation {
|
|
field: String,
|
|
code: String,
|
|
}
|
|
|
|
impl FieldViolation {
|
|
pub fn new(field: String, code: String) -> Result<Self, ValidationError> {
|
|
let value = Self { field, code };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.field.is_empty() { return Err(ValidationError::new("field", "required")); }
|
|
if !self.field.is_empty() && self.field.len() < 1 { return Err(ValidationError::new("field", "min_length")); }
|
|
if self.field.len() > 128 { return Err(ValidationError::new("field", "max_length")); }
|
|
if self.code.is_empty() { return Err(ValidationError::new("code", "required")); }
|
|
if !self.code.is_empty() && self.code.len() < 1 { return Err(ValidationError::new("code", "min_length")); }
|
|
if self.code.len() > 64 { return Err(ValidationError::new("code", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn field(&self) -> &String { &self.field }
|
|
pub fn code(&self) -> &String { &self.code }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct GatewayDrain {
|
|
version: String,
|
|
gatewayId: String,
|
|
sequence: i64,
|
|
reason: String,
|
|
deadline: String,
|
|
}
|
|
|
|
impl GatewayDrain {
|
|
pub fn new(version: String, gatewayId: String, sequence: i64, reason: String, deadline: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, gatewayId, sequence, reason, deadline };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.sequence < 1 { return Err(ValidationError::new("sequence", "minimum")); }
|
|
if self.reason.is_empty() { return Err(ValidationError::new("reason", "required")); }
|
|
if !self.reason.is_empty() && self.reason.len() < 1 { return Err(ValidationError::new("reason", "min_length")); }
|
|
if self.reason.len() > 256 { return Err(ValidationError::new("reason", "max_length")); }
|
|
if self.deadline.len() > 64 { return Err(ValidationError::new("deadline", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn sequence(&self) -> &i64 { &self.sequence }
|
|
pub fn reason(&self) -> &String { &self.reason }
|
|
pub fn deadline(&self) -> &String { &self.deadline }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct GatewayHeartbeat {
|
|
version: String,
|
|
gatewayId: String,
|
|
sequence: i64,
|
|
observedAt: String,
|
|
activeConnections: i64,
|
|
egressKbps: i64,
|
|
state: String,
|
|
}
|
|
|
|
impl GatewayHeartbeat {
|
|
pub fn new(version: String, gatewayId: String, sequence: i64, observedAt: String, activeConnections: i64, egressKbps: i64, state: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, gatewayId, sequence, observedAt, activeConnections, egressKbps, state };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.sequence < 1 { return Err(ValidationError::new("sequence", "minimum")); }
|
|
if self.observedAt.len() > 64 { return Err(ValidationError::new("observed_at", "max_length")); }
|
|
if self.activeConnections < 0 { return Err(ValidationError::new("active_connections", "minimum")); }
|
|
if self.activeConnections > 1000000 { return Err(ValidationError::new("active_connections", "maximum")); }
|
|
if self.egressKbps < 0 { return Err(ValidationError::new("egress_kbps", "minimum")); }
|
|
if self.egressKbps > 1000000000 { return Err(ValidationError::new("egress_kbps", "maximum")); }
|
|
if self.state != "ready" && self.state != "draining" && self.state != "offline" { return Err(ValidationError::new("state", "invalid_value")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn sequence(&self) -> &i64 { &self.sequence }
|
|
pub fn observedAt(&self) -> &String { &self.observedAt }
|
|
pub fn activeConnections(&self) -> &i64 { &self.activeConnections }
|
|
pub fn egressKbps(&self) -> &i64 { &self.egressKbps }
|
|
pub fn state(&self) -> &String { &self.state }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct GatewayRegistration {
|
|
version: String,
|
|
gatewayId: String,
|
|
instanceIdentity: String,
|
|
certificateIdentity: String,
|
|
publicIdentity: String,
|
|
address: String,
|
|
providerIdentity: String,
|
|
protocolMinVersion: i64,
|
|
protocolMaxVersion: i64,
|
|
connectionCapacity: i64,
|
|
bandwidthCapacityKbps: i64,
|
|
features: Vec<String>,
|
|
capabilities: CapabilityProfile,
|
|
}
|
|
|
|
impl GatewayRegistration {
|
|
pub fn new(version: String, gatewayId: String, instanceIdentity: String, certificateIdentity: String, publicIdentity: String, address: String, providerIdentity: String, protocolMinVersion: i64, protocolMaxVersion: i64, connectionCapacity: i64, bandwidthCapacityKbps: i64, features: Vec<String>, capabilities: CapabilityProfile) -> Result<Self, ValidationError> {
|
|
let value = Self { version, gatewayId, instanceIdentity, certificateIdentity, publicIdentity, address, providerIdentity, protocolMinVersion, protocolMaxVersion, connectionCapacity, bandwidthCapacityKbps, features, capabilities };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.instanceIdentity.is_empty() { return Err(ValidationError::new("instance_identity", "required")); }
|
|
if !self.instanceIdentity.is_empty() && self.instanceIdentity.len() < 1 { return Err(ValidationError::new("instance_identity", "min_length")); }
|
|
if self.instanceIdentity.len() > 512 { return Err(ValidationError::new("instance_identity", "max_length")); }
|
|
if self.certificateIdentity.is_empty() { return Err(ValidationError::new("certificate_identity", "required")); }
|
|
if !self.certificateIdentity.is_empty() && self.certificateIdentity.len() < 1 { return Err(ValidationError::new("certificate_identity", "min_length")); }
|
|
if self.certificateIdentity.len() > 512 { return Err(ValidationError::new("certificate_identity", "max_length")); }
|
|
if self.publicIdentity.is_empty() { return Err(ValidationError::new("public_identity", "required")); }
|
|
if !self.publicIdentity.is_empty() && self.publicIdentity.len() < 1 { return Err(ValidationError::new("public_identity", "min_length")); }
|
|
if self.publicIdentity.len() > 256 { return Err(ValidationError::new("public_identity", "max_length")); }
|
|
if self.address.is_empty() { return Err(ValidationError::new("address", "required")); }
|
|
if !self.address.is_empty() && self.address.len() < 1 { return Err(ValidationError::new("address", "min_length")); }
|
|
if self.address.len() > 256 { return Err(ValidationError::new("address", "max_length")); }
|
|
if self.providerIdentity.is_empty() { return Err(ValidationError::new("provider_identity", "required")); }
|
|
if !self.providerIdentity.is_empty() && self.providerIdentity.len() < 1 { return Err(ValidationError::new("provider_identity", "min_length")); }
|
|
if self.providerIdentity.len() > 256 { return Err(ValidationError::new("provider_identity", "max_length")); }
|
|
if self.protocolMinVersion < 1 { return Err(ValidationError::new("protocol_min_version", "minimum")); }
|
|
if self.protocolMinVersion > 100 { return Err(ValidationError::new("protocol_min_version", "maximum")); }
|
|
if self.protocolMaxVersion < 1 { return Err(ValidationError::new("protocol_max_version", "minimum")); }
|
|
if self.protocolMaxVersion > 100 { return Err(ValidationError::new("protocol_max_version", "maximum")); }
|
|
if self.connectionCapacity < 1 { return Err(ValidationError::new("connection_capacity", "minimum")); }
|
|
if self.connectionCapacity > 1000000 { return Err(ValidationError::new("connection_capacity", "maximum")); }
|
|
if self.bandwidthCapacityKbps < 1 { return Err(ValidationError::new("bandwidth_capacity_kbps", "minimum")); }
|
|
if self.bandwidthCapacityKbps > 1000000000 { return Err(ValidationError::new("bandwidth_capacity_kbps", "maximum")); }
|
|
if self.features.len() > 64 { return Err(ValidationError::new("features", "max_items")); }
|
|
self.capabilities.validate().map_err(|_| ValidationError::new("capabilities", "invalid_object"))?;
|
|
if self.protocolMinVersion > self.protocolMaxVersion { return Err(ValidationError::new("protocol_version", "invalid_order")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn instanceIdentity(&self) -> &String { &self.instanceIdentity }
|
|
pub fn certificateIdentity(&self) -> &String { &self.certificateIdentity }
|
|
pub fn publicIdentity(&self) -> &String { &self.publicIdentity }
|
|
pub fn address(&self) -> &String { &self.address }
|
|
pub fn providerIdentity(&self) -> &String { &self.providerIdentity }
|
|
pub fn protocolMinVersion(&self) -> &i64 { &self.protocolMinVersion }
|
|
pub fn protocolMaxVersion(&self) -> &i64 { &self.protocolMaxVersion }
|
|
pub fn connectionCapacity(&self) -> &i64 { &self.connectionCapacity }
|
|
pub fn bandwidthCapacityKbps(&self) -> &i64 { &self.bandwidthCapacityKbps }
|
|
pub fn features(&self) -> &Vec<String> { &self.features }
|
|
pub fn capabilities(&self) -> &CapabilityProfile { &self.capabilities }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct GrantReference {
|
|
opaqueValue: String,
|
|
expiresAt: String,
|
|
audience: String,
|
|
}
|
|
|
|
impl GrantReference {
|
|
pub fn new(opaqueValue: String, expiresAt: String, audience: String) -> Result<Self, ValidationError> {
|
|
let value = Self { opaqueValue, expiresAt, audience };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.opaqueValue.is_empty() { return Err(ValidationError::new("opaque_value", "required")); }
|
|
if !self.opaqueValue.is_empty() && self.opaqueValue.len() < 43 { return Err(ValidationError::new("opaque_value", "min_length")); }
|
|
if self.opaqueValue.len() > 256 { return Err(ValidationError::new("opaque_value", "max_length")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
if self.audience.is_empty() { return Err(ValidationError::new("audience", "required")); }
|
|
if !self.audience.is_empty() && self.audience.len() < 1 { return Err(ValidationError::new("audience", "min_length")); }
|
|
if self.audience.len() > 128 { return Err(ValidationError::new("audience", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn opaqueValue(&self) -> &String { &self.opaqueValue }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
pub fn audience(&self) -> &String { &self.audience }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct LoginRequest {
|
|
provider: Option<String>,
|
|
username: String,
|
|
password: String,
|
|
}
|
|
|
|
impl LoginRequest {
|
|
pub fn new(provider: Option<String>, username: String, password: String) -> Result<Self, ValidationError> {
|
|
let value = Self { provider, username, password };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if let Some(value) = &self.provider {
|
|
if value != "ldap" && value != "local" { return Err(ValidationError::new("provider", "invalid_value")); }
|
|
}
|
|
if self.username.is_empty() { return Err(ValidationError::new("username", "required")); }
|
|
if !self.username.is_empty() && self.username.len() < 1 { return Err(ValidationError::new("username", "min_length")); }
|
|
if self.username.len() > 256 { return Err(ValidationError::new("username", "max_length")); }
|
|
if self.password.is_empty() { return Err(ValidationError::new("password", "required")); }
|
|
if !self.password.is_empty() && self.password.len() < 1 { return Err(ValidationError::new("password", "min_length")); }
|
|
if self.password.len() > 1024 { return Err(ValidationError::new("password", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn provider(&self) -> &Option<String> { &self.provider }
|
|
pub fn username(&self) -> &String { &self.username }
|
|
pub fn password(&self) -> &String { &self.password }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ManifestBounds {
|
|
minimumKbps: i64,
|
|
targetKbps: i64,
|
|
maximumKbps: i64,
|
|
}
|
|
|
|
impl ManifestBounds {
|
|
pub fn new(minimumKbps: i64, targetKbps: i64, maximumKbps: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { minimumKbps, targetKbps, maximumKbps };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.minimumKbps < 1 { return Err(ValidationError::new("minimum_kbps", "minimum")); }
|
|
if self.minimumKbps > 100000000 { return Err(ValidationError::new("minimum_kbps", "maximum")); }
|
|
if self.targetKbps < 1 { return Err(ValidationError::new("target_kbps", "minimum")); }
|
|
if self.targetKbps > 100000000 { return Err(ValidationError::new("target_kbps", "maximum")); }
|
|
if self.maximumKbps < 1 { return Err(ValidationError::new("maximum_kbps", "minimum")); }
|
|
if self.maximumKbps > 100000000 { return Err(ValidationError::new("maximum_kbps", "maximum")); }
|
|
if self.minimumKbps > self.targetKbps || self.targetKbps > self.maximumKbps { return Err(ValidationError::new("bounds", "invalid_order")); }
|
|
Ok(())
|
|
}
|
|
pub fn minimumKbps(&self) -> &i64 { &self.minimumKbps }
|
|
pub fn targetKbps(&self) -> &i64 { &self.targetKbps }
|
|
pub fn maximumKbps(&self) -> &i64 { &self.maximumKbps }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ManifestGateway {
|
|
id: String,
|
|
addresses: Vec<String>,
|
|
publicIdentity: String,
|
|
}
|
|
|
|
impl ManifestGateway {
|
|
pub fn new(id: String, addresses: Vec<String>, publicIdentity: String) -> Result<Self, ValidationError> {
|
|
let value = Self { id, addresses, publicIdentity };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.id.is_empty() { return Err(ValidationError::new("id", "required")); }
|
|
if !self.id.is_empty() && self.id.len() < 1 { return Err(ValidationError::new("id", "min_length")); }
|
|
if self.id.len() > 128 { return Err(ValidationError::new("id", "max_length")); }
|
|
if self.addresses.len() < 1 { return Err(ValidationError::new("addresses", "min_items")); }
|
|
if self.addresses.len() > 4 { return Err(ValidationError::new("addresses", "max_items")); }
|
|
if self.publicIdentity.is_empty() { return Err(ValidationError::new("public_identity", "required")); }
|
|
if !self.publicIdentity.is_empty() && self.publicIdentity.len() < 1 { return Err(ValidationError::new("public_identity", "min_length")); }
|
|
if self.publicIdentity.len() > 256 { return Err(ValidationError::new("public_identity", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn id(&self) -> &String { &self.id }
|
|
pub fn addresses(&self) -> &Vec<String> { &self.addresses }
|
|
pub fn publicIdentity(&self) -> &String { &self.publicIdentity }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ManifestProfile {
|
|
id: String,
|
|
bounds: ManifestBounds,
|
|
}
|
|
|
|
impl ManifestProfile {
|
|
pub fn new(id: String, bounds: ManifestBounds) -> Result<Self, ValidationError> {
|
|
let value = Self { id, bounds };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.id.is_empty() { return Err(ValidationError::new("id", "required")); }
|
|
if !self.id.is_empty() && self.id.len() < 1 { return Err(ValidationError::new("id", "min_length")); }
|
|
if self.id.len() > 128 { return Err(ValidationError::new("id", "max_length")); }
|
|
self.bounds.validate().map_err(|_| ValidationError::new("bounds", "invalid_object"))?;
|
|
Ok(())
|
|
}
|
|
pub fn id(&self) -> &String { &self.id }
|
|
pub fn bounds(&self) -> &ManifestBounds { &self.bounds }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ManifestTunnel {
|
|
versions: Vec<String>,
|
|
features: Vec<String>,
|
|
}
|
|
|
|
impl ManifestTunnel {
|
|
pub fn new(versions: Vec<String>, features: Vec<String>) -> Result<Self, ValidationError> {
|
|
let value = Self { versions, features };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.versions.len() < 1 { return Err(ValidationError::new("versions", "min_items")); }
|
|
if self.versions.len() > 4 { return Err(ValidationError::new("versions", "max_items")); }
|
|
if self.features.len() > 32 { return Err(ValidationError::new("features", "max_items")); }
|
|
Ok(())
|
|
}
|
|
pub fn versions(&self) -> &Vec<String> { &self.versions }
|
|
pub fn features(&self) -> &Vec<String> { &self.features }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct NativeCredential {
|
|
deviceId: Option<String>,
|
|
familyId: String,
|
|
accessToken: String,
|
|
refreshToken: String,
|
|
expiresAt: String,
|
|
refreshExpiresAt: Option<String>,
|
|
}
|
|
|
|
impl NativeCredential {
|
|
pub fn new(deviceId: Option<String>, familyId: String, accessToken: String, refreshToken: String, expiresAt: String, refreshExpiresAt: Option<String>) -> Result<Self, ValidationError> {
|
|
let value = Self { deviceId, familyId, accessToken, refreshToken, expiresAt, refreshExpiresAt };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if let Some(value) = &self.deviceId {
|
|
if value.len() > 128 { return Err(ValidationError::new("device_id", "max_length")); }
|
|
}
|
|
if self.familyId.is_empty() { return Err(ValidationError::new("family_id", "required")); }
|
|
if !self.familyId.is_empty() && self.familyId.len() < 1 { return Err(ValidationError::new("family_id", "min_length")); }
|
|
if self.familyId.len() > 128 { return Err(ValidationError::new("family_id", "max_length")); }
|
|
if self.accessToken.is_empty() { return Err(ValidationError::new("access_token", "required")); }
|
|
if !self.accessToken.is_empty() && self.accessToken.len() < 1 { return Err(ValidationError::new("access_token", "min_length")); }
|
|
if self.accessToken.len() > 256 { return Err(ValidationError::new("access_token", "max_length")); }
|
|
if self.refreshToken.is_empty() { return Err(ValidationError::new("refresh_token", "required")); }
|
|
if !self.refreshToken.is_empty() && self.refreshToken.len() < 1 { return Err(ValidationError::new("refresh_token", "min_length")); }
|
|
if self.refreshToken.len() > 256 { return Err(ValidationError::new("refresh_token", "max_length")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
if let Some(value) = &self.refreshExpiresAt {
|
|
if value.len() > 64 { return Err(ValidationError::new("refresh_expires_at", "max_length")); }
|
|
}
|
|
Ok(())
|
|
}
|
|
pub fn deviceId(&self) -> &Option<String> { &self.deviceId }
|
|
pub fn familyId(&self) -> &String { &self.familyId }
|
|
pub fn accessToken(&self) -> &String { &self.accessToken }
|
|
pub fn refreshToken(&self) -> &String { &self.refreshToken }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
pub fn refreshExpiresAt(&self) -> &Option<String> { &self.refreshExpiresAt }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct PageInfo {
|
|
limit: i64,
|
|
nextCursor: String,
|
|
}
|
|
|
|
impl PageInfo {
|
|
pub fn new(limit: i64, nextCursor: String) -> Result<Self, ValidationError> {
|
|
let value = Self { limit, nextCursor };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.limit < 1 { return Err(ValidationError::new("limit", "minimum")); }
|
|
if self.limit > 100 { return Err(ValidationError::new("limit", "maximum")); }
|
|
if self.nextCursor.len() > 512 { return Err(ValidationError::new("next_cursor", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn limit(&self) -> &i64 { &self.limit }
|
|
pub fn nextCursor(&self) -> &String { &self.nextCursor }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ProviderSessionWork {
|
|
version: String,
|
|
sessionId: String,
|
|
gatewayId: String,
|
|
reconnectSequence: i64,
|
|
expiresAt: String,
|
|
providerProfile: String,
|
|
providerIdentity: String,
|
|
policyVersionId: String,
|
|
applicationId: String,
|
|
managementHost: String,
|
|
managementPort: i64,
|
|
streamHost: String,
|
|
streamPort: i64,
|
|
clientCertificatePem: String,
|
|
clientPrivateKeyPem: String,
|
|
serverCertificatePem: String,
|
|
}
|
|
|
|
impl ProviderSessionWork {
|
|
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, expiresAt: String, providerProfile: String, providerIdentity: String, policyVersionId: String, applicationId: String, managementHost: String, managementPort: i64, streamHost: String, streamPort: i64, clientCertificatePem: String, clientPrivateKeyPem: String, serverCertificatePem: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, sessionId, gatewayId, reconnectSequence, expiresAt, providerProfile, providerIdentity, policyVersionId, applicationId, managementHost, managementPort, streamHost, streamPort, clientCertificatePem, clientPrivateKeyPem, serverCertificatePem };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.sessionId.is_empty() { return Err(ValidationError::new("session_id", "required")); }
|
|
if !self.sessionId.is_empty() && self.sessionId.len() < 1 { return Err(ValidationError::new("session_id", "min_length")); }
|
|
if self.sessionId.len() > 128 { return Err(ValidationError::new("session_id", "max_length")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
if self.providerProfile != "apollo" { return Err(ValidationError::new("provider_profile", "invalid_value")); }
|
|
if self.providerIdentity.is_empty() { return Err(ValidationError::new("provider_identity", "required")); }
|
|
if !self.providerIdentity.is_empty() && self.providerIdentity.len() < 1 { return Err(ValidationError::new("provider_identity", "min_length")); }
|
|
if self.providerIdentity.len() > 256 { return Err(ValidationError::new("provider_identity", "max_length")); }
|
|
if self.policyVersionId.is_empty() { return Err(ValidationError::new("policy_version_id", "required")); }
|
|
if !self.policyVersionId.is_empty() && self.policyVersionId.len() < 1 { return Err(ValidationError::new("policy_version_id", "min_length")); }
|
|
if self.policyVersionId.len() > 128 { return Err(ValidationError::new("policy_version_id", "max_length")); }
|
|
if self.applicationId.is_empty() { return Err(ValidationError::new("application_id", "required")); }
|
|
if !self.applicationId.is_empty() && self.applicationId.len() < 1 { return Err(ValidationError::new("application_id", "min_length")); }
|
|
if self.applicationId.len() > 128 { return Err(ValidationError::new("application_id", "max_length")); }
|
|
if self.managementHost.is_empty() { return Err(ValidationError::new("management_host", "required")); }
|
|
if !self.managementHost.is_empty() && self.managementHost.len() < 1 { return Err(ValidationError::new("management_host", "min_length")); }
|
|
if self.managementHost.len() > 256 { return Err(ValidationError::new("management_host", "max_length")); }
|
|
if self.managementPort < 1 { return Err(ValidationError::new("management_port", "minimum")); }
|
|
if self.managementPort > 65535 { return Err(ValidationError::new("management_port", "maximum")); }
|
|
if self.streamHost.is_empty() { return Err(ValidationError::new("stream_host", "required")); }
|
|
if !self.streamHost.is_empty() && self.streamHost.len() < 1 { return Err(ValidationError::new("stream_host", "min_length")); }
|
|
if self.streamHost.len() > 256 { return Err(ValidationError::new("stream_host", "max_length")); }
|
|
if self.streamPort < 1 { return Err(ValidationError::new("stream_port", "minimum")); }
|
|
if self.streamPort > 65535 { return Err(ValidationError::new("stream_port", "maximum")); }
|
|
if self.clientCertificatePem.is_empty() { return Err(ValidationError::new("client_certificate_pem", "required")); }
|
|
if !self.clientCertificatePem.is_empty() && self.clientCertificatePem.len() < 1 { return Err(ValidationError::new("client_certificate_pem", "min_length")); }
|
|
if self.clientCertificatePem.len() > 32768 { return Err(ValidationError::new("client_certificate_pem", "max_length")); }
|
|
if self.clientPrivateKeyPem.is_empty() { return Err(ValidationError::new("client_private_key_pem", "required")); }
|
|
if !self.clientPrivateKeyPem.is_empty() && self.clientPrivateKeyPem.len() < 1 { return Err(ValidationError::new("client_private_key_pem", "min_length")); }
|
|
if self.clientPrivateKeyPem.len() > 32768 { return Err(ValidationError::new("client_private_key_pem", "max_length")); }
|
|
if self.serverCertificatePem.is_empty() { return Err(ValidationError::new("server_certificate_pem", "required")); }
|
|
if !self.serverCertificatePem.is_empty() && self.serverCertificatePem.len() < 1 { return Err(ValidationError::new("server_certificate_pem", "min_length")); }
|
|
if self.serverCertificatePem.len() > 32768 { return Err(ValidationError::new("server_certificate_pem", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn sessionId(&self) -> &String { &self.sessionId }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
pub fn providerProfile(&self) -> &String { &self.providerProfile }
|
|
pub fn providerIdentity(&self) -> &String { &self.providerIdentity }
|
|
pub fn policyVersionId(&self) -> &String { &self.policyVersionId }
|
|
pub fn applicationId(&self) -> &String { &self.applicationId }
|
|
pub fn managementHost(&self) -> &String { &self.managementHost }
|
|
pub fn managementPort(&self) -> &i64 { &self.managementPort }
|
|
pub fn streamHost(&self) -> &String { &self.streamHost }
|
|
pub fn streamPort(&self) -> &i64 { &self.streamPort }
|
|
pub fn clientCertificatePem(&self) -> &String { &self.clientCertificatePem }
|
|
pub fn clientPrivateKeyPem(&self) -> &String { &self.clientPrivateKeyPem }
|
|
pub fn serverCertificatePem(&self) -> &String { &self.serverCertificatePem }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ProviderState {
|
|
version: String,
|
|
sessionId: String,
|
|
state: String,
|
|
cleanupPending: bool,
|
|
channels: Vec<String>,
|
|
}
|
|
|
|
impl ProviderState {
|
|
pub fn new(version: String, sessionId: String, state: String, cleanupPending: bool, channels: Vec<String>) -> Result<Self, ValidationError> {
|
|
let value = Self { version, sessionId, state, cleanupPending, channels };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.sessionId.is_empty() { return Err(ValidationError::new("session_id", "required")); }
|
|
if !self.sessionId.is_empty() && self.sessionId.len() < 1 { return Err(ValidationError::new("session_id", "min_length")); }
|
|
if self.sessionId.len() > 128 { return Err(ValidationError::new("session_id", "max_length")); }
|
|
if self.state != "starting" && self.state != "ready" && self.state != "disconnected" && self.state != "terminating" && self.state != "terminated" && self.state != "cleanup_pending" && self.state != "failed" { return Err(ValidationError::new("state", "invalid_value")); }
|
|
if self.channels.len() > 8 { return Err(ValidationError::new("channels", "max_items")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn sessionId(&self) -> &String { &self.sessionId }
|
|
pub fn state(&self) -> &String { &self.state }
|
|
pub fn cleanupPending(&self) -> &bool { &self.cleanupPending }
|
|
pub fn channels(&self) -> &Vec<String> { &self.channels }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ReauthGrant {
|
|
token: String,
|
|
purpose: String,
|
|
expiresAt: String,
|
|
}
|
|
|
|
impl ReauthGrant {
|
|
pub fn new(token: String, purpose: String, expiresAt: String) -> Result<Self, ValidationError> {
|
|
let value = Self { token, purpose, expiresAt };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.token.is_empty() { return Err(ValidationError::new("token", "required")); }
|
|
if !self.token.is_empty() && self.token.len() < 1 { return Err(ValidationError::new("token", "min_length")); }
|
|
if self.token.len() > 256 { return Err(ValidationError::new("token", "max_length")); }
|
|
if self.purpose.is_empty() { return Err(ValidationError::new("purpose", "required")); }
|
|
if !self.purpose.is_empty() && self.purpose.len() < 1 { return Err(ValidationError::new("purpose", "min_length")); }
|
|
if self.purpose.len() > 64 { return Err(ValidationError::new("purpose", "max_length")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn token(&self) -> &String { &self.token }
|
|
pub fn purpose(&self) -> &String { &self.purpose }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ReauthRequest {
|
|
password: String,
|
|
purpose: String,
|
|
}
|
|
|
|
impl ReauthRequest {
|
|
pub fn new(password: String, purpose: String) -> Result<Self, ValidationError> {
|
|
let value = Self { password, purpose };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.password.is_empty() { return Err(ValidationError::new("password", "required")); }
|
|
if !self.password.is_empty() && self.password.len() < 1 { return Err(ValidationError::new("password", "min_length")); }
|
|
if self.password.len() > 1024 { return Err(ValidationError::new("password", "max_length")); }
|
|
if self.purpose != "identity_change" && self.purpose != "key_change" && self.purpose != "backup_enable" && self.purpose != "external_database_tls_disabled" && self.purpose != "assignment_change" { return Err(ValidationError::new("purpose", "invalid_value")); }
|
|
Ok(())
|
|
}
|
|
pub fn password(&self) -> &String { &self.password }
|
|
pub fn purpose(&self) -> &String { &self.purpose }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ReconnectRequest {
|
|
clientDeviceId: String,
|
|
deviceKeyId: String,
|
|
expectedVersion: i64,
|
|
}
|
|
|
|
impl ReconnectRequest {
|
|
pub fn new(clientDeviceId: String, deviceKeyId: String, expectedVersion: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { clientDeviceId, deviceKeyId, expectedVersion };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.clientDeviceId.is_empty() { return Err(ValidationError::new("client_device_id", "required")); }
|
|
if !self.clientDeviceId.is_empty() && self.clientDeviceId.len() < 1 { return Err(ValidationError::new("client_device_id", "min_length")); }
|
|
if self.clientDeviceId.len() > 128 { return Err(ValidationError::new("client_device_id", "max_length")); }
|
|
if self.deviceKeyId.is_empty() { return Err(ValidationError::new("device_key_id", "required")); }
|
|
if !self.deviceKeyId.is_empty() && self.deviceKeyId.len() < 1 { return Err(ValidationError::new("device_key_id", "min_length")); }
|
|
if self.deviceKeyId.len() > 128 { return Err(ValidationError::new("device_key_id", "max_length")); }
|
|
if self.expectedVersion < 1 { return Err(ValidationError::new("expected_version", "minimum")); }
|
|
Ok(())
|
|
}
|
|
pub fn clientDeviceId(&self) -> &String { &self.clientDeviceId }
|
|
pub fn deviceKeyId(&self) -> &String { &self.deviceKeyId }
|
|
pub fn expectedVersion(&self) -> &i64 { &self.expectedVersion }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct RefreshRequest {
|
|
familyId: String,
|
|
refreshToken: String,
|
|
}
|
|
|
|
impl RefreshRequest {
|
|
pub fn new(familyId: String, refreshToken: String) -> Result<Self, ValidationError> {
|
|
let value = Self { familyId, refreshToken };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.familyId.is_empty() { return Err(ValidationError::new("family_id", "required")); }
|
|
if !self.familyId.is_empty() && self.familyId.len() < 1 { return Err(ValidationError::new("family_id", "min_length")); }
|
|
if self.familyId.len() > 128 { return Err(ValidationError::new("family_id", "max_length")); }
|
|
if self.refreshToken.is_empty() { return Err(ValidationError::new("refresh_token", "required")); }
|
|
if !self.refreshToken.is_empty() && self.refreshToken.len() < 1 { return Err(ValidationError::new("refresh_token", "min_length")); }
|
|
if self.refreshToken.len() > 256 { return Err(ValidationError::new("refresh_token", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn familyId(&self) -> &String { &self.familyId }
|
|
pub fn refreshToken(&self) -> &String { &self.refreshToken }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct Resource {
|
|
id: String,
|
|
kind: String,
|
|
name: String,
|
|
state: String,
|
|
assignmentState: Option<String>,
|
|
version: i64,
|
|
links: Vec<ResourceLink>,
|
|
}
|
|
|
|
impl Resource {
|
|
pub fn new(id: String, kind: String, name: String, state: String, assignmentState: Option<String>, version: i64, links: Vec<ResourceLink>) -> Result<Self, ValidationError> {
|
|
let value = Self { id, kind, name, state, assignmentState, version, links };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.id.is_empty() { return Err(ValidationError::new("id", "required")); }
|
|
if !self.id.is_empty() && self.id.len() < 1 { return Err(ValidationError::new("id", "min_length")); }
|
|
if self.id.len() > 128 { return Err(ValidationError::new("id", "max_length")); }
|
|
if self.kind.is_empty() { return Err(ValidationError::new("kind", "required")); }
|
|
if !self.kind.is_empty() && self.kind.len() < 1 { return Err(ValidationError::new("kind", "min_length")); }
|
|
if self.kind.len() > 64 { return Err(ValidationError::new("kind", "max_length")); }
|
|
if self.name.is_empty() { return Err(ValidationError::new("name", "required")); }
|
|
if !self.name.is_empty() && self.name.len() < 1 { return Err(ValidationError::new("name", "min_length")); }
|
|
if self.name.len() > 256 { return Err(ValidationError::new("name", "max_length")); }
|
|
if self.state.is_empty() { return Err(ValidationError::new("state", "required")); }
|
|
if !self.state.is_empty() && self.state.len() < 1 { return Err(ValidationError::new("state", "min_length")); }
|
|
if self.state.len() > 64 { return Err(ValidationError::new("state", "max_length")); }
|
|
if let Some(value) = &self.assignmentState {
|
|
if value.len() > 64 { return Err(ValidationError::new("assignment_state", "max_length")); }
|
|
}
|
|
if self.version < 1 { return Err(ValidationError::new("version", "minimum")); }
|
|
if self.links.len() > 16 { return Err(ValidationError::new("links", "max_items")); }
|
|
for item in self.links.iter() { item.validate().map_err(|_| ValidationError::new("links", "invalid_item"))?; }
|
|
Ok(())
|
|
}
|
|
pub fn id(&self) -> &String { &self.id }
|
|
pub fn kind(&self) -> &String { &self.kind }
|
|
pub fn name(&self) -> &String { &self.name }
|
|
pub fn state(&self) -> &String { &self.state }
|
|
pub fn assignmentState(&self) -> &Option<String> { &self.assignmentState }
|
|
pub fn version(&self) -> &i64 { &self.version }
|
|
pub fn links(&self) -> &Vec<ResourceLink> { &self.links }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ResourceLink {
|
|
typeValue: String,
|
|
id: String,
|
|
version: i64,
|
|
}
|
|
|
|
impl ResourceLink {
|
|
pub fn new(typeValue: String, id: String, version: i64) -> Result<Self, ValidationError> {
|
|
let value = Self { typeValue, id, version };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.typeValue.is_empty() { return Err(ValidationError::new("type", "required")); }
|
|
if !self.typeValue.is_empty() && self.typeValue.len() < 1 { return Err(ValidationError::new("type", "min_length")); }
|
|
if self.typeValue.len() > 64 { return Err(ValidationError::new("type", "max_length")); }
|
|
if self.id.is_empty() { return Err(ValidationError::new("id", "required")); }
|
|
if !self.id.is_empty() && self.id.len() < 1 { return Err(ValidationError::new("id", "min_length")); }
|
|
if self.id.len() > 128 { return Err(ValidationError::new("id", "max_length")); }
|
|
if self.version < 1 { return Err(ValidationError::new("version", "minimum")); }
|
|
Ok(())
|
|
}
|
|
pub fn typeValue(&self) -> &String { &self.typeValue }
|
|
pub fn id(&self) -> &String { &self.id }
|
|
pub fn version(&self) -> &i64 { &self.version }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ResourceList {
|
|
assignedDesktops: Vec<AssignedDesktop>,
|
|
entitledPools: Vec<EntitledPool>,
|
|
page: PageInfo,
|
|
}
|
|
|
|
impl ResourceList {
|
|
pub fn new(assignedDesktops: Vec<AssignedDesktop>, entitledPools: Vec<EntitledPool>, page: PageInfo) -> Result<Self, ValidationError> {
|
|
let value = Self { assignedDesktops, entitledPools, page };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.assignedDesktops.len() > 100 { return Err(ValidationError::new("assigned_desktops", "max_items")); }
|
|
for item in self.assignedDesktops.iter() { item.validate().map_err(|_| ValidationError::new("assigned_desktops", "invalid_item"))?; }
|
|
if self.entitledPools.len() > 100 { return Err(ValidationError::new("entitled_pools", "max_items")); }
|
|
for item in self.entitledPools.iter() { item.validate().map_err(|_| ValidationError::new("entitled_pools", "invalid_item"))?; }
|
|
self.page.validate().map_err(|_| ValidationError::new("page", "invalid_object"))?;
|
|
Ok(())
|
|
}
|
|
pub fn assignedDesktops(&self) -> &Vec<AssignedDesktop> { &self.assignedDesktops }
|
|
pub fn entitledPools(&self) -> &Vec<EntitledPool> { &self.entitledPools }
|
|
pub fn page(&self) -> &PageInfo { &self.page }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct SessionAuthority {
|
|
version: String,
|
|
sessionId: String,
|
|
gatewayId: String,
|
|
audience: String,
|
|
reconnectSequence: i64,
|
|
expiresAt: String,
|
|
capabilities: CapabilityProfile,
|
|
providerProfile: String,
|
|
providerIdentity: String,
|
|
}
|
|
|
|
impl SessionAuthority {
|
|
pub fn new(version: String, sessionId: String, gatewayId: String, audience: String, reconnectSequence: i64, expiresAt: String, capabilities: CapabilityProfile, providerProfile: String, providerIdentity: String) -> Result<Self, ValidationError> {
|
|
let value = Self { version, sessionId, gatewayId, audience, reconnectSequence, expiresAt, capabilities, providerProfile, providerIdentity };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.sessionId.is_empty() { return Err(ValidationError::new("session_id", "required")); }
|
|
if !self.sessionId.is_empty() && self.sessionId.len() < 1 { return Err(ValidationError::new("session_id", "min_length")); }
|
|
if self.sessionId.len() > 128 { return Err(ValidationError::new("session_id", "max_length")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.audience.is_empty() { return Err(ValidationError::new("audience", "required")); }
|
|
if !self.audience.is_empty() && self.audience.len() < 1 { return Err(ValidationError::new("audience", "min_length")); }
|
|
if self.audience.len() > 256 { return Err(ValidationError::new("audience", "max_length")); }
|
|
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
|
if self.expiresAt.len() > 64 { return Err(ValidationError::new("expires_at", "max_length")); }
|
|
self.capabilities.validate().map_err(|_| ValidationError::new("capabilities", "invalid_object"))?;
|
|
if self.providerProfile != "apollo" { return Err(ValidationError::new("provider_profile", "invalid_value")); }
|
|
if self.providerIdentity.is_empty() { return Err(ValidationError::new("provider_identity", "required")); }
|
|
if !self.providerIdentity.is_empty() && self.providerIdentity.len() < 1 { return Err(ValidationError::new("provider_identity", "min_length")); }
|
|
if self.providerIdentity.len() > 256 { return Err(ValidationError::new("provider_identity", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn sessionId(&self) -> &String { &self.sessionId }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn audience(&self) -> &String { &self.audience }
|
|
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
|
pub fn expiresAt(&self) -> &String { &self.expiresAt }
|
|
pub fn capabilities(&self) -> &CapabilityProfile { &self.capabilities }
|
|
pub fn providerProfile(&self) -> &String { &self.providerProfile }
|
|
pub fn providerIdentity(&self) -> &String { &self.providerIdentity }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct SessionRequest {
|
|
clientDeviceId: String,
|
|
deviceKeyId: String,
|
|
poolId: String,
|
|
idempotencyKey: String,
|
|
policySnapshot: AllocationPolicy,
|
|
}
|
|
|
|
impl SessionRequest {
|
|
pub fn new(clientDeviceId: String, deviceKeyId: String, poolId: String, idempotencyKey: String, policySnapshot: AllocationPolicy) -> Result<Self, ValidationError> {
|
|
let value = Self { clientDeviceId, deviceKeyId, poolId, idempotencyKey, policySnapshot };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.clientDeviceId.is_empty() { return Err(ValidationError::new("client_device_id", "required")); }
|
|
if !self.clientDeviceId.is_empty() && self.clientDeviceId.len() < 1 { return Err(ValidationError::new("client_device_id", "min_length")); }
|
|
if self.clientDeviceId.len() > 128 { return Err(ValidationError::new("client_device_id", "max_length")); }
|
|
if self.deviceKeyId.is_empty() { return Err(ValidationError::new("device_key_id", "required")); }
|
|
if !self.deviceKeyId.is_empty() && self.deviceKeyId.len() < 1 { return Err(ValidationError::new("device_key_id", "min_length")); }
|
|
if self.deviceKeyId.len() > 128 { return Err(ValidationError::new("device_key_id", "max_length")); }
|
|
if self.poolId.is_empty() { return Err(ValidationError::new("pool_id", "required")); }
|
|
if !self.poolId.is_empty() && self.poolId.len() < 1 { return Err(ValidationError::new("pool_id", "min_length")); }
|
|
if self.poolId.len() > 128 { return Err(ValidationError::new("pool_id", "max_length")); }
|
|
if self.idempotencyKey.is_empty() { return Err(ValidationError::new("idempotency_key", "required")); }
|
|
if !self.idempotencyKey.is_empty() && self.idempotencyKey.len() < 1 { return Err(ValidationError::new("idempotency_key", "min_length")); }
|
|
if self.idempotencyKey.len() > 256 { return Err(ValidationError::new("idempotency_key", "max_length")); }
|
|
self.policySnapshot.validate().map_err(|_| ValidationError::new("policy_snapshot", "invalid_object"))?;
|
|
Ok(())
|
|
}
|
|
pub fn clientDeviceId(&self) -> &String { &self.clientDeviceId }
|
|
pub fn deviceKeyId(&self) -> &String { &self.deviceKeyId }
|
|
pub fn poolId(&self) -> &String { &self.poolId }
|
|
pub fn idempotencyKey(&self) -> &String { &self.idempotencyKey }
|
|
pub fn policySnapshot(&self) -> &AllocationPolicy { &self.policySnapshot }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct StableError {
|
|
version: String,
|
|
code: String,
|
|
message: String,
|
|
retryable: bool,
|
|
}
|
|
|
|
impl StableError {
|
|
pub fn new(version: String, code: String, message: String, retryable: bool) -> Result<Self, ValidationError> {
|
|
let value = Self { version, code, message, retryable };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.code.is_empty() { return Err(ValidationError::new("code", "required")); }
|
|
if !self.code.is_empty() && self.code.len() < 1 { return Err(ValidationError::new("code", "min_length")); }
|
|
if self.code.len() > 128 { return Err(ValidationError::new("code", "max_length")); }
|
|
if self.message.is_empty() { return Err(ValidationError::new("message", "required")); }
|
|
if !self.message.is_empty() && self.message.len() < 1 { return Err(ValidationError::new("message", "min_length")); }
|
|
if self.message.len() > 512 { return Err(ValidationError::new("message", "max_length")); }
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn code(&self) -> &String { &self.code }
|
|
pub fn message(&self) -> &String { &self.message }
|
|
pub fn retryable(&self) -> &bool { &self.retryable }
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct TunnelAdmissionRequest {
|
|
version: String,
|
|
sessionId: String,
|
|
gatewayId: String,
|
|
audience: String,
|
|
grant: String,
|
|
reconnectSequence: i64,
|
|
clientNonce: String,
|
|
deviceSignature: String,
|
|
capabilities: CapabilityProfile,
|
|
}
|
|
|
|
impl TunnelAdmissionRequest {
|
|
pub fn new(version: String, sessionId: String, gatewayId: String, audience: String, grant: String, reconnectSequence: i64, clientNonce: String, deviceSignature: String, capabilities: CapabilityProfile) -> Result<Self, ValidationError> {
|
|
let value = Self { version, sessionId, gatewayId, audience, grant, reconnectSequence, clientNonce, deviceSignature, capabilities };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.version != "1" { return Err(ValidationError::new("version", "invalid_value")); }
|
|
if self.sessionId.is_empty() { return Err(ValidationError::new("session_id", "required")); }
|
|
if !self.sessionId.is_empty() && self.sessionId.len() < 1 { return Err(ValidationError::new("session_id", "min_length")); }
|
|
if self.sessionId.len() > 128 { return Err(ValidationError::new("session_id", "max_length")); }
|
|
if self.gatewayId.is_empty() { return Err(ValidationError::new("gateway_id", "required")); }
|
|
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
|
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
|
if self.audience.is_empty() { return Err(ValidationError::new("audience", "required")); }
|
|
if !self.audience.is_empty() && self.audience.len() < 1 { return Err(ValidationError::new("audience", "min_length")); }
|
|
if self.audience.len() > 256 { return Err(ValidationError::new("audience", "max_length")); }
|
|
if self.grant.is_empty() { return Err(ValidationError::new("grant", "required")); }
|
|
if !self.grant.is_empty() && self.grant.len() < 43 { return Err(ValidationError::new("grant", "min_length")); }
|
|
if self.grant.len() > 256 { return Err(ValidationError::new("grant", "max_length")); }
|
|
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
|
if self.clientNonce.is_empty() { return Err(ValidationError::new("client_nonce", "required")); }
|
|
if !self.clientNonce.is_empty() && self.clientNonce.len() < 16 { return Err(ValidationError::new("client_nonce", "min_length")); }
|
|
if self.clientNonce.len() > 128 { return Err(ValidationError::new("client_nonce", "max_length")); }
|
|
if self.deviceSignature.is_empty() { return Err(ValidationError::new("device_signature", "required")); }
|
|
if !self.deviceSignature.is_empty() && self.deviceSignature.len() < 86 { return Err(ValidationError::new("device_signature", "min_length")); }
|
|
if self.deviceSignature.len() > 86 { return Err(ValidationError::new("device_signature", "max_length")); }
|
|
self.capabilities.validate().map_err(|_| ValidationError::new("capabilities", "invalid_object"))?;
|
|
Ok(())
|
|
}
|
|
pub fn version(&self) -> &String { &self.version }
|
|
pub fn sessionId(&self) -> &String { &self.sessionId }
|
|
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
|
pub fn audience(&self) -> &String { &self.audience }
|
|
pub fn grant(&self) -> &String { &self.grant }
|
|
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
|
pub fn clientNonce(&self) -> &String { &self.clientNonce }
|
|
pub fn deviceSignature(&self) -> &String { &self.deviceSignature }
|
|
pub fn capabilities(&self) -> &CapabilityProfile { &self.capabilities }
|
|
pub fn device_admission_transcript(&self) -> Vec<u8> {
|
|
let reconnect_sequence = self.reconnectSequence.to_string();
|
|
let fields = [&self.sessionId, &self.gatewayId, &self.audience, &self.grant, &reconnect_sequence, &self.clientNonce, &self.capabilities.transport, &self.capabilities.framing, &self.capabilities.media, &self.capabilities.audio, &self.capabilities.sourceRateControl, &self.capabilities.clientDecode];
|
|
let mut transcript = String::from("versevdi/tunnel-admission/v1");
|
|
for field in fields { transcript.push_str(&format!("{}:{}", field.as_bytes().len(), field)); }
|
|
transcript.into_bytes()
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct VersionNegotiation {
|
|
supportedVersions: Vec<String>,
|
|
features: Vec<String>,
|
|
}
|
|
|
|
impl VersionNegotiation {
|
|
pub fn new(supportedVersions: Vec<String>, features: Vec<String>) -> Result<Self, ValidationError> {
|
|
let value = Self { supportedVersions, features };
|
|
value.validate()?;
|
|
Ok(value)
|
|
}
|
|
pub fn validate(&self) -> Result<(), ValidationError> {
|
|
if self.supportedVersions.len() < 1 { return Err(ValidationError::new("supported_versions", "min_items")); }
|
|
if self.supportedVersions.len() > 3 { return Err(ValidationError::new("supported_versions", "max_items")); }
|
|
if self.features.len() > 64 { return Err(ValidationError::new("features", "max_items")); }
|
|
Ok(())
|
|
}
|
|
pub fn supportedVersions(&self) -> &Vec<String> { &self.supportedVersions }
|
|
pub fn features(&self) -> &Vec<String> { &self.features }
|
|
}
|
|
|
|
pub fn intersect_capability_profiles(profiles: &[CapabilityProfile]) -> Result<CapabilityProfile, ValidationError> {
|
|
let selected = profiles.first().ok_or_else(|| ValidationError::new("capabilities", "no_overlap"))?.clone();
|
|
selected.validate().map_err(|_| ValidationError::new("capabilities", "no_overlap"))?;
|
|
for profile in &profiles[1..] {
|
|
profile.validate().map_err(|_| ValidationError::new("capabilities", "no_overlap"))?;
|
|
if profile != &selected { return Err(ValidationError::new("capabilities", "no_overlap")); }
|
|
}
|
|
Ok(selected)
|
|
}
|