sdk-rust 0.1.0

Canonical Rust core for the Lattix metadata-only control-plane SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum AuthMode {
    TrustedHeaders,
    BearerToken,
    BearerTokenOrTrustedHeaders,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct RequestContext {
    pub tenant_id: String,
    pub principal_id: String,
    pub subject: String,
    pub auth_source: String,
    #[serde(default)]
    pub scopes: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkRouteCapability {
    pub route: String,
    pub domain: String,
    pub configured: bool,
    #[serde(default)]
    pub required_scopes: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkCapabilitiesResponse {
    pub service: String,
    pub status: String,
    pub auth_mode: AuthMode,
    pub caller: RequestContext,
    #[serde(default)]
    pub default_required_scopes: Vec<String>,
    #[serde(default)]
    pub routes: Vec<SdkRouteCapability>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct CallerIdentityResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ProtectionOperation {
    Protect,
    Access,
    Rewrap,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ArtifactProfile {
    Tdf,
    Envelope,
    DetachedSignature,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct PlatformDomainPlan {
    pub domain: String,
    pub configured: bool,
    pub reason: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkBootstrapResponse {
    pub service: String,
    pub status: String,
    pub auth_mode: AuthMode,
    pub caller: RequestContext,
    pub enforcement_model: String,
    pub plaintext_to_platform: bool,
    pub policy_resolution_mode: String,
    #[serde(default)]
    pub supported_operations: Vec<ProtectionOperation>,
    #[serde(default)]
    pub supported_artifact_profiles: Vec<ArtifactProfile>,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkSessionExchangeResponse {
    pub access_token: String,
    pub token_type: String,
    pub expires_in: u64,
    pub scope: String,
    pub tenant_id: String,
    pub client_id: String,
    pub subject: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct WorkloadDescriptor {
    pub application: String,
    pub environment: Option<String>,
    pub component: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ResourceDescriptor {
    pub kind: String,
    pub id: Option<String>,
    pub mime_type: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkProtectionPlanRequest {
    pub operation: ProtectionOperation,
    pub workload: WorkloadDescriptor,
    pub resource: ResourceDescriptor,
    pub preferred_artifact_profile: Option<ArtifactProfile>,
    pub content_digest: Option<String>,
    pub content_size_bytes: Option<u64>,
    pub purpose: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    #[serde(default)]
    pub attributes: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ProtectionPlanSummary {
    pub operation: ProtectionOperation,
    pub workload_application: String,
    pub workload_environment: Option<String>,
    pub workload_component: Option<String>,
    pub resource_kind: String,
    pub resource_id: Option<String>,
    pub mime_type: Option<String>,
    pub preferred_artifact_profile: ArtifactProfile,
    pub content_digest_present: bool,
    pub content_size_bytes: Option<u64>,
    pub label_count: usize,
    pub attribute_count: usize,
    pub purpose: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ProtectionPlanDecision {
    pub allow: bool,
    #[serde(default)]
    pub required_scopes: Vec<String>,
    pub handling_mode: String,
    pub plaintext_transport: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ProtectionExecutionPlan {
    pub protect_locally: bool,
    pub local_enforcement_library: String,
    pub send_plaintext_to_platform: bool,
    #[serde(default)]
    pub send_only: Vec<String>,
    pub artifact_profile: ArtifactProfile,
    pub key_strategy: String,
    pub policy_resolution: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkProtectionPlanResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
    pub request_summary: ProtectionPlanSummary,
    pub decision: ProtectionPlanDecision,
    pub execution: ProtectionExecutionPlan,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
    #[serde(default)]
    pub warnings: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkPolicyResolveRequest {
    pub operation: ProtectionOperation,
    pub workload: WorkloadDescriptor,
    pub resource: ResourceDescriptor,
    pub content_digest: Option<String>,
    pub content_size_bytes: Option<u64>,
    pub purpose: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    #[serde(default)]
    pub attributes: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct PolicyRequestSummary {
    pub operation: ProtectionOperation,
    pub workload_application: String,
    pub workload_environment: Option<String>,
    pub workload_component: Option<String>,
    pub resource_kind: String,
    pub resource_id: Option<String>,
    pub mime_type: Option<String>,
    pub content_digest_present: bool,
    pub content_size_bytes: Option<u64>,
    pub purpose: Option<String>,
    pub label_count: usize,
    pub attribute_count: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct PolicyResolutionDecision {
    pub allow: bool,
    pub enforcement_mode: String,
    #[serde(default)]
    pub required_scopes: Vec<String>,
    #[serde(default)]
    pub policy_inputs: Vec<String>,
    #[serde(default)]
    pub required_actions: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct PolicyHandlingGuidance {
    pub protect_locally: bool,
    pub plaintext_transport: String,
    #[serde(default)]
    pub bind_policy_to: Vec<String>,
    #[serde(default)]
    pub evidence_expected: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkPolicyResolveResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
    pub request_summary: PolicyRequestSummary,
    pub decision: PolicyResolutionDecision,
    pub handling: PolicyHandlingGuidance,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
    #[serde(default)]
    pub warnings: Vec<String>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum KeyAccessOperation {
    Wrap,
    Unwrap,
    Rewrap,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkKeyAccessPlanRequest {
    pub operation: KeyAccessOperation,
    pub workload: WorkloadDescriptor,
    pub resource: ResourceDescriptor,
    pub artifact_profile: Option<ArtifactProfile>,
    pub key_reference: Option<String>,
    pub content_digest: Option<String>,
    pub purpose: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    #[serde(default)]
    pub attributes: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct KeyAccessRequestSummary {
    pub operation: KeyAccessOperation,
    pub workload_application: String,
    pub workload_environment: Option<String>,
    pub workload_component: Option<String>,
    pub resource_kind: String,
    pub resource_id: Option<String>,
    pub mime_type: Option<String>,
    pub artifact_profile: ArtifactProfile,
    pub key_reference_present: bool,
    pub content_digest_present: bool,
    pub purpose: Option<String>,
    pub label_count: usize,
    pub attribute_count: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct KeyAccessDecision {
    pub allow: bool,
    #[serde(default)]
    pub required_scopes: Vec<String>,
    pub operation: KeyAccessOperation,
    pub key_reference_present: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct KeyAccessExecutionPlan {
    pub local_cryptographic_operation: bool,
    pub platform_role: String,
    pub send_plaintext_to_platform: bool,
    #[serde(default)]
    pub send_only: Vec<String>,
    pub artifact_profile: ArtifactProfile,
    pub authorization_strategy: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkKeyAccessPlanResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
    pub request_summary: KeyAccessRequestSummary,
    pub decision: KeyAccessDecision,
    pub execution: KeyAccessExecutionPlan,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
    #[serde(default)]
    pub warnings: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkArtifactRegisterRequest {
    pub operation: ProtectionOperation,
    pub workload: WorkloadDescriptor,
    pub resource: ResourceDescriptor,
    pub artifact_profile: ArtifactProfile,
    pub artifact_digest: String,
    pub artifact_locator: Option<String>,
    pub decision_id: Option<String>,
    pub key_reference: Option<String>,
    pub purpose: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    #[serde(default)]
    pub attributes: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ArtifactRegistrationSummary {
    pub operation: ProtectionOperation,
    pub workload_application: String,
    pub workload_environment: Option<String>,
    pub workload_component: Option<String>,
    pub resource_kind: String,
    pub resource_id: Option<String>,
    pub mime_type: Option<String>,
    pub artifact_profile: ArtifactProfile,
    pub artifact_digest: String,
    pub artifact_locator_present: bool,
    pub decision_id_present: bool,
    pub key_reference_present: bool,
    pub purpose: Option<String>,
    pub label_count: usize,
    pub attribute_count: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct ArtifactRegistrationPlan {
    pub accepted: bool,
    #[serde(default)]
    pub required_scopes: Vec<String>,
    pub artifact_transport: String,
    pub send_plaintext_to_platform: bool,
    #[serde(default)]
    pub catalog_actions: Vec<String>,
    #[serde(default)]
    pub evidence_expected: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkArtifactRegisterResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
    pub request_summary: ArtifactRegistrationSummary,
    pub registration: ArtifactRegistrationPlan,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
    #[serde(default)]
    pub warnings: Vec<String>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum EvidenceEventType {
    Protect,
    Access,
    Rewrap,
    Deny,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkEvidenceIngestRequest {
    pub event_type: EvidenceEventType,
    pub workload: WorkloadDescriptor,
    pub resource: ResourceDescriptor,
    pub artifact_profile: Option<ArtifactProfile>,
    pub artifact_digest: Option<String>,
    pub decision_id: Option<String>,
    pub outcome: Option<String>,
    pub occurred_at: Option<String>,
    pub purpose: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    #[serde(default)]
    pub attributes: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct EvidenceIngestSummary {
    pub event_type: EvidenceEventType,
    pub workload_application: String,
    pub workload_environment: Option<String>,
    pub workload_component: Option<String>,
    pub resource_kind: String,
    pub resource_id: Option<String>,
    pub mime_type: Option<String>,
    pub artifact_profile: Option<ArtifactProfile>,
    pub artifact_digest_present: bool,
    pub decision_id_present: bool,
    pub outcome: Option<String>,
    pub occurred_at: Option<String>,
    pub purpose: Option<String>,
    pub label_count: usize,
    pub attribute_count: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct EvidenceIngestionPlan {
    pub accepted: bool,
    #[serde(default)]
    pub required_scopes: Vec<String>,
    pub plaintext_transport: String,
    #[serde(default)]
    pub send_only: Vec<String>,
    #[serde(default)]
    pub correlate_by: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct SdkEvidenceIngestResponse {
    pub service: String,
    pub status: String,
    pub caller: RequestContext,
    pub request_summary: EvidenceIngestSummary,
    pub ingestion: EvidenceIngestionPlan,
    #[serde(default)]
    pub platform_domains: Vec<PlatformDomainPlan>,
    #[serde(default)]
    pub warnings: Vec<String>,
}