Skip to main content

jacquard_api/network_slices/slice/
create_o_auth_client.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.slice.createOAuthClient
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::UriValue;
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19use crate::network_slices::slice::get_o_auth_clients::OauthClientDetails;
20
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
22#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
23pub struct CreateOAuthClient<S: BosStr = DefaultStr> {
24    ///Human-readable name of the OAuth client
25    pub client_name: S,
26    ///URI of the client application
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub client_uri: Option<UriValue<S>>,
29    ///OAuth grant types
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub grant_types: Option<Vec<S>>,
32    ///URI of the client logo
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub logo_uri: Option<UriValue<S>>,
35    ///URI of the privacy policy
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub policy_uri: Option<UriValue<S>>,
38    ///Allowed redirect URIs for OAuth flow (must use HTTP or HTTPS)
39    pub redirect_uris: Vec<UriValue<S>>,
40    ///OAuth response types
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub response_types: Option<Vec<S>>,
43    ///OAuth scope
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub scope: Option<S>,
46    ///AT-URI of the slice to register the OAuth client for
47    pub slice_uri: S,
48    ///URI of the terms of service
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub tos_uri: Option<UriValue<S>>,
51    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
52    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
53}
54
55
56#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
57#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
58pub struct CreateOAuthClientOutput<S: BosStr = DefaultStr> {
59    #[serde(flatten)]
60    pub value: OauthClientDetails<S>,
61    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
62    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
63}
64
65/** Response marker for the `network.slices.slice.createOAuthClient` procedure.
66
67Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `CreateOAuthClientOutput<S>` for this endpoint.*/
68pub struct CreateOAuthClientResponse;
69impl jacquard_common::xrpc::XrpcResp for CreateOAuthClientResponse {
70    const NSID: &'static str = "network.slices.slice.createOAuthClient";
71    const ENCODING: &'static str = "application/json";
72    type Output<S: BosStr> = CreateOAuthClientOutput<S>;
73    type Err = jacquard_common::xrpc::GenericError;
74}
75
76impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CreateOAuthClient<S> {
77    const NSID: &'static str = "network.slices.slice.createOAuthClient";
78    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
79        "application/json",
80    );
81    type Response = CreateOAuthClientResponse;
82}
83
84/** Endpoint marker for the `network.slices.slice.createOAuthClient` procedure.
85
86Path: `/xrpc/network.slices.slice.createOAuthClient`. The request payload type is `CreateOAuthClient<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
87pub struct CreateOAuthClientRequest;
88impl jacquard_common::xrpc::XrpcEndpoint for CreateOAuthClientRequest {
89    const PATH: &'static str = "/xrpc/network.slices.slice.createOAuthClient";
90    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
91        "application/json",
92    );
93    type Request<S: BosStr> = CreateOAuthClient<S>;
94    type Response = CreateOAuthClientResponse;
95}
96
97pub mod create_o_auth_client_state {
98
99    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
100    #[allow(unused)]
101    use ::core::marker::PhantomData;
102    mod sealed {
103        pub trait Sealed {}
104    }
105    /// State trait tracking which required fields have been set
106    pub trait State: sealed::Sealed {
107        type ClientName;
108        type RedirectUris;
109        type SliceUri;
110    }
111    /// Empty state - all required fields are unset
112    pub struct Empty(());
113    impl sealed::Sealed for Empty {}
114    impl State for Empty {
115        type ClientName = Unset;
116        type RedirectUris = Unset;
117        type SliceUri = Unset;
118    }
119    ///State transition - sets the `client_name` field to Set
120    pub struct SetClientName<St: State = Empty>(PhantomData<fn() -> St>);
121    impl<St: State> sealed::Sealed for SetClientName<St> {}
122    impl<St: State> State for SetClientName<St> {
123        type ClientName = Set<members::client_name>;
124        type RedirectUris = St::RedirectUris;
125        type SliceUri = St::SliceUri;
126    }
127    ///State transition - sets the `redirect_uris` field to Set
128    pub struct SetRedirectUris<St: State = Empty>(PhantomData<fn() -> St>);
129    impl<St: State> sealed::Sealed for SetRedirectUris<St> {}
130    impl<St: State> State for SetRedirectUris<St> {
131        type ClientName = St::ClientName;
132        type RedirectUris = Set<members::redirect_uris>;
133        type SliceUri = St::SliceUri;
134    }
135    ///State transition - sets the `slice_uri` field to Set
136    pub struct SetSliceUri<St: State = Empty>(PhantomData<fn() -> St>);
137    impl<St: State> sealed::Sealed for SetSliceUri<St> {}
138    impl<St: State> State for SetSliceUri<St> {
139        type ClientName = St::ClientName;
140        type RedirectUris = St::RedirectUris;
141        type SliceUri = Set<members::slice_uri>;
142    }
143    /// Marker types for field names
144    #[allow(non_camel_case_types)]
145    pub mod members {
146        ///Marker type for the `client_name` field
147        pub struct client_name(());
148        ///Marker type for the `redirect_uris` field
149        pub struct redirect_uris(());
150        ///Marker type for the `slice_uri` field
151        pub struct slice_uri(());
152    }
153}
154
155/// Builder for constructing an instance of this type.
156pub struct CreateOAuthClientBuilder<
157    St: create_o_auth_client_state::State,
158    S: BosStr = DefaultStr,
159> {
160    _state: PhantomData<fn() -> St>,
161    _fields: (
162        Option<S>,
163        Option<UriValue<S>>,
164        Option<Vec<S>>,
165        Option<UriValue<S>>,
166        Option<UriValue<S>>,
167        Option<Vec<UriValue<S>>>,
168        Option<Vec<S>>,
169        Option<S>,
170        Option<S>,
171        Option<UriValue<S>>,
172    ),
173    _type: PhantomData<fn() -> S>,
174}
175
176impl CreateOAuthClient<DefaultStr> {
177    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
178    pub fn new() -> CreateOAuthClientBuilder<
179        create_o_auth_client_state::Empty,
180        DefaultStr,
181    > {
182        CreateOAuthClientBuilder::new()
183    }
184}
185
186impl<S: BosStr> CreateOAuthClient<S> {
187    /// Create a new builder for this type
188    pub fn builder() -> CreateOAuthClientBuilder<create_o_auth_client_state::Empty, S> {
189        CreateOAuthClientBuilder::builder()
190    }
191}
192
193impl CreateOAuthClientBuilder<create_o_auth_client_state::Empty, DefaultStr> {
194    /// Create a new builder with all fields unset, using the default string type, if needed
195    pub fn new() -> Self {
196        CreateOAuthClientBuilder {
197            _state: PhantomData,
198            _fields: (None, None, None, None, None, None, None, None, None, None),
199            _type: PhantomData,
200        }
201    }
202}
203
204impl<S: BosStr> CreateOAuthClientBuilder<create_o_auth_client_state::Empty, S> {
205    /// Create a new builder with all fields unset
206    pub fn builder() -> Self {
207        CreateOAuthClientBuilder {
208            _state: PhantomData,
209            _fields: (None, None, None, None, None, None, None, None, None, None),
210            _type: PhantomData,
211        }
212    }
213}
214
215impl<St, S: BosStr> CreateOAuthClientBuilder<St, S>
216where
217    St: create_o_auth_client_state::State,
218    St::ClientName: create_o_auth_client_state::IsUnset,
219{
220    /// Set the `clientName` field (required)
221    pub fn client_name(
222        mut self,
223        value: impl Into<S>,
224    ) -> CreateOAuthClientBuilder<create_o_auth_client_state::SetClientName<St>, S> {
225        self._fields.0 = Option::Some(value.into());
226        CreateOAuthClientBuilder {
227            _state: PhantomData,
228            _fields: self._fields,
229            _type: PhantomData,
230        }
231    }
232}
233
234impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
235    /// Set the `clientUri` field (optional)
236    pub fn client_uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
237        self._fields.1 = value.into();
238        self
239    }
240    /// Set the `clientUri` field to an Option value (optional)
241    pub fn maybe_client_uri(mut self, value: Option<UriValue<S>>) -> Self {
242        self._fields.1 = value;
243        self
244    }
245}
246
247impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
248    /// Set the `grantTypes` field (optional)
249    pub fn grant_types(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
250        self._fields.2 = value.into();
251        self
252    }
253    /// Set the `grantTypes` field to an Option value (optional)
254    pub fn maybe_grant_types(mut self, value: Option<Vec<S>>) -> Self {
255        self._fields.2 = value;
256        self
257    }
258}
259
260impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
261    /// Set the `logoUri` field (optional)
262    pub fn logo_uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
263        self._fields.3 = value.into();
264        self
265    }
266    /// Set the `logoUri` field to an Option value (optional)
267    pub fn maybe_logo_uri(mut self, value: Option<UriValue<S>>) -> Self {
268        self._fields.3 = value;
269        self
270    }
271}
272
273impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
274    /// Set the `policyUri` field (optional)
275    pub fn policy_uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
276        self._fields.4 = value.into();
277        self
278    }
279    /// Set the `policyUri` field to an Option value (optional)
280    pub fn maybe_policy_uri(mut self, value: Option<UriValue<S>>) -> Self {
281        self._fields.4 = value;
282        self
283    }
284}
285
286impl<St, S: BosStr> CreateOAuthClientBuilder<St, S>
287where
288    St: create_o_auth_client_state::State,
289    St::RedirectUris: create_o_auth_client_state::IsUnset,
290{
291    /// Set the `redirectUris` field (required)
292    pub fn redirect_uris(
293        mut self,
294        value: impl Into<Vec<UriValue<S>>>,
295    ) -> CreateOAuthClientBuilder<create_o_auth_client_state::SetRedirectUris<St>, S> {
296        self._fields.5 = Option::Some(value.into());
297        CreateOAuthClientBuilder {
298            _state: PhantomData,
299            _fields: self._fields,
300            _type: PhantomData,
301        }
302    }
303}
304
305impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
306    /// Set the `responseTypes` field (optional)
307    pub fn response_types(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
308        self._fields.6 = value.into();
309        self
310    }
311    /// Set the `responseTypes` field to an Option value (optional)
312    pub fn maybe_response_types(mut self, value: Option<Vec<S>>) -> Self {
313        self._fields.6 = value;
314        self
315    }
316}
317
318impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
319    /// Set the `scope` field (optional)
320    pub fn scope(mut self, value: impl Into<Option<S>>) -> Self {
321        self._fields.7 = value.into();
322        self
323    }
324    /// Set the `scope` field to an Option value (optional)
325    pub fn maybe_scope(mut self, value: Option<S>) -> Self {
326        self._fields.7 = value;
327        self
328    }
329}
330
331impl<St, S: BosStr> CreateOAuthClientBuilder<St, S>
332where
333    St: create_o_auth_client_state::State,
334    St::SliceUri: create_o_auth_client_state::IsUnset,
335{
336    /// Set the `sliceUri` field (required)
337    pub fn slice_uri(
338        mut self,
339        value: impl Into<S>,
340    ) -> CreateOAuthClientBuilder<create_o_auth_client_state::SetSliceUri<St>, S> {
341        self._fields.8 = Option::Some(value.into());
342        CreateOAuthClientBuilder {
343            _state: PhantomData,
344            _fields: self._fields,
345            _type: PhantomData,
346        }
347    }
348}
349
350impl<St: create_o_auth_client_state::State, S: BosStr> CreateOAuthClientBuilder<St, S> {
351    /// Set the `tosUri` field (optional)
352    pub fn tos_uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
353        self._fields.9 = value.into();
354        self
355    }
356    /// Set the `tosUri` field to an Option value (optional)
357    pub fn maybe_tos_uri(mut self, value: Option<UriValue<S>>) -> Self {
358        self._fields.9 = value;
359        self
360    }
361}
362
363impl<St, S: BosStr> CreateOAuthClientBuilder<St, S>
364where
365    St: create_o_auth_client_state::State,
366    St::ClientName: create_o_auth_client_state::IsSet,
367    St::RedirectUris: create_o_auth_client_state::IsSet,
368    St::SliceUri: create_o_auth_client_state::IsSet,
369{
370    /// Build the final struct.
371    pub fn build(self) -> CreateOAuthClient<S> {
372        CreateOAuthClient {
373            client_name: self._fields.0.unwrap(),
374            client_uri: self._fields.1,
375            grant_types: self._fields.2,
376            logo_uri: self._fields.3,
377            policy_uri: self._fields.4,
378            redirect_uris: self._fields.5.unwrap(),
379            response_types: self._fields.6,
380            scope: self._fields.7,
381            slice_uri: self._fields.8.unwrap(),
382            tos_uri: self._fields.9,
383            extra_data: Default::default(),
384        }
385    }
386    /// Build the final struct with custom extra_data.
387    pub fn build_with_data(
388        self,
389        extra_data: BTreeMap<SmolStr, Data<S>>,
390    ) -> CreateOAuthClient<S> {
391        CreateOAuthClient {
392            client_name: self._fields.0.unwrap(),
393            client_uri: self._fields.1,
394            grant_types: self._fields.2,
395            logo_uri: self._fields.3,
396            policy_uri: self._fields.4,
397            redirect_uris: self._fields.5.unwrap(),
398            response_types: self._fields.6,
399            scope: self._fields.7,
400            slice_uri: self._fields.8.unwrap(),
401            tos_uri: self._fields.9,
402            extra_data: Some(extra_data),
403        }
404    }
405}