# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::KeyVault::V7_2_preview # # The key vault client performs cryptographic key operations and vault # operations against the Key Vault service. # class HSMSecurityDomain include MsRestAzure # # Creates and initializes a new instance of the HSMSecurityDomain class. # @param client service class for accessing basic functionality. # def initialize(client) @client = client end # @return [KeyVaultClient] reference to the KeyVaultClient attr_reader :client # # Retrieves the Security Domain download operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainOperationStatus] operation results. # def download_pending(vault_base_url, custom_headers:nil) response = download_pending_async(vault_base_url, custom_headers:custom_headers).value! response.body unless response.nil? end # # Retrieves the Security Domain download operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def download_pending_with_http_info(vault_base_url, custom_headers:nil) download_pending_async(vault_base_url, custom_headers:custom_headers).value! end # # Retrieves the Security Domain download operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def download_pending_async(vault_base_url, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'securitydomain/download/pending' request_url = @base_url || @client.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainOperationStatus.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Retrieves the Security Domain from the managed HSM. Calling this endpoint can # be used to activate a provisioned managed HSM resource. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param certificate_info_object [CertificateInfoObject] The Security Domain # download operation requires customer to provide N certificates (minimum 3 and # maximum 10) containing a public key in JWK format. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainObject] operation results. # def download(vault_base_url, certificate_info_object, custom_headers:nil) response = download_async(vault_base_url, certificate_info_object, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param certificate_info_object [CertificateInfoObject] The Security Domain # download operation requires customer to provide N certificates (minimum 3 and # maximum 10) containing a public key in JWK format. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def download_async(vault_base_url, certificate_info_object, custom_headers:nil) # Send request promise = begin_download_async(vault_base_url, certificate_info_object, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainObject.mapper() parsed_response = @client.deserialize(result_mapper, parsed_response) end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method, FinalStateVia::AZURE_ASYNC_OPERATION) end promise end # # Retrieve Security Domain transfer key # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [TransferKey] operation results. # def transfer_key_method(vault_base_url, custom_headers:nil) response = transfer_key_method_async(vault_base_url, custom_headers:custom_headers).value! response.body unless response.nil? end # # Retrieve Security Domain transfer key # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def transfer_key_method_with_http_info(vault_base_url, custom_headers:nil) transfer_key_method_async(vault_base_url, custom_headers:custom_headers).value! end # # Retrieve Security Domain transfer key # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def transfer_key_method_async(vault_base_url, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'securitydomain/upload' request_url = @base_url || @client.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::TransferKey.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Restore the provided Security Domain. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param security_domain [SecurityDomainObject] The Security Domain to be # restored. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainOperationStatus] operation results. # def upload(vault_base_url, security_domain, custom_headers:nil) response = upload_async(vault_base_url, security_domain, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param security_domain [SecurityDomainObject] The Security Domain to be # restored. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def upload_async(vault_base_url, security_domain, custom_headers:nil) # Send request promise = begin_upload_async(vault_base_url, security_domain, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainOperationStatus.mapper() parsed_response = @client.deserialize(result_mapper, parsed_response) end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method, FinalStateVia::AZURE_ASYNC_OPERATION) end promise end # # Get Security Domain upload operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainOperationStatus] operation results. # def upload_pending(vault_base_url, custom_headers:nil) response = upload_pending_async(vault_base_url, custom_headers:custom_headers).value! response.body unless response.nil? end # # Get Security Domain upload operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def upload_pending_with_http_info(vault_base_url, custom_headers:nil) upload_pending_async(vault_base_url, custom_headers:custom_headers).value! end # # Get Security Domain upload operation status # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def upload_pending_async(vault_base_url, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'securitydomain/upload/pending' request_url = @base_url || @client.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainOperationStatus.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Retrieves the Security Domain from the managed HSM. Calling this endpoint can # be used to activate a provisioned managed HSM resource. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param certificate_info_object [CertificateInfoObject] The Security Domain # download operation requires customer to provide N certificates (minimum 3 and # maximum 10) containing a public key in JWK format. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainObject] operation results. # def begin_download(vault_base_url, certificate_info_object, custom_headers:nil) response = begin_download_async(vault_base_url, certificate_info_object, custom_headers:custom_headers).value! response.body unless response.nil? end # # Retrieves the Security Domain from the managed HSM. Calling this endpoint can # be used to activate a provisioned managed HSM resource. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param certificate_info_object [CertificateInfoObject] The Security Domain # download operation requires customer to provide N certificates (minimum 3 and # maximum 10) containing a public key in JWK format. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_download_with_http_info(vault_base_url, certificate_info_object, custom_headers:nil) begin_download_async(vault_base_url, certificate_info_object, custom_headers:custom_headers).value! end # # Retrieves the Security Domain from the managed HSM. Calling this endpoint can # be used to activate a provisioned managed HSM resource. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param certificate_info_object [CertificateInfoObject] The Security Domain # download operation requires customer to provide N certificates (minimum 3 and # maximum 10) containing a public key in JWK format. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_download_async(vault_base_url, certificate_info_object, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_info_object is nil' if certificate_info_object.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V7_2_preview::Models::CertificateInfoObject.mapper() request_content = @client.serialize(request_mapper, certificate_info_object) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'securitydomain/download' request_url = @base_url || @client.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:post, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 202 || status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 202 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainObject.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainObject.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Restore the provided Security Domain. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param security_domain [SecurityDomainObject] The Security Domain to be # restored. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecurityDomainOperationStatus] operation results. # def begin_upload(vault_base_url, security_domain, custom_headers:nil) response = begin_upload_async(vault_base_url, security_domain, custom_headers:custom_headers).value! response.body unless response.nil? end # # Restore the provided Security Domain. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param security_domain [SecurityDomainObject] The Security Domain to be # restored. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_upload_with_http_info(vault_base_url, security_domain, custom_headers:nil) begin_upload_async(vault_base_url, security_domain, custom_headers:custom_headers).value! end # # Restore the provided Security Domain. # # @param vault_base_url [String] The vault name, for example # https://myvault.vault.azure.net. # @param security_domain [SecurityDomainObject] The Security Domain to be # restored. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_upload_async(vault_base_url, security_domain, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'security_domain is nil' if security_domain.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainObject.mapper() request_content = @client.serialize(request_mapper, security_domain) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'securitydomain/upload' request_url = @base_url || @client.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:post, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 202 || status_code == 204 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 202 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V7_2_preview::Models::SecurityDomainOperationStatus.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end end end