Skip to content

Commit 539b5be

Browse files
committed
rust: Add method docs!
1 parent ea52a5c commit 539b5be

File tree

8 files changed

+279
-59
lines changed

8 files changed

+279
-59
lines changed

rust/src/api/application.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl<'a> Application<'a> {
2222
Self { cfg }
2323
}
2424

25+
/// List of all the organization's applications.
2526
pub async fn list(
2627
&self,
2728
options: Option<ApplicationListOptions>,
@@ -43,6 +44,7 @@ impl<'a> Application<'a> {
4344
.await
4445
}
4546

47+
/// Create a new application.
4648
pub async fn create(
4749
&self,
4850
application_in: ApplicationIn,
@@ -60,6 +62,8 @@ impl<'a> Application<'a> {
6062
.await
6163
}
6264

65+
/// Create the application with the given ID, or create a new one if it
66+
/// doesn't exist yet.
6367
pub async fn get_or_create(
6468
&self,
6569
application_in: ApplicationIn,
@@ -77,6 +81,7 @@ impl<'a> Application<'a> {
7781
.await
7882
}
7983

84+
/// Get an application.
8085
pub async fn get(&self, app_id: String) -> Result<ApplicationOut> {
8186
application_api::v1_period_application_period_get(
8287
self.cfg,
@@ -85,6 +90,7 @@ impl<'a> Application<'a> {
8590
.await
8691
}
8792

93+
/// Update an application.
8894
pub async fn update(
8995
&self,
9096
app_id: String,
@@ -100,6 +106,7 @@ impl<'a> Application<'a> {
100106
.await
101107
}
102108

109+
/// Delete an application.
103110
pub async fn delete(&self, app_id: String) -> Result<()> {
104111
application_api::v1_period_application_period_delete(
105112
self.cfg,
@@ -108,6 +115,7 @@ impl<'a> Application<'a> {
108115
.await
109116
}
110117

118+
/// Partially update an application.
111119
pub async fn patch(
112120
&self,
113121
app_id: String,

rust/src/api/authentication.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::PostOptions;
22
use crate::{apis::authentication_api, error::Result, models::*, Configuration};
3+
34
pub struct Authentication<'a> {
45
cfg: &'a Configuration,
56
}
@@ -25,26 +26,33 @@ impl<'a> Authentication<'a> {
2526
.await
2627
}
2728

29+
/// Use this function to get magic links (and authentication codes) for
30+
/// connecting your users to the Consumer Application Portal.
2831
pub async fn app_portal_access(
2932
&self,
3033
app_id: String,
3134
app_portal_access_in: AppPortalAccessIn,
3235
options: Option<PostOptions>,
3336
) -> Result<AppPortalAccessOut> {
34-
let options = options.unwrap_or_default();
37+
let PostOptions { idempotency_key } = options.unwrap_or_default();
38+
3539
authentication_api::v1_period_authentication_period_app_portal_access(
3640
self.cfg,
3741
authentication_api::V1PeriodAuthenticationPeriodAppPortalAccessParams {
3842
app_id,
3943
app_portal_access_in,
40-
idempotency_key: options.idempotency_key,
44+
idempotency_key,
4145
},
4246
)
4347
.await
4448
}
4549

50+
/// Logout an app token.
51+
///
52+
/// Trying to log out other tokens will fail.
4653
pub async fn logout(&self, options: Option<PostOptions>) -> Result<()> {
4754
let PostOptions { idempotency_key } = options.unwrap_or_default();
55+
4856
authentication_api::v1_period_authentication_period_logout(
4957
self.cfg,
5058
authentication_api::V1PeriodAuthenticationPeriodLogoutParams { idempotency_key },

rust/src/api/endpoint.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl<'a> Endpoint<'a> {
3535
Self { cfg }
3636
}
3737

38+
/// List the application's endpoints.
3839
pub async fn list(
3940
&self,
4041
app_id: String,
@@ -58,6 +59,10 @@ impl<'a> Endpoint<'a> {
5859
.await
5960
}
6061

62+
/// Create a new endpoint for the application.
63+
///
64+
/// When `secret` is `null` the secret is automatically generated
65+
/// (recommended)
6166
pub async fn create(
6267
&self,
6368
app_id: String,
@@ -77,6 +82,7 @@ impl<'a> Endpoint<'a> {
7782
.await
7883
}
7984

85+
/// Get an endpoint.
8086
pub async fn get(&self, app_id: String, endpoint_id: String) -> Result<EndpointOut> {
8187
endpoint_api::v1_period_endpoint_period_get(
8288
self.cfg,
@@ -88,6 +94,7 @@ impl<'a> Endpoint<'a> {
8894
.await
8995
}
9096

97+
/// Update an endpoint.
9198
pub async fn update(
9299
&self,
93100
app_id: String,
@@ -105,6 +112,7 @@ impl<'a> Endpoint<'a> {
105112
.await
106113
}
107114

115+
/// Delete an endpoint.
108116
pub async fn delete(&self, app_id: String, endpoint_id: String) -> Result<()> {
109117
endpoint_api::v1_period_endpoint_period_delete(
110118
self.cfg,
@@ -116,6 +124,7 @@ impl<'a> Endpoint<'a> {
116124
.await
117125
}
118126

127+
/// Partially update an endpoint.
119128
pub async fn patch(
120129
&self,
121130
app_id: String,
@@ -133,6 +142,11 @@ impl<'a> Endpoint<'a> {
133142
.await
134143
}
135144

145+
/// Get the endpoint's signing secret.
146+
///
147+
/// This is used to verify the authenticity of the webhook.
148+
/// For more information please refer to
149+
/// [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).
136150
pub async fn get_secret(
137151
&self,
138152
app_id: String,
@@ -148,6 +162,9 @@ impl<'a> Endpoint<'a> {
148162
.await
149163
}
150164

165+
/// Rotates the endpoint's signing secret.
166+
///
167+
/// The previous secret will remain valid for the next 24 hours.
151168
pub async fn rotate_secret(
152169
&self,
153170
app_id: String,
@@ -166,6 +183,10 @@ impl<'a> Endpoint<'a> {
166183
.await
167184
}
168185

186+
/// Resend all failed messages since a given time.
187+
///
188+
/// Messages that were sent successfully, even if failed initially, are not
189+
/// resent.
169190
pub async fn recover(
170191
&self,
171192
app_id: String,
@@ -185,6 +206,7 @@ impl<'a> Endpoint<'a> {
185206
Ok(())
186207
}
187208

209+
/// Get the additional headers to be sent with the webhook
188210
pub async fn get_headers(
189211
&self,
190212
app_id: String,
@@ -200,6 +222,7 @@ impl<'a> Endpoint<'a> {
200222
.await
201223
}
202224

225+
/// Set the additional headers to be sent with the webhook
203226
pub async fn update_headers(
204227
&self,
205228
app_id: String,
@@ -217,6 +240,7 @@ impl<'a> Endpoint<'a> {
217240
.await
218241
}
219242

243+
/// Partially set the additional headers to be sent with the webhook
220244
pub async fn patch_headers(
221245
&self,
222246
app_id: String,
@@ -234,13 +258,15 @@ impl<'a> Endpoint<'a> {
234258
.await
235259
}
236260

261+
/// Get basic statistics for the endpoint.
237262
pub async fn get_stats(
238263
&self,
239264
app_id: String,
240265
endpoint_id: String,
241266
options: Option<EndpointStatsOptions>,
242267
) -> Result<EndpointStats> {
243268
let EndpointStatsOptions { since, until } = options.unwrap_or_default();
269+
244270
endpoint_api::v1_period_endpoint_period_get_stats(
245271
self.cfg,
246272
endpoint_api::V1PeriodEndpointPeriodGetStatsParams {
@@ -253,6 +279,10 @@ impl<'a> Endpoint<'a> {
253279
.await
254280
}
255281

282+
/// Replays messages to the endpoint.
283+
///
284+
/// Only messages that were created after `since` will be sent. Messages
285+
/// that were previously sent to the endpoint are not resent.
256286
pub async fn replay_missing(
257287
&self,
258288
app_id: String,
@@ -274,6 +304,7 @@ impl<'a> Endpoint<'a> {
274304
Ok(())
275305
}
276306

307+
/// Get the transformation code associated with this endpoint
277308
pub async fn transformation_get(
278309
&self,
279310
app_id: String,
@@ -289,6 +320,7 @@ impl<'a> Endpoint<'a> {
289320
.await
290321
}
291322

323+
/// Set or unset the transformation code associated with this endpoint
292324
pub async fn transformation_partial_update(
293325
&self,
294326
app_id: String,
@@ -303,10 +335,10 @@ impl<'a> Endpoint<'a> {
303335
endpoint_transformation_in,
304336
},
305337
)
306-
.await?;
307-
Ok(())
338+
.await
308339
}
309340

341+
/// Send an example message for an event
310342
pub async fn send_example(
311343
&self,
312344
app_id: String,

rust/src/api/event_type.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl<'a> EventType<'a> {
2727
Self { cfg }
2828
}
2929

30+
/// Return the list of event types.
3031
pub async fn list(
3132
&self,
3233
options: Option<EventTypeListOptions>,
@@ -52,6 +53,12 @@ impl<'a> EventType<'a> {
5253
.await
5354
}
5455

56+
/// Create new or unarchive existing event type.
57+
///
58+
/// Unarchiving an event type will allow endpoints to filter on it and
59+
/// messages to be sent with it. Endpoints filtering on the event type
60+
/// before archival will continue to filter on it. This operation does
61+
/// not preserve the description and schemas.
5562
pub async fn create(
5663
&self,
5764
event_type_in: EventTypeIn,
@@ -69,6 +76,7 @@ impl<'a> EventType<'a> {
6976
.await
7077
}
7178

79+
/// Get an event type.
7280
pub async fn get(&self, event_type_name: String) -> Result<EventTypeOut> {
7381
event_type_api::v1_period_event_type_period_get(
7482
self.cfg,
@@ -77,6 +85,7 @@ impl<'a> EventType<'a> {
7785
.await
7886
}
7987

88+
/// Update an event type.
8089
pub async fn update(
8190
&self,
8291
event_type_name: String,
@@ -92,6 +101,7 @@ impl<'a> EventType<'a> {
92101
.await
93102
}
94103

104+
/// Partially update an event type.
95105
pub async fn patch(
96106
&self,
97107
event_type_name: String,
@@ -107,6 +117,12 @@ impl<'a> EventType<'a> {
107117
.await
108118
}
109119

120+
/// Archive an event type.
121+
///
122+
/// Endpoints already configured to filter on an event type will continue to
123+
/// do so after archival. However, new messages can not be sent with it
124+
/// and endpoints can not filter on it. An event type can be unarchived
125+
/// with the create operation.
110126
pub async fn delete(&self, event_type_name: String) -> Result<()> {
111127
event_type_api::v1_period_event_type_period_delete(
112128
self.cfg,
@@ -118,6 +134,12 @@ impl<'a> EventType<'a> {
118134
.await
119135
}
120136

137+
/// Given an OpenAPI spec, create new or update existing event types.
138+
///
139+
/// If an existing `archived` event type is updated, it will be unarchived.
140+
///
141+
/// The importer will convert all webhooks found in the either the
142+
/// `webhooks` or `x-webhooks` top-level.
121143
pub async fn import_openapi(
122144
&self,
123145
event_type_import_open_api_in: EventTypeImportOpenApiIn,

rust/src/api/integration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl<'a> Integration<'a> {
2222
Self { cfg }
2323
}
2424

25+
/// List the application's integrations.
2526
pub async fn list(
2627
&self,
2728
app_id: String,
@@ -45,6 +46,7 @@ impl<'a> Integration<'a> {
4546
.await
4647
}
4748

49+
/// Create an integration.
4850
pub async fn create(
4951
&self,
5052
app_id: String,
@@ -64,6 +66,7 @@ impl<'a> Integration<'a> {
6466
.await
6567
}
6668

69+
/// Get an integration.
6770
pub async fn get(&self, app_id: String, integ_id: String) -> Result<IntegrationOut> {
6871
integration_api::v1_period_integration_period_get(
6972
self.cfg,
@@ -72,6 +75,7 @@ impl<'a> Integration<'a> {
7275
.await
7376
}
7477

78+
/// Update an integration.
7579
pub async fn update(
7680
&self,
7781
app_id: String,
@@ -89,6 +93,7 @@ impl<'a> Integration<'a> {
8993
.await
9094
}
9195

96+
/// Delete an integration.
9297
pub async fn delete(&self, app_id: String, integ_id: String) -> Result<()> {
9398
integration_api::v1_period_integration_period_delete(
9499
self.cfg,
@@ -97,6 +102,7 @@ impl<'a> Integration<'a> {
97102
.await
98103
}
99104

105+
/// Get an integration's key.
100106
pub async fn get_key(&self, app_id: String, integ_id: String) -> Result<IntegrationKeyOut> {
101107
integration_api::v1_period_integration_period_get_key(
102108
self.cfg,
@@ -105,6 +111,8 @@ impl<'a> Integration<'a> {
105111
.await
106112
}
107113

114+
/// Rotate the integration's key. The previous key will be immediately
115+
/// revoked.
108116
pub async fn rotate_key(&self, app_id: String, integ_id: String) -> Result<IntegrationKeyOut> {
109117
integration_api::v1_period_integration_period_rotate_key(
110118
self.cfg,

0 commit comments

Comments
 (0)