Skip to content

Commit d52ac0a

Browse files
authored
rust: Add OperationalWebhook resource (#1780)
We are going to deprecate the `svix.operational_webhook_endpoint()` accessor in favor of `svix.operational_webhook().endpoint()` down the line. The new file was generated using svix/openapi-codegen#86. I'm not updating the git rev in this PR though because that PR is not yet merged, and because the other templates we use in CI have not yet been updated. Luckily we don't currently error when there are unused left-over files, though maybe we should do so down the line.
2 parents d082527 + 74ca58c commit d52ac0a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

rust/src/api/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod ingest_endpoint;
1515
mod integration;
1616
mod message;
1717
mod message_attempt;
18+
mod operational_webhook;
1819
mod operational_webhook_endpoint;
1920
mod statistics;
2021

@@ -53,6 +54,7 @@ pub use self::{
5354
MessageAttemptListAttemptedMessagesOptions, MessageAttemptListByEndpointOptions,
5455
MessageAttemptListByMsgOptions, MessageAttemptResendOptions,
5556
},
57+
operational_webhook::OperationalWebhook,
5658
operational_webhook_endpoint::{
5759
OperationalWebhookEndpoint, OperationalWebhookEndpointCreateOptions,
5860
OperationalWebhookEndpointListOptions,
@@ -106,6 +108,10 @@ impl Svix {
106108
MessageAttempt::new(&self.cfg)
107109
}
108110

111+
pub fn operational_webhook(&self) -> OperationalWebhook<'_> {
112+
OperationalWebhook::new(&self.cfg)
113+
}
114+
109115
pub fn operational_webhook_endpoint(&self) -> OperationalWebhookEndpoint<'_> {
110116
OperationalWebhookEndpoint::new(&self.cfg)
111117
}

rust/src/api/operational_webhook.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use super::OperationalWebhookEndpoint;
2+
use crate::Configuration;
3+
4+
pub struct OperationalWebhook<'a> {
5+
cfg: &'a Configuration,
6+
}
7+
8+
impl<'a> OperationalWebhook<'a> {
9+
pub(super) fn new(cfg: &'a Configuration) -> Self {
10+
Self { cfg }
11+
}
12+
13+
pub fn endpoint(&self) -> OperationalWebhookEndpoint<'a> {
14+
OperationalWebhookEndpoint::new(self.cfg)
15+
}
16+
}

rust/templates/api_resource.rs.jinja

+15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{% set resource_type_name = resource.name | to_upper_camel_case -%}
22

33
use crate::{
4+
{%- if resource.operations | length > 0 %}
45
error::Result,
56
models::*,
7+
{%- endif %}
68
Configuration,
79
};
10+
use super::{
11+
{% for _, sub in resource.subresources | items -%}
12+
{{ sub.name | to_upper_camel_case }} ,
13+
{%- endfor %}
14+
};
815

916
{% for op in resource.operations -%}
1017
{% if op | has_query_or_header_params %}
@@ -51,6 +58,14 @@ impl<'a> {{ resource_type_name }}<'a> {
5158
Self { cfg }
5259
}
5360

61+
{% for name, sub in resource.subresources | items -%}
62+
{% set sub_type_name = sub.name | to_upper_camel_case -%}
63+
pub fn {{ name | to_snake_case }}(&self) -> {{ sub_type_name }}<'a> {
64+
{{ sub_type_name }}::new(self.cfg)
65+
}
66+
67+
{% endfor -%}
68+
5469
{% for op in resource.operations %}
5570
{% set has_params = op | has_query_or_header_params -%}
5671
{% if op.description is defined -%}

0 commit comments

Comments
 (0)