workos/resources/
radar.rs1use 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 #[serde(skip)]
21 pub body: RadarStandaloneAssessRequest,
22}
23
24impl CreateAttemptParams {
25 #[allow(deprecated)]
27 pub fn new(body: RadarStandaloneAssessRequest) -> Self {
28 Self { body }
29 }
30}
31
32#[derive(Debug, Clone, Serialize)]
33pub struct UpdateAttemptParams {
34 #[serde(skip)]
38 pub body: RadarStandaloneUpdateRadarAttemptRequest,
39}
40
41impl UpdateAttemptParams {
42 #[allow(deprecated)]
44 pub fn new(body: RadarStandaloneUpdateRadarAttemptRequest) -> Self {
45 Self { body }
46 }
47}
48
49#[derive(Debug, Clone, Serialize)]
50pub struct AddListEntryParams {
51 #[serde(skip)]
55 pub body: RadarStandaloneUpdateRadarListRequest,
56}
57
58impl AddListEntryParams {
59 #[allow(deprecated)]
61 pub fn new(body: RadarStandaloneUpdateRadarListRequest) -> Self {
62 Self { body }
63 }
64}
65
66#[derive(Debug, Clone, Serialize)]
67pub struct RemoveListEntryParams {
68 #[serde(skip)]
72 pub body: RadarStandaloneDeleteRadarListEntryRequest,
73}
74
75impl RemoveListEntryParams {
76 #[allow(deprecated)]
78 pub fn new(body: RadarStandaloneDeleteRadarListEntryRequest) -> Self {
79 Self { body }
80 }
81}
82
83impl<'a> RadarApi<'a> {
84 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 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, ¶ms, Some(¶ms.body), options)
104 .await
105 }
106
107 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 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, ¶ms, Some(¶ms.body), options)
126 .await
127 }
128
129 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 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, ¶ms, Some(¶ms.body), options)
156 .await
157 }
158
159 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 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, ¶ms, Some(¶ms.body), options)
186 .await
187 }
188}