# 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::V2015_06_01 # # A service client - single point of access to the REST API. # class KeyVaultClient < MsRestAzure::AzureServiceClient include MsRestAzure include MsRestAzure::Serialization # @return [String] the base URI of the service. attr_reader :base_url # @return Credentials needed for the client to connect to Azure. attr_reader :credentials # @return [String] Client Api Version. attr_reader :api_version # @return [String] The preferred language for the response. attr_accessor :accept_language # @return [Integer] The retry timeout in seconds for Long Running # Operations. Default value is 30. attr_accessor :long_running_operation_retry_timeout # @return [Boolean] Whether a unique x-ms-client-request-id should be # generated. When set to true a unique x-ms-client-request-id value is # generated and included in each request. Default is true. attr_accessor :generate_client_request_id # # Creates initializes a new instance of the KeyVaultClient class. # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. # @param options [Array] filters to be applied to the HTTP requests. # def initialize(credentials = nil, options = nil) super(credentials, options) @base_url = '{vaultBaseUrl}' fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? @credentials = credentials @api_version = '2015-06-01' @accept_language = 'en-US' @long_running_operation_retry_timeout = 30 @generate_client_request_id = true add_telemetry end # # Makes a request and returns the body of the response. # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. # @param path [String] the path, relative to {base_url}. # @param options [Hash{String=>String}] specifying any request options like :body. # @return [Hash{String=>String}] containing the body of the response. # Example: # # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}" # path = "/path" # options = { # body: request_content, # query_params: {'api-version' => '2016-02-01'} # } # result = @client.make_request(:put, path, options) # def make_request(method, path, options = {}) result = make_request_with_http_info(method, path, options) result.body unless result.nil? end # # Makes a request and returns the operation response. # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. # @param path [String] the path, relative to {base_url}. # @param options [Hash{String=>String}] specifying any request options like :body. # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status. # def make_request_with_http_info(method, path, options = {}) result = make_request_async(method, path, options).value! result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body) result end # # Makes a request asynchronously. # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete. # @param path [String] the path, relative to {base_url}. # @param options [Hash{String=>String}] specifying any request options like :body. # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def make_request_async(method, path, options = {}) fail ArgumentError, 'method is nil' if method.nil? fail ArgumentError, 'path is nil' if path.nil? request_url = options[:base_url] || @base_url if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?) @request_headers['Content-Type'] = options[:headers]['Content-Type'] end request_headers = @request_headers request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil? options.merge!({headers: request_headers.merge(options[:headers] || {})}) options.merge!({credentials: @credentials}) unless @credentials.nil? super(request_url, method, path, options) end # # Creates a new, named, key in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param kty [JsonWebKeyType] The type of key to create. Valid key types, see # JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, # HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' # @param key_size [Integer] The key size in bits. e.g. 1024 or 2048. # @param key_ops [Array] # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def create_key(vault_base_url, key_name, kty, key_size:nil, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) response = create_key_async(vault_base_url, key_name, kty, key_size:key_size, key_ops:key_ops, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Creates a new, named, key in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param kty [JsonWebKeyType] The type of key to create. Valid key types, see # JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, # HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' # @param key_size [Integer] The key size in bits. e.g. 1024 or 2048. # @param key_ops [Array] # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 create_key_with_http_info(vault_base_url, key_name, kty, key_size:nil, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) create_key_async(vault_base_url, key_name, kty, key_size:key_size, key_ops:key_ops, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! end # # Creates a new, named, key in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param kty [JsonWebKeyType] The type of key to create. Valid key types, see # JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, # HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' # @param key_size [Integer] The key size in bits. e.g. 1024 or 2048. # @param key_ops [Array] # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 create_key_async(vault_base_url, key_name, kty, key_size:nil, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, "'key_name' should satisfy the constraint - 'Pattern': '^[0-9a-zA-Z-]+$'" if !key_name.nil? && key_name.match(Regexp.new('^^[0-9a-zA-Z-]+$$')).nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'kty is nil' if kty.nil? fail ArgumentError, "'kty' should satisfy the constraint - 'MinLength': '1'" if !kty.nil? && kty.length < 1 parameters = KeyCreateParameters.new unless kty.nil? && key_size.nil? && key_ops.nil? && key_attributes.nil? && tags.nil? parameters.kty = kty parameters.key_size = key_size parameters.key_ops = key_ops parameters.keyAttributes = key_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyCreateParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/create' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 # # Imports a key into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key [JsonWebKey] The Json web key # @param hsm [Boolean] Whether to import as a hardware key (HSM) or software # key # @param key_attributes [KeyAttributes] The key management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def import_key(vault_base_url, key_name, key, hsm:nil, key_attributes:nil, tags:nil, custom_headers:nil) response = import_key_async(vault_base_url, key_name, key, hsm:hsm, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Imports a key into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key [JsonWebKey] The Json web key # @param hsm [Boolean] Whether to import as a hardware key (HSM) or software # key # @param key_attributes [KeyAttributes] The key management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 import_key_with_http_info(vault_base_url, key_name, key, hsm:nil, key_attributes:nil, tags:nil, custom_headers:nil) import_key_async(vault_base_url, key_name, key, hsm:hsm, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! end # # Imports a key into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key [JsonWebKey] The Json web key # @param hsm [Boolean] Whether to import as a hardware key (HSM) or software # key # @param key_attributes [KeyAttributes] The key management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 import_key_async(vault_base_url, key_name, key, hsm:nil, key_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, "'key_name' should satisfy the constraint - 'Pattern': '^[0-9a-zA-Z-]+$'" if !key_name.nil? && key_name.match(Regexp.new('^^[0-9a-zA-Z-]+$$')).nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'key is nil' if key.nil? parameters = KeyImportParameters.new unless hsm.nil? && key.nil? && key_attributes.nil? && tags.nil? parameters.hsm = hsm parameters.key = key parameters.keyAttributes = key_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyImportParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:put, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 # # Deletes the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def delete_key(vault_base_url, key_name, custom_headers:nil) response = delete_key_async(vault_base_url, key_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @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 delete_key_with_http_info(vault_base_url, key_name, custom_headers:nil) delete_key_async(vault_base_url, key_name, custom_headers:custom_headers).value! end # # Deletes the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @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 delete_key_async(vault_base_url, key_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'keys/{key-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 # # Updates the Key Attributes associated with the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param key_ops [Array] Json web key operations. For more # information on possible key operations, see JsonWebKeyOperation. # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def update_key(vault_base_url, key_name, key_version, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) response = update_key_async(vault_base_url, key_name, key_version, key_ops:key_ops, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates the Key Attributes associated with the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param key_ops [Array] Json web key operations. For more # information on possible key operations, see JsonWebKeyOperation. # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_key_with_http_info(vault_base_url, key_name, key_version, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) update_key_async(vault_base_url, key_name, key_version, key_ops:key_ops, key_attributes:key_attributes, tags:tags, custom_headers:custom_headers).value! end # # Updates the Key Attributes associated with the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param key_ops [Array] Json web key operations. For more # information on possible key operations, see JsonWebKeyOperation. # @param key_attributes [KeyAttributes] # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_key_async(vault_base_url, key_name, key_version, key_ops:nil, key_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? parameters = KeyUpdateParameters.new unless key_ops.nil? && key_attributes.nil? && tags.nil? parameters.key_ops = key_ops parameters.keyAttributes = key_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyUpdateParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 public portion of a key plus its attributes # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def get_key(vault_base_url, key_name, key_version, custom_headers:nil) response = get_key_async(vault_base_url, key_name, key_version, custom_headers:custom_headers).value! response.body unless response.nil? end # # Retrieves the public portion of a key plus its attributes # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @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 get_key_with_http_info(vault_base_url, key_name, key_version, custom_headers:nil) get_key_async(vault_base_url, key_name, key_version, custom_headers:custom_headers).value! end # # Retrieves the public portion of a key plus its attributes # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @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 get_key_async(vault_base_url, key_name, key_version, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'keys/{key-name}/{key-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_key_versions(vault_base_url, key_name, maxresults:nil, custom_headers:nil) first_page = get_key_versions_as_lazy(vault_base_url, key_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_key_versions_with_http_info(vault_base_url, key_name, maxresults:nil, custom_headers:nil) get_key_versions_async(vault_base_url, key_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_key_versions_async(vault_base_url, key_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'keys/{key-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_keys(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_keys_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_keys_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_keys_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_keys_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'keys' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # Requests that a backup of the specified key be downloaded to the client. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [BackupKeyResult] operation results. # def backup_key(vault_base_url, key_name, custom_headers:nil) response = backup_key_async(vault_base_url, key_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Requests that a backup of the specified key be downloaded to the client. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @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 backup_key_with_http_info(vault_base_url, key_name, custom_headers:nil) backup_key_async(vault_base_url, key_name, custom_headers:custom_headers).value! end # # Requests that a backup of the specified key be downloaded to the client. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @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 backup_key_async(vault_base_url, key_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'keys/{key-name}/backup' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::BackupKeyResult.mapper() result.body = self.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 # # Restores the backup key in to a vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_bundle_backup the backup blob associated with a key bundle # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyBundle] operation results. # def restore_key(vault_base_url, key_bundle_backup, custom_headers:nil) response = restore_key_async(vault_base_url, key_bundle_backup, custom_headers:custom_headers).value! response.body unless response.nil? end # # Restores the backup key in to a vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_bundle_backup the backup blob associated with a key bundle # @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 restore_key_with_http_info(vault_base_url, key_bundle_backup, custom_headers:nil) restore_key_async(vault_base_url, key_bundle_backup, custom_headers:custom_headers).value! end # # Restores the backup key in to a vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_bundle_backup the backup blob associated with a key bundle # @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 restore_key_async(vault_base_url, key_bundle_backup, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'key_bundle_backup is nil' if key_bundle_backup.nil? parameters = KeyRestoreParameters.new unless key_bundle_backup.nil? parameters.keyBundleBackup = key_bundle_backup end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyRestoreParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/restore' request_url = @base_url || self.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' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyBundle.mapper() result.body = self.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 # # Encrypts an arbitrary sequence of bytes using an encryption key that is # stored in Azure Key Vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyOperationResult] operation results. # def encrypt(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) response = encrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! response.body unless response.nil? end # # Encrypts an arbitrary sequence of bytes using an encryption key that is # stored in Azure Key Vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 encrypt_with_http_info(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) encrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! end # # Encrypts an arbitrary sequence of bytes using an encryption key that is # stored in Azure Key Vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 encrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'value is nil' if value.nil? parameters = KeyOperationsParameters.new unless algorithm.nil? && value.nil? parameters.algorithm = algorithm parameters.value = value end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationsParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/encrypt' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationResult.mapper() result.body = self.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 # # Decrypts a single block of encrypted data # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyOperationResult] operation results. # def decrypt(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) response = decrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! response.body unless response.nil? end # # Decrypts a single block of encrypted data # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 decrypt_with_http_info(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) decrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! end # # Decrypts a single block of encrypted data # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 decrypt_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'value is nil' if value.nil? parameters = KeyOperationsParameters.new unless algorithm.nil? && value.nil? parameters.algorithm = algorithm parameters.value = value end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationsParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/decrypt' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationResult.mapper() result.body = self.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 # # Creates a signature from a digest using the specified key in the vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm identifier. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param value # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyOperationResult] operation results. # def sign(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) response = sign_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! response.body unless response.nil? end # # Creates a signature from a digest using the specified key in the vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm identifier. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param value # @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 sign_with_http_info(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) sign_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! end # # Creates a signature from a digest using the specified key in the vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm identifier. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param value # @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 sign_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'value is nil' if value.nil? parameters = KeySignParameters.new unless algorithm.nil? && value.nil? parameters.algorithm = algorithm parameters.value = value end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeySignParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/sign' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationResult.mapper() result.body = self.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 # # Verifies a signature using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param digest The digest used for signing # @param signature The signature to be verified # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyVerifyResult] operation results. # def verify(vault_base_url, key_name, key_version, algorithm, digest, signature, custom_headers:nil) response = verify_async(vault_base_url, key_name, key_version, algorithm, digest, signature, custom_headers:custom_headers).value! response.body unless response.nil? end # # Verifies a signature using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param digest The digest used for signing # @param signature The signature to be verified # @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 verify_with_http_info(vault_base_url, key_name, key_version, algorithm, digest, signature, custom_headers:nil) verify_async(vault_base_url, key_name, key_version, algorithm, digest, signature, custom_headers:custom_headers).value! end # # Verifies a signature using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeySignatureAlgorithm] The signing/verification # algorithm. For more information on possible algorithm types, see # JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', # 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' # @param digest The digest used for signing # @param signature The signature to be verified # @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 verify_async(vault_base_url, key_name, key_version, algorithm, digest, signature, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'digest is nil' if digest.nil? fail ArgumentError, 'signature is nil' if signature.nil? parameters = KeyVerifyParameters.new unless algorithm.nil? && digest.nil? && signature.nil? parameters.algorithm = algorithm parameters.digest = digest parameters.signature = signature end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyVerifyParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/verify' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyVerifyResult.mapper() result.body = self.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 # # Wraps a symmetric key using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyOperationResult] operation results. # def wrap_key(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) response = wrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! response.body unless response.nil? end # # Wraps a symmetric key using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 wrap_key_with_http_info(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) wrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! end # # Wraps a symmetric key using the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 wrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'value is nil' if value.nil? parameters = KeyOperationsParameters.new unless algorithm.nil? && value.nil? parameters.algorithm = algorithm parameters.value = value end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationsParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/wrapkey' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationResult.mapper() result.body = self.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 # # Unwraps a symmetric key using the specified key in the vault that has # initially been used for wrapping the key. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyOperationResult] operation results. # def unwrap_key(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) response = unwrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! response.body unless response.nil? end # # Unwraps a symmetric key using the specified key in the vault that has # initially been used for wrapping the key. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 unwrap_key_with_http_info(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) unwrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:custom_headers).value! end # # Unwraps a symmetric key using the specified key in the vault that has # initially been used for wrapping the key. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param key_version [String] The version of the key # @param algorithm [JsonWebKeyEncryptionAlgorithm] algorithm identifier. # Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' # @param value # @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 unwrap_key_async(vault_base_url, key_name, key_version, algorithm, value, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, 'key_version is nil' if key_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'algorithm is nil' if algorithm.nil? fail ArgumentError, "'algorithm' should satisfy the constraint - 'MinLength': '1'" if !algorithm.nil? && algorithm.length < 1 fail ArgumentError, 'value is nil' if value.nil? parameters = KeyOperationsParameters.new unless algorithm.nil? && value.nil? parameters.algorithm = algorithm parameters.value = value end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationsParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'keys/{key-name}/{key-version}/unwrapkey' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name,'key-version' => key_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyOperationResult.mapper() result.body = self.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 # # Sets a secret in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param value [String] The value of the secret # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretBundle] operation results. # def set_secret(vault_base_url, secret_name, value, tags:nil, content_type:nil, secret_attributes:nil, custom_headers:nil) response = set_secret_async(vault_base_url, secret_name, value, tags:tags, content_type:content_type, secret_attributes:secret_attributes, custom_headers:custom_headers).value! response.body unless response.nil? end # # Sets a secret in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param value [String] The value of the secret # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @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 set_secret_with_http_info(vault_base_url, secret_name, value, tags:nil, content_type:nil, secret_attributes:nil, custom_headers:nil) set_secret_async(vault_base_url, secret_name, value, tags:tags, content_type:content_type, secret_attributes:secret_attributes, custom_headers:custom_headers).value! end # # Sets a secret in the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param value [String] The value of the secret # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @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 set_secret_async(vault_base_url, secret_name, value, tags:nil, content_type:nil, secret_attributes:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, "'secret_name' should satisfy the constraint - 'Pattern': '^[0-9a-zA-Z-]+$'" if !secret_name.nil? && secret_name.match(Regexp.new('^^[0-9a-zA-Z-]+$$')).nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'value is nil' if value.nil? parameters = SecretSetParameters.new unless value.nil? && tags.nil? && content_type.nil? && secret_attributes.nil? parameters.value = value parameters.tags = tags parameters.content_type = content_type parameters.secretAttributes = secret_attributes end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::SecretSetParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'secrets/{secret-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:put, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretBundle.mapper() result.body = self.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 # # Deletes a secret from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretBundle] operation results. # def delete_secret(vault_base_url, secret_name, custom_headers:nil) response = delete_secret_async(vault_base_url, secret_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes a secret from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @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 delete_secret_with_http_info(vault_base_url, secret_name, custom_headers:nil) delete_secret_async(vault_base_url, secret_name, custom_headers:custom_headers).value! end # # Deletes a secret from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @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 delete_secret_async(vault_base_url, secret_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'secrets/{secret-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretBundle.mapper() result.body = self.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 # # Updates the attributes associated with the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretBundle] operation results. # def update_secret(vault_base_url, secret_name, secret_version, content_type:nil, secret_attributes:nil, tags:nil, custom_headers:nil) response = update_secret_async(vault_base_url, secret_name, secret_version, content_type:content_type, secret_attributes:secret_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates the attributes associated with the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_secret_with_http_info(vault_base_url, secret_name, secret_version, content_type:nil, secret_attributes:nil, tags:nil, custom_headers:nil) update_secret_async(vault_base_url, secret_name, secret_version, content_type:content_type, secret_attributes:secret_attributes, tags:tags, custom_headers:custom_headers).value! end # # Updates the attributes associated with the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @param content_type [String] Type of the secret value such as a password # @param secret_attributes [SecretAttributes] The secret management attributes # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_secret_async(vault_base_url, secret_name, secret_version, content_type:nil, secret_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, 'secret_version is nil' if secret_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? parameters = SecretUpdateParameters.new unless content_type.nil? && secret_attributes.nil? && tags.nil? parameters.content_type = content_type parameters.secretAttributes = secret_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::SecretUpdateParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'secrets/{secret-name}/{secret-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name,'secret-version' => secret_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretBundle.mapper() result.body = self.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 # # Gets a secret. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretBundle] operation results. # def get_secret(vault_base_url, secret_name, secret_version, custom_headers:nil) response = get_secret_async(vault_base_url, secret_name, secret_version, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets a secret. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @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 get_secret_with_http_info(vault_base_url, secret_name, secret_version, custom_headers:nil) get_secret_async(vault_base_url, secret_name, secret_version, custom_headers:custom_headers).value! end # # Gets a secret. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param secret_version [String] The version of the secret # @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 get_secret_async(vault_base_url, secret_name, secret_version, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, 'secret_version is nil' if secret_version.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'secrets/{secret-name}/{secret-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name,'secret-version' => secret_version}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretBundle.mapper() result.body = self.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 # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_secrets(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_secrets_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secrets_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_secrets_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secrets_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'secrets' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_secret_versions(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) first_page = get_secret_versions_as_lazy(vault_base_url, secret_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secret_versions_with_http_info(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) get_secret_versions_async(vault_base_url, secret_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secret_versions_async(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'secrets/{secret-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name}, query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_certificates(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_certificates_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificates_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_certificates_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificates_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 # # Deletes a certificate from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateBundle] operation results. # def delete_certificate(vault_base_url, certificate_name, custom_headers:nil) response = delete_certificate_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes a certificate from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @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 delete_certificate_with_http_info(vault_base_url, certificate_name, custom_headers:nil) delete_certificate_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! end # # Deletes a certificate from the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @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 delete_certificate_async(vault_base_url, certificate_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateBundle.mapper() result.body = self.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 # # Sets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param contacts [Contacts] The contacts for the vault certificates. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Contacts] operation results. # def set_certificate_contacts(vault_base_url, contacts, custom_headers:nil) response = set_certificate_contacts_async(vault_base_url, contacts, custom_headers:custom_headers).value! response.body unless response.nil? end # # Sets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param contacts [Contacts] The contacts for the vault certificates. # @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 set_certificate_contacts_with_http_info(vault_base_url, contacts, custom_headers:nil) set_certificate_contacts_async(vault_base_url, contacts, custom_headers:custom_headers).value! end # # Sets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param contacts [Contacts] The contacts for the vault certificates. # @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 set_certificate_contacts_async(vault_base_url, contacts, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'contacts is nil' if contacts.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::Contacts.mapper() request_content = self.serialize(request_mapper, contacts) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/contacts' request_url = @base_url || self.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' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:put, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::Contacts.mapper() result.body = self.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 # # Gets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 [Contacts] operation results. # def get_certificate_contacts(vault_base_url, custom_headers:nil) response = get_certificate_contacts_async(vault_base_url, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 get_certificate_contacts_with_http_info(vault_base_url, custom_headers:nil) get_certificate_contacts_async(vault_base_url, custom_headers:custom_headers).value! end # # Gets the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 get_certificate_contacts_async(vault_base_url, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/contacts' request_url = @base_url || self.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' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::Contacts.mapper() result.body = self.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 # # Deletes the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 [Contacts] operation results. # def delete_certificate_contacts(vault_base_url, custom_headers:nil) response = delete_certificate_contacts_async(vault_base_url, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 delete_certificate_contacts_with_http_info(vault_base_url, custom_headers:nil) delete_certificate_contacts_async(vault_base_url, custom_headers:custom_headers).value! end # # Deletes the certificate contacts for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # 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 delete_certificate_contacts_async(vault_base_url, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/contacts' request_url = @base_url || self.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' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::Contacts.mapper() result.body = self.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 # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_certificate_issuers(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_certificate_issuers_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_issuers_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_certificate_issuers_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_issuers_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/issuers' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateIssuerListResult.mapper() result.body = self.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 # # Sets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [IssuerBundle] operation results. # def set_certificate_issuer(vault_base_url, issuer_name, provider, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) response = set_certificate_issuer_async(vault_base_url, issuer_name, provider, credentials:credentials, organization_details:organization_details, attributes:attributes, custom_headers:custom_headers).value! response.body unless response.nil? end # # Sets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @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 set_certificate_issuer_with_http_info(vault_base_url, issuer_name, provider, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) set_certificate_issuer_async(vault_base_url, issuer_name, provider, credentials:credentials, organization_details:organization_details, attributes:attributes, custom_headers:custom_headers).value! end # # Sets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @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 set_certificate_issuer_async(vault_base_url, issuer_name, provider, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'issuer_name is nil' if issuer_name.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'provider is nil' if provider.nil? parameter = CertificateIssuerSetParameters.new unless provider.nil? && credentials.nil? && organization_details.nil? && attributes.nil? parameter.provider = provider parameter.credentials = credentials parameter.OrganizationDetails = organization_details parameter.attributes = attributes end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateIssuerSetParameters.mapper() request_content = self.serialize(request_mapper, parameter) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/issuers/{issuer-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'issuer-name' => issuer_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:put, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::IssuerBundle.mapper() result.body = self.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 # # Updates the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [IssuerBundle] operation results. # def update_certificate_issuer(vault_base_url, issuer_name, provider:nil, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) response = update_certificate_issuer_async(vault_base_url, issuer_name, provider:provider, credentials:credentials, organization_details:organization_details, attributes:attributes, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @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 update_certificate_issuer_with_http_info(vault_base_url, issuer_name, provider:nil, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) update_certificate_issuer_async(vault_base_url, issuer_name, provider:provider, credentials:credentials, organization_details:organization_details, attributes:attributes, custom_headers:custom_headers).value! end # # Updates the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param provider [String] The issuer provider. # @param credentials [IssuerCredentials] The credentials to be used for the # issuer. # @param organization_details [OrganizationDetails] Details of the organization # as provided to the issuer. # @param attributes [IssuerAttributes] Attributes of the issuer object. # @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 update_certificate_issuer_async(vault_base_url, issuer_name, provider:nil, credentials:nil, organization_details:nil, attributes:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'issuer_name is nil' if issuer_name.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? parameter = CertificateIssuerUpdateParameters.new unless provider.nil? && credentials.nil? && organization_details.nil? && attributes.nil? parameter.provider = provider parameter.credentials = credentials parameter.OrganizationDetails = organization_details parameter.attributes = attributes end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateIssuerUpdateParameters.mapper() request_content = self.serialize(request_mapper, parameter) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/issuers/{issuer-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'issuer-name' => issuer_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::IssuerBundle.mapper() result.body = self.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 # # Gets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [IssuerBundle] operation results. # def get_certificate_issuer(vault_base_url, issuer_name, custom_headers:nil) response = get_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @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 get_certificate_issuer_with_http_info(vault_base_url, issuer_name, custom_headers:nil) get_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:custom_headers).value! end # # Gets the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @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 get_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'issuer_name is nil' if issuer_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/issuers/{issuer-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'issuer-name' => issuer_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::IssuerBundle.mapper() result.body = self.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 # # Deletes the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [IssuerBundle] operation results. # def delete_certificate_issuer(vault_base_url, issuer_name, custom_headers:nil) response = delete_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @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 delete_certificate_issuer_with_http_info(vault_base_url, issuer_name, custom_headers:nil) delete_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:custom_headers).value! end # # Deletes the specified certificate issuer. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param issuer_name [String] The name of the issuer. # @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 delete_certificate_issuer_async(vault_base_url, issuer_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'issuer_name is nil' if issuer_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/issuers/{issuer-name}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'issuer-name' => issuer_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::IssuerBundle.mapper() result.body = self.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 # # Creates a new certificate version. If this is the first version, the # certificate resource is created. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateOperation] operation results. # def create_certificate(vault_base_url, certificate_name, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) response = create_certificate_async(vault_base_url, certificate_name, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Creates a new certificate version. If this is the first version, the # certificate resource is created. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 create_certificate_with_http_info(vault_base_url, certificate_name, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) create_certificate_async(vault_base_url, certificate_name, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! end # # Creates a new certificate version. If this is the first version, the # certificate resource is created. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 create_certificate_async(vault_base_url, certificate_name, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, "'certificate_name' should satisfy the constraint - 'Pattern': '^[0-9a-zA-Z-]+$'" if !certificate_name.nil? && certificate_name.match(Regexp.new('^^[0-9a-zA-Z-]+$$')).nil? fail ArgumentError, 'api_version is nil' if api_version.nil? parameters = CertificateCreateParameters.new unless certificate_policy.nil? && certificate_attributes.nil? && tags.nil? parameters.CertificatePolicy = certificate_policy parameters.CertificateAttributes = certificate_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateCreateParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/create' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 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? # Deserialize Response if status_code == 202 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateOperation.mapper() result.body = self.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 # # Imports a certificate into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param base64encoded_certificate [String] Base64 encoded representation of # the certificate object to import. This certificate needs to contain the # private key. # @param password [String] If the private key in base64EncodedCertificate is # encrypted, the password used for encryption # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateBundle] operation results. # def import_certificate(vault_base_url, certificate_name, base64encoded_certificate, password:nil, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) response = import_certificate_async(vault_base_url, certificate_name, base64encoded_certificate, password:password, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Imports a certificate into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param base64encoded_certificate [String] Base64 encoded representation of # the certificate object to import. This certificate needs to contain the # private key. # @param password [String] If the private key in base64EncodedCertificate is # encrypted, the password used for encryption # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 import_certificate_with_http_info(vault_base_url, certificate_name, base64encoded_certificate, password:nil, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) import_certificate_async(vault_base_url, certificate_name, base64encoded_certificate, password:password, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! end # # Imports a certificate into the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param base64encoded_certificate [String] Base64 encoded representation of # the certificate object to import. This certificate needs to contain the # private key. # @param password [String] If the private key in base64EncodedCertificate is # encrypted, the password used for encryption # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 import_certificate_async(vault_base_url, certificate_name, base64encoded_certificate, password:nil, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, "'certificate_name' should satisfy the constraint - 'Pattern': '^[0-9a-zA-Z-]+$'" if !certificate_name.nil? && certificate_name.match(Regexp.new('^^[0-9a-zA-Z-]+$$')).nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'base64encoded_certificate is nil' if base64encoded_certificate.nil? parameters = CertificateImportParameters.new unless base64encoded_certificate.nil? && password.nil? && certificate_policy.nil? && certificate_attributes.nil? && tags.nil? parameters.base64EncodedCertificate = base64encoded_certificate parameters.password = password parameters.CertificatePolicy = certificate_policy parameters.CertificateAttributes = certificate_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateImportParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/import' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateBundle.mapper() result.body = self.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 # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def get_certificate_versions(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) first_page = get_certificate_versions_as_lazy(vault_base_url, certificate_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_versions_with_http_info(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) get_certificate_versions_async(vault_base_url, certificate_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_versions_async(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'maxresults' => maxresults,'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 # # Gets the policy for a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificatePolicy] operation results. # def get_certificate_policy(vault_base_url, certificate_name, custom_headers:nil) response = get_certificate_policy_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the policy for a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @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 get_certificate_policy_with_http_info(vault_base_url, certificate_name, custom_headers:nil) get_certificate_policy_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! end # # Gets the policy for a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @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 get_certificate_policy_async(vault_base_url, certificate_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}/policy' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificatePolicy.mapper() result.body = self.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 # # Updates the policy for a certificate. Set appropriate members in the # certificatePolicy that must be updated. Leave others as null. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @param certificate_policy [CertificatePolicy] The policy for the certificate. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificatePolicy] operation results. # def update_certificate_policy(vault_base_url, certificate_name, certificate_policy, custom_headers:nil) response = update_certificate_policy_async(vault_base_url, certificate_name, certificate_policy, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates the policy for a certificate. Set appropriate members in the # certificatePolicy that must be updated. Leave others as null. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @param certificate_policy [CertificatePolicy] The policy for the certificate. # @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 update_certificate_policy_with_http_info(vault_base_url, certificate_name, certificate_policy, custom_headers:nil) update_certificate_policy_async(vault_base_url, certificate_name, certificate_policy, custom_headers:custom_headers).value! end # # Updates the policy for a certificate. Set appropriate members in the # certificatePolicy that must be updated. Leave others as null. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault. # @param certificate_policy [CertificatePolicy] The policy for the certificate. # @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 update_certificate_policy_async(vault_base_url, certificate_name, certificate_policy, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'certificate_policy is nil' if certificate_policy.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificatePolicy.mapper() request_content = self.serialize(request_mapper, certificate_policy) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/policy' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificatePolicy.mapper() result.body = self.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 # # Updates the attributes associated with the specified certificate # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateBundle] operation results. # def update_certificate(vault_base_url, certificate_name, certificate_version, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) response = update_certificate_async(vault_base_url, certificate_name, certificate_version, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates the attributes associated with the specified certificate # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_certificate_with_http_info(vault_base_url, certificate_name, certificate_version, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) update_certificate_async(vault_base_url, certificate_name, certificate_version, certificate_policy:certificate_policy, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! end # # Updates the attributes associated with the specified certificate # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @param certificate_policy [CertificatePolicy] The management policy for the # certificate # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 update_certificate_async(vault_base_url, certificate_name, certificate_version, certificate_policy:nil, certificate_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'certificate_version is nil' if certificate_version.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? parameters = CertificateUpdateParameters.new unless certificate_policy.nil? && certificate_attributes.nil? && tags.nil? parameters.CertificatePolicy = certificate_policy parameters.CertificateAttributes = certificate_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateUpdateParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/{certificate-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name,'certificate-version' => certificate_version}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateBundle.mapper() result.body = self.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 # # Gets a Certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateBundle] operation results. # def get_certificate(vault_base_url, certificate_name, certificate_version, custom_headers:nil) response = get_certificate_async(vault_base_url, certificate_name, certificate_version, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets a Certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @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 get_certificate_with_http_info(vault_base_url, certificate_name, certificate_version, custom_headers:nil) get_certificate_async(vault_base_url, certificate_name, certificate_version, custom_headers:custom_headers).value! end # # Gets a Certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate in the given # vault # @param certificate_version [String] The version of the certificate # @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 get_certificate_async(vault_base_url, certificate_name, certificate_version, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'certificate_version is nil' if certificate_version.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}/{certificate-version}' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name,'certificate-version' => certificate_version}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateBundle.mapper() result.body = self.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 # # Updates a certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param cancellation_requested [Boolean] Indicates if cancellation was # requested on the certificate operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateOperation] operation results. # def update_certificate_operation(vault_base_url, certificate_name, cancellation_requested, custom_headers:nil) response = update_certificate_operation_async(vault_base_url, certificate_name, cancellation_requested, custom_headers:custom_headers).value! response.body unless response.nil? end # # Updates a certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param cancellation_requested [Boolean] Indicates if cancellation was # requested on the certificate operation. # @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 update_certificate_operation_with_http_info(vault_base_url, certificate_name, cancellation_requested, custom_headers:nil) update_certificate_operation_async(vault_base_url, certificate_name, cancellation_requested, custom_headers:custom_headers).value! end # # Updates a certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param cancellation_requested [Boolean] Indicates if cancellation was # requested on the certificate operation. # @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 update_certificate_operation_async(vault_base_url, certificate_name, cancellation_requested, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'cancellation_requested is nil' if cancellation_requested.nil? certificate_operation = CertificateOperationUpdateParameter.new unless cancellation_requested.nil? certificate_operation.cancellation_requested = cancellation_requested end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateOperationUpdateParameter.mapper() request_content = self.serialize(request_mapper, certificate_operation) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/pending' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:patch, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateOperation.mapper() result.body = self.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 # # Gets the certificate operation response. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateOperation] operation results. # def get_certificate_operation(vault_base_url, certificate_name, custom_headers:nil) response = get_certificate_operation_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the certificate operation response. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @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 get_certificate_operation_with_http_info(vault_base_url, certificate_name, custom_headers:nil) get_certificate_operation_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! end # # Gets the certificate operation response. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @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 get_certificate_operation_async(vault_base_url, certificate_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}/pending' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateOperation.mapper() result.body = self.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 # # Deletes the certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateOperation] operation results. # def delete_certificate_operation(vault_base_url, certificate_name, custom_headers:nil) response = delete_certificate_operation_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Deletes the certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @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 delete_certificate_operation_with_http_info(vault_base_url, certificate_name, custom_headers:nil) delete_certificate_operation_async(vault_base_url, certificate_name, custom_headers:custom_headers).value! end # # Deletes the certificate operation. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @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 delete_certificate_operation_async(vault_base_url, certificate_name, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if 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'] = accept_language unless accept_language.nil? path_template = 'certificates/{certificate-name}/pending' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.make_request_async(:delete, 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateOperation.mapper() result.body = self.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 # # Merges a certificate or a certificate chain with a key pair existing on the # server. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param x509certificates [Array>] The certificate or the # certificate chain to merge # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateBundle] operation results. # def merge_certificate(vault_base_url, certificate_name, x509certificates, certificate_attributes:nil, tags:nil, custom_headers:nil) response = merge_certificate_async(vault_base_url, certificate_name, x509certificates, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! response.body unless response.nil? end # # Merges a certificate or a certificate chain with a key pair existing on the # server. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param x509certificates [Array>] The certificate or the # certificate chain to merge # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 merge_certificate_with_http_info(vault_base_url, certificate_name, x509certificates, certificate_attributes:nil, tags:nil, custom_headers:nil) merge_certificate_async(vault_base_url, certificate_name, x509certificates, certificate_attributes:certificate_attributes, tags:tags, custom_headers:custom_headers).value! end # # Merges a certificate or a certificate chain with a key pair existing on the # server. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param x509certificates [Array>] The certificate or the # certificate chain to merge # @param certificate_attributes [CertificateAttributes] The attributes of the # certificate (optional) # @param tags [Hash{String => String}] Application-specific metadata in the # form of key-value pairs # @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 merge_certificate_async(vault_base_url, certificate_name, x509certificates, certificate_attributes:nil, tags:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, 'api_version is nil' if api_version.nil? fail ArgumentError, 'x509certificates is nil' if x509certificates.nil? parameters = CertificateMergeParameters.new unless x509certificates.nil? && certificate_attributes.nil? && tags.nil? parameters.x509Certificates = x509certificates parameters.CertificateAttributes = certificate_attributes parameters.tags = tags end 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'] = accept_language unless accept_language.nil? # Serialize Request request_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateMergeParameters.mapper() request_content = self.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'certificates/{certificate-name}/pending/merge' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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 == 201 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? # Deserialize Response if status_code == 201 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateBundle.mapper() result.body = self.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 # # List the versions of the specified key # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyListResult] operation results. # def get_key_versions_next(next_page_link, custom_headers:nil) response = get_key_versions_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List the versions of the specified key # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_key_versions_next_with_http_info(next_page_link, custom_headers:nil) get_key_versions_next_async(next_page_link, custom_headers:custom_headers).value! end # # List the versions of the specified key # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_key_versions_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # List keys in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyListResult] operation results. # def get_keys_next(next_page_link, custom_headers:nil) response = get_keys_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List keys in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_keys_next_with_http_info(next_page_link, custom_headers:nil) get_keys_next_async(next_page_link, custom_headers:custom_headers).value! end # # List keys in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_keys_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # List secrets in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretListResult] operation results. # def get_secrets_next(next_page_link, custom_headers:nil) response = get_secrets_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List secrets in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_secrets_next_with_http_info(next_page_link, custom_headers:nil) get_secrets_next_async(next_page_link, custom_headers:custom_headers).value! end # # List secrets in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_secrets_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List the versions of the specified secret # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretListResult] operation results. # def get_secret_versions_next(next_page_link, custom_headers:nil) response = get_secret_versions_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List the versions of the specified secret # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_secret_versions_next_with_http_info(next_page_link, custom_headers:nil) get_secret_versions_next_async(next_page_link, custom_headers:custom_headers).value! end # # List the versions of the specified secret # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_secret_versions_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List certificates in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateListResult] operation results. # def get_certificates_next(next_page_link, custom_headers:nil) response = get_certificates_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List certificates in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificates_next_with_http_info(next_page_link, custom_headers:nil) get_certificates_next_async(next_page_link, custom_headers:custom_headers).value! end # # List certificates in the specified vault # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificates_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 # # List certificate issuers for the specified vault. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateIssuerListResult] operation results. # def get_certificate_issuers_next(next_page_link, custom_headers:nil) response = get_certificate_issuers_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List certificate issuers for the specified vault. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificate_issuers_next_with_http_info(next_page_link, custom_headers:nil) get_certificate_issuers_next_async(next_page_link, custom_headers:custom_headers).value! end # # List certificate issuers for the specified vault. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificate_issuers_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateIssuerListResult.mapper() result.body = self.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 # # List the versions of a certificate. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateListResult] operation results. # def get_certificate_versions_next(next_page_link, custom_headers:nil) response = get_certificate_versions_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List the versions of a certificate. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificate_versions_next_with_http_info(next_page_link, custom_headers:nil) get_certificate_versions_next_async(next_page_link, custom_headers:custom_headers).value! end # # List the versions of a certificate. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @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 get_certificate_versions_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.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'] = accept_language unless accept_language.nil? path_template = '{nextLink}' request_url = @base_url || self.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyListResult] operation results. # def get_key_versions_as_lazy(vault_base_url, key_name, maxresults:nil, custom_headers:nil) first_page = get_key_versions_as_lazy_as_lazy(vault_base_url, key_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_key_versions_as_lazy_with_http_info(vault_base_url, key_name, maxresults:nil, custom_headers:nil) get_key_versions_as_lazy_async(vault_base_url, key_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of the specified key # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param key_name [String] The name of the key # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_key_versions_as_lazy_async(vault_base_url, key_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'key_name is nil' if key_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'keys/{key-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'key-name' => key_name}, query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [KeyListResult] operation results. # def get_keys_as_lazy(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_keys_as_lazy_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_keys_as_lazy_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_keys_as_lazy_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List keys in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_keys_as_lazy_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'keys' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::KeyListResult.mapper() result.body = self.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 # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretListResult] operation results. # def get_secrets_as_lazy(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_secrets_as_lazy_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secrets_as_lazy_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_secrets_as_lazy_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List secrets in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secrets_as_lazy_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'secrets' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SecretListResult] operation results. # def get_secret_versions_as_lazy(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) first_page = get_secret_versions_as_lazy_as_lazy(vault_base_url, secret_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secret_versions_as_lazy_with_http_info(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) get_secret_versions_as_lazy_async(vault_base_url, secret_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of the specified secret # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param secret_name [String] The name of the secret in the given vault # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_secret_versions_as_lazy_async(vault_base_url, secret_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'secret_name is nil' if secret_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'secrets/{secret-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'secret-name' => secret_name}, query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::SecretListResult.mapper() result.body = self.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 # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateListResult] operation results. # def get_certificates_as_lazy(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_certificates_as_lazy_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificates_as_lazy_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_certificates_as_lazy_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List certificates in the specified vault # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificates_as_lazy_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'certificates' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateIssuerListResult] operation results. # def get_certificate_issuers_as_lazy(vault_base_url, maxresults:nil, custom_headers:nil) first_page = get_certificate_issuers_as_lazy_as_lazy(vault_base_url, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_issuers_as_lazy_with_http_info(vault_base_url, maxresults:nil, custom_headers:nil) get_certificate_issuers_as_lazy_async(vault_base_url, maxresults:maxresults, custom_headers:custom_headers).value! end # # List certificate issuers for the specified vault. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_issuers_as_lazy_async(vault_base_url, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'certificates/issuers' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateIssuerListResult.mapper() result.body = self.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 # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CertificateListResult] operation results. # def get_certificate_versions_as_lazy(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) first_page = get_certificate_versions_as_lazy_as_lazy(vault_base_url, certificate_name, maxresults:maxresults, custom_headers:custom_headers) first_page.get_all_items end # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_versions_as_lazy_with_http_info(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) get_certificate_versions_as_lazy_async(vault_base_url, certificate_name, maxresults:maxresults, custom_headers:custom_headers).value! end # # List the versions of a certificate. # # @param vault_base_url [String] The vault name, e.g. # https://myvault.vault.azure.net # @param certificate_name [String] The name of the certificate # @param maxresults [Integer] Maximum number of results to return in a page. If # not specified the service will return up to 25 results. # @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 get_certificate_versions_as_lazy_async(vault_base_url, certificate_name, maxresults:nil, custom_headers:nil) fail ArgumentError, 'vault_base_url is nil' if vault_base_url.nil? fail ArgumentError, 'certificate_name is nil' if certificate_name.nil? fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMaximum': '25'" if !maxresults.nil? && maxresults > 25 fail ArgumentError, "'maxresults' should satisfy the constraint - 'InclusiveMinimum': '1'" if !maxresults.nil? && maxresults < 1 request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' path_template = 'certificates/{certificate-name}/versions' request_url = @base_url || self.base_url request_url = request_url.gsub('{vaultBaseUrl}', vault_base_url) options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'certificate-name' => certificate_name}, query_params: {'maxresults' => maxresults}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = self.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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::KeyVault::V2015_06_01::Models::CertificateListResult.mapper() result.body = self.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 private # # Adds telemetry information. # def add_telemetry sdk_information = 'azure_key_vault' sdk_information = "#{sdk_information}/0.17.3" add_user_agent_information(sdk_information) end end end