tapis-sk 0.3.1

The Tapis Security API provides for management of Security Kernel (SK) role-based authorization and secrets resources.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
/*
 * Tapis Security API
 *
 * The Tapis Security API provides for management of Security Kernel (SK) role-based authorization and secrets resources.
 *
 * The version of the OpenAPI document: 1.8.2
 * Contact: cicsupport@tacc.utexas.edu
 * Generated by: https://openapi-generator.tech
 */

use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};

/// struct for typed errors of method [`delete_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSecretError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status404(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`destroy_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DestroySecretError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`destroy_secret_meta`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DestroySecretMetaError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`list_secret_meta`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecretMetaError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`read_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadSecretError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status404(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`read_secret_meta`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadSecretMetaError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`undelete_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UndeleteSecretError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`validate_service_password`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateServicePasswordError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`validate_site_admin_password`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateSiteAdminPasswordError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`write_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WriteSecretError {
    Status400(models::RespBasic),
    Status401(models::RespBasic),
    Status403(models::RespBasic),
    Status500(models::RespBasic),
    UnknownValue(serde_json::Value),
}

/// Soft delete one or more versions of a secret. Each version can be deleted individually or as part of a group specified in the input array. Deletion can be reversed using the *secret/undelete/{secretName}* endpoint, which make this a _soft_ deletion operation.  The input versions array is interpreted as follows:     * [-] - empty = delete all versions    * [0] - zero = delete only the latest version    * [1, 3, ...] - list = delete the specified versions  A valid tenant and user must also be specified in the body.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn delete_secret(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    req_versions: models::ReqVersions,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespVersions, Error<DeleteSecretError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_body_req_versions = req_versions;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/delete/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_versions);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespVersions`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespVersions`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<DeleteSecretError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Destroy one or more versions of a secret. Destroy implements a hard delete which delete that cannot be undone. It does not, however, remove any metadata associated with the secret.  The input versions array is interpreted as follows:     * [-] - empty = destroy all versions    * [0] - zero = destroy only the latest version    * [1, 3, ...] - list = destroy the specified versions  A valid tenant and user must be specified in the body.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn destroy_secret(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    req_versions: models::ReqVersions,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespVersions, Error<DestroySecretError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_body_req_versions = req_versions;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/destroy/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_versions);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespVersions`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespVersions`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<DestroySecretError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Erase all traces of a secret: its key, all versions of its value and all its metadata. Specifying a folder erases all secrets in that folder.  A valid tenant and user must be specified as query parameters.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn destroy_secret_meta(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    tenant: Option<&str>,
    user: Option<&str>,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespBasic, Error<DestroySecretMetaError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_query_tenant = tenant;
    let p_query_user = user;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/destroy/meta/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::DELETE, &uri_str);

    if let Some(ref param_value) = p_query_tenant {
        req_builder = req_builder.query(&[("tenant", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_user {
        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespBasic`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespBasic`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<DestroySecretMetaError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// List the secret names at the specified path. The path must represent a folder, not an actual secret name. If the path does not have a trailing slash one will be inserted. Secret names should not encode private information.  A valid tenant and user must be specified as query parameters.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the secret name. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* path parameter and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn list_secret_meta(
    configuration: &configuration::Configuration,
    secret_type: &str,
    tenant: Option<&str>,
    user: Option<&str>,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespSecretList, Error<ListSecretMetaError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_query_tenant = tenant;
    let p_query_user = user;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/list/meta/{secretType}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type)
    );
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref param_value) = p_query_tenant {
        req_builder = req_builder.query(&[("tenant", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_user {
        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespSecretList`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespSecretList`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<ListSecretMetaError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Read a versioned secret. By default, the latest version of the secret is read. If the *version* query parameter is specified then that version of the secret is read. The *version* parameter should be passed as an integer with zero indicating the latest version of the secret. A NOT FOUND status code is returned if the secret version does not exist or if it's deleted or destroyed.  The response object includes the map of zero or more key/value pairs and metadata that describes the secret. The metadata includes which version of the secret was returned.  A valid tenant and user must be specified as query parameters.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn read_secret(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    tenant: Option<&str>,
    user: Option<&str>,
    version: Option<i32>,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespSecret, Error<ReadSecretError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_query_tenant = tenant;
    let p_query_user = user;
    let p_query_version = version;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref param_value) = p_query_tenant {
        req_builder = req_builder.query(&[("tenant", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_user {
        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_version {
        req_builder = req_builder.query(&[("version", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespSecret`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespSecret`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<ReadSecretError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// List a secret's metadata including its version information. The input parameter must be a secret name, not a folder. The result includes which version of the secret is the latest.  A valid tenant and user must be specified as query parameters.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn read_secret_meta(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    tenant: Option<&str>,
    user: Option<&str>,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespSecretVersionMetadata, Error<ReadSecretMetaError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_query_tenant = tenant;
    let p_query_user = user;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/read/meta/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref param_value) = p_query_tenant {
        req_builder = req_builder.query(&[("tenant", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_user {
        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespSecretVersionMetadata`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespSecretVersionMetadata`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<ReadSecretMetaError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Restore one or more versions of a secret that have previously been deleted. This endpoint undoes soft deletions performed using the *secret/delete/{secretType}/{secretName}* endpoint.  The input versions array is interpreted as follows:     * [-] - empty = undelete all versions    * [0] - zero = undelete only the latest version    * [1, 3, ...] - list = undelete the specified versions  A valid tenant and user must be specified in the body.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service
pub async fn undelete_secret(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    req_versions: models::ReqVersions,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespVersions, Error<UndeleteSecretError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_body_req_versions = req_versions;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/undelete/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_versions);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespVersions`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespVersions`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<UndeleteSecretError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Validate a service's password. The JSON payload contains the password that needs to be validated against the password stored in the vault for the service specifie din the X-Tapis-User header. The secret name is the path under which the password was stored.  A valid tenant and user must also be specified in the payload.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  Only services can make this request.
pub async fn validate_service_password(
    configuration: &configuration::Configuration,
    secret_name: &str,
    req_validate_pwd: models::ReqValidatePwd,
) -> Result<models::RespAuthorized, Error<ValidateServicePasswordError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_name = secret_name;
    let p_body_req_validate_pwd = req_validate_pwd;

    let uri_str = format!(
        "{}/security/vault/secret/validateServicePassword/{secretName}",
        configuration.base_path,
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_validate_pwd);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespAuthorized`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespAuthorized`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<ValidateServicePasswordError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Validate a Site Admin's password. The JSON payload contains the password that needs to be validated against the password stored in the vault for the site admin specified in the X-Tapis-User header. The secret name is the path under which the password was stored.  A valid tenant and user must also be specified in the payload.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  Only services can make this request.
pub async fn validate_site_admin_password(
    configuration: &configuration::Configuration,
    secret_name: &str,
    req_validate_pwd: models::ReqValidatePwd,
) -> Result<models::RespAuthorized, Error<ValidateSiteAdminPasswordError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_name = secret_name;
    let p_body_req_validate_pwd = req_validate_pwd;

    let uri_str = format!(
        "{}/security/vault/secret/validateSiteAdminPassword/{secretName}",
        configuration.base_path,
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_validate_pwd);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespAuthorized`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespAuthorized`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<ValidateSiteAdminPasswordError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Create or update a secret. The JSON payload contains a required *data* object and an optional *options* object. It also contains the required tenant and user fields.  The *data* object is a JSON object that contains one or more key/value pairs in which both the key and value are strings. These are the individual secrets that are saved under the path name. The secrets are automatically versioned, which allows a pre-configured number of past secret values to be accessible even after new values are assigned. See the various GET operations for details on how to access different aspects of secrets.  NOTE: The *cas* option is currently ignored but documented here for future reference.  The *options* object can contain a *cas* key and with an integer value that represents a secret version. CAS stands for check-and-set and will check an existing secret's version before updating. If cas is not set the write will be always be allowed. If set to 0, a write will only be allowed if the key doesn’t exist. If the index is greater than zero, then the write will only be allowed if the key’s current version matches the version specified in the cas parameter.  ### Naming Secrets Secrets can be arranged hierarchically by using the \"+\" characters in the *secretName*. These characters will be converted to slashes upon receipt, allowing secrets to be arranged in folders.  A secret is assigned a path name constructed from the *secretType* and *secretName* path parameters and, optionally, from query parameters determined by the *secretType*. Each *secretType* determines a specific transformation from the url path to a path in the vault. The *secretType* may require certain query parameters to be present on the request in order to construct the vault path. See the next section for details.  ### Secret Types The list below documents each *secretType* and their applicable query parameters. Highlighted parameter names indicate required parameters. When present, default values are listed first and also highlighted.    - **system**     - *sysid*: the unique system id     - *sysuser*: the accessing user (except when keytype=cert)     - keytype: *sshkey* | password | accesskey | token | tmskey | cert   - **dbcred**     - *dbhost*:  the DBMS hostname, IP address or alias     - *dbname*:  the database name or alias     - *dbservice*: service name   - **jwtsigning** - *no query parameters*   - **user** - *no query parameters*   - **service** - *no query parameters*  ### Authorization Requestors are authorized based on the secret type specified in the URL path. The following authorizations are enforced:  - system: limited to the systems service - dbcred: any service - jwtsigning: limited to the tokens service - user: any user - service: any service  ### Generating Secrets Passwords and public/private key pairs appropriate for Tapis use can be generated as part of this secret write call. To direct SK to create a secret, assign the special value `<generate-secret>` to a key. When SK detects this value, it generates a password or key pair depending on context, and replaces the `<generate-secret>` text with the generated secret. In the case of a key pair, both the public and private keys are saved.  Key pairs are always generated for secrets of type JWTSigning, while passwords are generated for all other secret types unless the key is named *privateKey*.  To generate a key pair, insert the following key/value pair into the payload's data map:      key=\"privateKey\", value=\"<generate-secret>\"  When the key pair is generated, the above key/value item is replaced by these two key/value pairs:      key=\"privateKey\", value=<private key in pem format>     key=\"publicKey\",  value=<public key in pem format>  In non-JWTSigning secret types, passwords are generated whenever the following key/value pair is encountered in the payload's data map:      key=<name other than privateKey>, value=\"<generate-secret>\"  The generated password simply replaces the item's value and the key name is left unchanged.
pub async fn write_secret(
    configuration: &configuration::Configuration,
    secret_type: &str,
    secret_name: &str,
    req_write_secret: models::ReqWriteSecret,
    sysid: Option<&str>,
    sysuser: Option<&str>,
    keytype: Option<&str>,
    dbhost: Option<&str>,
    dbname: Option<&str>,
    dbservice: Option<&str>,
) -> Result<models::RespSecretMeta, Error<WriteSecretError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_secret_type = secret_type;
    let p_path_secret_name = secret_name;
    let p_body_req_write_secret = req_write_secret;
    let p_query_sysid = sysid;
    let p_query_sysuser = sysuser;
    let p_query_keytype = keytype;
    let p_query_dbhost = dbhost;
    let p_query_dbname = dbname;
    let p_query_dbservice = dbservice;

    let uri_str = format!(
        "{}/security/vault/secret/{secretType}/{secretName}",
        configuration.base_path,
        secretType = crate::apis::urlencode(p_path_secret_type),
        secretName = crate::apis::urlencode(p_path_secret_name)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref param_value) = p_query_sysid {
        req_builder = req_builder.query(&[("sysid", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sysuser {
        req_builder = req_builder.query(&[("sysuser", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_keytype {
        req_builder = req_builder.query(&[("keytype", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbhost {
        req_builder = req_builder.query(&[("dbhost", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbname {
        req_builder = req_builder.query(&[("dbname", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_dbservice {
        req_builder = req_builder.query(&[("dbservice", &param_value.to_string())]);
    }
    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("X-Tapis-Token", value);
    };
    req_builder = req_builder.json(&p_body_req_write_secret);

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespSecretMeta`"))),
            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespSecretMeta`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<WriteSecretError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}