fireblocks_sdk/apis/
key_link_api.rs

1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10    super::{Error, configuration},
11    crate::{
12        apis::{ContentType, ResponseContent},
13        models,
14    },
15    async_trait::async_trait,
16    reqwest,
17    serde::{Deserialize, Serialize, de::Error as _},
18    std::sync::Arc,
19};
20
21#[async_trait]
22pub trait KeyLinkApi: Send + Sync {
23    /// POST /key_link/signing_keys
24    ///
25    /// Adds a new signing key to the workspace. The added key will be linked to
26    /// the specific Fireblocks agent user ID. The same user will receive the
27    /// proof of ownership message to be signed, and upon successful proof, the
28    /// key will become enabled. Please note that this endpoint is available
29    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
30    /// and Non-Signing Admin.
31    async fn create_signing_key(
32        &self,
33        params: CreateSigningKeyParams,
34    ) -> Result<models::SigningKeyDto, Error<CreateSigningKeyError>>;
35
36    /// POST /key_link/validation_keys
37    ///
38    /// Adds a new validation key used to validate signing keys. The new
39    /// validation key will undergo an approval process by the workspace quorum.
40    /// Please note that this endpoint is available only for Key Link enabled
41    /// workspaces. </br>Endpoint Permission: Admin and Non-Signing Admin.
42    async fn create_validation_key(
43        &self,
44        params: CreateValidationKeyParams,
45    ) -> Result<models::CreateValidationKeyResponseDto, Error<CreateValidationKeyError>>;
46
47    /// PATCH /key_link/validation_keys/{keyId}
48    ///
49    /// Allows disabling validation key even if it has not expired yet. It is
50    /// not allowed to enable the validation key back. Another key has to be
51    /// used for future validations. Please note that this endpoint is available
52    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
53    /// and Non-Signing Admin.
54    async fn disable_validation_key(
55        &self,
56        params: DisableValidationKeyParams,
57    ) -> Result<models::ValidationKeyDto, Error<DisableValidationKeyError>>;
58
59    /// GET /key_link/signing_keys/{keyId}
60    ///
61    /// Returns a signing key if it exists, identified by the specified
62    /// Fireblocks provided `keyId`. Please note that this endpoint is available
63    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
64    /// and Non-Signing Admin.
65    async fn get_signing_key(
66        &self,
67        params: GetSigningKeyParams,
68    ) -> Result<models::SigningKeyDto, Error<GetSigningKeyError>>;
69
70    /// GET /key_link/signing_keys
71    ///
72    /// Returns the list of signing keys in the workspace Please note that this
73    /// endpoint is available only for Key Link enabled workspaces.
74    /// </br>Endpoint Permission: Admin and Non-Signing Admin.
75    async fn get_signing_keys_list(
76        &self,
77        params: GetSigningKeysListParams,
78    ) -> Result<models::GetSigningKeyResponseDto, Error<GetSigningKeysListError>>;
79
80    /// GET /key_link/validation_keys/{keyId}
81    ///
82    /// Returns a validation key if it exists, identified by the specified
83    /// `keyId`. Please note that this endpoint is available only for Key Link
84    /// enabled workspaces. </br>Endpoint Permission: Admin and Non-Signing
85    /// Admin.
86    async fn get_validation_key(
87        &self,
88        params: GetValidationKeyParams,
89    ) -> Result<models::ValidationKeyDto, Error<GetValidationKeyError>>;
90
91    /// GET /key_link/validation_keys
92    ///
93    /// Returns the list of validation keys in the workspace Please note that
94    /// this endpoint is available only for Key Link enabled workspaces.
95    /// </br>Endpoint Permission: Admin and Non-Signing Admin.
96    async fn get_validation_keys_list(
97        &self,
98        params: GetValidationKeysListParams,
99    ) -> Result<models::GetValidationKeyResponseDto, Error<GetValidationKeysListError>>;
100
101    /// PATCH /key_link/signing_keys/{keyId}/agent_user_id
102    ///
103    /// Can modify existing signing key id if the key is not enabled. The change
104    /// done in background and will be visible once applied. If key is already
105    /// enabled (after proof of ownership) the user cannot be changed. Please
106    /// note that this endpoint is available only for Key Link enabled
107    /// workspaces. </br>Endpoint Permission: Admin and Non-Signing Admin.
108    async fn set_agent_id(&self, params: SetAgentIdParams) -> Result<(), Error<SetAgentIdError>>;
109
110    /// PATCH /key_link/signing_keys/{keyId}
111    ///
112    /// Allows assigning the signing key to a vault account, if it hasn't been
113    /// assigned to any other vault accounts yet. Please note that this endpoint
114    /// is available only for Key Link enabled workspaces. </br>Endpoint
115    /// Permission: Admin and Non-Signing Admin.
116    async fn update_signing_key(
117        &self,
118        params: UpdateSigningKeyParams,
119    ) -> Result<models::SigningKeyDto, Error<UpdateSigningKeyError>>;
120}
121
122pub struct KeyLinkApiClient {
123    configuration: Arc<configuration::Configuration>,
124}
125
126impl KeyLinkApiClient {
127    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
128        Self { configuration }
129    }
130}
131
132/// struct for passing parameters to the method [`create_signing_key`]
133#[derive(Clone, Debug)]
134#[cfg_attr(feature = "bon", derive(::bon::Builder))]
135pub struct CreateSigningKeyParams {
136    pub create_signing_key_dto: models::CreateSigningKeyDto,
137    /// A unique identifier for the request. If the request is sent multiple
138    /// times with the same idempotency key, the server will return the same
139    /// response as the first request. The idempotency key is valid for 24
140    /// hours.
141    pub idempotency_key: Option<String>,
142}
143
144/// struct for passing parameters to the method [`create_validation_key`]
145#[derive(Clone, Debug)]
146#[cfg_attr(feature = "bon", derive(::bon::Builder))]
147pub struct CreateValidationKeyParams {
148    pub create_validation_key_dto: models::CreateValidationKeyDto,
149    /// A unique identifier for the request. If the request is sent multiple
150    /// times with the same idempotency key, the server will return the same
151    /// response as the first request. The idempotency key is valid for 24
152    /// hours.
153    pub idempotency_key: Option<String>,
154}
155
156/// struct for passing parameters to the method [`disable_validation_key`]
157#[derive(Clone, Debug)]
158#[cfg_attr(feature = "bon", derive(::bon::Builder))]
159pub struct DisableValidationKeyParams {
160    /// The unique identifier for the validation key provided by Fireblocks
161    pub key_id: String,
162    pub modify_validation_key_dto: models::ModifyValidationKeyDto,
163}
164
165/// struct for passing parameters to the method [`get_signing_key`]
166#[derive(Clone, Debug)]
167#[cfg_attr(feature = "bon", derive(::bon::Builder))]
168pub struct GetSigningKeyParams {
169    /// The unique identifier for the signing key provided by Fireblocks
170    pub key_id: String,
171}
172
173/// struct for passing parameters to the method [`get_signing_keys_list`]
174#[derive(Clone, Debug)]
175#[cfg_attr(feature = "bon", derive(::bon::Builder))]
176pub struct GetSigningKeysListParams {
177    /// Cursor to the next page
178    pub page_cursor: Option<String>,
179    /// Amount of results to return in the next page
180    pub page_size: Option<f64>,
181    /// Field(s) to use for sorting
182    pub sort_by: Option<String>,
183    /// Is the order ascending or descending
184    pub order: Option<String>,
185    /// Return keys assigned to a specific vault
186    pub vault_account_id: Option<f64>,
187    /// Return keys associated with a specific agent user
188    pub agent_user_id: Option<String>,
189    /// Return only keys with a specific algorithm
190    pub algorithm: Option<String>,
191    /// Return keys that have been proof of ownership
192    pub enabled: Option<bool>,
193    /// Return keys that are proof of ownership but not assigned. Available
194    /// filter can be used only when vaultAccountId and enabled filters are not
195    /// set
196    pub available: Option<bool>,
197}
198
199/// struct for passing parameters to the method [`get_validation_key`]
200#[derive(Clone, Debug)]
201#[cfg_attr(feature = "bon", derive(::bon::Builder))]
202pub struct GetValidationKeyParams {
203    pub key_id: String,
204}
205
206/// struct for passing parameters to the method [`get_validation_keys_list`]
207#[derive(Clone, Debug)]
208#[cfg_attr(feature = "bon", derive(::bon::Builder))]
209pub struct GetValidationKeysListParams {
210    /// Cursor to the next page
211    pub page_cursor: Option<String>,
212    /// Amount of results to return in the next page
213    pub page_size: Option<f64>,
214    /// Field(s) to use for sorting
215    pub sort_by: Option<String>,
216    /// Is the order ascending or descending
217    pub order: Option<String>,
218}
219
220/// struct for passing parameters to the method [`set_agent_id`]
221#[derive(Clone, Debug)]
222#[cfg_attr(feature = "bon", derive(::bon::Builder))]
223pub struct SetAgentIdParams {
224    /// The unique identifier for the signing key provided by Fireblocks
225    pub key_id: String,
226    pub modify_signing_key_agent_id_dto: models::ModifySigningKeyAgentIdDto,
227}
228
229/// struct for passing parameters to the method [`update_signing_key`]
230#[derive(Clone, Debug)]
231#[cfg_attr(feature = "bon", derive(::bon::Builder))]
232pub struct UpdateSigningKeyParams {
233    /// The unique identifier for the signing key provided by Fireblocks
234    pub key_id: String,
235    pub modify_signing_key_dto: models::ModifySigningKeyDto,
236}
237
238#[async_trait]
239impl KeyLinkApi for KeyLinkApiClient {
240    /// Adds a new signing key to the workspace. The added key will be linked to
241    /// the specific Fireblocks agent user ID. The same user will receive the
242    /// proof of ownership message to be signed, and upon successful proof, the
243    /// key will become enabled. Please note that this endpoint is available
244    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
245    /// and Non-Signing Admin.
246    async fn create_signing_key(
247        &self,
248        params: CreateSigningKeyParams,
249    ) -> Result<models::SigningKeyDto, Error<CreateSigningKeyError>> {
250        let CreateSigningKeyParams {
251            create_signing_key_dto,
252            idempotency_key,
253        } = params;
254
255        let local_var_configuration = &self.configuration;
256
257        let local_var_client = &local_var_configuration.client;
258
259        let local_var_uri_str = format!(
260            "{}/key_link/signing_keys",
261            local_var_configuration.base_path
262        );
263        let mut local_var_req_builder =
264            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267            local_var_req_builder = local_var_req_builder
268                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
269        }
270        if let Some(local_var_param_value) = idempotency_key {
271            local_var_req_builder =
272                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
273        }
274        local_var_req_builder = local_var_req_builder.json(&create_signing_key_dto);
275
276        let local_var_req = local_var_req_builder.build()?;
277        let local_var_resp = local_var_client.execute(local_var_req).await?;
278
279        let local_var_status = local_var_resp.status();
280        let local_var_content_type = local_var_resp
281            .headers()
282            .get("content-type")
283            .and_then(|v| v.to_str().ok())
284            .unwrap_or("application/octet-stream");
285        let local_var_content_type = super::ContentType::from(local_var_content_type);
286        let local_var_content = local_var_resp.text().await?;
287
288        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
289            match local_var_content_type {
290                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
291                ContentType::Text => {
292                    return Err(Error::from(serde_json::Error::custom(
293                        "Received `text/plain` content type response that cannot be converted to \
294                         `models::SigningKeyDto`",
295                    )));
296                }
297                ContentType::Unsupported(local_var_unknown_type) => {
298                    return Err(Error::from(serde_json::Error::custom(format!(
299                        "Received `{local_var_unknown_type}` content type response that cannot be \
300                         converted to `models::SigningKeyDto`"
301                    ))));
302                }
303            }
304        } else {
305            let local_var_entity: Option<CreateSigningKeyError> =
306                serde_json::from_str(&local_var_content).ok();
307            let local_var_error = ResponseContent {
308                status: local_var_status,
309                content: local_var_content,
310                entity: local_var_entity,
311            };
312            Err(Error::ResponseError(local_var_error))
313        }
314    }
315
316    /// Adds a new validation key used to validate signing keys. The new
317    /// validation key will undergo an approval process by the workspace quorum.
318    /// Please note that this endpoint is available only for Key Link enabled
319    /// workspaces. </br>Endpoint Permission: Admin and Non-Signing Admin.
320    async fn create_validation_key(
321        &self,
322        params: CreateValidationKeyParams,
323    ) -> Result<models::CreateValidationKeyResponseDto, Error<CreateValidationKeyError>> {
324        let CreateValidationKeyParams {
325            create_validation_key_dto,
326            idempotency_key,
327        } = params;
328
329        let local_var_configuration = &self.configuration;
330
331        let local_var_client = &local_var_configuration.client;
332
333        let local_var_uri_str = format!(
334            "{}/key_link/validation_keys",
335            local_var_configuration.base_path
336        );
337        let mut local_var_req_builder =
338            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
339
340        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
341            local_var_req_builder = local_var_req_builder
342                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
343        }
344        if let Some(local_var_param_value) = idempotency_key {
345            local_var_req_builder =
346                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
347        }
348        local_var_req_builder = local_var_req_builder.json(&create_validation_key_dto);
349
350        let local_var_req = local_var_req_builder.build()?;
351        let local_var_resp = local_var_client.execute(local_var_req).await?;
352
353        let local_var_status = local_var_resp.status();
354        let local_var_content_type = local_var_resp
355            .headers()
356            .get("content-type")
357            .and_then(|v| v.to_str().ok())
358            .unwrap_or("application/octet-stream");
359        let local_var_content_type = super::ContentType::from(local_var_content_type);
360        let local_var_content = local_var_resp.text().await?;
361
362        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
363            match local_var_content_type {
364                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
365                ContentType::Text => {
366                    return Err(Error::from(serde_json::Error::custom(
367                        "Received `text/plain` content type response that cannot be converted to \
368                         `models::CreateValidationKeyResponseDto`",
369                    )));
370                }
371                ContentType::Unsupported(local_var_unknown_type) => {
372                    return Err(Error::from(serde_json::Error::custom(format!(
373                        "Received `{local_var_unknown_type}` content type response that cannot be \
374                         converted to `models::CreateValidationKeyResponseDto`"
375                    ))));
376                }
377            }
378        } else {
379            let local_var_entity: Option<CreateValidationKeyError> =
380                serde_json::from_str(&local_var_content).ok();
381            let local_var_error = ResponseContent {
382                status: local_var_status,
383                content: local_var_content,
384                entity: local_var_entity,
385            };
386            Err(Error::ResponseError(local_var_error))
387        }
388    }
389
390    /// Allows disabling validation key even if it has not expired yet. It is
391    /// not allowed to enable the validation key back. Another key has to be
392    /// used for future validations. Please note that this endpoint is available
393    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
394    /// and Non-Signing Admin.
395    async fn disable_validation_key(
396        &self,
397        params: DisableValidationKeyParams,
398    ) -> Result<models::ValidationKeyDto, Error<DisableValidationKeyError>> {
399        let DisableValidationKeyParams {
400            key_id,
401            modify_validation_key_dto,
402        } = params;
403
404        let local_var_configuration = &self.configuration;
405
406        let local_var_client = &local_var_configuration.client;
407
408        let local_var_uri_str = format!(
409            "{}/key_link/validation_keys/{keyId}",
410            local_var_configuration.base_path,
411            keyId = crate::apis::urlencode(key_id)
412        );
413        let mut local_var_req_builder =
414            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
415
416        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
417            local_var_req_builder = local_var_req_builder
418                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
419        }
420        local_var_req_builder = local_var_req_builder.json(&modify_validation_key_dto);
421
422        let local_var_req = local_var_req_builder.build()?;
423        let local_var_resp = local_var_client.execute(local_var_req).await?;
424
425        let local_var_status = local_var_resp.status();
426        let local_var_content_type = local_var_resp
427            .headers()
428            .get("content-type")
429            .and_then(|v| v.to_str().ok())
430            .unwrap_or("application/octet-stream");
431        let local_var_content_type = super::ContentType::from(local_var_content_type);
432        let local_var_content = local_var_resp.text().await?;
433
434        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435            match local_var_content_type {
436                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
437                ContentType::Text => {
438                    return Err(Error::from(serde_json::Error::custom(
439                        "Received `text/plain` content type response that cannot be converted to \
440                         `models::ValidationKeyDto`",
441                    )));
442                }
443                ContentType::Unsupported(local_var_unknown_type) => {
444                    return Err(Error::from(serde_json::Error::custom(format!(
445                        "Received `{local_var_unknown_type}` content type response that cannot be \
446                         converted to `models::ValidationKeyDto`"
447                    ))));
448                }
449            }
450        } else {
451            let local_var_entity: Option<DisableValidationKeyError> =
452                serde_json::from_str(&local_var_content).ok();
453            let local_var_error = ResponseContent {
454                status: local_var_status,
455                content: local_var_content,
456                entity: local_var_entity,
457            };
458            Err(Error::ResponseError(local_var_error))
459        }
460    }
461
462    /// Returns a signing key if it exists, identified by the specified
463    /// Fireblocks provided `keyId`. Please note that this endpoint is available
464    /// only for Key Link enabled workspaces. </br>Endpoint Permission: Admin
465    /// and Non-Signing Admin.
466    async fn get_signing_key(
467        &self,
468        params: GetSigningKeyParams,
469    ) -> Result<models::SigningKeyDto, Error<GetSigningKeyError>> {
470        let GetSigningKeyParams { key_id } = params;
471
472        let local_var_configuration = &self.configuration;
473
474        let local_var_client = &local_var_configuration.client;
475
476        let local_var_uri_str = format!(
477            "{}/key_link/signing_keys/{keyId}",
478            local_var_configuration.base_path,
479            keyId = crate::apis::urlencode(key_id)
480        );
481        let mut local_var_req_builder =
482            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
483
484        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
485            local_var_req_builder = local_var_req_builder
486                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
487        }
488
489        let local_var_req = local_var_req_builder.build()?;
490        let local_var_resp = local_var_client.execute(local_var_req).await?;
491
492        let local_var_status = local_var_resp.status();
493        let local_var_content_type = local_var_resp
494            .headers()
495            .get("content-type")
496            .and_then(|v| v.to_str().ok())
497            .unwrap_or("application/octet-stream");
498        let local_var_content_type = super::ContentType::from(local_var_content_type);
499        let local_var_content = local_var_resp.text().await?;
500
501        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
502            match local_var_content_type {
503                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
504                ContentType::Text => {
505                    return Err(Error::from(serde_json::Error::custom(
506                        "Received `text/plain` content type response that cannot be converted to \
507                         `models::SigningKeyDto`",
508                    )));
509                }
510                ContentType::Unsupported(local_var_unknown_type) => {
511                    return Err(Error::from(serde_json::Error::custom(format!(
512                        "Received `{local_var_unknown_type}` content type response that cannot be \
513                         converted to `models::SigningKeyDto`"
514                    ))));
515                }
516            }
517        } else {
518            let local_var_entity: Option<GetSigningKeyError> =
519                serde_json::from_str(&local_var_content).ok();
520            let local_var_error = ResponseContent {
521                status: local_var_status,
522                content: local_var_content,
523                entity: local_var_entity,
524            };
525            Err(Error::ResponseError(local_var_error))
526        }
527    }
528
529    /// Returns the list of signing keys in the workspace Please note that this
530    /// endpoint is available only for Key Link enabled workspaces.
531    /// </br>Endpoint Permission: Admin and Non-Signing Admin.
532    async fn get_signing_keys_list(
533        &self,
534        params: GetSigningKeysListParams,
535    ) -> Result<models::GetSigningKeyResponseDto, Error<GetSigningKeysListError>> {
536        let GetSigningKeysListParams {
537            page_cursor,
538            page_size,
539            sort_by,
540            order,
541            vault_account_id,
542            agent_user_id,
543            algorithm,
544            enabled,
545            available,
546        } = params;
547
548        let local_var_configuration = &self.configuration;
549
550        let local_var_client = &local_var_configuration.client;
551
552        let local_var_uri_str = format!(
553            "{}/key_link/signing_keys",
554            local_var_configuration.base_path
555        );
556        let mut local_var_req_builder =
557            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
558
559        if let Some(ref local_var_str) = page_cursor {
560            local_var_req_builder =
561                local_var_req_builder.query(&[("pageCursor", &local_var_str.to_string())]);
562        }
563        if let Some(ref local_var_str) = page_size {
564            local_var_req_builder =
565                local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
566        }
567        if let Some(ref local_var_str) = sort_by {
568            local_var_req_builder =
569                local_var_req_builder.query(&[("sortBy", &local_var_str.to_string())]);
570        }
571        if let Some(ref local_var_str) = order {
572            local_var_req_builder =
573                local_var_req_builder.query(&[("order", &local_var_str.to_string())]);
574        }
575        if let Some(ref local_var_str) = vault_account_id {
576            local_var_req_builder =
577                local_var_req_builder.query(&[("vaultAccountId", &local_var_str.to_string())]);
578        }
579        if let Some(ref local_var_str) = agent_user_id {
580            local_var_req_builder =
581                local_var_req_builder.query(&[("agentUserId", &local_var_str.to_string())]);
582        }
583        if let Some(ref local_var_str) = algorithm {
584            local_var_req_builder =
585                local_var_req_builder.query(&[("algorithm", &local_var_str.to_string())]);
586        }
587        if let Some(ref local_var_str) = enabled {
588            local_var_req_builder =
589                local_var_req_builder.query(&[("enabled", &local_var_str.to_string())]);
590        }
591        if let Some(ref local_var_str) = available {
592            local_var_req_builder =
593                local_var_req_builder.query(&[("available", &local_var_str.to_string())]);
594        }
595        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
596            local_var_req_builder = local_var_req_builder
597                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
598        }
599
600        let local_var_req = local_var_req_builder.build()?;
601        let local_var_resp = local_var_client.execute(local_var_req).await?;
602
603        let local_var_status = local_var_resp.status();
604        let local_var_content_type = local_var_resp
605            .headers()
606            .get("content-type")
607            .and_then(|v| v.to_str().ok())
608            .unwrap_or("application/octet-stream");
609        let local_var_content_type = super::ContentType::from(local_var_content_type);
610        let local_var_content = local_var_resp.text().await?;
611
612        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
613            match local_var_content_type {
614                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
615                ContentType::Text => {
616                    return Err(Error::from(serde_json::Error::custom(
617                        "Received `text/plain` content type response that cannot be converted to \
618                         `models::GetSigningKeyResponseDto`",
619                    )));
620                }
621                ContentType::Unsupported(local_var_unknown_type) => {
622                    return Err(Error::from(serde_json::Error::custom(format!(
623                        "Received `{local_var_unknown_type}` content type response that cannot be \
624                         converted to `models::GetSigningKeyResponseDto`"
625                    ))));
626                }
627            }
628        } else {
629            let local_var_entity: Option<GetSigningKeysListError> =
630                serde_json::from_str(&local_var_content).ok();
631            let local_var_error = ResponseContent {
632                status: local_var_status,
633                content: local_var_content,
634                entity: local_var_entity,
635            };
636            Err(Error::ResponseError(local_var_error))
637        }
638    }
639
640    /// Returns a validation key if it exists, identified by the specified
641    /// `keyId`. Please note that this endpoint is available only for Key Link
642    /// enabled workspaces. </br>Endpoint Permission: Admin and Non-Signing
643    /// Admin.
644    async fn get_validation_key(
645        &self,
646        params: GetValidationKeyParams,
647    ) -> Result<models::ValidationKeyDto, Error<GetValidationKeyError>> {
648        let GetValidationKeyParams { key_id } = params;
649
650        let local_var_configuration = &self.configuration;
651
652        let local_var_client = &local_var_configuration.client;
653
654        let local_var_uri_str = format!(
655            "{}/key_link/validation_keys/{keyId}",
656            local_var_configuration.base_path,
657            keyId = crate::apis::urlencode(key_id)
658        );
659        let mut local_var_req_builder =
660            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
661
662        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
663            local_var_req_builder = local_var_req_builder
664                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
665        }
666
667        let local_var_req = local_var_req_builder.build()?;
668        let local_var_resp = local_var_client.execute(local_var_req).await?;
669
670        let local_var_status = local_var_resp.status();
671        let local_var_content_type = local_var_resp
672            .headers()
673            .get("content-type")
674            .and_then(|v| v.to_str().ok())
675            .unwrap_or("application/octet-stream");
676        let local_var_content_type = super::ContentType::from(local_var_content_type);
677        let local_var_content = local_var_resp.text().await?;
678
679        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
680            match local_var_content_type {
681                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
682                ContentType::Text => {
683                    return Err(Error::from(serde_json::Error::custom(
684                        "Received `text/plain` content type response that cannot be converted to \
685                         `models::ValidationKeyDto`",
686                    )));
687                }
688                ContentType::Unsupported(local_var_unknown_type) => {
689                    return Err(Error::from(serde_json::Error::custom(format!(
690                        "Received `{local_var_unknown_type}` content type response that cannot be \
691                         converted to `models::ValidationKeyDto`"
692                    ))));
693                }
694            }
695        } else {
696            let local_var_entity: Option<GetValidationKeyError> =
697                serde_json::from_str(&local_var_content).ok();
698            let local_var_error = ResponseContent {
699                status: local_var_status,
700                content: local_var_content,
701                entity: local_var_entity,
702            };
703            Err(Error::ResponseError(local_var_error))
704        }
705    }
706
707    /// Returns the list of validation keys in the workspace Please note that
708    /// this endpoint is available only for Key Link enabled workspaces.
709    /// </br>Endpoint Permission: Admin and Non-Signing Admin.
710    async fn get_validation_keys_list(
711        &self,
712        params: GetValidationKeysListParams,
713    ) -> Result<models::GetValidationKeyResponseDto, Error<GetValidationKeysListError>> {
714        let GetValidationKeysListParams {
715            page_cursor,
716            page_size,
717            sort_by,
718            order,
719        } = params;
720
721        let local_var_configuration = &self.configuration;
722
723        let local_var_client = &local_var_configuration.client;
724
725        let local_var_uri_str = format!(
726            "{}/key_link/validation_keys",
727            local_var_configuration.base_path
728        );
729        let mut local_var_req_builder =
730            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
731
732        if let Some(ref local_var_str) = page_cursor {
733            local_var_req_builder =
734                local_var_req_builder.query(&[("pageCursor", &local_var_str.to_string())]);
735        }
736        if let Some(ref local_var_str) = page_size {
737            local_var_req_builder =
738                local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
739        }
740        if let Some(ref local_var_str) = sort_by {
741            local_var_req_builder =
742                local_var_req_builder.query(&[("sortBy", &local_var_str.to_string())]);
743        }
744        if let Some(ref local_var_str) = order {
745            local_var_req_builder =
746                local_var_req_builder.query(&[("order", &local_var_str.to_string())]);
747        }
748        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
749            local_var_req_builder = local_var_req_builder
750                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
751        }
752
753        let local_var_req = local_var_req_builder.build()?;
754        let local_var_resp = local_var_client.execute(local_var_req).await?;
755
756        let local_var_status = local_var_resp.status();
757        let local_var_content_type = local_var_resp
758            .headers()
759            .get("content-type")
760            .and_then(|v| v.to_str().ok())
761            .unwrap_or("application/octet-stream");
762        let local_var_content_type = super::ContentType::from(local_var_content_type);
763        let local_var_content = local_var_resp.text().await?;
764
765        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
766            match local_var_content_type {
767                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
768                ContentType::Text => {
769                    return Err(Error::from(serde_json::Error::custom(
770                        "Received `text/plain` content type response that cannot be converted to \
771                         `models::GetValidationKeyResponseDto`",
772                    )));
773                }
774                ContentType::Unsupported(local_var_unknown_type) => {
775                    return Err(Error::from(serde_json::Error::custom(format!(
776                        "Received `{local_var_unknown_type}` content type response that cannot be \
777                         converted to `models::GetValidationKeyResponseDto`"
778                    ))));
779                }
780            }
781        } else {
782            let local_var_entity: Option<GetValidationKeysListError> =
783                serde_json::from_str(&local_var_content).ok();
784            let local_var_error = ResponseContent {
785                status: local_var_status,
786                content: local_var_content,
787                entity: local_var_entity,
788            };
789            Err(Error::ResponseError(local_var_error))
790        }
791    }
792
793    /// Can modify existing signing key id if the key is not enabled. The change
794    /// done in background and will be visible once applied. If key is already
795    /// enabled (after proof of ownership) the user cannot be changed. Please
796    /// note that this endpoint is available only for Key Link enabled
797    /// workspaces. </br>Endpoint Permission: Admin and Non-Signing Admin.
798    async fn set_agent_id(&self, params: SetAgentIdParams) -> Result<(), Error<SetAgentIdError>> {
799        let SetAgentIdParams {
800            key_id,
801            modify_signing_key_agent_id_dto,
802        } = params;
803
804        let local_var_configuration = &self.configuration;
805
806        let local_var_client = &local_var_configuration.client;
807
808        let local_var_uri_str = format!(
809            "{}/key_link/signing_keys/{keyId}/agent_user_id",
810            local_var_configuration.base_path,
811            keyId = crate::apis::urlencode(key_id)
812        );
813        let mut local_var_req_builder =
814            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
815
816        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
817            local_var_req_builder = local_var_req_builder
818                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
819        }
820        local_var_req_builder = local_var_req_builder.json(&modify_signing_key_agent_id_dto);
821
822        let local_var_req = local_var_req_builder.build()?;
823        let local_var_resp = local_var_client.execute(local_var_req).await?;
824
825        let local_var_status = local_var_resp.status();
826        let local_var_content = local_var_resp.text().await?;
827
828        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
829            Ok(())
830        } else {
831            let local_var_entity: Option<SetAgentIdError> =
832                serde_json::from_str(&local_var_content).ok();
833            let local_var_error = ResponseContent {
834                status: local_var_status,
835                content: local_var_content,
836                entity: local_var_entity,
837            };
838            Err(Error::ResponseError(local_var_error))
839        }
840    }
841
842    /// Allows assigning the signing key to a vault account, if it hasn't been
843    /// assigned to any other vault accounts yet. Please note that this endpoint
844    /// is available only for Key Link enabled workspaces. </br>Endpoint
845    /// Permission: Admin and Non-Signing Admin.
846    async fn update_signing_key(
847        &self,
848        params: UpdateSigningKeyParams,
849    ) -> Result<models::SigningKeyDto, Error<UpdateSigningKeyError>> {
850        let UpdateSigningKeyParams {
851            key_id,
852            modify_signing_key_dto,
853        } = params;
854
855        let local_var_configuration = &self.configuration;
856
857        let local_var_client = &local_var_configuration.client;
858
859        let local_var_uri_str = format!(
860            "{}/key_link/signing_keys/{keyId}",
861            local_var_configuration.base_path,
862            keyId = crate::apis::urlencode(key_id)
863        );
864        let mut local_var_req_builder =
865            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
866
867        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
868            local_var_req_builder = local_var_req_builder
869                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
870        }
871        local_var_req_builder = local_var_req_builder.json(&modify_signing_key_dto);
872
873        let local_var_req = local_var_req_builder.build()?;
874        let local_var_resp = local_var_client.execute(local_var_req).await?;
875
876        let local_var_status = local_var_resp.status();
877        let local_var_content_type = local_var_resp
878            .headers()
879            .get("content-type")
880            .and_then(|v| v.to_str().ok())
881            .unwrap_or("application/octet-stream");
882        let local_var_content_type = super::ContentType::from(local_var_content_type);
883        let local_var_content = local_var_resp.text().await?;
884
885        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
886            match local_var_content_type {
887                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
888                ContentType::Text => {
889                    return Err(Error::from(serde_json::Error::custom(
890                        "Received `text/plain` content type response that cannot be converted to \
891                         `models::SigningKeyDto`",
892                    )));
893                }
894                ContentType::Unsupported(local_var_unknown_type) => {
895                    return Err(Error::from(serde_json::Error::custom(format!(
896                        "Received `{local_var_unknown_type}` content type response that cannot be \
897                         converted to `models::SigningKeyDto`"
898                    ))));
899                }
900            }
901        } else {
902            let local_var_entity: Option<UpdateSigningKeyError> =
903                serde_json::from_str(&local_var_content).ok();
904            let local_var_error = ResponseContent {
905                status: local_var_status,
906                content: local_var_content,
907                entity: local_var_entity,
908            };
909            Err(Error::ResponseError(local_var_error))
910        }
911    }
912}
913
914/// struct for typed errors of method [`create_signing_key`]
915#[derive(Debug, Clone, Serialize, Deserialize)]
916#[serde(untagged)]
917pub enum CreateSigningKeyError {
918    DefaultResponse(models::ErrorSchema),
919    UnknownValue(serde_json::Value),
920}
921
922/// struct for typed errors of method [`create_validation_key`]
923#[derive(Debug, Clone, Serialize, Deserialize)]
924#[serde(untagged)]
925pub enum CreateValidationKeyError {
926    DefaultResponse(models::ErrorSchema),
927    UnknownValue(serde_json::Value),
928}
929
930/// struct for typed errors of method [`disable_validation_key`]
931#[derive(Debug, Clone, Serialize, Deserialize)]
932#[serde(untagged)]
933pub enum DisableValidationKeyError {
934    DefaultResponse(models::ErrorSchema),
935    UnknownValue(serde_json::Value),
936}
937
938/// struct for typed errors of method [`get_signing_key`]
939#[derive(Debug, Clone, Serialize, Deserialize)]
940#[serde(untagged)]
941pub enum GetSigningKeyError {
942    DefaultResponse(models::ErrorSchema),
943    UnknownValue(serde_json::Value),
944}
945
946/// struct for typed errors of method [`get_signing_keys_list`]
947#[derive(Debug, Clone, Serialize, Deserialize)]
948#[serde(untagged)]
949pub enum GetSigningKeysListError {
950    DefaultResponse(models::ErrorSchema),
951    UnknownValue(serde_json::Value),
952}
953
954/// struct for typed errors of method [`get_validation_key`]
955#[derive(Debug, Clone, Serialize, Deserialize)]
956#[serde(untagged)]
957pub enum GetValidationKeyError {
958    DefaultResponse(models::ErrorSchema),
959    UnknownValue(serde_json::Value),
960}
961
962/// struct for typed errors of method [`get_validation_keys_list`]
963#[derive(Debug, Clone, Serialize, Deserialize)]
964#[serde(untagged)]
965pub enum GetValidationKeysListError {
966    DefaultResponse(models::ErrorSchema),
967    UnknownValue(serde_json::Value),
968}
969
970/// struct for typed errors of method [`set_agent_id`]
971#[derive(Debug, Clone, Serialize, Deserialize)]
972#[serde(untagged)]
973pub enum SetAgentIdError {
974    DefaultResponse(models::ErrorSchema),
975    UnknownValue(serde_json::Value),
976}
977
978/// struct for typed errors of method [`update_signing_key`]
979#[derive(Debug, Clone, Serialize, Deserialize)]
980#[serde(untagged)]
981pub enum UpdateSigningKeyError {
982    DefaultResponse(models::ErrorSchema),
983    UnknownValue(serde_json::Value),
984}