sylphx 0.3.8

The Sylphx SDK: one API, one key, every Sylphx service. Generated from the Sylphx schema registry.
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
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
// @generated by sylphx-gen. Do not edit.
//! `sylphx.entitlement.v1`.

#![allow(clippy::all)]

/// An Entitlement is what an org may use: its plan, account state, included
/// usage per meter, resource and rate limits, and budget-lease policy. Each
/// org has exactly one, `orgs/{org}/entitlements/default`; its spec is
/// Billing's latest decision and its history is Billing's decision log.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Entitlement {
    /// `orgs/{org}/entitlements/default`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `ent_<cell><ulid>`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// Billing's latest decision.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spec: Option<EntitlementSpec>,
    /// Observed state.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<EntitlementStatus>,
}

/// EntitlementSpec is Billing's latest entitlement decision for an org.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct EntitlementSpec {
    /// The plan, for example `plans/pro`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub plan: String,
    /// The plan version, for example `pro@2026-11-02`.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "planVersion"
    )]
    pub plan_version: String,
    /// The account state derived from plan and payment.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<AccountState>,
    /// Sylphx for Platforms is enabled (partner sub-orgs).
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub platforms: bool,
    /// Included usage and over-limit behaviour per meter.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub meters: Vec<MeterAllowance>,
    /// Limits on how many Resources of a collection the org may hold.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "Vec::is_empty",
        alias = "resourceLimits"
    )]
    pub resource_limits: Vec<ResourceLimit>,
    /// Request rate limits per rate class.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "rateLimits")]
    pub rate_limits: Vec<RateLimit>,
    /// Budget-lease policy per hard-spend pool.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "leasePools")]
    pub lease_pools: Vec<LeasePolicy>,
    /// When Billing computed this decision. The platform enforces it as is for
    /// 24 hours after this time; past that, non-hard-spend checks fail open.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "computeTime"
    )]
    pub compute_time: String,
    /// Monotonic per org; the platform never applies a lower sequence than it
    /// holds.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "decisionSequence"
    )]
    pub decision_sequence: i64,
    /// Caps a partner set on this sub-org, each at most the partner's own.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub overrides: Vec<PartnerOverride>,
}

/// EntitlementStatus is the observed state of an Entitlement.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct EntitlementStatus {
    /// The generation this status was computed from.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "observedGeneration"
    )]
    pub observed_generation: i64,
    /// Ready, Reconciling, Stalled.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<crate::common::Condition>,
    /// The Snapshot generation that first carried this decision.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "publishedGeneration"
    )]
    pub published_generation: i64,
}

/// The request of GetEntitlement.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetEntitlementRequest {
    /// The name of the entitlement to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// LeasePolicy is the budget-lease policy of one hard-spend pool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeasePolicy {
    /// The pool: `sandboxes`, `ai`, `runners`, or `notify.sms`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub pool: String,
    /// The largest lease Billing grants, in nano-USD.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "maxLeaseNanoUsd"
    )]
    pub max_lease_nano_usd: i64,
    /// What a holder may spend when it holds no lease and Billing is
    /// unreachable, in nano-USD.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "offlineAllowanceNanoUsd"
    )]
    pub offline_allowance_nano_usd: i64,
    /// Spend in this pool requires a lease.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "leaseRequired"
    )]
    pub lease_required: bool,
}

/// The request of ListEntitlements.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListEntitlementsRequest {
    /// The org 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, filterable spec fields, and Ready.
    #[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 ListEntitlements.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListEntitlementsResponse {
    /// The page.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub entitlements: Vec<Entitlement>,
    /// 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,
}

/// MeterAllowance is the included usage of one meter per billing period.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct MeterAllowance {
    /// The meter id, for example `hosting.vcpu_seconds`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub meter: String,
    /// Included quantity per billing period, in the meter's base unit.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub included: i64,
    /// What happens past the included quantity.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub overage: Option<Overage>,
    /// The included quantity is used up, as of `compute_time`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub exhausted: bool,
    /// An org-specific price version (enterprise, partner); empty for list price.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "priceVersionOverride"
    )]
    pub price_version_override: String,
}

