Skip to main content

spiral/api/apps/
objects.rs

1// Generated by tools/service-contracts/rust.py. Do not edit.
2#![doc = "Generated transport-independent contract objects."]
3
4use std::collections::BTreeMap;
5use std::error::Error as StdError;
6use std::fmt::{self, Display, Formatter};
7
8use serde::{Deserialize, Deserializer, Serialize, Serializer};
9use serde_json::Value;
10use spiral_contract::error::{ErrorEnvelope, ServiceError};
11use spiral_contract::strict::{DeserializeStrict, Strict};
12use uuid::Uuid;
13
14/// AppAccessDecision contract value.
15#[derive(Clone, Debug, PartialEq, Eq)]
16pub enum AppAccessDecision {
17    /// A known contract value.
18    Allow,
19    /// A known contract value.
20    Block,
21    /// A value introduced by a newer server.
22    Unknown(String),
23}
24impl Serialize for AppAccessDecision {
25    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
26        serializer.serialize_str(match self {
27            Self::Allow => "allow",
28            Self::Block => "block",
29            Self::Unknown(value) => value,
30        })
31    }
32}
33impl<'de> Deserialize<'de> for AppAccessDecision {
34    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
35        Ok(match String::deserialize(deserializer)?.as_str() {
36            "allow" => Self::Allow,
37            "block" => Self::Block,
38            value => Self::Unknown(value.to_owned()),
39        })
40    }
41}
42impl<'de> DeserializeStrict<'de> for AppAccessDecision {
43    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
44        #[derive(Deserialize)]
45        enum __Known {
46            #[serde(rename = "allow")]
47            Allow,
48            #[serde(rename = "block")]
49            Block,
50        }
51        Ok(match __Known::deserialize(deserializer)? {
52            __Known::Allow => Self::Allow,
53            __Known::Block => Self::Block,
54        })
55    }
56}
57
58/// The configuration and status of an Application. An Application belongs to one Project and cannot
59/// move to another. You cannot use the ID of a deleted Application again.
60#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
61pub struct Application {
62    /// Contract field configuration.
63    #[serde(rename = "configuration")]
64    pub configuration: ApplicationConfiguration,
65    /// Contract field id.
66    #[serde(rename = "id")]
67    pub id: String,
68    /// Contract field organizationId.
69    #[serde(rename = "organizationId")]
70    pub organization_id: String,
71    /// Contract field projectId.
72    #[serde(rename = "projectId")]
73    pub project_id: String,
74    /// Contract field status.
75    #[serde(rename = "status")]
76    pub status: ApplicationStatus,
77}
78impl<'de> DeserializeStrict<'de> for Application {
79    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
80        #[derive(Deserialize)]
81        #[serde(deny_unknown_fields)]
82        struct __Wire {
83            #[serde(rename = "configuration")]
84            configuration: Strict<ApplicationConfiguration>,
85            #[serde(rename = "id")]
86            id: Strict<String>,
87            #[serde(rename = "organizationId")]
88            organization_id: Strict<String>,
89            #[serde(rename = "projectId")]
90            project_id: Strict<String>,
91            #[serde(rename = "status")]
92            status: Strict<ApplicationStatus>,
93        }
94        let wire = __Wire::deserialize(deserializer)?;
95        Ok(Self {
96            configuration: wire.configuration.0,
97            id: wire.id.0,
98            organization_id: wire.organization_id.0,
99            project_id: wire.project_id.0,
100            status: wire.status.0,
101        })
102    }
103}
104
105/// Who can sign in to the Application. `internal` admits only users of the Organization that owns
106/// the Application's Project. `public` also admits users of other Organizations after Spiral
107/// reviews the Application, subject to the app access of each Organization.
108#[derive(Clone, Debug, PartialEq, Eq)]
109pub enum ApplicationAudience {
110    /// A known contract value.
111    Internal,
112    /// A known contract value.
113    Public,
114    /// A value introduced by a newer server.
115    Unknown(String),
116}
117impl Serialize for ApplicationAudience {
118    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
119        serializer.serialize_str(match self {
120            Self::Internal => "internal",
121            Self::Public => "public",
122            Self::Unknown(value) => value,
123        })
124    }
125}
126impl<'de> Deserialize<'de> for ApplicationAudience {
127    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
128        Ok(match String::deserialize(deserializer)?.as_str() {
129            "internal" => Self::Internal,
130            "public" => Self::Public,
131            value => Self::Unknown(value.to_owned()),
132        })
133    }
134}
135impl<'de> DeserializeStrict<'de> for ApplicationAudience {
136    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
137        #[derive(Deserialize)]
138        enum __Known {
139            #[serde(rename = "internal")]
140            Internal,
141            #[serde(rename = "public")]
142            Public,
143        }
144        Ok(match __Known::deserialize(deserializer)? {
145            __Known::Internal => Self::Internal,
146            __Known::Public => Self::Public,
147        })
148    }
149}
150
151/// The exact redirect URIs and the resource scopes that the Application can request. The
152/// Application calls the API of the stack that owns its Project. Each user still approves the
153/// scopes, and the user's current permissions still apply. setupUrl returns the browser after
154/// installation setup. It uses HTTPS (or HTTP on loopback) and receives installation_id,
155/// setup_action and optional state; the Application checks the actual grant through the API.
156/// redirectOnUpdate also returns after changes to an existing installation; it defaults to false
157/// and requires setupUrl. installOnSignIn defaults to false. When enabled, sign-in requires an
158/// active installation and lets an Organization owner install during user consent.
159/// allowedCorsOrigins lists the exact browser origins (scheme, host and port) whose scripts may
160/// obtain tokens and call ScanDAL as the Application.
161#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
162pub struct ApplicationConfiguration {
163    /// Contract field allowedCorsOrigins.
164    #[serde(rename = "allowedCorsOrigins")]
165    #[serde(default, skip_serializing_if = "Option::is_none")]
166    pub allowed_cors_origins: Option<Vec<String>>,
167    /// Contract field audience.
168    #[serde(rename = "audience")]
169    #[serde(default, skip_serializing_if = "Option::is_none")]
170    pub audience: Option<ApplicationAudience>,
171    /// Contract field backgroundIdentity.
172    #[serde(rename = "backgroundIdentity")]
173    #[serde(default, skip_serializing_if = "Option::is_none")]
174    pub background_identity: Option<BackgroundIdentity>,
175    /// Contract field enabled.
176    #[serde(rename = "enabled")]
177    pub enabled: bool,
178    /// Contract field installOnSignIn.
179    #[serde(rename = "installOnSignIn")]
180    #[serde(default, skip_serializing_if = "Option::is_none")]
181    pub install_on_sign_in: Option<bool>,
182    /// Contract field jwks.
183    #[serde(rename = "jwks")]
184    #[serde(default, skip_serializing_if = "Option::is_none")]
185    pub jwks: Option<Value>,
186    /// Contract field jwtBearerIssuers.
187    #[serde(rename = "jwtBearerIssuers")]
188    #[serde(default, skip_serializing_if = "Option::is_none")]
189    pub jwt_bearer_issuers: Option<Vec<BackgroundIdentity>>,
190    /// Contract field name.
191    #[serde(rename = "name")]
192    pub name: String,
193    /// Contract field redirectOnUpdate.
194    #[serde(rename = "redirectOnUpdate")]
195    #[serde(default, skip_serializing_if = "Option::is_none")]
196    pub redirect_on_update: Option<bool>,
197    /// Contract field redirectUris.
198    #[serde(rename = "redirectUris")]
199    pub redirect_uris: Vec<String>,
200    /// Contract field scopes.
201    #[serde(rename = "scopes")]
202    pub scopes: Vec<String>,
203    /// Contract field setupUrl.
204    #[serde(rename = "setupUrl")]
205    #[serde(default, skip_serializing_if = "Option::is_none")]
206    pub setup_url: Option<String>,
207}
208impl<'de> DeserializeStrict<'de> for ApplicationConfiguration {
209    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
210        #[derive(Deserialize)]
211        #[serde(deny_unknown_fields)]
212        struct __Wire {
213            #[serde(rename = "allowedCorsOrigins")]
214            #[serde(default)]
215            allowed_cors_origins: Strict<Option<Vec<String>>>,
216            #[serde(rename = "audience")]
217            #[serde(default)]
218            audience: Strict<Option<ApplicationAudience>>,
219            #[serde(rename = "backgroundIdentity")]
220            #[serde(default)]
221            background_identity: Strict<Option<BackgroundIdentity>>,
222            #[serde(rename = "enabled")]
223            enabled: Strict<bool>,
224            #[serde(rename = "installOnSignIn")]
225            #[serde(default)]
226            install_on_sign_in: Strict<Option<bool>>,
227            #[serde(rename = "jwks")]
228            #[serde(default)]
229            jwks: Strict<Option<Value>>,
230            #[serde(rename = "jwtBearerIssuers")]
231            #[serde(default)]
232            jwt_bearer_issuers: Strict<Option<Vec<BackgroundIdentity>>>,
233            #[serde(rename = "name")]
234            name: Strict<String>,
235            #[serde(rename = "redirectOnUpdate")]
236            #[serde(default)]
237            redirect_on_update: Strict<Option<bool>>,
238            #[serde(rename = "redirectUris")]
239            redirect_uris: Strict<Vec<String>>,
240            #[serde(rename = "scopes")]
241            scopes: Strict<Vec<String>>,
242            #[serde(rename = "setupUrl")]
243            #[serde(default)]
244            setup_url: Strict<Option<String>>,
245        }
246        let wire = __Wire::deserialize(deserializer)?;
247        Ok(Self {
248            allowed_cors_origins: wire.allowed_cors_origins.0,
249            audience: wire.audience.0,
250            background_identity: wire.background_identity.0,
251            enabled: wire.enabled.0,
252            install_on_sign_in: wire.install_on_sign_in.0,
253            jwks: wire.jwks.0,
254            jwt_bearer_issuers: wire.jwt_bearer_issuers.0,
255            name: wire.name.0,
256            redirect_on_update: wire.redirect_on_update.0,
257            redirect_uris: wire.redirect_uris.0,
258            scopes: wire.scopes.0,
259            setup_url: wire.setup_url.0,
260        })
261    }
262}
263
264/// ApplicationPage contract value.
265#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
266pub struct ApplicationPage {
267    /// Contract field applications.
268    #[serde(rename = "applications")]
269    pub applications: Vec<Application>,
270    /// Contract field nextPageToken.
271    #[serde(rename = "nextPageToken")]
272    #[serde(default, skip_serializing_if = "Option::is_none")]
273    pub next_page_token: Option<String>,
274}
275impl<'de> DeserializeStrict<'de> for ApplicationPage {
276    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
277        #[derive(Deserialize)]
278        #[serde(deny_unknown_fields)]
279        struct __Wire {
280            #[serde(rename = "applications")]
281            applications: Strict<Vec<Application>>,
282            #[serde(rename = "nextPageToken")]
283            #[serde(default)]
284            next_page_token: Strict<Option<String>>,
285        }
286        let wire = __Wire::deserialize(deserializer)?;
287        Ok(Self {
288            applications: wire.applications.0,
289            next_page_token: wire.next_page_token.0,
290        })
291    }
292}
293
294/// ApplicationScope contract value.
295#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
296pub struct ApplicationScope {
297    /// Contract field description.
298    #[serde(rename = "description")]
299    pub description: String,
300    /// Contract field name.
301    #[serde(rename = "name")]
302    pub name: String,
303}
304impl<'de> DeserializeStrict<'de> for ApplicationScope {
305    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
306        #[derive(Deserialize)]
307        #[serde(deny_unknown_fields)]
308        struct __Wire {
309            #[serde(rename = "description")]
310            description: Strict<String>,
311            #[serde(rename = "name")]
312            name: Strict<String>,
313        }
314        let wire = __Wire::deserialize(deserializer)?;
315        Ok(Self {
316            description: wire.description.0,
317            name: wire.name.0,
318        })
319    }
320}
321
322/// ApplicationScopes contract value.
323#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
324pub struct ApplicationScopes {
325    /// Contract field scopes.
326    #[serde(rename = "scopes")]
327    pub scopes: Vec<ApplicationScope>,
328}
329impl<'de> DeserializeStrict<'de> for ApplicationScopes {
330    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
331        #[derive(Deserialize)]
332        #[serde(deny_unknown_fields)]
333        struct __Wire {
334            #[serde(rename = "scopes")]
335            scopes: Strict<Vec<ApplicationScope>>,
336        }
337        let wire = __Wire::deserialize(deserializer)?;
338        Ok(Self {
339            scopes: wire.scopes.0,
340        })
341    }
342}
343
344/// ApplicationStatus contract value.
345#[derive(Clone, Debug, PartialEq, Eq)]
346pub enum ApplicationStatus {
347    /// A known contract value.
348    Active,
349    /// A known contract value.
350    Suspended,
351    /// A known contract value.
352    Deleted,
353    /// A value introduced by a newer server.
354    Unknown(String),
355}
356impl Serialize for ApplicationStatus {
357    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
358        serializer.serialize_str(match self {
359            Self::Active => "active",
360            Self::Suspended => "suspended",
361            Self::Deleted => "deleted",
362            Self::Unknown(value) => value,
363        })
364    }
365}
366impl<'de> Deserialize<'de> for ApplicationStatus {
367    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
368        Ok(match String::deserialize(deserializer)?.as_str() {
369            "active" => Self::Active,
370            "suspended" => Self::Suspended,
371            "deleted" => Self::Deleted,
372            value => Self::Unknown(value.to_owned()),
373        })
374    }
375}
376impl<'de> DeserializeStrict<'de> for ApplicationStatus {
377    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
378        #[derive(Deserialize)]
379        enum __Known {
380            #[serde(rename = "active")]
381            Active,
382            #[serde(rename = "suspended")]
383            Suspended,
384            #[serde(rename = "deleted")]
385            Deleted,
386        }
387        Ok(match __Known::deserialize(deserializer)? {
388            __Known::Active => Self::Active,
389            __Known::Suspended => Self::Suspended,
390            __Known::Deleted => Self::Deleted,
391        })
392    }
393}
394
395/// An OpenID Connect identity of the Application's backend, such as a cloud service account.
396/// backgroundIdentity applies to installation tokens; jwtBearerIssuers applies to app tokens. A
397/// token must come from issuer and carry every listed claim value.
398#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
399pub struct BackgroundIdentity {
400    /// Contract field audience.
401    #[serde(rename = "audience")]
402    #[serde(default, skip_serializing_if = "Option::is_none")]
403    pub audience: Option<String>,
404    /// Contract field claims.
405    #[serde(rename = "claims")]
406    pub claims: BTreeMap<String, String>,
407    /// Contract field issuer.
408    #[serde(rename = "issuer")]
409    pub issuer: String,
410}
411impl<'de> DeserializeStrict<'de> for BackgroundIdentity {
412    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
413        #[derive(Deserialize)]
414        #[serde(deny_unknown_fields)]
415        struct __Wire {
416            #[serde(rename = "audience")]
417            #[serde(default)]
418            audience: Strict<Option<String>>,
419            #[serde(rename = "claims")]
420            claims: Strict<BTreeMap<String, String>>,
421            #[serde(rename = "issuer")]
422            issuer: Strict<String>,
423        }
424        let wire = __Wire::deserialize(deserializer)?;
425        Ok(Self {
426            audience: wire.audience.0,
427            claims: wire.claims.0,
428            issuer: wire.issuer.0,
429        })
430    }
431}
432
433/// ClientAppAccess contract value.
434#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
435pub struct ClientAppAccess {
436    /// Contract field clientId.
437    #[serde(rename = "clientId")]
438    pub client_id: String,
439    /// Contract field decision.
440    #[serde(rename = "decision")]
441    pub decision: AppAccessDecision,
442}
443impl<'de> DeserializeStrict<'de> for ClientAppAccess {
444    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
445        #[derive(Deserialize)]
446        #[serde(deny_unknown_fields)]
447        struct __Wire {
448            #[serde(rename = "clientId")]
449            client_id: Strict<String>,
450            #[serde(rename = "decision")]
451            decision: Strict<AppAccessDecision>,
452        }
453        let wire = __Wire::deserialize(deserializer)?;
454        Ok(Self {
455            client_id: wire.client_id.0,
456            decision: wire.decision.0,
457        })
458    }
459}
460
461/// The verified OAuth client and callback shown by the consent application.
462#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
463pub struct ConsentClient {
464    /// Contract field id.
465    #[serde(rename = "id")]
466    pub id: String,
467    /// Contract field loopbackOnly.
468    #[serde(rename = "loopbackOnly")]
469    pub loopback_only: bool,
470    /// Contract field managed.
471    #[serde(rename = "managed")]
472    pub managed: bool,
473    /// Contract field name.
474    #[serde(rename = "name")]
475    pub name: String,
476    /// Contract field publisher.
477    #[serde(rename = "publisher")]
478    pub publisher: String,
479    /// Contract field publisherName.
480    #[serde(rename = "publisherName")]
481    #[serde(default, skip_serializing_if = "Option::is_none")]
482    pub publisher_name: Option<String>,
483    /// Contract field redirectHost.
484    #[serde(rename = "redirectHost")]
485    pub redirect_host: String,
486}
487impl<'de> DeserializeStrict<'de> for ConsentClient {
488    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
489        #[derive(Deserialize)]
490        #[serde(deny_unknown_fields)]
491        struct __Wire {
492            #[serde(rename = "id")]
493            id: Strict<String>,
494            #[serde(rename = "loopbackOnly")]
495            loopback_only: Strict<bool>,
496            #[serde(rename = "managed")]
497            managed: Strict<bool>,
498            #[serde(rename = "name")]
499            name: Strict<String>,
500            #[serde(rename = "publisher")]
501            publisher: Strict<String>,
502            #[serde(rename = "publisherName")]
503            #[serde(default)]
504            publisher_name: Strict<Option<String>>,
505            #[serde(rename = "redirectHost")]
506            redirect_host: Strict<String>,
507        }
508        let wire = __Wire::deserialize(deserializer)?;
509        Ok(Self {
510            id: wire.id.0,
511            loopback_only: wire.loopback_only.0,
512            managed: wire.managed.0,
513            name: wire.name.0,
514            publisher: wire.publisher.0,
515            publisher_name: wire.publisher_name.0,
516            redirect_host: wire.redirect_host.0,
517        })
518    }
519}
520
521/// Accept only the listed requested scopes, or reject the authorization.
522#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
523pub struct ConsentDecision {
524    /// Contract field approve.
525    #[serde(rename = "approve")]
526    pub approve: bool,
527    /// Contract field scopes.
528    #[serde(rename = "scopes")]
529    pub scopes: Vec<String>,
530}
531impl<'de> DeserializeStrict<'de> for ConsentDecision {
532    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
533        #[derive(Deserialize)]
534        #[serde(deny_unknown_fields)]
535        struct __Wire {
536            #[serde(rename = "approve")]
537            approve: Strict<bool>,
538            #[serde(rename = "scopes")]
539            scopes: Strict<Vec<String>>,
540        }
541        let wire = __Wire::deserialize(deserializer)?;
542        Ok(Self {
543            approve: wire.approve.0,
544            scopes: wire.scopes.0,
545        })
546    }
547}
548
549/// Return the initiating browser to this authorization-server URL to finish consent.
550#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
551pub struct ConsentRedirect {
552    /// Contract field redirectTo.
553    #[serde(rename = "redirectTo")]
554    pub redirect_to: String,
555}
556impl<'de> DeserializeStrict<'de> for ConsentRedirect {
557    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
558        #[derive(Deserialize)]
559        #[serde(deny_unknown_fields)]
560        struct __Wire {
561            #[serde(rename = "redirectTo")]
562            redirect_to: Strict<String>,
563        }
564        let wire = __Wire::deserialize(deserializer)?;
565        Ok(Self {
566            redirect_to: wire.redirect_to.0,
567        })
568    }
569}
570
571/// The requested delegation. A challenge contains no access or refresh token.
572#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
573pub struct ConsentRequest {
574    /// Contract field client.
575    #[serde(rename = "client")]
576    pub client: ConsentClient,
577    /// Contract field resource.
578    #[serde(rename = "resource")]
579    pub resource: String,
580    /// Contract field scopes.
581    #[serde(rename = "scopes")]
582    pub scopes: Vec<String>,
583    /// Contract field skip.
584    #[serde(rename = "skip")]
585    pub skip: bool,
586    /// Contract field subject.
587    #[serde(rename = "subject")]
588    pub subject: ConsentSubject,
589}
590impl<'de> DeserializeStrict<'de> for ConsentRequest {
591    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
592        #[derive(Deserialize)]
593        #[serde(deny_unknown_fields)]
594        struct __Wire {
595            #[serde(rename = "client")]
596            client: Strict<ConsentClient>,
597            #[serde(rename = "resource")]
598            resource: Strict<String>,
599            #[serde(rename = "scopes")]
600            scopes: Strict<Vec<String>>,
601            #[serde(rename = "skip")]
602            skip: Strict<bool>,
603            #[serde(rename = "subject")]
604            subject: Strict<ConsentSubject>,
605        }
606        let wire = __Wire::deserialize(deserializer)?;
607        Ok(Self {
608            client: wire.client.0,
609            resource: wire.resource.0,
610            scopes: wire.scopes.0,
611            skip: wire.skip.0,
612            subject: wire.subject.0,
613        })
614    }
615}
616
617/// The authenticated user and Organization bound to this authorization.
618#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
619pub struct ConsentSubject {
620    /// Contract field organizationId.
621    #[serde(rename = "organizationId")]
622    pub organization_id: String,
623    /// Contract field organizationName.
624    #[serde(rename = "organizationName")]
625    pub organization_name: String,
626    /// Contract field userId.
627    #[serde(rename = "userId")]
628    pub user_id: String,
629}
630impl<'de> DeserializeStrict<'de> for ConsentSubject {
631    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
632        #[derive(Deserialize)]
633        #[serde(deny_unknown_fields)]
634        struct __Wire {
635            #[serde(rename = "organizationId")]
636            organization_id: Strict<String>,
637            #[serde(rename = "organizationName")]
638            organization_name: Strict<String>,
639            #[serde(rename = "userId")]
640            user_id: Strict<String>,
641        }
642        let wire = __Wire::deserialize(deserializer)?;
643        Ok(Self {
644            organization_id: wire.organization_id.0,
645            organization_name: wire.organization_name.0,
646            user_id: wire.user_id.0,
647        })
648    }
649}
650
651/// Application details for an Organization member to review before installation. Credentials,
652/// sign-in callbacks and developer Project configuration are not included. The registered setup URL
653/// identifies where the browser returns after setup.
654#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
655pub struct InstallableApplication {
656    /// Contract field id.
657    #[serde(rename = "id")]
658    pub id: String,
659    /// Contract field installOnSignIn.
660    #[serde(rename = "installOnSignIn")]
661    #[serde(default, skip_serializing_if = "Option::is_none")]
662    pub install_on_sign_in: Option<bool>,
663    /// Contract field installation.
664    #[serde(rename = "installation")]
665    #[serde(default, skip_serializing_if = "Option::is_none")]
666    pub installation: Option<Installation>,
667    /// Contract field name.
668    #[serde(rename = "name")]
669    pub name: String,
670    /// Contract field organizationId.
671    #[serde(rename = "organizationId")]
672    pub organization_id: String,
673    /// Contract field redirectOnUpdate.
674    #[serde(rename = "redirectOnUpdate")]
675    #[serde(default, skip_serializing_if = "Option::is_none")]
676    pub redirect_on_update: Option<bool>,
677    /// Contract field scopes.
678    #[serde(rename = "scopes")]
679    pub scopes: Vec<String>,
680    /// Contract field setupUrl.
681    #[serde(rename = "setupUrl")]
682    #[serde(default, skip_serializing_if = "Option::is_none")]
683    pub setup_url: Option<String>,
684    /// Contract field status.
685    #[serde(rename = "status")]
686    pub status: ApplicationStatus,
687}
688impl<'de> DeserializeStrict<'de> for InstallableApplication {
689    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
690        #[derive(Deserialize)]
691        #[serde(deny_unknown_fields)]
692        struct __Wire {
693            #[serde(rename = "id")]
694            id: Strict<String>,
695            #[serde(rename = "installOnSignIn")]
696            #[serde(default)]
697            install_on_sign_in: Strict<Option<bool>>,
698            #[serde(rename = "installation")]
699            #[serde(default)]
700            installation: Strict<Option<Installation>>,
701            #[serde(rename = "name")]
702            name: Strict<String>,
703            #[serde(rename = "organizationId")]
704            organization_id: Strict<String>,
705            #[serde(rename = "redirectOnUpdate")]
706            #[serde(default)]
707            redirect_on_update: Strict<Option<bool>>,
708            #[serde(rename = "scopes")]
709            scopes: Strict<Vec<String>>,
710            #[serde(rename = "setupUrl")]
711            #[serde(default)]
712            setup_url: Strict<Option<String>>,
713            #[serde(rename = "status")]
714            status: Strict<ApplicationStatus>,
715        }
716        let wire = __Wire::deserialize(deserializer)?;
717        Ok(Self {
718            id: wire.id.0,
719            install_on_sign_in: wire.install_on_sign_in.0,
720            installation: wire.installation.0,
721            name: wire.name.0,
722            organization_id: wire.organization_id.0,
723            redirect_on_update: wire.redirect_on_update.0,
724            scopes: wire.scopes.0,
725            setup_url: wire.setup_url.0,
726            status: wire.status.0,
727        })
728    }
729}
730
731/// An Application installed in one Organization, where it acts as its own identity. `requested` is
732/// the latest request. `approved` is what an Organization owner approved, and it is the only grant
733/// that Spiral enforces. A request for more access takes effect only when an owner approves it.
734#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
735pub struct Installation {
736    /// Contract field applicationId.
737    #[serde(rename = "applicationId")]
738    pub application_id: String,
739    /// Contract field approved.
740    #[serde(rename = "approved")]
741    #[serde(default, skip_serializing_if = "Option::is_none")]
742    pub approved: Option<InstallationGrant>,
743    /// Contract field id.
744    #[serde(rename = "id")]
745    pub id: String,
746    /// Contract field organizationId.
747    #[serde(rename = "organizationId")]
748    pub organization_id: String,
749    /// Contract field requested.
750    #[serde(rename = "requested")]
751    pub requested: InstallationGrant,
752    /// Contract field status.
753    #[serde(rename = "status")]
754    pub status: InstallationStatus,
755}
756impl<'de> DeserializeStrict<'de> for Installation {
757    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
758        #[derive(Deserialize)]
759        #[serde(deny_unknown_fields)]
760        struct __Wire {
761            #[serde(rename = "applicationId")]
762            application_id: Strict<String>,
763            #[serde(rename = "approved")]
764            #[serde(default)]
765            approved: Strict<Option<InstallationGrant>>,
766            #[serde(rename = "id")]
767            id: Strict<String>,
768            #[serde(rename = "organizationId")]
769            organization_id: Strict<String>,
770            #[serde(rename = "requested")]
771            requested: Strict<InstallationGrant>,
772            #[serde(rename = "status")]
773            status: Strict<InstallationStatus>,
774        }
775        let wire = __Wire::deserialize(deserializer)?;
776        Ok(Self {
777            application_id: wire.application_id.0,
778            approved: wire.approved.0,
779            id: wire.id.0,
780            organization_id: wire.organization_id.0,
781            requested: wire.requested.0,
782            status: wire.status.0,
783        })
784    }
785}
786
787/// Installation metadata and its API audience. configurationUrl is the Studio page where an
788/// Organization member changes this installation; it carries no `state`, so append your own.
789/// configurationUrl is absent when the deployment does not name its Studio.
790#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
791pub struct InstallationDetails {
792    /// Contract field apiUrl.
793    #[serde(rename = "apiUrl")]
794    pub api_url: String,
795    /// Contract field configurationUrl.
796    #[serde(rename = "configurationUrl")]
797    #[serde(default, skip_serializing_if = "Option::is_none")]
798    pub configuration_url: Option<String>,
799    /// Contract field installation.
800    #[serde(rename = "installation")]
801    pub installation: Installation,
802}
803impl<'de> DeserializeStrict<'de> for InstallationDetails {
804    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
805        #[derive(Deserialize)]
806        #[serde(deny_unknown_fields)]
807        struct __Wire {
808            #[serde(rename = "apiUrl")]
809            api_url: Strict<String>,
810            #[serde(rename = "configurationUrl")]
811            #[serde(default)]
812            configuration_url: Strict<Option<String>>,
813            #[serde(rename = "installation")]
814            installation: Strict<Installation>,
815        }
816        let wire = __Wire::deserialize(deserializer)?;
817        Ok(Self {
818            api_url: wire.api_url.0,
819            configuration_url: wire.configuration_url.0,
820            installation: wire.installation.0,
821        })
822    }
823}
824
825/// InstallationGrant contract value.
826#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
827pub struct InstallationGrant {
828    /// Contract field projects.
829    #[serde(rename = "projects")]
830    pub projects: InstallationProjects,
831    /// Contract field scopes.
832    #[serde(rename = "scopes")]
833    pub scopes: Vec<String>,
834}
835impl<'de> DeserializeStrict<'de> for InstallationGrant {
836    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
837        #[derive(Deserialize)]
838        #[serde(deny_unknown_fields)]
839        struct __Wire {
840            #[serde(rename = "projects")]
841            projects: Strict<InstallationProjects>,
842            #[serde(rename = "scopes")]
843            scopes: Strict<Vec<String>>,
844        }
845        let wire = __Wire::deserialize(deserializer)?;
846        Ok(Self {
847            projects: wire.projects.0,
848            scopes: wire.scopes.0,
849        })
850    }
851}
852
853/// InstallationPage contract value.
854#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
855pub struct InstallationPage {
856    /// Contract field installations.
857    #[serde(rename = "installations")]
858    pub installations: Vec<Installation>,
859    /// Contract field nextPageToken.
860    #[serde(rename = "nextPageToken")]
861    #[serde(default, skip_serializing_if = "Option::is_none")]
862    pub next_page_token: Option<String>,
863}
864impl<'de> DeserializeStrict<'de> for InstallationPage {
865    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
866        #[derive(Deserialize)]
867        #[serde(deny_unknown_fields)]
868        struct __Wire {
869            #[serde(rename = "installations")]
870            installations: Strict<Vec<Installation>>,
871            #[serde(rename = "nextPageToken")]
872            #[serde(default)]
873            next_page_token: Strict<Option<String>>,
874        }
875        let wire = __Wire::deserialize(deserializer)?;
876        Ok(Self {
877            installations: wire.installations.0,
878            next_page_token: wire.next_page_token.0,
879        })
880    }
881}
882
883/// InstallationProject contract value.
884#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
885pub struct InstallationProject {
886    /// Contract field description.
887    #[serde(rename = "description")]
888    #[serde(default, skip_serializing_if = "Option::is_none")]
889    pub description: Option<String>,
890    /// Contract field id.
891    #[serde(rename = "id")]
892    pub id: String,
893    /// Contract field organizationId.
894    #[serde(rename = "organizationId")]
895    pub organization_id: String,
896}
897impl<'de> DeserializeStrict<'de> for InstallationProject {
898    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
899        #[derive(Deserialize)]
900        #[serde(deny_unknown_fields)]
901        struct __Wire {
902            #[serde(rename = "description")]
903            #[serde(default)]
904            description: Strict<Option<String>>,
905            #[serde(rename = "id")]
906            id: Strict<String>,
907            #[serde(rename = "organizationId")]
908            organization_id: Strict<String>,
909        }
910        let wire = __Wire::deserialize(deserializer)?;
911        Ok(Self {
912            description: wire.description.0,
913            id: wire.id.0,
914            organization_id: wire.organization_id.0,
915        })
916    }
917}
918
919/// InstallationProjectPage contract value.
920#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
921pub struct InstallationProjectPage {
922    /// Contract field nextPageToken.
923    #[serde(rename = "nextPageToken")]
924    #[serde(default, skip_serializing_if = "Option::is_none")]
925    pub next_page_token: Option<String>,
926    /// Contract field projects.
927    #[serde(rename = "projects")]
928    pub projects: Vec<InstallationProject>,
929}
930impl<'de> DeserializeStrict<'de> for InstallationProjectPage {
931    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
932        #[derive(Deserialize)]
933        #[serde(deny_unknown_fields)]
934        struct __Wire {
935            #[serde(rename = "nextPageToken")]
936            #[serde(default)]
937            next_page_token: Strict<Option<String>>,
938            #[serde(rename = "projects")]
939            projects: Strict<Vec<InstallationProject>>,
940        }
941        let wire = __Wire::deserialize(deserializer)?;
942        Ok(Self {
943            next_page_token: wire.next_page_token.0,
944            projects: wire.projects.0,
945        })
946    }
947}
948
949/// Every Project in the Organization, including Projects created later, when `all` is true.
950/// Otherwise, only the listed Projects.
951#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
952pub struct InstallationProjects {
953    /// Contract field all.
954    #[serde(rename = "all")]
955    pub all: bool,
956    /// Contract field projectIds.
957    #[serde(rename = "projectIds")]
958    pub project_ids: Vec<String>,
959}
960impl<'de> DeserializeStrict<'de> for InstallationProjects {
961    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
962        #[derive(Deserialize)]
963        #[serde(deny_unknown_fields)]
964        struct __Wire {
965            #[serde(rename = "all")]
966            all: Strict<bool>,
967            #[serde(rename = "projectIds")]
968            project_ids: Strict<Vec<String>>,
969        }
970        let wire = __Wire::deserialize(deserializer)?;
971        Ok(Self {
972            all: wire.all.0,
973            project_ids: wire.project_ids.0,
974        })
975    }
976}
977
978/// InstallationRequest contract value.
979#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
980pub struct InstallationRequest {
981    /// Contract field applicationId.
982    #[serde(rename = "applicationId")]
983    pub application_id: String,
984    /// Contract field projects.
985    #[serde(rename = "projects")]
986    pub projects: InstallationProjects,
987    /// Contract field scopes.
988    #[serde(rename = "scopes")]
989    pub scopes: Vec<String>,
990}
991impl<'de> DeserializeStrict<'de> for InstallationRequest {
992    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
993        #[derive(Deserialize)]
994        #[serde(deny_unknown_fields)]
995        struct __Wire {
996            #[serde(rename = "applicationId")]
997            application_id: Strict<String>,
998            #[serde(rename = "projects")]
999            projects: Strict<InstallationProjects>,
1000            #[serde(rename = "scopes")]
1001            scopes: Strict<Vec<String>>,
1002        }
1003        let wire = __Wire::deserialize(deserializer)?;
1004        Ok(Self {
1005            application_id: wire.application_id.0,
1006            projects: wire.projects.0,
1007            scopes: wire.scopes.0,
1008        })
1009    }
1010}
1011
1012/// Approve or decline the exact request shown to an Organization owner. A changed request returns
1013/// Conflict and must be reviewed again. Declining an update preserves the existing approval;
1014/// declining a new installation removes the request.
1015#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1016pub struct InstallationReview {
1017    /// Contract field approve.
1018    #[serde(rename = "approve")]
1019    pub approve: bool,
1020    /// Contract field requested.
1021    #[serde(rename = "requested")]
1022    pub requested: InstallationGrant,
1023}
1024impl<'de> DeserializeStrict<'de> for InstallationReview {
1025    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1026        #[derive(Deserialize)]
1027        #[serde(deny_unknown_fields)]
1028        struct __Wire {
1029            #[serde(rename = "approve")]
1030            approve: Strict<bool>,
1031            #[serde(rename = "requested")]
1032            requested: Strict<InstallationGrant>,
1033        }
1034        let wire = __Wire::deserialize(deserializer)?;
1035        Ok(Self {
1036            approve: wire.approve.0,
1037            requested: wire.requested.0,
1038        })
1039    }
1040}
1041
1042/// InstallationStatus contract value.
1043#[derive(Clone, Debug, PartialEq, Eq)]
1044pub enum InstallationStatus {
1045    /// A known contract value.
1046    Requested,
1047    /// A known contract value.
1048    Active,
1049    /// A known contract value.
1050    Suspended,
1051    /// A value introduced by a newer server.
1052    Unknown(String),
1053}
1054impl Serialize for InstallationStatus {
1055    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1056        serializer.serialize_str(match self {
1057            Self::Requested => "requested",
1058            Self::Active => "active",
1059            Self::Suspended => "suspended",
1060            Self::Unknown(value) => value,
1061        })
1062    }
1063}
1064impl<'de> Deserialize<'de> for InstallationStatus {
1065    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1066        Ok(match String::deserialize(deserializer)?.as_str() {
1067            "requested" => Self::Requested,
1068            "active" => Self::Active,
1069            "suspended" => Self::Suspended,
1070            value => Self::Unknown(value.to_owned()),
1071        })
1072    }
1073}
1074impl<'de> DeserializeStrict<'de> for InstallationStatus {
1075    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1076        #[derive(Deserialize)]
1077        enum __Known {
1078            #[serde(rename = "requested")]
1079            Requested,
1080            #[serde(rename = "active")]
1081            Active,
1082            #[serde(rename = "suspended")]
1083            Suspended,
1084        }
1085        Ok(match __Known::deserialize(deserializer)? {
1086            __Known::Requested => Self::Requested,
1087            __Known::Active => Self::Active,
1088            __Known::Suspended => Self::Suspended,
1089        })
1090    }
1091}
1092
1093/// InstallationStatusChange contract value.
1094#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1095pub struct InstallationStatusChange {
1096    /// Contract field enabled.
1097    #[serde(rename = "enabled")]
1098    pub enabled: bool,
1099}
1100impl<'de> DeserializeStrict<'de> for InstallationStatusChange {
1101    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1102        #[derive(Deserialize)]
1103        #[serde(deny_unknown_fields)]
1104        struct __Wire {
1105            #[serde(rename = "enabled")]
1106            enabled: Strict<bool>,
1107        }
1108        let wire = __Wire::deserialize(deserializer)?;
1109        Ok(Self {
1110            enabled: wire.enabled.0,
1111        })
1112    }
1113}
1114
1115/// approvedAllProjects is true when the approved grant covers every Project in the Organization,
1116/// including Projects created later, and false when it covers only listed Projects. It is absent
1117/// while no grant is approved, and approvedScopes is then empty.
1118#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1119pub struct InstallationSummary {
1120    /// Contract field apiUrl.
1121    #[serde(rename = "apiUrl")]
1122    pub api_url: String,
1123    /// Contract field applicationId.
1124    #[serde(rename = "applicationId")]
1125    pub application_id: String,
1126    /// Contract field approvedAllProjects.
1127    #[serde(rename = "approvedAllProjects")]
1128    #[serde(default, skip_serializing_if = "Option::is_none")]
1129    pub approved_all_projects: Option<bool>,
1130    /// Contract field approvedScopes.
1131    #[serde(rename = "approvedScopes")]
1132    pub approved_scopes: Vec<String>,
1133    /// Contract field id.
1134    #[serde(rename = "id")]
1135    pub id: String,
1136    /// Contract field organizationId.
1137    #[serde(rename = "organizationId")]
1138    pub organization_id: String,
1139    /// Contract field requestedScopes.
1140    #[serde(rename = "requestedScopes")]
1141    pub requested_scopes: Vec<String>,
1142    /// Contract field status.
1143    #[serde(rename = "status")]
1144    pub status: InstallationStatus,
1145}
1146impl<'de> DeserializeStrict<'de> for InstallationSummary {
1147    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1148        #[derive(Deserialize)]
1149        #[serde(deny_unknown_fields)]
1150        struct __Wire {
1151            #[serde(rename = "apiUrl")]
1152            api_url: Strict<String>,
1153            #[serde(rename = "applicationId")]
1154            application_id: Strict<String>,
1155            #[serde(rename = "approvedAllProjects")]
1156            #[serde(default)]
1157            approved_all_projects: Strict<Option<bool>>,
1158            #[serde(rename = "approvedScopes")]
1159            approved_scopes: Strict<Vec<String>>,
1160            #[serde(rename = "id")]
1161            id: Strict<String>,
1162            #[serde(rename = "organizationId")]
1163            organization_id: Strict<String>,
1164            #[serde(rename = "requestedScopes")]
1165            requested_scopes: Strict<Vec<String>>,
1166            #[serde(rename = "status")]
1167            status: Strict<InstallationStatus>,
1168        }
1169        let wire = __Wire::deserialize(deserializer)?;
1170        Ok(Self {
1171            api_url: wire.api_url.0,
1172            application_id: wire.application_id.0,
1173            approved_all_projects: wire.approved_all_projects.0,
1174            approved_scopes: wire.approved_scopes.0,
1175            id: wire.id.0,
1176            organization_id: wire.organization_id.0,
1177            requested_scopes: wire.requested_scopes.0,
1178            status: wire.status.0,
1179        })
1180    }
1181}
1182
1183/// ListApplicationsRequest contract value.
1184#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1185pub struct ListApplicationsRequest {
1186    /// Contract field pageSize.
1187    #[serde(rename = "pageSize")]
1188    #[serde(default, skip_serializing_if = "Option::is_none")]
1189    pub page_size: Option<u32>,
1190    /// Contract field pageToken.
1191    #[serde(rename = "pageToken")]
1192    #[serde(default, skip_serializing_if = "Option::is_none")]
1193    pub page_token: Option<String>,
1194}
1195impl<'de> DeserializeStrict<'de> for ListApplicationsRequest {
1196    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1197        #[derive(Deserialize)]
1198        #[serde(deny_unknown_fields)]
1199        struct __Wire {
1200            #[serde(rename = "pageSize")]
1201            #[serde(default)]
1202            page_size: Strict<Option<u32>>,
1203            #[serde(rename = "pageToken")]
1204            #[serde(default)]
1205            page_token: Strict<Option<String>>,
1206        }
1207        let wire = __Wire::deserialize(deserializer)?;
1208        Ok(Self {
1209            page_size: wire.page_size.0,
1210            page_token: wire.page_token.0,
1211        })
1212    }
1213}
1214
1215/// The Applications and MCP clients that the users of an Organization can sign in to. The decision
1216/// for a listed client applies first. `unlisted` applies to every other client.
1217#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1218pub struct OrganizationAppAccess {
1219    /// Contract field clients.
1220    #[serde(rename = "clients")]
1221    pub clients: Vec<ClientAppAccess>,
1222    /// Contract field unlisted.
1223    #[serde(rename = "unlisted")]
1224    pub unlisted: UnlistedAppAccess,
1225}
1226impl<'de> DeserializeStrict<'de> for OrganizationAppAccess {
1227    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1228        #[derive(Deserialize)]
1229        #[serde(deny_unknown_fields)]
1230        struct __Wire {
1231            #[serde(rename = "clients")]
1232            clients: Strict<Vec<ClientAppAccess>>,
1233            #[serde(rename = "unlisted")]
1234            unlisted: Strict<UnlistedAppAccess>,
1235        }
1236        let wire = __Wire::deserialize(deserializer)?;
1237        Ok(Self {
1238            clients: wire.clients.0,
1239            unlisted: wire.unlisted.0,
1240        })
1241    }
1242}
1243
1244/// What happens to an Application that the Organization did not list. `allow_reviewed` allows
1245/// Applications that Spiral reviewed. `block` blocks all of them.
1246#[derive(Clone, Debug, PartialEq, Eq)]
1247pub enum UnlistedAppAccess {
1248    /// A known contract value.
1249    AllowReviewed,
1250    /// A known contract value.
1251    Block,
1252    /// A value introduced by a newer server.
1253    Unknown(String),
1254}
1255impl Serialize for UnlistedAppAccess {
1256    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1257        serializer.serialize_str(match self {
1258            Self::AllowReviewed => "allow_reviewed",
1259            Self::Block => "block",
1260            Self::Unknown(value) => value,
1261        })
1262    }
1263}
1264impl<'de> Deserialize<'de> for UnlistedAppAccess {
1265    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1266        Ok(match String::deserialize(deserializer)?.as_str() {
1267            "allow_reviewed" => Self::AllowReviewed,
1268            "block" => Self::Block,
1269            value => Self::Unknown(value.to_owned()),
1270        })
1271    }
1272}
1273impl<'de> DeserializeStrict<'de> for UnlistedAppAccess {
1274    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1275        #[derive(Deserialize)]
1276        enum __Known {
1277            #[serde(rename = "allow_reviewed")]
1278            AllowReviewed,
1279            #[serde(rename = "block")]
1280            Block,
1281        }
1282        Ok(match __Known::deserialize(deserializer)? {
1283            __Known::AllowReviewed => Self::AllowReviewed,
1284            __Known::Block => Self::Block,
1285        })
1286    }
1287}
1288
1289/// Setup state for the caller's app and Organization. An absent installation means setup has not
1290/// started. configurationUrl is the Studio page for this app and Organization: it starts setup when
1291/// there is no installation and changes the existing one otherwise. It depends only on the app and
1292/// Organization, so it is here and not on the installation. It carries no `state`, so append your
1293/// own. It is absent when the deployment does not name its Studio. Project enumeration uses the
1294/// user installation project list.
1295#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1296pub struct UserInstallation {
1297    /// Contract field configurationUrl.
1298    #[serde(rename = "configurationUrl")]
1299    #[serde(default, skip_serializing_if = "Option::is_none")]
1300    pub configuration_url: Option<String>,
1301    /// Contract field installation.
1302    #[serde(rename = "installation")]
1303    #[serde(default, skip_serializing_if = "Option::is_none")]
1304    pub installation: Option<InstallationSummary>,
1305}
1306impl<'de> DeserializeStrict<'de> for UserInstallation {
1307    fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1308        #[derive(Deserialize)]
1309        #[serde(deny_unknown_fields)]
1310        struct __Wire {
1311            #[serde(rename = "configurationUrl")]
1312            #[serde(default)]
1313            configuration_url: Strict<Option<String>>,
1314            #[serde(rename = "installation")]
1315            #[serde(default)]
1316            installation: Strict<Option<InstallationSummary>>,
1317        }
1318        let wire = __Wire::deserialize(deserializer)?;
1319        Ok(Self {
1320            configuration_url: wire.configuration_url.0,
1321            installation: wire.installation.0,
1322        })
1323    }
1324}
1325
1326/// Typed errors declared by this service contract.
1327#[derive(Clone, Debug, PartialEq, Eq)]
1328pub enum AppsError {
1329    /// Apps:Conflict.
1330    Conflict { application_id: String },
1331    /// Apps:ConsentConflict.
1332    ConsentConflict { reason: String },
1333    /// Apps:InvalidArgument.
1334    InvalidArgument { reason: String },
1335    /// Apps:InvalidConsent.
1336    InvalidConsent { reason: String },
1337    /// Apps:NotFound.
1338    NotFound { application_id: String },
1339    /// Apps:RegistrationUnavailable.
1340    RegistrationUnavailable { application_id: String },
1341}
1342impl AppsError {
1343    /// HTTP status for this declared error.
1344    pub fn status(&self) -> u16 {
1345        match self {
1346            Self::Conflict { .. } => 409,
1347            Self::ConsentConflict { .. } => 409,
1348            Self::InvalidArgument { .. } => 400,
1349            Self::InvalidConsent { .. } => 400,
1350            Self::NotFound { .. } => 404,
1351            Self::RegistrationUnavailable { .. } => 500,
1352        }
1353    }
1354    /// Serialize only contract-declared error parameters.
1355    pub fn envelope(&self, instance: String) -> ErrorEnvelope {
1356        match self {
1357            Self::Conflict { application_id } => {
1358                let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:Conflict", instance);
1359                envelope
1360                    .parameters
1361                    .insert("applicationId".into(), application_id.to_string());
1362                envelope
1363            }
1364            Self::ConsentConflict { reason } => {
1365                let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:ConsentConflict", instance);
1366                envelope
1367                    .parameters
1368                    .insert("reason".into(), reason.to_string());
1369                envelope
1370            }
1371            Self::InvalidArgument { reason } => {
1372                let mut envelope =
1373                    ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidArgument", instance);
1374                envelope
1375                    .parameters
1376                    .insert("reason".into(), reason.to_string());
1377                envelope
1378            }
1379            Self::InvalidConsent { reason } => {
1380                let mut envelope =
1381                    ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidConsent", instance);
1382                envelope
1383                    .parameters
1384                    .insert("reason".into(), reason.to_string());
1385                envelope
1386            }
1387            Self::NotFound { application_id } => {
1388                let mut envelope = ErrorEnvelope::new("NOT_FOUND", "Apps:NotFound", instance);
1389                envelope
1390                    .parameters
1391                    .insert("applicationId".into(), application_id.to_string());
1392                envelope
1393            }
1394            Self::RegistrationUnavailable { application_id } => {
1395                let mut envelope =
1396                    ErrorEnvelope::new("INTERNAL", "Apps:RegistrationUnavailable", instance);
1397                envelope
1398                    .parameters
1399                    .insert("applicationId".into(), application_id.to_string());
1400                envelope
1401            }
1402        }
1403    }
1404    /// Decode a declared error and its typed error parameters.
1405    pub fn decode_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
1406        if envelope.error_instance_id.len() != 36
1407            || Uuid::parse_str(&envelope.error_instance_id).is_err()
1408        {
1409            return None;
1410        }
1411        match envelope.error_name.as_str() {
1412            "Apps:Conflict" => {
1413                if envelope.error_code != "CONFLICT" {
1414                    return None;
1415                }
1416                let application_id = envelope.parameters.get("applicationId")?.clone();
1417                Some(Self::Conflict { application_id })
1418            }
1419            "Apps:ConsentConflict" => {
1420                if envelope.error_code != "CONFLICT" {
1421                    return None;
1422                }
1423                let reason = envelope.parameters.get("reason")?.clone();
1424                Some(Self::ConsentConflict { reason })
1425            }
1426            "Apps:InvalidArgument" => {
1427                if envelope.error_code != "INVALID_ARGUMENT" {
1428                    return None;
1429                }
1430                let reason = envelope.parameters.get("reason")?.clone();
1431                Some(Self::InvalidArgument { reason })
1432            }
1433            "Apps:InvalidConsent" => {
1434                if envelope.error_code != "INVALID_ARGUMENT" {
1435                    return None;
1436                }
1437                let reason = envelope.parameters.get("reason")?.clone();
1438                Some(Self::InvalidConsent { reason })
1439            }
1440            "Apps:NotFound" => {
1441                if envelope.error_code != "NOT_FOUND" {
1442                    return None;
1443                }
1444                let application_id = envelope.parameters.get("applicationId")?.clone();
1445                Some(Self::NotFound { application_id })
1446            }
1447            "Apps:RegistrationUnavailable" => {
1448                if envelope.error_code != "INTERNAL" {
1449                    return None;
1450                }
1451                let application_id = envelope.parameters.get("applicationId")?.clone();
1452                Some(Self::RegistrationUnavailable { application_id })
1453            }
1454            _ => None,
1455        }
1456    }
1457}
1458impl Display for AppsError {
1459    fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
1460        match self {
1461            Self::Conflict { application_id } => write!(
1462                formatter,
1463                "Apps:Conflict (applicationId: {})",
1464                application_id
1465            ),
1466            Self::ConsentConflict { reason } => {
1467                write!(formatter, "Apps:ConsentConflict (reason: {})", reason)
1468            }
1469            Self::InvalidArgument { reason } => {
1470                write!(formatter, "Apps:InvalidArgument (reason: {})", reason)
1471            }
1472            Self::InvalidConsent { reason } => {
1473                write!(formatter, "Apps:InvalidConsent (reason: {})", reason)
1474            }
1475            Self::NotFound { application_id } => write!(
1476                formatter,
1477                "Apps:NotFound (applicationId: {})",
1478                application_id
1479            ),
1480            Self::RegistrationUnavailable { application_id } => write!(
1481                formatter,
1482                "Apps:RegistrationUnavailable (applicationId: {})",
1483                application_id
1484            ),
1485        }
1486    }
1487}
1488impl StdError for AppsError {}
1489impl ServiceError for AppsError {
1490    fn to_envelope(&self, instance: String) -> ErrorEnvelope {
1491        Self::envelope(self, instance)
1492    }
1493    fn from_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
1494        Self::decode_envelope(envelope)
1495    }
1496}
1497#[automatically_derived]
1498impl Default for ListApplicationsRequest {
1499    fn default() -> Self {
1500        Self {
1501            page_size: None,
1502            page_token: None,
1503        }
1504    }
1505}