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
// Code 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 EventsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListEventsParams {
/// 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`.
#[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 descending.
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
/// Filter events by one or more event types (e.g. `dsync.user.created`).
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<String>>,
/// ISO-8601 date string to filter events created after this date.
#[serde(skip_serializing_if = "Option::is_none")]
pub range_start: Option<String>,
/// ISO-8601 date string to filter events created before this date.
#[serde(skip_serializing_if = "Option::is_none")]
pub range_end: Option<String>,
/// Filter events by the [Organization](https://workos.com/docs/reference/organization) that the event is associated with.
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
}
impl<'a> EventsApi<'a> {
/// List events
///
/// List events for the current environment.
pub async fn list_events(&self, params: ListEventsParams) -> Result<EventList, Error> {
self.list_events_with_options(params, None).await
}
/// Variant of [`Self::list_events`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_events_with_options(
&self,
params: ListEventsParams,
options: Option<&crate::RequestOptions>,
) -> Result<EventList, Error> {
let path = "/events".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 `EventSchema`
/// across all pages, advancing the `after` cursor under the hood.
///
/// ```ignore
/// use futures_util::TryStreamExt;
/// let all: Vec<EventSchema> = self
/// .list_events_auto_paging(params)
/// .try_collect()
/// .await?;
/// ```
pub fn list_events_auto_paging(
&self,
params: ListEventsParams,
) -> impl futures_util::Stream<Item = Result<EventSchema, Error>> + '_ {
crate::pagination::auto_paginate_pages(move |after| {
let mut params = params.clone();
params.after = after;
async move {
let page = self.list_events(params).await?;
Ok((page.data, page.list_metadata.after))
}
})
}
}