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