Skip to main content

workos/resources/
radar.rs

1// This file is auto-generated by oagen. Do not edit.
2
3use crate::client::Client;
4#[allow(unused_imports)]
5use crate::enums::*;
6use crate::error::Error;
7#[allow(unused_imports)]
8use crate::models::*;
9use serde::Serialize;
10
11pub struct RadarApi<'a> {
12    pub(crate) client: &'a Client,
13}
14
15#[derive(Debug, Clone, Serialize)]
16pub struct CreateAttemptParams {
17    /// Request body sent with this call.
18    ///
19    /// Required.
20    #[serde(skip)]
21    pub body: RadarStandaloneAssessRequest,
22}
23
24impl CreateAttemptParams {
25    /// Construct a new `CreateAttemptParams` with the required fields set.
26    #[allow(deprecated)]
27    pub fn new(body: RadarStandaloneAssessRequest) -> Self {
28        Self { body }
29    }
30}
31
32#[derive(Debug, Clone, Serialize)]
33pub struct UpdateAttemptParams {
34    /// Request body sent with this call.
35    ///
36    /// Required.
37    #[serde(skip)]
38    pub body: RadarStandaloneUpdateRadarAttemptRequest,
39}
40
41impl UpdateAttemptParams {
42    /// Construct a new `UpdateAttemptParams` with the required fields set.
43    #[allow(deprecated)]
44    pub fn new(body: RadarStandaloneUpdateRadarAttemptRequest) -> Self {
45        Self { body }
46    }
47}
48
49#[derive(Debug, Clone, Serialize)]
50pub struct AddListEntryParams {
51    /// Request body sent with this call.
52    ///
53    /// Required.
54    #[serde(skip)]
55    pub body: RadarStandaloneUpdateRadarListRequest,
56}
57
58impl AddListEntryParams {
59    /// Construct a new `AddListEntryParams` with the required fields set.
60    #[allow(deprecated)]
61    pub fn new(body: RadarStandaloneUpdateRadarListRequest) -> Self {
62        Self { body }
63    }
64}
65
66#[derive(Debug, Clone, Serialize)]
67pub struct RemoveListEntryParams {
68    /// Request body sent with this call.
69    ///
70    /// Required.
71    #[serde(skip)]
72    pub body: RadarStandaloneDeleteRadarListEntryRequest,
73}
74
75impl RemoveListEntryParams {
76    /// Construct a new `RemoveListEntryParams` with the required fields set.
77    #[allow(deprecated)]
78    pub fn new(body: RadarStandaloneDeleteRadarListEntryRequest) -> Self {
79        Self { body }
80    }
81}
82
83impl<'a> RadarApi<'a> {
84    /// Create an attempt
85    ///
86    /// Assess a request for risk using the Radar engine and receive a verdict.
87    pub async fn create_attempt(
88        &self,
89        params: CreateAttemptParams,
90    ) -> Result<RadarStandaloneResponse, Error> {
91        self.create_attempt_with_options(params, None).await
92    }
93
94    /// Variant of [`Self::create_attempt`] that accepts per-request [`crate::RequestOptions`].
95    pub async fn create_attempt_with_options(
96        &self,
97        params: CreateAttemptParams,
98        options: Option<&crate::RequestOptions>,
99    ) -> Result<RadarStandaloneResponse, Error> {
100        let path = "/radar/attempts".to_string();
101        let method = http::Method::POST;
102        self.client
103            .request_with_body_opts(method, &path, &params, Some(&params.body), options)
104            .await
105    }
106
107    /// Update a Radar attempt
108    ///
109    /// You may optionally inform Radar that an authentication attempt or challenge was successful using this endpoint. Some Radar controls depend on tracking recent successful attempts, such as impossible travel.
110    pub async fn update_attempt(&self, id: &str, params: UpdateAttemptParams) -> Result<(), Error> {
111        self.update_attempt_with_options(id, params, None).await
112    }
113
114    /// Variant of [`Self::update_attempt`] that accepts per-request [`crate::RequestOptions`].
115    pub async fn update_attempt_with_options(
116        &self,
117        id: &str,
118        params: UpdateAttemptParams,
119        options: Option<&crate::RequestOptions>,
120    ) -> Result<(), Error> {
121        let id = crate::client::path_segment(id);
122        let path = format!("/radar/attempts/{id}");
123        let method = http::Method::PUT;
124        self.client
125            .request_with_body_opts_empty(method, &path, &params, Some(&params.body), options)
126            .await
127    }
128
129    /// Add an entry to a Radar list
130    ///
131    /// Add an entry to a Radar list.
132    pub async fn add_list_entry(
133        &self,
134        type_: &str,
135        action: &str,
136        params: AddListEntryParams,
137    ) -> Result<RadarListEntryAlreadyPresentResponse, Error> {
138        self.add_list_entry_with_options(type_, action, params, None)
139            .await
140    }
141
142    /// Variant of [`Self::add_list_entry`] that accepts per-request [`crate::RequestOptions`].
143    pub async fn add_list_entry_with_options(
144        &self,
145        type_: &str,
146        action: &str,
147        params: AddListEntryParams,
148        options: Option<&crate::RequestOptions>,
149    ) -> Result<RadarListEntryAlreadyPresentResponse, Error> {
150        let type_ = crate::client::path_segment(type_);
151        let action = crate::client::path_segment(action);
152        let path = format!("/radar/lists/{type_}/{action}");
153        let method = http::Method::POST;
154        self.client
155            .request_with_body_opts(method, &path, &params, Some(&params.body), options)
156            .await
157    }
158
159    /// Remove an entry from a Radar list
160    ///
161    /// Remove an entry from a Radar list.
162    pub async fn remove_list_entry(
163        &self,
164        type_: &str,
165        action: &str,
166        params: RemoveListEntryParams,
167    ) -> Result<(), Error> {
168        self.remove_list_entry_with_options(type_, action, params, None)
169            .await
170    }
171
172    /// Variant of [`Self::remove_list_entry`] that accepts per-request [`crate::RequestOptions`].
173    pub async fn remove_list_entry_with_options(
174        &self,
175        type_: &str,
176        action: &str,
177        params: RemoveListEntryParams,
178        options: Option<&crate::RequestOptions>,
179    ) -> Result<(), Error> {
180        let type_ = crate::client::path_segment(type_);
181        let action = crate::client::path_segment(action);
182        let path = format!("/radar/lists/{type_}/{action}");
183        let method = http::Method::DELETE;
184        self.client
185            .request_with_body_opts_empty(method, &path, &params, Some(&params.body), options)
186            .await
187    }
188}