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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
// @generated by sylphx-gen. Do not edit.
//! `sylphx.artifacts.v1`.
#![allow(clippy::all)]
/// An Artifact is one immutable content object addressed by digest: an
/// image, or evidence about one (an SBOM, a provenance attestation, a
/// signature) that names it as its subject.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Artifact {
/// `orgs/{org}/projects/{project}/artifacts/{artifact}`, where `{artifact}`
/// is the digest with `-` for `:`, for example `sha256-4f1c…`.
///
/// Field behavior: `identifier`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub name: String,
/// `art_<cell><ulid>`.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub uid: String,
/// Resource metadata.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub meta: Option<crate::common::ResourceMeta>,
/// The algorithm-qualified digest of the stored bytes, for example
/// `sha256:4f1c…`.
///
/// Field behavior: `required`, `immutable`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub digest: String,
/// What the Artifact is.
///
/// Field behavior: `required`, `immutable`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kind: Option<ArtifactKind>,
/// The media type, for example
/// `application/vnd.oci.image.manifest.v1+json`.
///
/// Field behavior: `required`, `immutable`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "mediaType"
)]
pub media_type: String,
/// The size of the stored bytes.
///
/// Field behavior: `required`, `immutable`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
with = "crate::runtime::int64",
alias = "sizeBytes"
)]
pub size_bytes: i64,
/// The Artifact this one describes, for an SBOM, provenance, or signature.
///
/// Field behavior: `immutable`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub subject: String,
/// Digests of the sources and inputs that produced it.
///
/// Field behavior: `immutable`.
#[serde(
default,
skip_serializing_if = "Vec::is_empty",
alias = "sourceDigests"
)]
pub source_digests: Vec<String>,
/// The builder identity (a SPIFFE id) that produced it.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub builder: String,
/// The newest SBOM whose subject is this Artifact.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub sbom: String,
/// The newest provenance attestation whose subject is this Artifact.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub provenance: String,
/// Whether the signature and provenance verified. Evidence, never
/// identity: a failure does not change the digest.
///
/// Field behavior: `output_only`.
#[serde(
default,
skip_serializing_if = "Option::is_none",
alias = "verificationState"
)]
pub verification_state: Option<VerificationState>,
/// When verification last ran.
///
/// Field behavior: `output_only`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "verifyTime"
)]
pub verify_time: String,
/// How long the Artifact is kept.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub retention: Option<RetentionClass>,
/// A legal hold is active; Delete fails.
///
/// Field behavior: `output_only`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "legalHold"
)]
pub legal_hold: bool,
/// The regions the bytes are replicated to.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub regions: Vec<String>,
/// The OCI reference by digest to pull, for example
/// `registry.sylphx.com/<org>/<project>-image@sha256:4f1c…`. Set by the
/// server for an Artifact registered from a managed upload; empty for a
/// generic registration.
///
/// Field behavior: `output_only`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub reference: String,
}
/// The request of CreateArtifact.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CreateArtifactRequest {
/// The project to create in.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub parent: String,
/// The artifact to create; only spec and caller-writable metadata are read.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub artifact: Option<Artifact>,
/// The id of the new artifact, the digest with `-` for `:`; the server derives it from `digest` when empty; the server assigns one when
/// empty.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "artifactId"
)]
pub artifact_id: String,
/// Validate and return the result without writing anything.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "validateOnly"
)]
pub validate_only: bool,
/// The bytes were pushed to this project's managed upload reference, so the
/// registry is asked before the digest is registered: it must hold the
/// manifest for `digest` in the project's managed repository, with this
/// `media_type` and `size_bytes`. The record then carries the pull
/// `reference`. Unset, the artifact is registered as given (generic
/// registration), and `reference` stays empty.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "managedUpload"
)]
pub managed_upload: bool,
}
/// The request of DeleteArtifact.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DeleteArtifactRequest {
/// The name of the artifact to delete.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub name: String,
/// Delete only if the current etag matches.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub etag: String,
/// Validate without deleting anything.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "validateOnly"
)]
pub validate_only: bool,
}
/// The request of GetArtifact.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetArtifactRequest {
/// The name of the artifact to get.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub name: String,
}
/// The request of ListArtifacts.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListArtifactsRequest {
/// The project to list in.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub parent: String,
/// At most this many; default 50, clamped to 1000.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "pageSize"
)]
pub page_size: i32,
/// `next_page_token` of the previous page.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "pageToken"
)]
pub page_token: String,
/// AIP-160 filter over labels and filterable fields.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub filter: String,
/// AIP-132 ordering over filterable fields.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "orderBy"
)]
pub order_by: String,
}
/// The response of ListArtifacts.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListArtifactsResponse {
/// The page.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub artifacts: Vec<Artifact>,
/// The token of the next page; empty on the last page.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "nextPageToken"
)]
pub next_page_token: String,
}
/// The request of PrepareUpload.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PrepareUploadRequest {
/// The project the image is uploaded to.
///
/// Field behavior: `required`.
#[serde(default, skip_serializing_if = "crate::runtime::is_default")]
pub parent: String,
}
/// The response of PrepareUpload.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PrepareUploadResponse {
/// The repository and tag to push, `<registry>/<org>/<project>-image:<upload>`;
/// the tag is unique per call.
///
/// Field behavior: `output_only`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "imageReference"
)]
pub image_reference: String,
/// A Docker config JSON whose `identitytoken` for the registry authenticates
/// this upload; a push credential, never stored or logged.
///
/// Field behavior: `output_only`, `sensitive`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "registryAuth"
)]
pub registry_auth: String,
/// When the credential stops authenticating. `expires_at` names the issuer
/// credential's expiry, the credential protocol's field.
///
/// Field behavior: `output_only`.
#[serde(
default,
skip_serializing_if = "crate::runtime::is_default",
alias = "expiresAt"
)]
pub expires_at: String,
}
/// ArtifactKind is what an Artifact is.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ArtifactKind {
/// An OCI image or image index.
Image,
/// A software bill of materials (SPDX or CycloneDX).
Sbom,
/// A provenance attestation (in-toto, SLSA).
Provenance,
/// A signature over another Artifact.
Signature,
/// Any other content or evidence bundle.
Bundle,
/// A value this SDK version does not know.
Unknown(String),
}
impl ArtifactKind {
/// The wire string.
pub fn as_str(&self) -> &str {
match self {
Self::Image => "image",
Self::Sbom => "sbom",
Self::Provenance => "provenance",
Self::Signature => "signature",
Self::Bundle => "bundle",
Self::Unknown(s) => s.as_str(),
}
}
/// Parses a wire string; unknown values are kept.
pub fn from_wire(s: &str) -> Self {
match s {
"image" => Self::Image,
"sbom" => Self::Sbom,
"provenance" => Self::Provenance,
"signature" => Self::Signature,
"bundle" => Self::Bundle,
other => Self::Unknown(other.to_string()),
}
}
}
impl serde::Serialize for ArtifactKind {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for ArtifactKind {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
let s = <String as serde::Deserialize>::deserialize(d)?;
Ok(Self::from_wire(&s))
}
}
impl crate::runtime::QueryValue for ArtifactKind {
fn query_value(&self) -> Option<String> {
Some(self.as_str().to_string())
}
}
/// RetentionClass is how long an Artifact is kept.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RetentionClass {
/// Kept per the project's retention policy.
Standard,
/// Kept while a Release or another Artifact references it.
Referenced,
/// A value this SDK version does not know.
Unknown(String),
}
impl RetentionClass {
/// The wire string.
pub fn as_str(&self) -> &str {
match self {
Self::Standard => "standard",
Self::Referenced => "referenced",
Self::Unknown(s) => s.as_str(),
}
}
/// Parses a wire string; unknown values are kept.
pub fn from_wire(s: &str) -> Self {
match s {
"standard" => Self::Standard,
"referenced" => Self::Referenced,
other => Self::Unknown(other.to_string()),
}
}
}
impl serde::Serialize for RetentionClass {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for RetentionClass {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
let s = <String as serde::Deserialize>::deserialize(d)?;
Ok(Self::from_wire(&s))
}
}
impl crate::runtime::QueryValue for RetentionClass {
fn query_value(&self) -> Option<String> {
Some(self.as_str().to_string())
}
}
/// VerificationState is the result of verifying an Artifact.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum VerificationState {
/// Not yet verified.
Unverified,
/// Verification is running.
Pending,
/// The signature and provenance verified against the trusted builders.
Verified,
/// Verification failed; no Release may name the Artifact.
Failed,
/// A value this SDK version does not know.
Unknown(String),
}
impl VerificationState {
/// The wire string.
pub fn as_str(&self) -> &str {
match self {
Self::Unverified => "unverified",
Self::Pending => "pending",
Self::Verified => "verified",
Self::Failed => "failed",
Self::Unknown(s) => s.as_str(),
}
}
/// Parses a wire string; unknown values are kept.
pub fn from_wire(s: &str) -> Self {
match s {
"unverified" => Self::Unverified,
"pending" => Self::Pending,
"verified" => Self::Verified,
"failed" => Self::Failed,
other => Self::Unknown(other.to_string()),
}
}
}
impl serde::Serialize for VerificationState {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for VerificationState {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
let s = <String as serde::Deserialize>::deserialize(d)?;
Ok(Self::from_wire(&s))
}
}
impl crate::runtime::QueryValue for VerificationState {
fn query_value(&self) -> Option<String> {
Some(self.as_str().to_string())
}
}
impl<T: crate::runtime::Transport> crate::runtime::Client<T> {
/// Sylphx Artifacts (`preview`).
pub fn artifacts(&self) -> ArtifactsApi<'_, T> {
ArtifactsApi { client: self }
}
}
/// ArtifactsService is Sylphx Artifacts: immutable content by digest, with
/// its SBOM and provenance. Sylphx Build writes them; Release reads them.
///
/// Namespace of Sylphx Artifacts on the client.
pub struct ArtifactsApi<'a, T> {
client: &'a crate::runtime::Client<T>,
}
impl<'a, T: crate::runtime::Transport> ArtifactsApi<'a, T> {
/// The `artifacts` collection.
pub fn artifacts(&self) -> ArtifactsCollection<'a, T> {
ArtifactsCollection {
client: self.client,
}
}
}
/// `artifacts` of Sylphx Artifacts: Resource type `artifacts.sylphx.com/Artifact`.
pub struct ArtifactsCollection<'a, T> {
client: &'a crate::runtime::Client<T>,
}
impl<'a, T: crate::runtime::Transport> ArtifactsCollection<'a, T> {
/// Gets an artifact.
///
/// `GET /v1/{name=orgs/*/projects/*/artifacts/*}` · permission `artifacts:read` · effect `read`
///
/// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
pub async fn get(
&self,
request: GetArtifactRequest,
) -> Result<Artifact, crate::runtime::Error> {
let path = format!(
"/v1/{}",
crate::runtime::path_param(&request.name, "orgs/*/projects/*/artifacts/*", "name")?
);
let query = crate::runtime::Query::default();
let http = crate::runtime::HttpRequest {
method: "GET",
path,
query: query.0,
body: None,
mutation: false,
origin: None,
effect_ids: false,
};
self.client.call(http).await
}
/// Lists a project's artifacts; filter by `digest`, `kind`, or `subject`.
///
/// `GET /v1/{parent=orgs/*/projects/*}/artifacts` · permission `artifacts:read` · effect `read`
///
/// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
pub async fn list(
&self,
request: ListArtifactsRequest,
) -> Result<ListArtifactsResponse, crate::runtime::Error> {
let path = format!(
"/v1/{}/artifacts",
crate::runtime::path_param(&request.parent, "orgs/*/projects/*", "parent")?
);
let mut query = crate::runtime::Query::default();
query.push("page_size", &request.page_size);
query.push("page_token", &request.page_token);
query.push("filter", &request.filter);
query.push("order_by", &request.order_by);
let http = crate::runtime::HttpRequest {
method: "GET",
path,
query: query.0,
body: None,
mutation: false,
origin: None,
effect_ids: false,
};
self.client.call(http).await
}
/// Every page of [`Self::list`], collected.
pub async fn list_all(
&self,
mut request: ListArtifactsRequest,
) -> Result<Vec<Artifact>, crate::runtime::Error> {
let mut items = Vec::new();
loop {
let page = self.list(request.clone()).await?;
items.extend(page.artifacts);
if page.next_page_token.is_empty() {
return Ok(items);
}
request.page_token = page.next_page_token;
}
}
/// Registers an artifact whose bytes were pushed by digest; verification runs after.
///
/// `POST /v1/{parent=orgs/*/projects/*}/artifacts` · permission `artifacts:write` · effect `write`
///
/// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`.
pub async fn create(
&self,
request: CreateArtifactRequest,
) -> Result<Artifact, crate::runtime::Error> {
let path = format!(
"/v1/{}/artifacts",
crate::runtime::path_param(&request.parent, "orgs/*/projects/*", "parent")?
);
let mut query = crate::runtime::Query::default();
query.push("artifact_id", &request.artifact_id);
query.push("validate_only", &request.validate_only);
query.push("managed_upload", &request.managed_upload);
let http = crate::runtime::HttpRequest {
method: "POST",
path,
query: query.0,
body: Some(crate::runtime::body(&request.artifact)?),
mutation: true,
origin: None,
effect_ids: false,
};
self.client.call(http).await
}
/// Mints one short-lived registry credential and the unique image reference
/// for an upload of this project. The repository is derived from the
/// caller's grant and this parent, never from the caller; the tag is unique
/// per call, so uploads of the same project never collide. Push to the
/// reference, then register the pushed digest with CreateArtifact.
///
/// `POST /v1/{parent=orgs/*/projects/*}/artifacts:prepareUpload` · permission `artifacts:write` · effect `write`
///
/// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `UNAVAILABLE`.
pub async fn prepare_upload(
&self,
request: PrepareUploadRequest,
) -> Result<PrepareUploadResponse, crate::runtime::Error> {
let path = format!(
"/v1/{}/artifacts:prepareUpload",
crate::runtime::path_param(&request.parent, "orgs/*/projects/*", "parent")?
);
let query = crate::runtime::Query::default();
let http = crate::runtime::HttpRequest {
method: "POST",
path,
query: query.0,
body: Some(crate::runtime::body_without(&request, &["parent"])?),
mutation: true,
origin: None,
effect_ids: false,
};
self.client.call(http).await
}
/// Deletes an artifact; fails while a Release references it or a legal hold is active.
///
/// `DELETE /v1/{name=orgs/*/projects/*/artifacts/*}` · permission `artifacts:write` · effect `destructive`
///
/// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
pub async fn delete(
&self,
request: DeleteArtifactRequest,
) -> Result<crate::runtime::Empty, crate::runtime::Error> {
let path = format!(
"/v1/{}",
crate::runtime::path_param(&request.name, "orgs/*/projects/*/artifacts/*", "name")?
);
let mut query = crate::runtime::Query::default();
query.push("etag", &request.etag);
query.push("validate_only", &request.validate_only);
let http = crate::runtime::HttpRequest {
method: "DELETE",
path,
query: query.0,
body: None,
mutation: true,
origin: None,
effect_ids: false,
};
self.client.call(http).await
}
}