1use {
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 async fn create_signing_key(
32 &self,
33 params: CreateSigningKeyParams,
34 ) -> Result<models::SigningKeyDto, Error<CreateSigningKeyError>>;
35
36 async fn create_validation_key(
43 &self,
44 params: CreateValidationKeyParams,
45 ) -> Result<models::CreateValidationKeyResponseDto, Error<CreateValidationKeyError>>;
46
47 async fn disable_validation_key(
55 &self,
56 params: DisableValidationKeyParams,
57 ) -> Result<models::ValidationKeyDto, Error<DisableValidationKeyError>>;
58
59 async fn get_signing_key(
66 &self,
67 params: GetSigningKeyParams,
68 ) -> Result<models::SigningKeyDto, Error<GetSigningKeyError>>;
69
70 async fn get_signing_keys_list(
76 &self,
77 params: GetSigningKeysListParams,
78 ) -> Result<models::GetSigningKeyResponseDto, Error<GetSigningKeysListError>>;
79
80 async fn get_validation_key(
87 &self,
88 params: GetValidationKeyParams,
89 ) -> Result<models::ValidationKeyDto, Error<GetValidationKeyError>>;
90
91 async fn get_validation_keys_list(
97 &self,
98 params: GetValidationKeysListParams,
99 ) -> Result<models::GetValidationKeyResponseDto, Error<GetValidationKeysListError>>;
100
101 async fn set_agent_id(&self, params: SetAgentIdParams) -> Result<(), Error<SetAgentIdError>>;
109
110 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#[derive(Clone, Debug)]
135#[cfg_attr(feature = "bon", derive(::bon::Builder))]
136pub struct CreateSigningKeyParams {
137 pub create_signing_key_dto: models::CreateSigningKeyDto,
138 pub idempotency_key: Option<String>,
143}
144
145#[derive(Clone, Debug)]
148#[cfg_attr(feature = "bon", derive(::bon::Builder))]
149pub struct CreateValidationKeyParams {
150 pub create_validation_key_dto: models::CreateValidationKeyDto,
151 pub idempotency_key: Option<String>,
156}
157
158#[derive(Clone, Debug)]
161#[cfg_attr(feature = "bon", derive(::bon::Builder))]
162pub struct DisableValidationKeyParams {
163 pub key_id: String,
165 pub modify_validation_key_dto: models::ModifyValidationKeyDto,
166}
167
168#[derive(Clone, Debug)]
170#[cfg_attr(feature = "bon", derive(::bon::Builder))]
171pub struct GetSigningKeyParams {
172 pub key_id: String,
174}
175
176#[derive(Clone, Debug)]
179#[cfg_attr(feature = "bon", derive(::bon::Builder))]
180pub struct GetSigningKeysListParams {
181 pub page_cursor: Option<String>,
183 pub page_size: Option<f64>,
185 pub sort_by: Option<String>,
187 pub order: Option<String>,
189 pub vault_account_id: Option<f64>,
191 pub agent_user_id: Option<String>,
193 pub algorithm: Option<String>,
195 pub enabled: Option<bool>,
197 pub available: Option<bool>,
201}
202
203#[derive(Clone, Debug)]
206#[cfg_attr(feature = "bon", derive(::bon::Builder))]
207pub struct GetValidationKeyParams {
208 pub key_id: String,
209}
210
211#[derive(Clone, Debug)]
214#[cfg_attr(feature = "bon", derive(::bon::Builder))]
215pub struct GetValidationKeysListParams {
216 pub page_cursor: Option<String>,
218 pub page_size: Option<f64>,
220 pub sort_by: Option<String>,
222 pub order: Option<String>,
224}
225
226#[derive(Clone, Debug)]
228#[cfg_attr(feature = "bon", derive(::bon::Builder))]
229pub struct SetAgentIdParams {
230 pub key_id: String,
232 pub modify_signing_key_agent_id_dto: models::ModifySigningKeyAgentIdDto,
233}
234
235#[derive(Clone, Debug)]
238#[cfg_attr(feature = "bon", derive(::bon::Builder))]
239pub struct UpdateSigningKeyParams {
240 pub key_id: String,
242 pub modify_signing_key_dto: models::ModifySigningKeyDto,
243}
244
245#[async_trait]
246impl KeyLinkApi for KeyLinkApiClient {
247 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 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 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 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 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", ¶m_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", ¶m_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", ¶m_value.to_string())]);
585 }
586 if let Some(ref param_value) = order {
587 local_var_req_builder =
588 local_var_req_builder.query(&[("order", ¶m_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", ¶m_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", ¶m_value.to_string())]);
597 }
598 if let Some(ref param_value) = algorithm {
599 local_var_req_builder =
600 local_var_req_builder.query(&[("algorithm", ¶m_value.to_string())]);
601 }
602 if let Some(ref param_value) = enabled {
603 local_var_req_builder =
604 local_var_req_builder.query(&[("enabled", ¶m_value.to_string())]);
605 }
606 if let Some(ref param_value) = available {
607 local_var_req_builder =
608 local_var_req_builder.query(&[("available", ¶m_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 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 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", ¶m_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", ¶m_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", ¶m_value.to_string())]);
762 }
763 if let Some(ref param_value) = order {
764 local_var_req_builder =
765 local_var_req_builder.query(&[("order", ¶m_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 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 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#[derive(Debug, Clone, Serialize, Deserialize)]
939#[serde(untagged)]
940pub enum CreateSigningKeyError {
941 DefaultResponse(models::ErrorSchema),
942 UnknownValue(serde_json::Value),
943}
944
945#[derive(Debug, Clone, Serialize, Deserialize)]
947#[serde(untagged)]
948pub enum CreateValidationKeyError {
949 DefaultResponse(models::ErrorSchema),
950 UnknownValue(serde_json::Value),
951}
952
953#[derive(Debug, Clone, Serialize, Deserialize)]
955#[serde(untagged)]
956pub enum DisableValidationKeyError {
957 DefaultResponse(models::ErrorSchema),
958 UnknownValue(serde_json::Value),
959}
960
961#[derive(Debug, Clone, Serialize, Deserialize)]
963#[serde(untagged)]
964pub enum GetSigningKeyError {
965 DefaultResponse(models::ErrorSchema),
966 UnknownValue(serde_json::Value),
967}
968
969#[derive(Debug, Clone, Serialize, Deserialize)]
971#[serde(untagged)]
972pub enum GetSigningKeysListError {
973 DefaultResponse(models::ErrorSchema),
974 UnknownValue(serde_json::Value),
975}
976
977#[derive(Debug, Clone, Serialize, Deserialize)]
979#[serde(untagged)]
980pub enum GetValidationKeyError {
981 DefaultResponse(models::ErrorSchema),
982 UnknownValue(serde_json::Value),
983}
984
985#[derive(Debug, Clone, Serialize, Deserialize)]
987#[serde(untagged)]
988pub enum GetValidationKeysListError {
989 DefaultResponse(models::ErrorSchema),
990 UnknownValue(serde_json::Value),
991}
992
993#[derive(Debug, Clone, Serialize, Deserialize)]
995#[serde(untagged)]
996pub enum SetAgentIdError {
997 DefaultResponse(models::ErrorSchema),
998 UnknownValue(serde_json::Value),
999}
1000
1001#[derive(Debug, Clone, Serialize, Deserialize)]
1003#[serde(untagged)]
1004pub enum UpdateSigningKeyError {
1005 DefaultResponse(models::ErrorSchema),
1006 UnknownValue(serde_json::Value),
1007}