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