okta/
applications.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Applications {
5    pub client: Client,
6}
7
8impl Applications {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Applications { client }
12    }
13
14    /**
15     * List Applications.
16     *
17     * This function performs a `GET` to the `/api/v1/apps` endpoint.
18     *
19     * Enumerates apps added to your organization with pagination. A subset of apps can be returned that match a supported filter expression or query.
20     *
21     * **Parameters:**
22     *
23     * * `q: &str`
24     * * `after: &str` -- Specifies the pagination cursor for the next page of apps.
25     * * `limit: i64` -- Specifies the number of results for a page.
26     * * `filter: &str` -- Filters apps by status, user.id, group.id or credentials.signing.kid expression.
27     * * `expand: &str` -- Traverses users link relationship and optionally embeds Application User resource.
28     * * `include_non_deleted: bool`
29     */
30    pub async fn list(
31        &self,
32        q: &str,
33        after: &str,
34        limit: i64,
35        filter: &str,
36        expand: &str,
37        include_non_deleted: bool,
38    ) -> ClientResult<crate::Response<Vec<crate::types::Application>>> {
39        let mut query_args: Vec<(String, String)> = Default::default();
40        if !after.is_empty() {
41            query_args.push(("after".to_string(), after.to_string()));
42        }
43        if !expand.is_empty() {
44            query_args.push(("expand".to_string(), expand.to_string()));
45        }
46        if !filter.is_empty() {
47            query_args.push(("filter".to_string(), filter.to_string()));
48        }
49        if include_non_deleted {
50            query_args.push((
51                "includeNonDeleted".to_string(),
52                include_non_deleted.to_string(),
53            ));
54        }
55        if limit > 0 {
56            query_args.push(("limit".to_string(), limit.to_string()));
57        }
58        if !q.is_empty() {
59            query_args.push(("q".to_string(), q.to_string()));
60        }
61        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
62        let url = self.client.url(&format!("/api/v1/apps?{}", query_), None);
63        self.client
64            .get(
65                &url,
66                crate::Message {
67                    body: None,
68                    content_type: None,
69                },
70            )
71            .await
72    }
73    /**
74     * List Applications.
75     *
76     * This function performs a `GET` to the `/api/v1/apps` endpoint.
77     *
78     * As opposed to `list`, this function returns all the pages of the request at once.
79     *
80     * Enumerates apps added to your organization with pagination. A subset of apps can be returned that match a supported filter expression or query.
81     */
82    pub async fn list_all(
83        &self,
84        q: &str,
85        filter: &str,
86        expand: &str,
87        include_non_deleted: bool,
88    ) -> ClientResult<crate::Response<Vec<crate::types::Application>>> {
89        let mut query_args: Vec<(String, String)> = Default::default();
90        if !expand.is_empty() {
91            query_args.push(("expand".to_string(), expand.to_string()));
92        }
93        if !filter.is_empty() {
94            query_args.push(("filter".to_string(), filter.to_string()));
95        }
96        if include_non_deleted {
97            query_args.push((
98                "includeNonDeleted".to_string(),
99                include_non_deleted.to_string(),
100            ));
101        }
102        if !q.is_empty() {
103            query_args.push(("q".to_string(), q.to_string()));
104        }
105        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
106        let url = self.client.url(&format!("/api/v1/apps?{}", query_), None);
107        self.client
108            .get_all_pages(
109                &url,
110                crate::Message {
111                    body: None,
112                    content_type: None,
113                },
114            )
115            .await
116    }
117    /**
118     * Add Application.
119     *
120     * This function performs a `POST` to the `/api/v1/apps` endpoint.
121     *
122     * Adds a new application to your Okta organization.
123     *
124     * **Parameters:**
125     *
126     * * `activate: bool` -- Executes activation lifecycle operation when creating the app.
127     * * `okta_access_gateway_agent: &str`
128     */
129    pub async fn create(
130        &self,
131        activate: bool,
132        body: &crate::types::Application,
133    ) -> ClientResult<crate::Response<crate::types::Application>> {
134        let mut query_args: Vec<(String, String)> = Default::default();
135        if activate {
136            query_args.push(("activate".to_string(), activate.to_string()));
137        }
138        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
139        let url = self.client.url(&format!("/api/v1/apps?{}", query_), None);
140        self.client
141            .post(
142                &url,
143                crate::Message {
144                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
145                    content_type: None,
146                },
147            )
148            .await
149    }
150    /**
151     * Get Application.
152     *
153     * This function performs a `GET` to the `/api/v1/apps/{appId}` endpoint.
154     *
155     * Fetches an application from your Okta organization by `id`.
156     *
157     * **Parameters:**
158     *
159     * * `app_id: &str`
160     * * `expand: &str`
161     */
162    pub async fn get(
163        &self,
164        app_id: &str,
165        expand: &str,
166    ) -> ClientResult<crate::Response<crate::types::Application>> {
167        let mut query_args: Vec<(String, String)> = Default::default();
168        if !expand.is_empty() {
169            query_args.push(("expand".to_string(), expand.to_string()));
170        }
171        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
172        let url = self.client.url(
173            &format!(
174                "/api/v1/apps/{}?{}",
175                crate::progenitor_support::encode_path(app_id),
176                query_
177            ),
178            None,
179        );
180        self.client
181            .get(
182                &url,
183                crate::Message {
184                    body: None,
185                    content_type: None,
186                },
187            )
188            .await
189    }
190    /**
191     * Update Application.
192     *
193     * This function performs a `PUT` to the `/api/v1/apps/{appId}` endpoint.
194     *
195     * Updates an application in your organization.
196     *
197     * **Parameters:**
198     *
199     * * `app_id: &str`
200     */
201    pub async fn update(
202        &self,
203        app_id: &str,
204        body: &crate::types::Application,
205    ) -> ClientResult<crate::Response<crate::types::Application>> {
206        let url = self.client.url(
207            &format!(
208                "/api/v1/apps/{}",
209                crate::progenitor_support::encode_path(app_id),
210            ),
211            None,
212        );
213        self.client
214            .put(
215                &url,
216                crate::Message {
217                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
218                    content_type: None,
219                },
220            )
221            .await
222    }
223    /**
224     * Delete Application.
225     *
226     * This function performs a `DELETE` to the `/api/v1/apps/{appId}` endpoint.
227     *
228     * Removes an inactive application.
229     *
230     * **Parameters:**
231     *
232     * * `app_id: &str`
233     */
234    pub async fn delete(&self, app_id: &str) -> ClientResult<crate::Response<()>> {
235        let url = self.client.url(
236            &format!(
237                "/api/v1/apps/{}",
238                crate::progenitor_support::encode_path(app_id),
239            ),
240            None,
241        );
242        self.client
243            .delete(
244                &url,
245                crate::Message {
246                    body: None,
247                    content_type: None,
248                },
249            )
250            .await
251    }
252    /**
253     * List Certificate Signing Requests for Application.
254     *
255     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/csrs` endpoint.
256     *
257     * Enumerates Certificate Signing Requests for an application
258     *
259     * **Parameters:**
260     *
261     * * `app_id: &str`
262     */
263    pub async fn list_csrs_fors(
264        &self,
265        app_id: &str,
266    ) -> ClientResult<crate::Response<Vec<crate::types::Csr>>> {
267        let url = self.client.url(
268            &format!(
269                "/api/v1/apps/{}/credentials/csrs",
270                crate::progenitor_support::encode_path(app_id),
271            ),
272            None,
273        );
274        self.client
275            .get(
276                &url,
277                crate::Message {
278                    body: None,
279                    content_type: None,
280                },
281            )
282            .await
283    }
284    /**
285     * List Certificate Signing Requests for Application.
286     *
287     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/csrs` endpoint.
288     *
289     * As opposed to `list_csrs_for`, this function returns all the pages of the request at once.
290     *
291     * Enumerates Certificate Signing Requests for an application
292     */
293    pub async fn list_all_csrs_fors(
294        &self,
295        app_id: &str,
296    ) -> ClientResult<crate::Response<Vec<crate::types::Csr>>> {
297        let url = self.client.url(
298            &format!(
299                "/api/v1/apps/{}/credentials/csrs",
300                crate::progenitor_support::encode_path(app_id),
301            ),
302            None,
303        );
304        self.client
305            .get_all_pages(
306                &url,
307                crate::Message {
308                    body: None,
309                    content_type: None,
310                },
311            )
312            .await
313    }
314    /**
315     * Generate Certificate Signing Request for Application.
316     *
317     * This function performs a `POST` to the `/api/v1/apps/{appId}/credentials/csrs` endpoint.
318     *
319     * Generates a new key pair and returns the Certificate Signing Request for it.
320     *
321     * **Parameters:**
322     *
323     * * `app_id: &str`
324     */
325    pub async fn generate_csr_for(
326        &self,
327        app_id: &str,
328        body: &crate::types::CsrMetadata,
329    ) -> ClientResult<crate::Response<crate::types::Csr>> {
330        let url = self.client.url(
331            &format!(
332                "/api/v1/apps/{}/credentials/csrs",
333                crate::progenitor_support::encode_path(app_id),
334            ),
335            None,
336        );
337        self.client
338            .post(
339                &url,
340                crate::Message {
341                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
342                    content_type: None,
343                },
344            )
345            .await
346    }
347    /**
348     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/csrs/{csrId}` endpoint.
349     *
350     * **Parameters:**
351     *
352     * * `app_id: &str`
353     * * `csr_id: &str`
354     */
355    pub async fn get_csr_for(
356        &self,
357        app_id: &str,
358        csr_id: &str,
359    ) -> ClientResult<crate::Response<crate::types::Csr>> {
360        let url = self.client.url(
361            &format!(
362                "/api/v1/apps/{}/credentials/csrs/{}",
363                crate::progenitor_support::encode_path(app_id),
364                crate::progenitor_support::encode_path(csr_id),
365            ),
366            None,
367        );
368        self.client
369            .get(
370                &url,
371                crate::Message {
372                    body: None,
373                    content_type: None,
374                },
375            )
376            .await
377    }
378    /**
379     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/credentials/csrs/{csrId}` endpoint.
380     *
381     * **Parameters:**
382     *
383     * * `app_id: &str`
384     * * `csr_id: &str`
385     */
386    pub async fn revoke_csr_from(
387        &self,
388        app_id: &str,
389        csr_id: &str,
390    ) -> ClientResult<crate::Response<()>> {
391        let url = self.client.url(
392            &format!(
393                "/api/v1/apps/{}/credentials/csrs/{}",
394                crate::progenitor_support::encode_path(app_id),
395                crate::progenitor_support::encode_path(csr_id),
396            ),
397            None,
398        );
399        self.client
400            .delete(
401                &url,
402                crate::Message {
403                    body: None,
404                    content_type: None,
405                },
406            )
407            .await
408    }
409    /**
410     * This function performs a `POST` to the `/api/v1/apps/{appId}/credentials/csrs/{csrId}/lifecycle/publish` endpoint.
411     *
412     * **Parameters:**
413     *
414     * * `app_id: &str`
415     * * `csr_id: &str`
416     */
417    pub async fn post_app_credentials_csr_lifecycle_publish(
418        &self,
419        app_id: &str,
420        csr_id: &str,
421    ) -> ClientResult<crate::Response<crate::types::JsonWebKey>> {
422        let url = self.client.url(
423            &format!(
424                "/api/v1/apps/{}/credentials/csrs/{}/lifecycle/publish",
425                crate::progenitor_support::encode_path(app_id),
426                crate::progenitor_support::encode_path(csr_id),
427            ),
428            None,
429        );
430        self.client
431            .post(
432                &url,
433                crate::Message {
434                    body: None,
435                    content_type: None,
436                },
437            )
438            .await
439    }
440    /**
441     * List Key Credentials for Application.
442     *
443     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/keys` endpoint.
444     *
445     * Enumerates key credentials for an application
446     *
447     * **Parameters:**
448     *
449     * * `app_id: &str`
450     */
451    pub async fn list_keys(
452        &self,
453        app_id: &str,
454    ) -> ClientResult<crate::Response<Vec<crate::types::JsonWebKey>>> {
455        let url = self.client.url(
456            &format!(
457                "/api/v1/apps/{}/credentials/keys",
458                crate::progenitor_support::encode_path(app_id),
459            ),
460            None,
461        );
462        self.client
463            .get(
464                &url,
465                crate::Message {
466                    body: None,
467                    content_type: None,
468                },
469            )
470            .await
471    }
472    /**
473     * List Key Credentials for Application.
474     *
475     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/keys` endpoint.
476     *
477     * As opposed to `list_keys`, this function returns all the pages of the request at once.
478     *
479     * Enumerates key credentials for an application
480     */
481    pub async fn list_all_keys(
482        &self,
483        app_id: &str,
484    ) -> ClientResult<crate::Response<Vec<crate::types::JsonWebKey>>> {
485        let url = self.client.url(
486            &format!(
487                "/api/v1/apps/{}/credentials/keys",
488                crate::progenitor_support::encode_path(app_id),
489            ),
490            None,
491        );
492        self.client
493            .get_all_pages(
494                &url,
495                crate::Message {
496                    body: None,
497                    content_type: None,
498                },
499            )
500            .await
501    }
502    /**
503     * This function performs a `POST` to the `/api/v1/apps/{appId}/credentials/keys/generate` endpoint.
504     *
505     * Generates a new X.509 certificate for an application key credential
506     *
507     * **Parameters:**
508     *
509     * * `app_id: &str`
510     * * `validity_years: i64`
511     */
512    pub async fn generate_key(
513        &self,
514        app_id: &str,
515        validity_years: i64,
516    ) -> ClientResult<crate::Response<crate::types::JsonWebKey>> {
517        let mut query_args: Vec<(String, String)> = Default::default();
518        if validity_years > 0 {
519            query_args.push(("validityYears".to_string(), validity_years.to_string()));
520        }
521        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
522        let url = self.client.url(
523            &format!(
524                "/api/v1/apps/{}/credentials/keys/generate?{}",
525                crate::progenitor_support::encode_path(app_id),
526                query_
527            ),
528            None,
529        );
530        self.client
531            .post(
532                &url,
533                crate::Message {
534                    body: None,
535                    content_type: None,
536                },
537            )
538            .await
539    }
540    /**
541     * Get Key Credential for Application.
542     *
543     * This function performs a `GET` to the `/api/v1/apps/{appId}/credentials/keys/{keyId}` endpoint.
544     *
545     * Gets a specific application key credential by kid
546     *
547     * **Parameters:**
548     *
549     * * `app_id: &str`
550     * * `key_id: &str`
551     */
552    pub async fn get_key(
553        &self,
554        app_id: &str,
555        key_id: &str,
556    ) -> ClientResult<crate::Response<crate::types::JsonWebKey>> {
557        let url = self.client.url(
558            &format!(
559                "/api/v1/apps/{}/credentials/keys/{}",
560                crate::progenitor_support::encode_path(app_id),
561                crate::progenitor_support::encode_path(key_id),
562            ),
563            None,
564        );
565        self.client
566            .get(
567                &url,
568                crate::Message {
569                    body: None,
570                    content_type: None,
571                },
572            )
573            .await
574    }
575    /**
576     * Clone Application Key Credential.
577     *
578     * This function performs a `POST` to the `/api/v1/apps/{appId}/credentials/keys/{keyId}/clone` endpoint.
579     *
580     * Clones a X.509 certificate for an application key credential from a source application to target application.
581     *
582     * **Parameters:**
583     *
584     * * `app_id: &str`
585     * * `key_id: &str`
586     * * `target_aid: &str` -- Unique key of the target Application.
587     */
588    pub async fn clone_key(
589        &self,
590        app_id: &str,
591        key_id: &str,
592        target_aid: &str,
593    ) -> ClientResult<crate::Response<crate::types::JsonWebKey>> {
594        let mut query_args: Vec<(String, String)> = Default::default();
595        if !target_aid.is_empty() {
596            query_args.push(("targetAid".to_string(), target_aid.to_string()));
597        }
598        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
599        let url = self.client.url(
600            &format!(
601                "/api/v1/apps/{}/credentials/keys/{}/clone?{}",
602                crate::progenitor_support::encode_path(app_id),
603                crate::progenitor_support::encode_path(key_id),
604                query_
605            ),
606            None,
607        );
608        self.client
609            .post(
610                &url,
611                crate::Message {
612                    body: None,
613                    content_type: None,
614                },
615            )
616            .await
617    }
618    /**
619     * This function performs a `GET` to the `/api/v1/apps/{appId}/grants` endpoint.
620     *
621     * Lists all scope consent grants for the application
622     *
623     * **Parameters:**
624     *
625     * * `app_id: &str`
626     * * `expand: &str`
627     */
628    pub async fn list_scope_consent_grants(
629        &self,
630        app_id: &str,
631        expand: &str,
632    ) -> ClientResult<crate::Response<Vec<crate::types::OAuth2ScopeConsentGrant>>> {
633        let mut query_args: Vec<(String, String)> = Default::default();
634        if !expand.is_empty() {
635            query_args.push(("expand".to_string(), expand.to_string()));
636        }
637        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
638        let url = self.client.url(
639            &format!(
640                "/api/v1/apps/{}/grants?{}",
641                crate::progenitor_support::encode_path(app_id),
642                query_
643            ),
644            None,
645        );
646        self.client
647            .get(
648                &url,
649                crate::Message {
650                    body: None,
651                    content_type: None,
652                },
653            )
654            .await
655    }
656    /**
657     * This function performs a `GET` to the `/api/v1/apps/{appId}/grants` endpoint.
658     *
659     * As opposed to `list_scope_consent_grants`, this function returns all the pages of the request at once.
660     *
661     * Lists all scope consent grants for the application
662     */
663    pub async fn list_all_scope_consent_grants(
664        &self,
665        app_id: &str,
666        expand: &str,
667    ) -> ClientResult<crate::Response<Vec<crate::types::OAuth2ScopeConsentGrant>>> {
668        let mut query_args: Vec<(String, String)> = Default::default();
669        if !expand.is_empty() {
670            query_args.push(("expand".to_string(), expand.to_string()));
671        }
672        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
673        let url = self.client.url(
674            &format!(
675                "/api/v1/apps/{}/grants?{}",
676                crate::progenitor_support::encode_path(app_id),
677                query_
678            ),
679            None,
680        );
681        self.client
682            .get_all_pages(
683                &url,
684                crate::Message {
685                    body: None,
686                    content_type: None,
687                },
688            )
689            .await
690    }
691    /**
692     * This function performs a `POST` to the `/api/v1/apps/{appId}/grants` endpoint.
693     *
694     * Grants consent for the application to request an OAuth 2.0 Okta scope
695     *
696     * **Parameters:**
697     *
698     * * `app_id: &str`
699     */
700    pub async fn grant_consent_scope(
701        &self,
702        app_id: &str,
703        body: &crate::types::OAuth2ScopeConsentGrant,
704    ) -> ClientResult<crate::Response<crate::types::OAuth2ScopeConsentGrant>> {
705        let url = self.client.url(
706            &format!(
707                "/api/v1/apps/{}/grants",
708                crate::progenitor_support::encode_path(app_id),
709            ),
710            None,
711        );
712        self.client
713            .post(
714                &url,
715                crate::Message {
716                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
717                    content_type: Some("application/json".to_string()),
718                },
719            )
720            .await
721    }
722    /**
723     * This function performs a `GET` to the `/api/v1/apps/{appId}/grants/{grantId}` endpoint.
724     *
725     * Fetches a single scope consent grant for the application
726     *
727     * **Parameters:**
728     *
729     * * `app_id: &str`
730     * * `grant_id: &str`
731     * * `expand: &str`
732     */
733    pub async fn get_scope_consent_grant(
734        &self,
735        app_id: &str,
736        grant_id: &str,
737        expand: &str,
738    ) -> ClientResult<crate::Response<crate::types::OAuth2ScopeConsentGrant>> {
739        let mut query_args: Vec<(String, String)> = Default::default();
740        if !expand.is_empty() {
741            query_args.push(("expand".to_string(), expand.to_string()));
742        }
743        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
744        let url = self.client.url(
745            &format!(
746                "/api/v1/apps/{}/grants/{}?{}",
747                crate::progenitor_support::encode_path(app_id),
748                crate::progenitor_support::encode_path(grant_id),
749                query_
750            ),
751            None,
752        );
753        self.client
754            .get(
755                &url,
756                crate::Message {
757                    body: None,
758                    content_type: None,
759                },
760            )
761            .await
762    }
763    /**
764     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/grants/{grantId}` endpoint.
765     *
766     * Revokes permission for the application to request the given scope
767     *
768     * **Parameters:**
769     *
770     * * `app_id: &str`
771     * * `grant_id: &str`
772     */
773    pub async fn revoke_scope_consent_grant(
774        &self,
775        app_id: &str,
776        grant_id: &str,
777    ) -> ClientResult<crate::Response<()>> {
778        let url = self.client.url(
779            &format!(
780                "/api/v1/apps/{}/grants/{}",
781                crate::progenitor_support::encode_path(app_id),
782                crate::progenitor_support::encode_path(grant_id),
783            ),
784            None,
785        );
786        self.client
787            .delete(
788                &url,
789                crate::Message {
790                    body: None,
791                    content_type: None,
792                },
793            )
794            .await
795    }
796    /**
797     * List Groups Assigned to Application.
798     *
799     * This function performs a `GET` to the `/api/v1/apps/{appId}/groups` endpoint.
800     *
801     * Enumerates group assignments for an application.
802     *
803     * **Parameters:**
804     *
805     * * `app_id: &str`
806     * * `q: &str`
807     * * `after: &str` -- Specifies the pagination cursor for the next page of assignments.
808     * * `limit: i64` -- Specifies the number of results for a page.
809     * * `expand: &str`
810     */
811    pub async fn list_group_assignments(
812        &self,
813        app_id: &str,
814        q: &str,
815        after: &str,
816        limit: i64,
817        expand: &str,
818    ) -> ClientResult<crate::Response<Vec<crate::types::ApplicationGroupAssignment>>> {
819        let mut query_args: Vec<(String, String)> = Default::default();
820        if !after.is_empty() {
821            query_args.push(("after".to_string(), after.to_string()));
822        }
823        if !expand.is_empty() {
824            query_args.push(("expand".to_string(), expand.to_string()));
825        }
826        if limit > 0 {
827            query_args.push(("limit".to_string(), limit.to_string()));
828        }
829        if !q.is_empty() {
830            query_args.push(("q".to_string(), q.to_string()));
831        }
832        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
833        let url = self.client.url(
834            &format!(
835                "/api/v1/apps/{}/groups?{}",
836                crate::progenitor_support::encode_path(app_id),
837                query_
838            ),
839            None,
840        );
841        self.client
842            .get(
843                &url,
844                crate::Message {
845                    body: None,
846                    content_type: None,
847                },
848            )
849            .await
850    }
851    /**
852     * List Groups Assigned to Application.
853     *
854     * This function performs a `GET` to the `/api/v1/apps/{appId}/groups` endpoint.
855     *
856     * As opposed to `list_group_assignments`, this function returns all the pages of the request at once.
857     *
858     * Enumerates group assignments for an application.
859     */
860    pub async fn list_all_group_assignments(
861        &self,
862        app_id: &str,
863        q: &str,
864        expand: &str,
865    ) -> ClientResult<crate::Response<Vec<crate::types::ApplicationGroupAssignment>>> {
866        let mut query_args: Vec<(String, String)> = Default::default();
867        if !expand.is_empty() {
868            query_args.push(("expand".to_string(), expand.to_string()));
869        }
870        if !q.is_empty() {
871            query_args.push(("q".to_string(), q.to_string()));
872        }
873        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
874        let url = self.client.url(
875            &format!(
876                "/api/v1/apps/{}/groups?{}",
877                crate::progenitor_support::encode_path(app_id),
878                query_
879            ),
880            None,
881        );
882        self.client
883            .get_all_pages(
884                &url,
885                crate::Message {
886                    body: None,
887                    content_type: None,
888                },
889            )
890            .await
891    }
892    /**
893     * Get Assigned Group for Application.
894     *
895     * This function performs a `GET` to the `/api/v1/apps/{appId}/groups/{groupId}` endpoint.
896     *
897     * Fetches an application group assignment
898     *
899     * **Parameters:**
900     *
901     * * `app_id: &str`
902     * * `group_id: &str`
903     * * `expand: &str`
904     */
905    pub async fn get_group_assignment(
906        &self,
907        app_id: &str,
908        group_id: &str,
909        expand: &str,
910    ) -> ClientResult<crate::Response<crate::types::ApplicationGroupAssignment>> {
911        let mut query_args: Vec<(String, String)> = Default::default();
912        if !expand.is_empty() {
913            query_args.push(("expand".to_string(), expand.to_string()));
914        }
915        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
916        let url = self.client.url(
917            &format!(
918                "/api/v1/apps/{}/groups/{}?{}",
919                crate::progenitor_support::encode_path(app_id),
920                crate::progenitor_support::encode_path(group_id),
921                query_
922            ),
923            None,
924        );
925        self.client
926            .get(
927                &url,
928                crate::Message {
929                    body: None,
930                    content_type: None,
931                },
932            )
933            .await
934    }
935    /**
936     * Assign Group to Application.
937     *
938     * This function performs a `PUT` to the `/api/v1/apps/{appId}/groups/{groupId}` endpoint.
939     *
940     * Assigns a group to an application
941     *
942     * **Parameters:**
943     *
944     * * `app_id: &str`
945     * * `group_id: &str`
946     */
947    pub async fn create_group_assignment(
948        &self,
949        app_id: &str,
950        group_id: &str,
951        body: &crate::types::ApplicationGroupAssignment,
952    ) -> ClientResult<crate::Response<crate::types::ApplicationGroupAssignment>> {
953        let url = self.client.url(
954            &format!(
955                "/api/v1/apps/{}/groups/{}",
956                crate::progenitor_support::encode_path(app_id),
957                crate::progenitor_support::encode_path(group_id),
958            ),
959            None,
960        );
961        self.client
962            .put(
963                &url,
964                crate::Message {
965                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
966                    content_type: Some("application/json".to_string()),
967                },
968            )
969            .await
970    }
971    /**
972     * Remove Group from Application.
973     *
974     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/groups/{groupId}` endpoint.
975     *
976     * Removes a group assignment from an application.
977     *
978     * **Parameters:**
979     *
980     * * `app_id: &str`
981     * * `group_id: &str`
982     */
983    pub async fn delete_group_assignment(
984        &self,
985        app_id: &str,
986        group_id: &str,
987    ) -> ClientResult<crate::Response<()>> {
988        let url = self.client.url(
989            &format!(
990                "/api/v1/apps/{}/groups/{}",
991                crate::progenitor_support::encode_path(app_id),
992                crate::progenitor_support::encode_path(group_id),
993            ),
994            None,
995        );
996        self.client
997            .delete(
998                &url,
999                crate::Message {
1000                    body: None,
1001                    content_type: None,
1002                },
1003            )
1004            .await
1005    }
1006    /**
1007     * Activate Application.
1008     *
1009     * This function performs a `POST` to the `/api/v1/apps/{appId}/lifecycle/activate` endpoint.
1010     *
1011     * Activates an inactive application.
1012     *
1013     * **Parameters:**
1014     *
1015     * * `app_id: &str`
1016     */
1017    pub async fn activate(&self, app_id: &str) -> ClientResult<crate::Response<()>> {
1018        let url = self.client.url(
1019            &format!(
1020                "/api/v1/apps/{}/lifecycle/activate",
1021                crate::progenitor_support::encode_path(app_id),
1022            ),
1023            None,
1024        );
1025        self.client
1026            .post(
1027                &url,
1028                crate::Message {
1029                    body: None,
1030                    content_type: None,
1031                },
1032            )
1033            .await
1034    }
1035    /**
1036     * Deactivate Application.
1037     *
1038     * This function performs a `POST` to the `/api/v1/apps/{appId}/lifecycle/deactivate` endpoint.
1039     *
1040     * Deactivates an active application.
1041     *
1042     * **Parameters:**
1043     *
1044     * * `app_id: &str`
1045     */
1046    pub async fn deactivate(&self, app_id: &str) -> ClientResult<crate::Response<()>> {
1047        let url = self.client.url(
1048            &format!(
1049                "/api/v1/apps/{}/lifecycle/deactivate",
1050                crate::progenitor_support::encode_path(app_id),
1051            ),
1052            None,
1053        );
1054        self.client
1055            .post(
1056                &url,
1057                crate::Message {
1058                    body: None,
1059                    content_type: None,
1060                },
1061            )
1062            .await
1063    }
1064    /**
1065     * This function performs a `GET` to the `/api/v1/apps/{appId}/tokens` endpoint.
1066     *
1067     * Lists all tokens for the application
1068     *
1069     * **Parameters:**
1070     *
1071     * * `app_id: &str`
1072     * * `expand: &str`
1073     * * `after: &str`
1074     * * `limit: i64`
1075     */
1076    pub async fn list_o_auth_2_tokens_fors(
1077        &self,
1078        app_id: &str,
1079        expand: &str,
1080        after: &str,
1081        limit: i64,
1082    ) -> ClientResult<crate::Response<Vec<crate::types::OAuth2Token>>> {
1083        let mut query_args: Vec<(String, String)> = Default::default();
1084        if !after.is_empty() {
1085            query_args.push(("after".to_string(), after.to_string()));
1086        }
1087        if !expand.is_empty() {
1088            query_args.push(("expand".to_string(), expand.to_string()));
1089        }
1090        if limit > 0 {
1091            query_args.push(("limit".to_string(), limit.to_string()));
1092        }
1093        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1094        let url = self.client.url(
1095            &format!(
1096                "/api/v1/apps/{}/tokens?{}",
1097                crate::progenitor_support::encode_path(app_id),
1098                query_
1099            ),
1100            None,
1101        );
1102        self.client
1103            .get(
1104                &url,
1105                crate::Message {
1106                    body: None,
1107                    content_type: None,
1108                },
1109            )
1110            .await
1111    }
1112    /**
1113     * This function performs a `GET` to the `/api/v1/apps/{appId}/tokens` endpoint.
1114     *
1115     * As opposed to `list_o_auth_2_tokens_for`, this function returns all the pages of the request at once.
1116     *
1117     * Lists all tokens for the application
1118     */
1119    pub async fn list_all_o_auth_2_tokens_fors(
1120        &self,
1121        app_id: &str,
1122        expand: &str,
1123    ) -> ClientResult<crate::Response<Vec<crate::types::OAuth2Token>>> {
1124        let mut query_args: Vec<(String, String)> = Default::default();
1125        if !expand.is_empty() {
1126            query_args.push(("expand".to_string(), expand.to_string()));
1127        }
1128        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1129        let url = self.client.url(
1130            &format!(
1131                "/api/v1/apps/{}/tokens?{}",
1132                crate::progenitor_support::encode_path(app_id),
1133                query_
1134            ),
1135            None,
1136        );
1137        self.client
1138            .get_all_pages(
1139                &url,
1140                crate::Message {
1141                    body: None,
1142                    content_type: None,
1143                },
1144            )
1145            .await
1146    }
1147    /**
1148     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/tokens` endpoint.
1149     *
1150     * Revokes all tokens for the specified application
1151     *
1152     * **Parameters:**
1153     *
1154     * * `app_id: &str`
1155     */
1156    pub async fn revoke_o_auth_2_tokens_for(
1157        &self,
1158        app_id: &str,
1159    ) -> ClientResult<crate::Response<()>> {
1160        let url = self.client.url(
1161            &format!(
1162                "/api/v1/apps/{}/tokens",
1163                crate::progenitor_support::encode_path(app_id),
1164            ),
1165            None,
1166        );
1167        self.client
1168            .delete(
1169                &url,
1170                crate::Message {
1171                    body: None,
1172                    content_type: None,
1173                },
1174            )
1175            .await
1176    }
1177    /**
1178     * This function performs a `GET` to the `/api/v1/apps/{appId}/tokens/{tokenId}` endpoint.
1179     *
1180     * Gets a token for the specified application
1181     *
1182     * **Parameters:**
1183     *
1184     * * `app_id: &str`
1185     * * `token_id: &str`
1186     * * `expand: &str`
1187     */
1188    pub async fn get_o_auth_2_token_for(
1189        &self,
1190        app_id: &str,
1191        token_id: &str,
1192        expand: &str,
1193    ) -> ClientResult<crate::Response<crate::types::OAuth2Token>> {
1194        let mut query_args: Vec<(String, String)> = Default::default();
1195        if !expand.is_empty() {
1196            query_args.push(("expand".to_string(), expand.to_string()));
1197        }
1198        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1199        let url = self.client.url(
1200            &format!(
1201                "/api/v1/apps/{}/tokens/{}?{}",
1202                crate::progenitor_support::encode_path(app_id),
1203                crate::progenitor_support::encode_path(token_id),
1204                query_
1205            ),
1206            None,
1207        );
1208        self.client
1209            .get(
1210                &url,
1211                crate::Message {
1212                    body: None,
1213                    content_type: None,
1214                },
1215            )
1216            .await
1217    }
1218    /**
1219     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/tokens/{tokenId}` endpoint.
1220     *
1221     * Revokes the specified token for the specified application
1222     *
1223     * **Parameters:**
1224     *
1225     * * `app_id: &str`
1226     * * `token_id: &str`
1227     */
1228    pub async fn revoke_o_auth_2_token_for(
1229        &self,
1230        app_id: &str,
1231        token_id: &str,
1232    ) -> ClientResult<crate::Response<()>> {
1233        let url = self.client.url(
1234            &format!(
1235                "/api/v1/apps/{}/tokens/{}",
1236                crate::progenitor_support::encode_path(app_id),
1237                crate::progenitor_support::encode_path(token_id),
1238            ),
1239            None,
1240        );
1241        self.client
1242            .delete(
1243                &url,
1244                crate::Message {
1245                    body: None,
1246                    content_type: None,
1247                },
1248            )
1249            .await
1250    }
1251    /**
1252     * List Users Assigned to Application.
1253     *
1254     * This function performs a `GET` to the `/api/v1/apps/{appId}/users` endpoint.
1255     *
1256     * Enumerates all assigned [application users](#application-user-model) for an application.
1257     *
1258     * **Parameters:**
1259     *
1260     * * `app_id: &str`
1261     * * `q: &str`
1262     * * `query_scope: &str`
1263     * * `after: &str` -- specifies the pagination cursor for the next page of assignments.
1264     * * `limit: i64` -- specifies the number of results for a page.
1265     * * `filter: &str`
1266     * * `expand: &str`
1267     */
1268    pub async fn list_users(
1269        &self,
1270        app_id: &str,
1271        q: &str,
1272        query_scope: &str,
1273        after: &str,
1274        limit: i64,
1275        filter: &str,
1276        expand: &str,
1277    ) -> ClientResult<crate::Response<Vec<crate::types::AppUser>>> {
1278        let mut query_args: Vec<(String, String)> = Default::default();
1279        if !after.is_empty() {
1280            query_args.push(("after".to_string(), after.to_string()));
1281        }
1282        if !expand.is_empty() {
1283            query_args.push(("expand".to_string(), expand.to_string()));
1284        }
1285        if !filter.is_empty() {
1286            query_args.push(("filter".to_string(), filter.to_string()));
1287        }
1288        if limit > 0 {
1289            query_args.push(("limit".to_string(), limit.to_string()));
1290        }
1291        if !q.is_empty() {
1292            query_args.push(("q".to_string(), q.to_string()));
1293        }
1294        if !query_scope.is_empty() {
1295            query_args.push(("query_scope".to_string(), query_scope.to_string()));
1296        }
1297        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1298        let url = self.client.url(
1299            &format!(
1300                "/api/v1/apps/{}/users?{}",
1301                crate::progenitor_support::encode_path(app_id),
1302                query_
1303            ),
1304            None,
1305        );
1306        self.client
1307            .get(
1308                &url,
1309                crate::Message {
1310                    body: None,
1311                    content_type: None,
1312                },
1313            )
1314            .await
1315    }
1316    /**
1317     * List Users Assigned to Application.
1318     *
1319     * This function performs a `GET` to the `/api/v1/apps/{appId}/users` endpoint.
1320     *
1321     * As opposed to `list_users`, this function returns all the pages of the request at once.
1322     *
1323     * Enumerates all assigned [application users](#application-user-model) for an application.
1324     */
1325    pub async fn list_all_users(
1326        &self,
1327        app_id: &str,
1328        q: &str,
1329        query_scope: &str,
1330        filter: &str,
1331        expand: &str,
1332    ) -> ClientResult<crate::Response<Vec<crate::types::AppUser>>> {
1333        let mut query_args: Vec<(String, String)> = Default::default();
1334        if !expand.is_empty() {
1335            query_args.push(("expand".to_string(), expand.to_string()));
1336        }
1337        if !filter.is_empty() {
1338            query_args.push(("filter".to_string(), filter.to_string()));
1339        }
1340        if !q.is_empty() {
1341            query_args.push(("q".to_string(), q.to_string()));
1342        }
1343        if !query_scope.is_empty() {
1344            query_args.push(("query_scope".to_string(), query_scope.to_string()));
1345        }
1346        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1347        let url = self.client.url(
1348            &format!(
1349                "/api/v1/apps/{}/users?{}",
1350                crate::progenitor_support::encode_path(app_id),
1351                query_
1352            ),
1353            None,
1354        );
1355        self.client
1356            .get_all_pages(
1357                &url,
1358                crate::Message {
1359                    body: None,
1360                    content_type: None,
1361                },
1362            )
1363            .await
1364    }
1365    /**
1366     * Assign User to Application for SSO & Provisioning.
1367     *
1368     * This function performs a `POST` to the `/api/v1/apps/{appId}/users` endpoint.
1369     *
1370     * Assigns an user to an application with [credentials](#application-user-credentials-object) and an app-specific [profile](#application-user-profile-object). Profile mappings defined for the application are first applied before applying any profile properties specified in the request.
1371     *
1372     * **Parameters:**
1373     *
1374     * * `app_id: &str`
1375     */
1376    pub async fn assign_user(
1377        &self,
1378        app_id: &str,
1379        body: &crate::types::AppUser,
1380    ) -> ClientResult<crate::Response<crate::types::AppUser>> {
1381        let url = self.client.url(
1382            &format!(
1383                "/api/v1/apps/{}/users",
1384                crate::progenitor_support::encode_path(app_id),
1385            ),
1386            None,
1387        );
1388        self.client
1389            .post(
1390                &url,
1391                crate::Message {
1392                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
1393                    content_type: None,
1394                },
1395            )
1396            .await
1397    }
1398    /**
1399     * Get Assigned User for Application.
1400     *
1401     * This function performs a `GET` to the `/api/v1/apps/{appId}/users/{userId}` endpoint.
1402     *
1403     * Fetches a specific user assignment for application by `id`.
1404     *
1405     * **Parameters:**
1406     *
1407     * * `app_id: &str`
1408     * * `user_id: &str`
1409     * * `expand: &str`
1410     */
1411    pub async fn get_user(
1412        &self,
1413        app_id: &str,
1414        user_id: &str,
1415        expand: &str,
1416    ) -> ClientResult<crate::Response<crate::types::AppUser>> {
1417        let mut query_args: Vec<(String, String)> = Default::default();
1418        if !expand.is_empty() {
1419            query_args.push(("expand".to_string(), expand.to_string()));
1420        }
1421        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1422        let url = self.client.url(
1423            &format!(
1424                "/api/v1/apps/{}/users/{}?{}",
1425                crate::progenitor_support::encode_path(app_id),
1426                crate::progenitor_support::encode_path(user_id),
1427                query_
1428            ),
1429            None,
1430        );
1431        self.client
1432            .get(
1433                &url,
1434                crate::Message {
1435                    body: None,
1436                    content_type: None,
1437                },
1438            )
1439            .await
1440    }
1441    /**
1442     * Update Application Profile for Assigned User.
1443     *
1444     * This function performs a `POST` to the `/api/v1/apps/{appId}/users/{userId}` endpoint.
1445     *
1446     * Updates a user's profile for an application
1447     *
1448     * **Parameters:**
1449     *
1450     * * `app_id: &str`
1451     * * `user_id: &str`
1452     */
1453    pub async fn update_user(
1454        &self,
1455        app_id: &str,
1456        user_id: &str,
1457        body: &crate::types::AppUser,
1458    ) -> ClientResult<crate::Response<crate::types::AppUser>> {
1459        let url = self.client.url(
1460            &format!(
1461                "/api/v1/apps/{}/users/{}",
1462                crate::progenitor_support::encode_path(app_id),
1463                crate::progenitor_support::encode_path(user_id),
1464            ),
1465            None,
1466        );
1467        self.client
1468            .post(
1469                &url,
1470                crate::Message {
1471                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
1472                    content_type: None,
1473                },
1474            )
1475            .await
1476    }
1477    /**
1478     * Remove User from Application.
1479     *
1480     * This function performs a `DELETE` to the `/api/v1/apps/{appId}/users/{userId}` endpoint.
1481     *
1482     * Removes an assignment for a user from an application.
1483     *
1484     * **Parameters:**
1485     *
1486     * * `app_id: &str`
1487     * * `user_id: &str`
1488     * * `send_email: bool`
1489     */
1490    pub async fn delete_user(
1491        &self,
1492        app_id: &str,
1493        user_id: &str,
1494        send_email: bool,
1495    ) -> ClientResult<crate::Response<()>> {
1496        let mut query_args: Vec<(String, String)> = Default::default();
1497        if send_email {
1498            query_args.push(("sendEmail".to_string(), send_email.to_string()));
1499        }
1500        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1501        let url = self.client.url(
1502            &format!(
1503                "/api/v1/apps/{}/users/{}?{}",
1504                crate::progenitor_support::encode_path(app_id),
1505                crate::progenitor_support::encode_path(user_id),
1506                query_
1507            ),
1508            None,
1509        );
1510        self.client
1511            .delete(
1512                &url,
1513                crate::Message {
1514                    body: None,
1515                    content_type: None,
1516                },
1517            )
1518            .await
1519    }
1520}