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