/// PartnerOverride is a cap a partner set on one meter of its sub-org.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PartnerOverride {
    /// The meter id.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub meter: String,
    /// The cap, in the meter's base unit per billing period.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub cap: i64,
    /// The partner org that set the cap.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "partnerOrg"
    )]
    pub partner_org: String,
}

/// RateLimit is the request rate of one rate class.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct RateLimit {
    /// `control` or `inference`.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "rateClass"
    )]
    pub rate_class: String,
    /// Requests per minute, per org, enforced per cell.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "requestsPerMinute"
    )]
    pub requests_per_minute: i64,
    /// Sustained requests per second of the org's token bucket (the plan's
    /// class, raised by its committed-spend band).
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "requestsPerSecond"
    )]
    pub requests_per_second: i64,
    /// Requests the bucket holds for a burst.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub burst: i64,
}

/// ResourceLimit caps the Resources of one collection in the org.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ResourceLimit {
    /// The collection, for example `projects`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub collection: String,
    /// The most Resources allowed; zero means none, -1 means unlimited.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub limit: i64,
}

/// AccountState is an org's standing, derived from plan and payment.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum AccountState {
    /// In good standing.
    Active,
    /// An invoice is more than 7 days past due.
    PastDue,
    /// Suspended: keys fail verification; rides the priority chunk.
    Suspended,
    /// An unclaimed agent org on the agent-trial plan.
    Unclaimed,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl AccountState {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::PastDue => "past_due",
            Self::Suspended => "suspended",
            Self::Unclaimed => "unclaimed",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "active" => Self::Active,
            "past_due" => Self::PastDue,
            "suspended" => Self::Suspended,
            "unclaimed" => Self::Unclaimed,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for AccountState {
    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 AccountState {
    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 AccountState {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// Overage is what happens when usage passes the included quantity.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Overage {
    /// Deny further use (Free).
    Deny,
    /// Bill per the meter's price (Pro).
    Bill,
    /// Bill until the org's spend limit, then deny.
    BillUntilSpendLimit,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl Overage {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Deny => "deny",
            Self::Bill => "bill",
            Self::BillUntilSpendLimit => "bill_until_spend_limit",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "deny" => Self::Deny,
            "bill" => Self::Bill,
            "bill_until_spend_limit" => Self::BillUntilSpendLimit,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for Overage {
    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 Overage {
    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 Overage {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

impl<T: crate::runtime::Transport> crate::runtime::Client<T> {
    /// Sylphx Entitlement (`preview`).
    pub fn entitlement(&self) -> EntitlementApi<'_, T> {
        EntitlementApi { client: self }
    }
}

/// EntitlementService is the read-only view of Sylphx Entitlement. Billing
/// writes it through the Resource store; this service has no mutation.
///
/// Namespace of Sylphx Entitlement on the client.
pub struct EntitlementApi<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> EntitlementApi<'a, T> {
    /// The `entitlements` collection.
    pub fn entitlements(&self) -> EntitlementsCollection<'a, T> {
        EntitlementsCollection {
            client: self.client,
        }
    }
}

/// `entitlements` of Sylphx Entitlement: Resource type `entitlement.sylphx.com/Entitlement`.
pub struct EntitlementsCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> EntitlementsCollection<'a, T> {
    /// Gets an org's entitlement.
    ///
    /// `GET /v1/{name=orgs/*/entitlements/*}` · permission `entitlement:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(
        &self,
        request: GetEntitlementRequest,
    ) -> Result<Entitlement, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(&request.name, "orgs/*/entitlements/*", "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 an org's entitlements: exactly one, `default`.
    ///
    /// `GET /v1/{parent=orgs/*}/entitlements` · permission `entitlement:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListEntitlementsRequest,
    ) -> Result<ListEntitlementsResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/entitlements",
            crate::runtime::path_param(&request.parent, "orgs/*", "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: ListEntitlementsRequest,
    ) -> Result<Vec<Entitlement>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.entitlements);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }
}