1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
// This file is auto-generated by oagen. Do not edit.
use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;
pub struct OrganizationsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListOrganizationsParams {
/// An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
/// An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
/// Upper limit on the number of objects to return, between `1` and `100`.
///
/// Defaults to `10`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records).
///
/// Defaults to `desc`.
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
/// The domains of an Organization. Any Organization with a matching domain will be returned.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(serialize_with = "crate::query::serialize_comma_separated_opt")]
pub domains: Option<Vec<String>>,
/// Searchable text for an Organization. Matches against the organization name.
#[serde(skip_serializing_if = "Option::is_none")]
pub search: Option<String>,
}
impl Default for ListOrganizationsParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
before: Default::default(),
after: Default::default(),
limit: Some(10),
order: Some(PaginationOrder::Desc),
domains: Default::default(),
search: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateOrganizationParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: OrganizationInput,
}
impl CreateOrganizationParams {
/// Construct a new `CreateOrganizationParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: OrganizationInput) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateOrganizationParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: UpdateOrganization,
}
impl UpdateOrganizationParams {
/// Construct a new `UpdateOrganizationParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: UpdateOrganization) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ListAuthorizedApplicationsParams {
/// An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
/// An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
/// Upper limit on the number of objects to return, between `1` and `100`.
///
/// Defaults to `10`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records).
///
/// Defaults to `desc`.
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
}
impl Default for ListAuthorizedApplicationsParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
before: Default::default(),
after: Default::default(),
limit: Some(10),
order: Some(PaginationOrder::Desc),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateItContactParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: CreateItContact,
}
impl CreateItContactParams {
/// Construct a new `CreateItContactParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: CreateItContact) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct InviteItContactParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: InviteItContact,
}
impl InviteItContactParams {
/// Construct a new `InviteItContactParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: InviteItContact) -> Self {
Self { body }
}
}
impl<'a> OrganizationsApi<'a> {
/// List Organizations
///
/// Get a list of all of your existing organizations matching the criteria specified.
pub async fn list_organizations(
&self,
params: ListOrganizationsParams,
) -> Result<OrganizationList, Error> {
self.list_organizations_with_options(params, None).await
}
/// Variant of [`Self::list_organizations`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_organizations_with_options(
&self,
params: ListOrganizationsParams,
options: Option<&crate::RequestOptions>,
) -> Result<OrganizationList, Error> {
let path = "/organizations".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
/// Returns an async [`futures_util::Stream`] that yields every `Organization`
/// across all pages, advancing the `after` cursor under the hood.
///
/// ```ignore
/// use futures_util::TryStreamExt;
/// let all: Vec<Organization> = self
/// .list_organizations_auto_paging(params)
/// .try_collect()
/// .await?;
/// ```
pub fn list_organizations_auto_paging(
&self,
params: ListOrganizationsParams,
) -> impl futures_util::Stream<Item = Result<Organization, Error>> + '_ {
crate::pagination::auto_paginate_pages(move |after| {
let mut params = params.clone();
params.after = after;
async move {
let page = self.list_organizations(params).await?;
Ok((page.data, page.list_metadata.after))
}
})
}
/// Create an Organization
///
/// Creates a new organization in the current environment.
pub async fn create_organization(
&self,
params: CreateOrganizationParams,
) -> Result<Organization, Error> {
self.create_organization_with_options(params, None).await
}
/// Variant of [`Self::create_organization`] that accepts per-request [`crate::RequestOptions`].
pub async fn create_organization_with_options(
&self,
params: CreateOrganizationParams,
options: Option<&crate::RequestOptions>,
) -> Result<Organization, Error> {
let path = "/organizations".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
/// Get an Organization by External ID
///
/// Get the details of an existing organization by an [external identifier](https://workos.com/docs/authkit/metadata/external-identifiers).
pub async fn get_organization_by_external_id(
&self,
external_id: &str,
) -> Result<Organization, Error> {
self.get_organization_by_external_id_with_options(external_id, None)
.await
}
/// Variant of [`Self::get_organization_by_external_id`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_organization_by_external_id_with_options(
&self,
external_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<Organization, Error> {
let external_id = crate::client::path_segment(external_id);
let path = format!("/organizations/external_id/{external_id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
/// Get an Organization
///
/// Get the details of an existing organization.
pub async fn get_organization(&self, id: &str) -> Result<Organization, Error> {
self.get_organization_with_options(id, None).await
}
/// Variant of [`Self::get_organization`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_organization_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<Organization, Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
/// Update an Organization
///
/// Updates an organization in the current environment.
pub async fn update_organization(
&self,
id: &str,
params: UpdateOrganizationParams,
) -> Result<Organization, Error> {
self.update_organization_with_options(id, params, None)
.await
}
/// Variant of [`Self::update_organization`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_organization_with_options(
&self,
id: &str,
params: UpdateOrganizationParams,
options: Option<&crate::RequestOptions>,
) -> Result<Organization, Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}");
let method = http::Method::PUT;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
/// Delete an Organization
///
/// Permanently deletes an organization in the current environment. It cannot be undone.
pub async fn delete_organization(&self, id: &str) -> Result<(), Error> {
self.delete_organization_with_options(id, None).await
}
/// Variant of [`Self::delete_organization`] that accepts per-request [`crate::RequestOptions`].
pub async fn delete_organization_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
/// Get Audit Log Configuration
///
/// Get the unified view of audit log trail and stream configuration for an organization.
pub async fn get_audit_log_configuration(
&self,
id: &str,
) -> Result<AuditLogConfiguration, Error> {
self.get_audit_log_configuration_with_options(id, None)
.await
}
/// Variant of [`Self::get_audit_log_configuration`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_audit_log_configuration_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<AuditLogConfiguration, Error> {
let id = crate::client::path_segment(id);
let path = format!("/organizations/{id}/audit_log_configuration");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
/// List authorized applications
///
/// Get a list of all Connect applications that users in the organization have authorized.
pub async fn list_authorized_applications(
&self,
organization_id: &str,
params: ListAuthorizedApplicationsParams,
) -> Result<OrganizationAuthorizedConnectApplicationList, Error> {
self.list_authorized_applications_with_options(organization_id, params, None)
.await
}
/// Variant of [`Self::list_authorized_applications`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_authorized_applications_with_options(
&self,
organization_id: &str,
params: ListAuthorizedApplicationsParams,
options: Option<&crate::RequestOptions>,
) -> Result<OrganizationAuthorizedConnectApplicationList, Error> {
let organization_id = crate::client::path_segment(organization_id);
let path = format!("/organizations/{organization_id}/authorized_applications");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
/// Returns an async [`futures_util::Stream`] that yields every `OrganizationAuthorizedConnectApplicationListData`
/// across all pages, advancing the `after` cursor under the hood.
///
/// ```ignore
/// use futures_util::TryStreamExt;
/// let all: Vec<OrganizationAuthorizedConnectApplicationListData> = self
/// .list_authorized_applications_auto_paging(organization_id, params)
/// .try_collect()
/// .await?;
/// ```
pub fn list_authorized_applications_auto_paging(
&self,
organization_id: impl Into<String>,
params: ListAuthorizedApplicationsParams,
) -> impl futures_util::Stream<
Item = Result<OrganizationAuthorizedConnectApplicationListData, Error>,
> + '_ {
let organization_id: String = organization_id.into();
crate::pagination::auto_paginate_pages(move |after| {
let organization_id = organization_id.clone();
let mut params = params.clone();
params.after = after;
async move {
let page = self
.list_authorized_applications(&organization_id, params)
.await?;
Ok((page.data, page.list_metadata.after))
}
})
}
/// List IT contacts
///
/// Get the IT contacts for an organization.
pub async fn list_it_contacts(&self, organization_id: &str) -> Result<ItContactList, Error> {
self.list_it_contacts_with_options(organization_id, None)
.await
}
/// Variant of [`Self::list_it_contacts`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_it_contacts_with_options(
&self,
organization_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<ItContactList, Error> {
let organization_id = crate::client::path_segment(organization_id);
let path = format!("/organizations/{organization_id}/it_contacts");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
/// Create an IT contact
///
/// Add an IT contact to an organization. No Admin Portal invitation is sent, though the contact is notified if the organization has a connection certificate nearing expiry.
pub async fn create_it_contact(
&self,
organization_id: &str,
params: CreateItContactParams,
) -> Result<ItContact, Error> {
self.create_it_contact_with_options(organization_id, params, None)
.await
}
/// Variant of [`Self::create_it_contact`] that accepts per-request [`crate::RequestOptions`].
pub async fn create_it_contact_with_options(
&self,
organization_id: &str,
params: CreateItContactParams,
options: Option<&crate::RequestOptions>,
) -> Result<ItContact, Error> {
let organization_id = crate::client::path_segment(organization_id);
let path = format!("/organizations/{organization_id}/it_contacts");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
/// Delete an IT contact
///
/// Remove an IT contact from an organization and revoke the contact's active setup links.
pub async fn delete_it_contact(
&self,
organization_id: &str,
contact_id: &str,
) -> Result<(), Error> {
self.delete_it_contact_with_options(organization_id, contact_id, None)
.await
}
/// Variant of [`Self::delete_it_contact`] that accepts per-request [`crate::RequestOptions`].
pub async fn delete_it_contact_with_options(
&self,
organization_id: &str,
contact_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let organization_id = crate::client::path_segment(organization_id);
let contact_id = crate::client::path_segment(contact_id);
let path = format!("/organizations/{organization_id}/it_contacts/{contact_id}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
/// Invite an IT contact
///
/// Create an Admin Portal setup link and email it to the IT contact. An organization can have at most one active invitation.
pub async fn invite_it_contact(
&self,
organization_id: &str,
contact_id: &str,
params: InviteItContactParams,
) -> Result<(), Error> {
self.invite_it_contact_with_options(organization_id, contact_id, params, None)
.await
}
/// Variant of [`Self::invite_it_contact`] that accepts per-request [`crate::RequestOptions`].
pub async fn invite_it_contact_with_options(
&self,
organization_id: &str,
contact_id: &str,
params: InviteItContactParams,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let organization_id = crate::client::path_segment(organization_id);
let contact_id = crate::client::path_segment(contact_id);
let path = format!("/organizations/{organization_id}/it_contacts/{contact_id}/invite");
let method = http::Method::POST;
self.client
.request_with_body_opts_empty(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
/// Revoke an IT contact's invitation
///
/// Revoke the organization's active Admin Portal invitation.
pub async fn revoke_it_contact(
&self,
organization_id: &str,
contact_id: &str,
) -> Result<(), Error> {
self.revoke_it_contact_with_options(organization_id, contact_id, None)
.await
}
/// Variant of [`Self::revoke_it_contact`] that accepts per-request [`crate::RequestOptions`].
pub async fn revoke_it_contact_with_options(
&self,
organization_id: &str,
contact_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let organization_id = crate::client::path_segment(organization_id);
let contact_id = crate::client::path_segment(contact_id);
let path = format!("/organizations/{organization_id}/it_contacts/{contact_id}/revoke");
let method = http::Method::POST;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
}