From 904ac9c62146224a132e7ac2e977a8a71444f977 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 27 Nov 2023 14:53:26 +0100 Subject: [PATCH] Update NetHSM API (#12) --- .openapi-generator/FILES | 6 + .openapi-generator/VERSION | 2 +- docs/BackupPassphraseConfig.md | 3 +- docs/CreateResourceId.md | 11 ++ docs/DefaultApi.md | 57 +++--- docs/KeyItem.md | 2 +- docs/PrivateKey.md | 2 +- docs/PrivateKeyPemArguments.md | 12 ++ docs/PublicKey.md | 2 +- docs/RestoreRequestArguments.md | 12 ++ docs/UnlockPassphraseConfig.md | 3 +- src/apis/default_api.rs | 233 +++++------------------- src/models/backup_passphrase_config.rs | 13 +- src/models/create_resource_id.rs | 21 +++ src/models/key_item.rs | 8 +- src/models/mod.rs | 6 + src/models/private_key.rs | 8 +- src/models/private_key_pem_arguments.rs | 26 +++ src/models/public_key.rs | 6 +- src/models/restore_request_arguments.rs | 26 +++ src/models/unlock_passphrase_config.rs | 13 +- 21 files changed, 226 insertions(+), 246 deletions(-) create mode 100644 docs/CreateResourceId.md create mode 100644 docs/PrivateKeyPemArguments.md create mode 100644 docs/RestoreRequestArguments.md create mode 100644 src/models/create_resource_id.rs create mode 100644 src/models/private_key_pem_arguments.rs create mode 100644 src/models/restore_request_arguments.rs diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 9e3d96d..748fc6b 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,4 +1,5 @@ docs/BackupPassphraseConfig.md +docs/CreateResourceId.md docs/DecryptData.md docs/DecryptMode.md docs/DecryptRequestData.md @@ -20,10 +21,12 @@ docs/LogLevel.md docs/LoggingConfig.md docs/NetworkConfig.md docs/PrivateKey.md +docs/PrivateKeyPemArguments.md docs/ProvisionRequestData.md docs/PublicKey.md docs/RandomData.md docs/RandomRequestData.md +docs/RestoreRequestArguments.md docs/SignData.md docs/SignMode.md docs/SignRequestData.md @@ -47,6 +50,7 @@ src/apis/default_api.rs src/apis/mod.rs src/lib.rs src/models/backup_passphrase_config.rs +src/models/create_resource_id.rs src/models/decrypt_data.rs src/models/decrypt_mode.rs src/models/decrypt_request_data.rs @@ -68,10 +72,12 @@ src/models/logging_config.rs src/models/mod.rs src/models/network_config.rs src/models/private_key.rs +src/models/private_key_pem_arguments.rs src/models/provision_request_data.rs src/models/public_key.rs src/models/random_data.rs src/models/random_request_data.rs +src/models/restore_request_arguments.rs src/models/sign_data.rs src/models/sign_mode.rs src/models/sign_request_data.rs diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 757e674..0f78c31 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.0.0-SNAPSHOT \ No newline at end of file +7.2.0-SNAPSHOT \ No newline at end of file diff --git a/docs/BackupPassphraseConfig.md b/docs/BackupPassphraseConfig.md index e11268e..facb014 100644 --- a/docs/BackupPassphraseConfig.md +++ b/docs/BackupPassphraseConfig.md @@ -4,7 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**passphrase** | **String** | | +**new_passphrase** | **String** | | +**current_passphrase** | **String** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/CreateResourceId.md b/docs/CreateResourceId.md new file mode 100644 index 0000000..1291745 --- /dev/null +++ b/docs/CreateResourceId.md @@ -0,0 +1,11 @@ +# CreateResourceId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md index 68764a2..43ec4e2 100644 --- a/docs/DefaultApi.md +++ b/docs/DefaultApi.md @@ -70,7 +70,7 @@ Method | HTTP request | Description > config_backup_passphrase_put(backup_passphrase_config) -Update the backup passphrase. +Update the backup passphrase. If the backup passphrase is not set yet, use \"\" as currentPassphrase. *WARNING:* Like the unlock passphrase, this configuration can't be reset by an admin user without knowing the current value, so if the backup passphrase is lost, neither can it be reset to a new value nor can the created backups be restored. ### Parameters @@ -472,7 +472,7 @@ Name | Type | Description | Required | Notes > config_unlock_passphrase_put(unlock_passphrase_config) -Update the unlock passphrase. +Update the unlock passphrase. *WARNING:* The unlock passphrase can't be reset by an admin user without knowing the current value, so if the unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be unlocked. ### Parameters @@ -607,7 +607,7 @@ No authorization required ## keys_generate_post -> keys_generate_post(key_generate_request_data) +> crate::models::CreateResourceId keys_generate_post(key_generate_request_data) Generate a pair of public and private key and store it in NetHSM. KeyID is optional as a parameter and will be generated by NetHSM if not present. @@ -621,7 +621,7 @@ Name | Type | Description | Required | Notes ### Return type - (empty response body) +[**crate::models::CreateResourceId**](CreateResourceId.md) ### Authorization @@ -630,7 +630,7 @@ Name | Type | Description | Required | Notes ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -697,10 +697,10 @@ Name | Type | Description | Required | Notes ## keys_key_id_cert_get -> String keys_key_id_cert_get(key_id) +> std::vec::Vec keys_key_id_cert_get(key_id) -Retrieve stored certificate. The content-type header will display the media type of the stored data. +Retrieve a stored certificate in the exact format it was stored. ### Parameters @@ -711,7 +711,7 @@ Name | Type | Description | Required | Notes ### Return type -**String** +[**std::vec::Vec**](std::vec::Vec.md) ### Authorization @@ -720,7 +720,7 @@ Name | Type | Description | Required | Notes ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/x-pem-file, application/x-x509-ca-cert, application/pgp-keys +- **Accept**: application/octet-stream [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -730,7 +730,7 @@ Name | Type | Description | Required | Notes > keys_key_id_cert_put(key_id, body) -Store a certificate. Maximum size 1MB. The content-type header provides the media type. Only application/json, application/x-pem-file, application/x-x509-ca-cert, application/octet-stream, text/plain and application/pgp-keys is allowed. +Store a certificate. Maximum size 1MB. The Content-Type must be application/octet-stream. ### Parameters @@ -738,7 +738,7 @@ Store a certificate. Maximum size 1MB. The content-type header provides the medi Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- **key_id** | **String** | | [required] | -**body** | **String** | | [required] | +**body** | **std::vec::Vec** | | [required] | ### Return type @@ -750,7 +750,7 @@ Name | Type | Description | Required | Notes ### HTTP request headers -- **Content-Type**: application/x-pem-file, application/x-x509-ca-cert, application/pgp-keys +- **Content-Type**: application/octet-stream - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -941,7 +941,7 @@ Name | Type | Description | Required | Notes ## keys_key_id_put -> keys_key_id_put(key_id, private_key, mechanisms, tags) +> keys_key_id_put(key_id, private_key) Import a private key into NetHSM and store it under the *KeyID* path. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object. @@ -953,8 +953,6 @@ Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- **key_id** | **String** | | [required] | **private_key** | [**PrivateKey**](PrivateKey.md) | For request body with content type `application/json`: * *RSA* includes `primeP`, `primeQ`, and `publicExponent` properties. The remaining properties `privateExponent`, `modulus`, ..) are computed. * *EC_P224*, *EC_P256*, *EC_P384*, *EC_P521* uses the `data` property. Keys are the raw (big endian) scalar. * *Curve25519* uses the `data` property. Keys are the raw (little endian) key. | [required] | -**mechanisms** | Option<[**Vec**](crate::models::KeyMechanism.md)> | | | -**tags** | Option<[**Vec**](String.md)> | | | ### Return type @@ -966,7 +964,7 @@ Name | Type | Description | Required | Notes ### HTTP request headers -- **Content-Type**: application/json, application/x-pem-file +- **Content-Type**: application/json, multipart/form-data - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -1067,7 +1065,7 @@ Name | Type | Description | Required | Notes ## keys_post -> keys_post(private_key, mechanisms, tags) +> crate::models::CreateResourceId keys_post(private_key) Import a private key into NetHSM and let NetHSM generate a KeyID. The public key will be automatically derived. The parameters of the key can be passed as a PEM file or a JSON object. @@ -1078,12 +1076,10 @@ Import a private key into NetHSM and let NetHSM generate a KeyID. The public key Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- **private_key** | [**PrivateKey**](PrivateKey.md) | | [required] | -**mechanisms** | Option<[**Vec**](crate::models::KeyMechanism.md)> | | | -**tags** | Option<[**Vec**](String.md)> | | | ### Return type - (empty response body) +[**crate::models::CreateResourceId**](CreateResourceId.md) ### Authorization @@ -1091,8 +1087,8 @@ Name | Type | Description | Required | Notes ### HTTP request headers -- **Content-Type**: application/json, application/x-pem-file -- **Accept**: Not defined +- **Content-Type**: application/json, multipart/form-data +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -1156,7 +1152,7 @@ This endpoint does not need any parameter. > provision_post(provision_request_data) -Initial provisioning, only available in *Unprovisioned* state. +Initial provisioning, only available in *Unprovisioned* state. *WARNING:* The unlock passphrase can't be reset by an admin user without knowing the current value, so if the unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be unlocked. ### Parameters @@ -1375,7 +1371,7 @@ This endpoint does not need any parameter. ## system_restore_post -> system_restore_post(backup_passphrase, body, system_time) +> system_restore_post(arguments, backup_file) Restore the key store and user store from a backup file. If NetHSM is *Unprovisioned*, then the configuration is restored. @@ -1385,9 +1381,8 @@ Restore the key store and user store from a backup file. If NetHSM is *Unprovisi Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**backup_passphrase** | **String** | | [required] | -**body** | **std::vec::Vec** | | [required] | -**system_time** | Option<**String**> | | | +**arguments** | Option<[**crate::models::RestoreRequestArguments**](RestoreRequest_arguments.md)> | | | +**backup_file** | Option<**std::vec::Vec**> | | | ### Return type @@ -1399,7 +1394,7 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/octet-stream +- **Content-Type**: multipart/form-data - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -1521,7 +1516,7 @@ This endpoint does not need any parameter. ## users_post -> users_post(user_post_data) +> crate::models::CreateResourceId users_post(user_post_data) Create a new user on NetHSM. The user-ID is generated by NetHSM. @@ -1535,7 +1530,7 @@ Name | Type | Description | Required | Notes ### Return type - (empty response body) +[**crate::models::CreateResourceId**](CreateResourceId.md) ### Authorization @@ -1544,7 +1539,7 @@ Name | Type | Description | Required | Notes ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/KeyItem.md b/docs/KeyItem.md index a737eea..31e0fbc 100644 --- a/docs/KeyItem.md +++ b/docs/KeyItem.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**key** | **String** | | +**id** | **String** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/PrivateKey.md b/docs/PrivateKey.md index 6d469e2..0c6dce8 100644 --- a/docs/PrivateKey.md +++ b/docs/PrivateKey.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **mechanisms** | [**Vec**](KeyMechanism.md) | | **r#type** | [**crate::models::KeyType**](KeyType.md) | | -**key** | [**crate::models::KeyPrivateData**](KeyPrivateData.md) | | +**private** | [**crate::models::KeyPrivateData**](KeyPrivateData.md) | | **restrictions** | Option<[**crate::models::KeyRestrictions**](KeyRestrictions.md)> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/PrivateKeyPemArguments.md b/docs/PrivateKeyPemArguments.md new file mode 100644 index 0000000..cd47727 --- /dev/null +++ b/docs/PrivateKeyPemArguments.md @@ -0,0 +1,12 @@ +# PrivateKeyPemArguments + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mechanisms** | Option<[**Vec**](KeyMechanism.md)> | | [optional] +**restrictions** | Option<[**crate::models::KeyRestrictions**](KeyRestrictions.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/PublicKey.md b/docs/PublicKey.md index 39abdb9..84d0053 100644 --- a/docs/PublicKey.md +++ b/docs/PublicKey.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **mechanisms** | [**Vec**](KeyMechanism.md) | | **r#type** | [**crate::models::KeyType**](KeyType.md) | | **restrictions** | [**crate::models::KeyRestrictions**](KeyRestrictions.md) | | -**key** | Option<[**crate::models::KeyPublicData**](KeyPublicData.md)> | | [optional] +**public** | Option<[**crate::models::KeyPublicData**](KeyPublicData.md)> | | [optional] **operations** | **i32** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/RestoreRequestArguments.md b/docs/RestoreRequestArguments.md new file mode 100644 index 0000000..5390139 --- /dev/null +++ b/docs/RestoreRequestArguments.md @@ -0,0 +1,12 @@ +# RestoreRequestArguments + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**backup_passphrase** | Option<**String**> | | [optional] +**system_time** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UnlockPassphraseConfig.md b/docs/UnlockPassphraseConfig.md index 9626f33..3a9ee72 100644 --- a/docs/UnlockPassphraseConfig.md +++ b/docs/UnlockPassphraseConfig.md @@ -4,7 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**passphrase** | **String** | | +**new_passphrase** | **String** | | +**current_passphrase** | **String** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/src/apis/default_api.rs b/src/apis/default_api.rs index 1588036..39bf15b 100644 --- a/src/apis/default_api.rs +++ b/src/apis/default_api.rs @@ -12,86 +12,30 @@ use super::{configuration, Error}; use crate::apis::ResponseContent; use std::io::Read; -#[derive(Clone, Debug)] -pub enum KeysKeyIdCertGetAccept { - ApplicationXPemFile, - ApplicationXX509CaCert, - ApplicationPgpKeys, -} - -impl KeysKeyIdCertGetAccept { - pub fn as_str(&self) -> &'static str { - match self { - Self::ApplicationXPemFile => "application/x-pem-file", - Self::ApplicationXX509CaCert => "application/x-x509-ca-cert", - Self::ApplicationPgpKeys => "application/pgp-keys", - } - } - - pub fn is_json(&self) -> bool { - match self { - Self::ApplicationXPemFile => false, - Self::ApplicationXX509CaCert => false, - Self::ApplicationPgpKeys => false, - } - } -} -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum KeysKeyIdCertPutBody { - ApplicationXPemFile(String), - ApplicationXX509CaCert(String), - ApplicationPgpKeys(String), -} - -impl KeysKeyIdCertPutBody { - pub fn content_type(&self) -> &'static str { - match self { - Self::ApplicationXPemFile(_) => "application/x-pem-file", - Self::ApplicationXX509CaCert(_) => "application/x-x509-ca-cert", - Self::ApplicationPgpKeys(_) => "application/pgp-keys", - } - } - pub fn is_json(&self) -> bool { - match self { - Self::ApplicationXPemFile(_) => false, - Self::ApplicationXX509CaCert(_) => false, - Self::ApplicationPgpKeys(_) => false, - } - } - pub fn get_string(&self) -> String { - match self { - Self::ApplicationXPemFile(s) => s.clone(), - Self::ApplicationXX509CaCert(s) => s.clone(), - Self::ApplicationPgpKeys(s) => s.clone(), - } - } -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum KeysKeyIdPutBody { ApplicationJson(crate::models::PrivateKey), - ApplicationXPemFile(String), + MultipartFormData(String), } impl KeysKeyIdPutBody { pub fn content_type(&self) -> &'static str { match self { Self::ApplicationJson(_) => "application/json", - Self::ApplicationXPemFile(_) => "application/x-pem-file", + Self::MultipartFormData(_) => "multipart/form-data", } } pub fn is_json(&self) -> bool { match self { Self::ApplicationJson(_) => true, - Self::ApplicationXPemFile(_) => false, + Self::MultipartFormData(_) => false, } } pub fn get_string(&self) -> String { match self { Self::ApplicationJson(_) => "".to_string(), - Self::ApplicationXPemFile(s) => s.clone(), + Self::MultipartFormData(s) => s.clone(), } } } @@ -100,26 +44,26 @@ impl KeysKeyIdPutBody { #[serde(untagged)] pub enum KeysPostBody { ApplicationJson(crate::models::PrivateKey), - ApplicationXPemFile(String), + MultipartFormData(String), } impl KeysPostBody { pub fn content_type(&self) -> &'static str { match self { Self::ApplicationJson(_) => "application/json", - Self::ApplicationXPemFile(_) => "application/x-pem-file", + Self::MultipartFormData(_) => "multipart/form-data", } } pub fn is_json(&self) -> bool { match self { Self::ApplicationJson(_) => true, - Self::ApplicationXPemFile(_) => false, + Self::MultipartFormData(_) => false, } } pub fn get_string(&self) -> String { match self { Self::ApplicationJson(_) => "".to_string(), - Self::ApplicationXPemFile(s) => s.clone(), + Self::MultipartFormData(s) => s.clone(), } } } @@ -363,7 +307,6 @@ pub enum KeysKeyIdCertDeleteError { Status403(), Status404(), Status406(), - Status409(), Status412(), UnknownValue(serde_json::Value), } @@ -800,7 +743,7 @@ pub enum UsersUserIdTagsTagPutError { UnknownValue(serde_json::Value), } -/// Update the backup passphrase. +/// Update the backup passphrase. If the backup passphrase is not set yet, use \"\" as currentPassphrase. *WARNING:* Like the unlock passphrase, this configuration can't be reset by an admin user without knowing the current value, so if the backup passphrase is lost, neither can it be reset to a new value nor can the created backups be restored. pub fn config_backup_passphrase_put( configuration: &configuration::Configuration, @@ -1604,7 +1547,7 @@ pub fn config_unattended_boot_put( } } -/// Update the unlock passphrase. +/// Update the unlock passphrase. *WARNING:* The unlock passphrase can't be reset by an admin user without knowing the current value, so if the unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be unlocked. pub fn config_unlock_passphrase_put( configuration: &configuration::Configuration, @@ -1868,7 +1811,7 @@ pub fn info_get( pub fn keys_generate_post( configuration: &configuration::Configuration, key_generate_request_data: crate::models::KeyGenerateRequestData, -) -> Result, Error> { +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; @@ -1884,6 +1827,8 @@ pub fn keys_generate_post( local_var_req_builder = local_var_req_builder.set("authorization", &value); }; + let accept_str = "application/json"; + local_var_req_builder = local_var_req_builder.set("accept", accept_str); local_var_req_builder = local_var_req_builder.set("content-type", "application/json"); let local_var_resp = local_var_req_builder.send_json(key_generate_request_data)?; @@ -1899,10 +1844,12 @@ pub fn keys_generate_post( let local_var_content_clone = local_var_content.clone(); if !local_var_status >= 400 { + let local_var_entity: crate::models::CreateResourceId = + serde_json::from_slice(&local_var_content).map_err(Error::from)?; let local_var_result = ResponseContent { status: local_var_status, content: local_var_content_clone, - entity: (), + entity: local_var_entity, headers: local_var_headers, }; Ok(local_var_result) @@ -2039,13 +1986,12 @@ pub fn keys_key_id_cert_delete( } } -/// Retrieve stored certificate. The content-type header will display the media type of the stored data. +/// Retrieve a stored certificate in the exact format it was stored. pub fn keys_key_id_cert_get( configuration: &configuration::Configuration, key_id: &str, - accept: KeysKeyIdCertGetAccept, -) -> Result, Error> { +) -> Result>, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; @@ -2065,8 +2011,7 @@ pub fn keys_key_id_cert_get( local_var_req_builder = local_var_req_builder.set("authorization", &value); }; - let accept_str = accept.as_str(); - let is_json = accept.is_json(); + let accept_str = "application/octet-stream"; local_var_req_builder = local_var_req_builder.set("accept", accept_str); let local_var_resp = local_var_req_builder.call()?; @@ -2082,11 +2027,7 @@ pub fn keys_key_id_cert_get( let local_var_content_clone = local_var_content.clone(); if !local_var_status >= 400 { - let local_var_entity: String = if is_json { - serde_json::from_slice(&local_var_content).map_err(Error::from)? - } else { - String::from_utf8(local_var_content)? - }; + let local_var_entity = local_var_content.clone(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content_clone, @@ -2106,12 +2047,12 @@ pub fn keys_key_id_cert_get( } } -/// Store a certificate. Maximum size 1MB. The content-type header provides the media type. Only application/json, application/x-pem-file, application/x-x509-ca-cert, application/octet-stream, text/plain and application/pgp-keys is allowed. +/// Store a certificate. Maximum size 1MB. The Content-Type must be application/octet-stream. pub fn keys_key_id_cert_put( configuration: &configuration::Configuration, key_id: &str, - body: KeysKeyIdCertPutBody, + body: std::vec::Vec, ) -> Result, Error> { let local_var_configuration = configuration; @@ -2133,14 +2074,9 @@ pub fn keys_key_id_cert_put( local_var_req_builder = local_var_req_builder.set("authorization", &value); }; - let body_json = body.is_json(); - local_var_req_builder = local_var_req_builder.set("content-type", body.content_type()); - - let local_var_resp = if body_json { - local_var_req_builder.send_json(body)? - } else { - local_var_req_builder.send_string(body.get_string().as_str())? - }; + local_var_req_builder = local_var_req_builder.set("content-type", "application/octet-stream"); + let body = std::io::Cursor::new(body); + let local_var_resp = local_var_req_builder.send(body)?; let local_var_headers = super::get_header_map(&local_var_resp); @@ -2554,8 +2490,6 @@ pub fn keys_key_id_put( configuration: &configuration::Configuration, key_id: &str, body: KeysKeyIdPutBody, - mechanisms: Option>, - tags: Option>, ) -> Result, Error> { let local_var_configuration = configuration; @@ -2568,46 +2502,6 @@ pub fn keys_key_id_put( ); let mut local_var_req_builder = local_var_client.request("PUT", local_var_uri_str.as_str()); - if let Some(local_var_str) = mechanisms { - local_var_req_builder = match "multi" { - "multi" => { - for i in local_var_str.iter() { - local_var_req_builder = - local_var_req_builder.query("mechanisms", i.to_string().as_str()); - } - local_var_req_builder - } - _ => local_var_req_builder.query_pairs([( - "mechanisms", - local_var_str - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .as_str(), - )]), - }; - } - if let Some(local_var_str) = tags { - local_var_req_builder = match "multi" { - "multi" => { - for i in local_var_str.iter() { - local_var_req_builder = - local_var_req_builder.query("tags", i.to_string().as_str()); - } - local_var_req_builder - } - _ => local_var_req_builder.query_pairs([( - "tags", - local_var_str - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .as_str(), - )]), - }; - } if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = local_var_req_builder.set("user-agent", local_var_user_agent); } @@ -2847,9 +2741,7 @@ pub fn keys_key_id_sign_post( pub fn keys_post( configuration: &configuration::Configuration, body: KeysPostBody, - mechanisms: Option>, - tags: Option>, -) -> Result, Error> { +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; @@ -2857,46 +2749,6 @@ pub fn keys_post( let local_var_uri_str = format!("{}/keys", local_var_configuration.base_path); let mut local_var_req_builder = local_var_client.request("POST", local_var_uri_str.as_str()); - if let Some(local_var_str) = mechanisms { - local_var_req_builder = match "multi" { - "multi" => { - for i in local_var_str.iter() { - local_var_req_builder = - local_var_req_builder.query("mechanisms", i.to_string().as_str()); - } - local_var_req_builder - } - _ => local_var_req_builder.query_pairs([( - "mechanisms", - local_var_str - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .as_str(), - )]), - }; - } - if let Some(local_var_str) = tags { - local_var_req_builder = match "multi" { - "multi" => { - for i in local_var_str.iter() { - local_var_req_builder = - local_var_req_builder.query("tags", i.to_string().as_str()); - } - local_var_req_builder - } - _ => local_var_req_builder.query_pairs([( - "tags", - local_var_str - .iter() - .map(|p| p.to_string()) - .collect::>() - .join(",") - .as_str(), - )]), - }; - } if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = local_var_req_builder.set("user-agent", local_var_user_agent); } @@ -2905,6 +2757,8 @@ pub fn keys_post( local_var_req_builder = local_var_req_builder.set("authorization", &value); }; + let accept_str = "application/json"; + local_var_req_builder = local_var_req_builder.set("accept", accept_str); let body_json = body.is_json(); local_var_req_builder = local_var_req_builder.set("content-type", body.content_type()); @@ -2926,10 +2780,12 @@ pub fn keys_post( let local_var_content_clone = local_var_content.clone(); if !local_var_status >= 400 { + let local_var_entity: crate::models::CreateResourceId = + serde_json::from_slice(&local_var_content).map_err(Error::from)?; let local_var_result = ResponseContent { status: local_var_status, content: local_var_content_clone, - entity: (), + entity: local_var_entity, headers: local_var_headers, }; Ok(local_var_result) @@ -3055,7 +2911,7 @@ pub fn metrics_get( } } -/// Initial provisioning, only available in *Unprovisioned* state. +/// Initial provisioning, only available in *Unprovisioned* state. *WARNING:* The unlock passphrase can't be reset by an admin user without knowing the current value, so if the unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be unlocked. pub fn provision_post( configuration: &configuration::Configuration, @@ -3496,9 +3352,8 @@ pub fn system_reboot_post( pub fn system_restore_post( configuration: &configuration::Configuration, - backup_passphrase: &str, - body: std::vec::Vec, - system_time: Option, + arguments: Option, + backup_file: Option>, ) -> Result, Error> { let local_var_configuration = configuration; @@ -3507,19 +3362,13 @@ pub fn system_restore_post( let local_var_uri_str = format!("{}/system/restore", local_var_configuration.base_path); let mut local_var_req_builder = local_var_client.request("POST", local_var_uri_str.as_str()); - local_var_req_builder = - local_var_req_builder.query_pairs([("backupPassphrase", backup_passphrase)]); - if let Some(local_var_str) = system_time { - local_var_req_builder = - local_var_req_builder.query_pairs([("systemTime", local_var_str.to_string().as_str())]); - } if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { local_var_req_builder = local_var_req_builder.set("user-agent", local_var_user_agent); } - local_var_req_builder = local_var_req_builder.set("content-type", "application/octet-stream"); - let body = std::io::Cursor::new(body); - let local_var_resp = local_var_req_builder.send(body)?; + local_var_req_builder = local_var_req_builder.set("content-type", "multipart/form-data"); + + let local_var_resp = local_var_req_builder.call()?; let local_var_headers = super::get_header_map(&local_var_resp); @@ -3776,7 +3625,7 @@ pub fn users_get( pub fn users_post( configuration: &configuration::Configuration, user_post_data: crate::models::UserPostData, -) -> Result, Error> { +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; @@ -3792,6 +3641,8 @@ pub fn users_post( local_var_req_builder = local_var_req_builder.set("authorization", &value); }; + let accept_str = "application/json"; + local_var_req_builder = local_var_req_builder.set("accept", accept_str); local_var_req_builder = local_var_req_builder.set("content-type", "application/json"); let local_var_resp = local_var_req_builder.send_json(user_post_data)?; @@ -3807,10 +3658,12 @@ pub fn users_post( let local_var_content_clone = local_var_content.clone(); if !local_var_status >= 400 { + let local_var_entity: crate::models::CreateResourceId = + serde_json::from_slice(&local_var_content).map_err(Error::from)?; let local_var_result = ResponseContent { status: local_var_status, content: local_var_content_clone, - entity: (), + entity: local_var_entity, headers: local_var_headers, }; Ok(local_var_result) diff --git a/src/models/backup_passphrase_config.rs b/src/models/backup_passphrase_config.rs index 91157a2..e129303 100644 --- a/src/models/backup_passphrase_config.rs +++ b/src/models/backup_passphrase_config.rs @@ -10,12 +10,17 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct BackupPassphraseConfig { - #[serde(rename = "passphrase")] - pub passphrase: String, + #[serde(rename = "newPassphrase")] + pub new_passphrase: String, + #[serde(rename = "currentPassphrase")] + pub current_passphrase: String, } impl BackupPassphraseConfig { - pub fn new(passphrase: String) -> BackupPassphraseConfig { - BackupPassphraseConfig { passphrase } + pub fn new(new_passphrase: String, current_passphrase: String) -> BackupPassphraseConfig { + BackupPassphraseConfig { + new_passphrase, + current_passphrase, + } } } diff --git a/src/models/create_resource_id.rs b/src/models/create_resource_id.rs new file mode 100644 index 0000000..3438172 --- /dev/null +++ b/src/models/create_resource_id.rs @@ -0,0 +1,21 @@ +/* + * NetHSM + * + * All endpoints expect exactly the specified JSON. Additional properties will cause a Bad Request Error (400). All HTTP errors contain a JSON structure with an explanation of type string. All [base64](https://tools.ietf.org/html/rfc4648#section-4) encoded values are Big Endian. + * + * The version of the OpenAPI document: v1 + * Contact: Nitrokey + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct CreateResourceId { + #[serde(rename = "id")] + pub id: String, +} + +impl CreateResourceId { + pub fn new(id: String) -> CreateResourceId { + CreateResourceId { id } + } +} diff --git a/src/models/key_item.rs b/src/models/key_item.rs index 898d3e0..d57dceb 100644 --- a/src/models/key_item.rs +++ b/src/models/key_item.rs @@ -10,12 +10,12 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct KeyItem { - #[serde(rename = "key")] - pub key: String, + #[serde(rename = "id")] + pub id: String, } impl KeyItem { - pub fn new(key: String) -> KeyItem { - KeyItem { key } + pub fn new(id: String) -> KeyItem { + KeyItem { id } } } diff --git a/src/models/mod.rs b/src/models/mod.rs index 4d0f398..9459eac 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -1,5 +1,7 @@ pub mod backup_passphrase_config; pub use self::backup_passphrase_config::BackupPassphraseConfig; +pub mod create_resource_id; +pub use self::create_resource_id::CreateResourceId; pub mod decrypt_data; pub use self::decrypt_data::DecryptData; pub mod decrypt_mode; @@ -40,6 +42,8 @@ pub mod network_config; pub use self::network_config::NetworkConfig; pub mod private_key; pub use self::private_key::PrivateKey; +pub mod private_key_pem_arguments; +pub use self::private_key_pem_arguments::PrivateKeyPemArguments; pub mod provision_request_data; pub use self::provision_request_data::ProvisionRequestData; pub mod public_key; @@ -48,6 +52,8 @@ pub mod random_data; pub use self::random_data::RandomData; pub mod random_request_data; pub use self::random_request_data::RandomRequestData; +pub mod restore_request_arguments; +pub use self::restore_request_arguments::RestoreRequestArguments; pub mod sign_data; pub use self::sign_data::SignData; pub mod sign_mode; diff --git a/src/models/private_key.rs b/src/models/private_key.rs index cbf0001..519634e 100644 --- a/src/models/private_key.rs +++ b/src/models/private_key.rs @@ -14,8 +14,8 @@ pub struct PrivateKey { pub mechanisms: Vec, #[serde(rename = "type")] pub r#type: crate::models::KeyType, - #[serde(rename = "key")] - pub key: Box, + #[serde(rename = "private")] + pub private: Box, #[serde(rename = "restrictions", skip_serializing_if = "Option::is_none")] pub restrictions: Option>, } @@ -24,12 +24,12 @@ impl PrivateKey { pub fn new( mechanisms: Vec, r#type: crate::models::KeyType, - key: crate::models::KeyPrivateData, + private: crate::models::KeyPrivateData, ) -> PrivateKey { PrivateKey { mechanisms, r#type, - key: Box::new(key), + private: Box::new(private), restrictions: None, } } diff --git a/src/models/private_key_pem_arguments.rs b/src/models/private_key_pem_arguments.rs new file mode 100644 index 0000000..637ed10 --- /dev/null +++ b/src/models/private_key_pem_arguments.rs @@ -0,0 +1,26 @@ +/* + * NetHSM + * + * All endpoints expect exactly the specified JSON. Additional properties will cause a Bad Request Error (400). All HTTP errors contain a JSON structure with an explanation of type string. All [base64](https://tools.ietf.org/html/rfc4648#section-4) encoded values are Big Endian. + * + * The version of the OpenAPI document: v1 + * Contact: Nitrokey + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct PrivateKeyPemArguments { + #[serde(rename = "mechanisms", skip_serializing_if = "Option::is_none")] + pub mechanisms: Option>, + #[serde(rename = "restrictions", skip_serializing_if = "Option::is_none")] + pub restrictions: Option>, +} + +impl PrivateKeyPemArguments { + pub fn new() -> PrivateKeyPemArguments { + PrivateKeyPemArguments { + mechanisms: None, + restrictions: None, + } + } +} diff --git a/src/models/public_key.rs b/src/models/public_key.rs index ca44cb5..b107ffd 100644 --- a/src/models/public_key.rs +++ b/src/models/public_key.rs @@ -16,8 +16,8 @@ pub struct PublicKey { pub r#type: crate::models::KeyType, #[serde(rename = "restrictions")] pub restrictions: Box, - #[serde(rename = "key", skip_serializing_if = "Option::is_none")] - pub key: Option>, + #[serde(rename = "public", skip_serializing_if = "Option::is_none")] + pub public: Option>, #[serde(rename = "operations")] pub operations: i32, } @@ -33,7 +33,7 @@ impl PublicKey { mechanisms, r#type, restrictions: Box::new(restrictions), - key: None, + public: None, operations, } } diff --git a/src/models/restore_request_arguments.rs b/src/models/restore_request_arguments.rs new file mode 100644 index 0000000..0000f4c --- /dev/null +++ b/src/models/restore_request_arguments.rs @@ -0,0 +1,26 @@ +/* + * NetHSM + * + * All endpoints expect exactly the specified JSON. Additional properties will cause a Bad Request Error (400). All HTTP errors contain a JSON structure with an explanation of type string. All [base64](https://tools.ietf.org/html/rfc4648#section-4) encoded values are Big Endian. + * + * The version of the OpenAPI document: v1 + * Contact: Nitrokey + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct RestoreRequestArguments { + #[serde(rename = "backupPassphrase", skip_serializing_if = "Option::is_none")] + pub backup_passphrase: Option, + #[serde(rename = "systemTime", skip_serializing_if = "Option::is_none")] + pub system_time: Option, +} + +impl RestoreRequestArguments { + pub fn new() -> RestoreRequestArguments { + RestoreRequestArguments { + backup_passphrase: None, + system_time: None, + } + } +} diff --git a/src/models/unlock_passphrase_config.rs b/src/models/unlock_passphrase_config.rs index 946df9b..cc55c71 100644 --- a/src/models/unlock_passphrase_config.rs +++ b/src/models/unlock_passphrase_config.rs @@ -10,12 +10,17 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct UnlockPassphraseConfig { - #[serde(rename = "passphrase")] - pub passphrase: String, + #[serde(rename = "newPassphrase")] + pub new_passphrase: String, + #[serde(rename = "currentPassphrase")] + pub current_passphrase: String, } impl UnlockPassphraseConfig { - pub fn new(passphrase: String) -> UnlockPassphraseConfig { - UnlockPassphraseConfig { passphrase } + pub fn new(new_passphrase: String, current_passphrase: String) -> UnlockPassphraseConfig { + UnlockPassphraseConfig { + new_passphrase, + current_passphrase, + } } }