diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb index ef58e5e377..b87d5a7530 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb @@ -20,81 +20,101 @@ require 'ms_rest_azure' module Azure::ARM::SQL - autoload :Databases, 'generated/azure_mgmt_sql/databases.rb' - autoload :Servers, 'generated/azure_mgmt_sql/servers.rb' + autoload :BackupLongTermRetentionPolicies, 'generated/azure_mgmt_sql/backup_long_term_retention_policies.rb' + autoload :BackupLongTermRetentionVaults, 'generated/azure_mgmt_sql/backup_long_term_retention_vaults.rb' + autoload :RestorePoints, 'generated/azure_mgmt_sql/restore_points.rb' autoload :RecoverableDatabases, 'generated/azure_mgmt_sql/recoverable_databases.rb' autoload :RestorableDroppedDatabases, 'generated/azure_mgmt_sql/restorable_dropped_databases.rb' autoload :Capabilities, 'generated/azure_mgmt_sql/capabilities.rb' + autoload :ServerConnectionPolicies, 'generated/azure_mgmt_sql/server_connection_policies.rb' + autoload :DatabaseThreatDetectionPolicies, 'generated/azure_mgmt_sql/database_threat_detection_policies.rb' + autoload :DataMaskingPolicies, 'generated/azure_mgmt_sql/data_masking_policies.rb' + autoload :DataMaskingRules, 'generated/azure_mgmt_sql/data_masking_rules.rb' autoload :FirewallRules, 'generated/azure_mgmt_sql/firewall_rules.rb' + autoload :GeoBackupPolicies, 'generated/azure_mgmt_sql/geo_backup_policies.rb' + autoload :Databases, 'generated/azure_mgmt_sql/databases.rb' autoload :ElasticPools, 'generated/azure_mgmt_sql/elastic_pools.rb' autoload :Operations, 'generated/azure_mgmt_sql/operations.rb' + autoload :ReplicationLinks, 'generated/azure_mgmt_sql/replication_links.rb' autoload :ServerAzureADAdministrators, 'generated/azure_mgmt_sql/server_azure_adadministrators.rb' autoload :ServerCommunicationLinks, 'generated/azure_mgmt_sql/server_communication_links.rb' + autoload :ServiceObjectives, 'generated/azure_mgmt_sql/service_objectives.rb' + autoload :Servers, 'generated/azure_mgmt_sql/servers.rb' + autoload :ElasticPoolActivities, 'generated/azure_mgmt_sql/elastic_pool_activities.rb' + autoload :ElasticPoolDatabaseActivities, 'generated/azure_mgmt_sql/elastic_pool_database_activities.rb' autoload :RecommendedElasticPools, 'generated/azure_mgmt_sql/recommended_elastic_pools.rb' + autoload :ServiceTierAdvisors, 'generated/azure_mgmt_sql/service_tier_advisors.rb' + autoload :TransparentDataEncryptions, 'generated/azure_mgmt_sql/transparent_data_encryptions.rb' + autoload :TransparentDataEncryptionActivities, 'generated/azure_mgmt_sql/transparent_data_encryption_activities.rb' + autoload :ServerUsages, 'generated/azure_mgmt_sql/server_usages.rb' + autoload :DatabaseUsages, 'generated/azure_mgmt_sql/database_usages.rb' + autoload :DatabaseBlobAuditingPolicies, 'generated/azure_mgmt_sql/database_blob_auditing_policies.rb' + autoload :EncryptionProtectors, 'generated/azure_mgmt_sql/encryption_protectors.rb' autoload :FailoverGroups, 'generated/azure_mgmt_sql/failover_groups.rb' autoload :ServerKeys, 'generated/azure_mgmt_sql/server_keys.rb' autoload :VirtualNetworkRules, 'generated/azure_mgmt_sql/virtual_network_rules.rb' autoload :SqlManagementClient, 'generated/azure_mgmt_sql/sql_management_client.rb' module Models - autoload :SqlSubResource, 'generated/azure_mgmt_sql/models/sql_sub_resource.rb' - autoload :MetricDefinition, 'generated/azure_mgmt_sql/models/metric_definition.rb' - autoload :ImportExtensionRequest, 'generated/azure_mgmt_sql/models/import_extension_request.rb' - autoload :PartnerInfo, 'generated/azure_mgmt_sql/models/partner_info.rb' - autoload :TransparentDataEncryptionActivityListResult, 'generated/azure_mgmt_sql/models/transparent_data_encryption_activity_list_result.rb' - autoload :RecommendedElasticPoolListMetricsResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_metrics_result.rb' - autoload :ServiceTierAdvisorListResult, 'generated/azure_mgmt_sql/models/service_tier_advisor_list_result.rb' + autoload :ServerCommunicationLinkListResult, 'generated/azure_mgmt_sql/models/server_communication_link_list_result.rb' + autoload :OperationDisplay, 'generated/azure_mgmt_sql/models/operation_display.rb' autoload :ExportRequest, 'generated/azure_mgmt_sql/models/export_request.rb' - autoload :DatabaseListResult, 'generated/azure_mgmt_sql/models/database_list_result.rb' - autoload :RecommendedElasticPoolListResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_result.rb' autoload :DatabaseUsageListResult, 'generated/azure_mgmt_sql/models/database_usage_list_result.rb' + autoload :MetricValue, 'generated/azure_mgmt_sql/models/metric_value.rb' + autoload :ServerUsageListResult, 'generated/azure_mgmt_sql/models/server_usage_list_result.rb' autoload :MetricName, 'generated/azure_mgmt_sql/models/metric_name.rb' - autoload :MaxSizeCapability, 'generated/azure_mgmt_sql/models/max_size_capability.rb' + autoload :ServerUsage, 'generated/azure_mgmt_sql/models/server_usage.rb' autoload :Metric, 'generated/azure_mgmt_sql/models/metric.rb' - autoload :EditionCapability, 'generated/azure_mgmt_sql/models/edition_capability.rb' + autoload :TransparentDataEncryptionActivityListResult, 'generated/azure_mgmt_sql/models/transparent_data_encryption_activity_list_result.rb' autoload :MetricListResult, 'generated/azure_mgmt_sql/models/metric_list_result.rb' - autoload :ElasticPoolPerDatabaseMaxDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_max_dtu_capability.rb' + autoload :MaxSizeCapability, 'generated/azure_mgmt_sql/models/max_size_capability.rb' autoload :MetricAvailability, 'generated/azure_mgmt_sql/models/metric_availability.rb' + autoload :EditionCapability, 'generated/azure_mgmt_sql/models/edition_capability.rb' + autoload :MetricDefinition, 'generated/azure_mgmt_sql/models/metric_definition.rb' + autoload :ElasticPoolPerDatabaseMaxDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_max_dtu_capability.rb' + autoload :MetricDefinitionListResult, 'generated/azure_mgmt_sql/models/metric_definition_list_result.rb' autoload :ElasticPoolEditionCapability, 'generated/azure_mgmt_sql/models/elastic_pool_edition_capability.rb' - autoload :FailoverGroupListResult, 'generated/azure_mgmt_sql/models/failover_group_list_result.rb' + autoload :ElasticPoolListResult, 'generated/azure_mgmt_sql/models/elastic_pool_list_result.rb' autoload :LocationCapabilities, 'generated/azure_mgmt_sql/models/location_capabilities.rb' - autoload :MetricDefinitionListResult, 'generated/azure_mgmt_sql/models/metric_definition_list_result.rb' - autoload :EncryptionProtectorListResult, 'generated/azure_mgmt_sql/models/encryption_protector_list_result.rb' - autoload :OperationDisplay, 'generated/azure_mgmt_sql/models/operation_display.rb' - autoload :FailoverGroupReadWriteEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb' autoload :Operation, 'generated/azure_mgmt_sql/models/operation.rb' - autoload :SubResource, 'generated/azure_mgmt_sql/models/sub_resource.rb' + autoload :ServiceTierAdvisorListResult, 'generated/azure_mgmt_sql/models/service_tier_advisor_list_result.rb' autoload :OperationListResult, 'generated/azure_mgmt_sql/models/operation_list_result.rb' - autoload :FirewallRuleListResult, 'generated/azure_mgmt_sql/models/firewall_rule_list_result.rb' - autoload :ServerKeyListResult, 'generated/azure_mgmt_sql/models/server_key_list_result.rb' - autoload :GeoBackupPolicyListResult, 'generated/azure_mgmt_sql/models/geo_backup_policy_list_result.rb' + autoload :FailoverGroupReadWriteEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb' + autoload :FailoverGroupUpdate, 'generated/azure_mgmt_sql/models/failover_group_update.rb' + autoload :ElasticPoolDatabaseActivityListResult, 'generated/azure_mgmt_sql/models/elastic_pool_database_activity_list_result.rb' autoload :ReplicationLinkListResult, 'generated/azure_mgmt_sql/models/replication_link_list_result.rb' - autoload :ServerUsageListResult, 'generated/azure_mgmt_sql/models/server_usage_list_result.rb' - autoload :ResourceIdentity, 'generated/azure_mgmt_sql/models/resource_identity.rb' - autoload :RecoverableDatabaseListResult, 'generated/azure_mgmt_sql/models/recoverable_database_list_result.rb' + autoload :FailoverGroupReadOnlyEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_only_endpoint.rb' + autoload :FailoverGroupListResult, 'generated/azure_mgmt_sql/models/failover_group_list_result.rb' + autoload :ImportExtensionRequest, 'generated/azure_mgmt_sql/models/import_extension_request.rb' autoload :ServerAdministratorListResult, 'generated/azure_mgmt_sql/models/server_administrator_list_result.rb' + autoload :PartnerInfo, 'generated/azure_mgmt_sql/models/partner_info.rb' + autoload :RecommendedElasticPoolListMetricsResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_metrics_result.rb' + autoload :RestorePointListResult, 'generated/azure_mgmt_sql/models/restore_point_list_result.rb' + autoload :RecoverableDatabaseListResult, 'generated/azure_mgmt_sql/models/recoverable_database_list_result.rb' + autoload :RecommendedElasticPoolListResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_result.rb' autoload :ServiceObjectiveCapability, 'generated/azure_mgmt_sql/models/service_objective_capability.rb' autoload :ElasticPoolDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_dtu_capability.rb' - autoload :ElasticPoolDatabaseActivityListResult, 'generated/azure_mgmt_sql/models/elastic_pool_database_activity_list_result.rb' - autoload :ServerCommunicationLinkListResult, 'generated/azure_mgmt_sql/models/server_communication_link_list_result.rb' - autoload :DataMaskingRuleListResult, 'generated/azure_mgmt_sql/models/data_masking_rule_list_result.rb' - autoload :VirtualNetworkRuleListResult, 'generated/azure_mgmt_sql/models/virtual_network_rule_list_result.rb' - autoload :FailoverGroupReadOnlyEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_only_endpoint.rb' autoload :ServiceObjectiveListResult, 'generated/azure_mgmt_sql/models/service_objective_list_result.rb' - autoload :RestorePointListResult, 'generated/azure_mgmt_sql/models/restore_point_list_result.rb' + autoload :EncryptionProtectorListResult, 'generated/azure_mgmt_sql/models/encryption_protector_list_result.rb' autoload :CheckNameAvailabilityRequest, 'generated/azure_mgmt_sql/models/check_name_availability_request.rb' - autoload :ElasticPoolPerDatabaseMinDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_min_dtu_capability.rb' + autoload :DataMaskingRuleListResult, 'generated/azure_mgmt_sql/models/data_masking_rule_list_result.rb' autoload :CheckNameAvailabilityResponse, 'generated/azure_mgmt_sql/models/check_name_availability_response.rb' - autoload :ElasticPoolActivityListResult, 'generated/azure_mgmt_sql/models/elastic_pool_activity_list_result.rb' + autoload :GeoBackupPolicyListResult, 'generated/azure_mgmt_sql/models/geo_backup_policy_list_result.rb' autoload :RecommendedElasticPoolMetric, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_metric.rb' - autoload :ServerUsage, 'generated/azure_mgmt_sql/models/server_usage.rb' + autoload :DatabaseUsage, 'generated/azure_mgmt_sql/models/database_usage.rb' autoload :SloUsageMetric, 'generated/azure_mgmt_sql/models/slo_usage_metric.rb' - autoload :ServerVersionCapability, 'generated/azure_mgmt_sql/models/server_version_capability.rb' + autoload :ElasticPoolPerDatabaseMinDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_min_dtu_capability.rb' + autoload :VirtualNetworkRuleListResult, 'generated/azure_mgmt_sql/models/virtual_network_rule_list_result.rb' + autoload :DatabaseListResult, 'generated/azure_mgmt_sql/models/database_list_result.rb' autoload :ServerUpdate, 'generated/azure_mgmt_sql/models/server_update.rb' - autoload :RestorableDroppedDatabaseListResult, 'generated/azure_mgmt_sql/models/restorable_dropped_database_list_result.rb' - autoload :ServerListResult, 'generated/azure_mgmt_sql/models/server_list_result.rb' - autoload :ElasticPoolListResult, 'generated/azure_mgmt_sql/models/elastic_pool_list_result.rb' + autoload :ElasticPoolActivityListResult, 'generated/azure_mgmt_sql/models/elastic_pool_activity_list_result.rb' autoload :OperationImpact, 'generated/azure_mgmt_sql/models/operation_impact.rb' + autoload :ServerVersionCapability, 'generated/azure_mgmt_sql/models/server_version_capability.rb' + autoload :ServerListResult, 'generated/azure_mgmt_sql/models/server_list_result.rb' + autoload :RestorableDroppedDatabaseListResult, 'generated/azure_mgmt_sql/models/restorable_dropped_database_list_result.rb' + autoload :ResourceIdentity, 'generated/azure_mgmt_sql/models/resource_identity.rb' + autoload :FirewallRuleListResult, 'generated/azure_mgmt_sql/models/firewall_rule_list_result.rb' + autoload :ServerKeyListResult, 'generated/azure_mgmt_sql/models/server_key_list_result.rb' autoload :ProxyResource, 'generated/azure_mgmt_sql/models/proxy_resource.rb' autoload :BackupLongTermRetentionPolicy, 'generated/azure_mgmt_sql/models/backup_long_term_retention_policy.rb' autoload :BackupLongTermRetentionVault, 'generated/azure_mgmt_sql/models/backup_long_term_retention_vault.rb' @@ -110,7 +130,6 @@ module Models autoload :GeoBackupPolicy, 'generated/azure_mgmt_sql/models/geo_backup_policy.rb' autoload :ImportExportResponse, 'generated/azure_mgmt_sql/models/import_export_response.rb' autoload :ImportRequest, 'generated/azure_mgmt_sql/models/import_request.rb' - autoload :MetricValue, 'generated/azure_mgmt_sql/models/metric_value.rb' autoload :ReplicationLink, 'generated/azure_mgmt_sql/models/replication_link.rb' autoload :ServerAzureADAdministrator, 'generated/azure_mgmt_sql/models/server_azure_adadministrator.rb' autoload :ServerCommunicationLink, 'generated/azure_mgmt_sql/models/server_communication_link.rb' @@ -126,7 +145,6 @@ module Models autoload :ElasticPoolDatabaseActivity, 'generated/azure_mgmt_sql/models/elastic_pool_database_activity.rb' autoload :DatabaseUpdate, 'generated/azure_mgmt_sql/models/database_update.rb' autoload :TransparentDataEncryptionActivity, 'generated/azure_mgmt_sql/models/transparent_data_encryption_activity.rb' - autoload :DatabaseUsage, 'generated/azure_mgmt_sql/models/database_usage.rb' autoload :DatabaseBlobAuditingPolicy, 'generated/azure_mgmt_sql/models/database_blob_auditing_policy.rb' autoload :EncryptionProtector, 'generated/azure_mgmt_sql/models/encryption_protector.rb' autoload :FailoverGroup, 'generated/azure_mgmt_sql/models/failover_group.rb' @@ -172,5 +190,6 @@ module Models autoload :ReadOnlyEndpointFailoverPolicy, 'generated/azure_mgmt_sql/models/read_only_endpoint_failover_policy.rb' autoload :FailoverGroupReplicationRole, 'generated/azure_mgmt_sql/models/failover_group_replication_role.rb' autoload :IdentityType, 'generated/azure_mgmt_sql/models/identity_type.rb' + autoload :VirtualNetworkRuleState, 'generated/azure_mgmt_sql/models/virtual_network_rule_state.rb' end end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_policies.rb new file mode 100644 index 0000000000..93fea92539 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_policies.rb @@ -0,0 +1,310 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class BackupLongTermRetentionPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the BackupLongTermRetentionPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionPolicy] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Returns a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + backup_long_term_retention_policy_name = 'Default' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'backupLongTermRetentionPolicyName' => backup_long_term_retention_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Creates or updates a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database + # @param parameters [BackupLongTermRetentionPolicy] The required parameters to + # update a backup long term retention policy + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database + # @param parameters [BackupLongTermRetentionPolicy] The required parameters to + # update a backup long term retention policy + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + # Send request + promise = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise + end + + # + # Creates or updates a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database + # @param parameters [BackupLongTermRetentionPolicy] The required parameters to + # update a backup long term retention policy + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionPolicy] operation results. + # + def begin_create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database + # @param parameters [BackupLongTermRetentionPolicy] The required parameters to + # update a backup long term retention policy + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [MsRestAzure::AzureOperationResponse] HTTP response information. + # + def begin_create_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database backup long term retention policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database + # @param parameters [BackupLongTermRetentionPolicy] The required parameters to + # update a backup long term retention policy + # @param [Hash{String => String}] A hash of custom headers that will be added + # to the HTTP request. + # + # @return [Concurrent::Promise] Promise object which holds the HTTP response. + # + def begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + backup_long_term_retention_policy_name = 'Default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'backupLongTermRetentionPolicyName' => backup_long_term_retention_policy_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 || status_code == 202 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_vaults.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_vaults.rb new file mode 100644 index 0000000000..162fb19a18 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/backup_long_term_retention_vaults.rb @@ -0,0 +1,300 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class BackupLongTermRetentionVaults + include MsRestAzure + + # + # Creates and initializes a new instance of the BackupLongTermRetentionVaults class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionVault] operation results. + # + def get(resource_group_name, server_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_with_http_info(resource_group_name, server_name, custom_headers = nil) + get_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Gets a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_async(resource_group_name, server_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + backup_long_term_retention_vault_name = 'RegisteredVault' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'backupLongTermRetentionVaultName' => backup_long_term_retention_vault_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Updates a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [BackupLongTermRetentionVault] The required parameters to + # update a backup long term retention vault + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionVault] operation results. + # + def create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [BackupLongTermRetentionVault] The required parameters to + # update a backup long term retention vault + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + # Send request + promise = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise + end + + # + # Updates a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [BackupLongTermRetentionVault] The required parameters to + # update a backup long term retention vault + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [BackupLongTermRetentionVault] operation results. + # + def begin_create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Updates a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [BackupLongTermRetentionVault] The required parameters to + # update a backup long term retention 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 begin_create_or_update_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) + begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + end + + # + # Updates a server backup long term retention vault + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [BackupLongTermRetentionVault] The required parameters to + # update a backup long term retention 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 begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + backup_long_term_retention_vault_name = 'RegisteredVault' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'backupLongTermRetentionVaultName' => backup_long_term_retention_vault_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 || status_code == 202 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_policies.rb new file mode 100644 index 0000000000..a726298ec4 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_policies.rb @@ -0,0 +1,248 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class DataMaskingPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the DataMaskingPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Creates or updates a database data masking policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [DataMaskingPolicy] Parameters for creating or updating a + # data masking policy. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DataMaskingPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database data masking policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [DataMaskingPolicy] Parameters for creating or updating a + # data masking policy. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database data masking policy + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [DataMaskingPolicy] Parameters for creating or updating a + # data masking policy. + # @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_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + data_masking_policy_name = 'Default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::DataMaskingPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a database data masking policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DataMaskingPolicy] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database data masking policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a database data masking policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + data_masking_policy_name = 'Default' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_rules.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_rules.rb new file mode 100644 index 0000000000..465434f9ab --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/data_masking_rules.rb @@ -0,0 +1,262 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class DataMaskingRules + include MsRestAzure + + # + # Creates and initializes a new instance of the DataMaskingRules class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Creates or updates a database data masking rule. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param data_masking_rule_name [String] The name of the data masking rule. + # @param parameters [DataMaskingRule] The required parameters for creating or + # updating a data masking rule. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DataMaskingRule] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database data masking rule. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param data_masking_rule_name [String] The name of the data masking rule. + # @param parameters [DataMaskingRule] The required parameters for creating or + # updating a data masking rule. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database data masking rule. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param data_masking_rule_name [String] The name of the data masking rule. + # @param parameters [DataMaskingRule] The required parameters for creating or + # updating a data masking rule. + # @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_or_update_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + data_masking_policy_name = 'Default' + fail ArgumentError, 'data_masking_rule_name is nil' if data_masking_rule_name.nil? + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::DataMaskingRule.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name,'dataMaskingRuleName' => data_masking_rule_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingRule.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::DataMaskingRule.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a list of database data masking rules. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DataMaskingRuleListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a list of database data masking rules. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a list of database data masking rules. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + data_masking_policy_name = 'Default' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingRuleListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_blob_auditing_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_blob_auditing_policies.rb new file mode 100644 index 0000000000..ad32a179ec --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_blob_auditing_policies.rb @@ -0,0 +1,264 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class DatabaseBlobAuditingPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the DatabaseBlobAuditingPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # audit policy is defined. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseBlobAuditingPolicy] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # audit policy is defined. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # audit policy is defined. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + blob_auditing_policy_name = 'default' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'blobAuditingPolicyName' => blob_auditing_policy_name,'subscriptionId' => @client.subscription_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Creates or updates a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # auditing policy will be defined. + # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing + # policy. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseBlobAuditingPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # auditing policy will be defined. + # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing + # policy. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database's blob auditing policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the blob + # auditing policy will be defined. + # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing + # policy. + # @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_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + blob_auditing_policy_name = 'default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'blobAuditingPolicyName' => blob_auditing_policy_name,'subscriptionId' => @client.subscription_id}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_threat_detection_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_threat_detection_policies.rb new file mode 100644 index 0000000000..15720b5c7a --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_threat_detection_policies.rb @@ -0,0 +1,264 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class DatabaseThreatDetectionPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the DatabaseThreatDetectionPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseSecurityAlertPolicy] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + security_alert_policy_name = 'default' + api_version = '2014-04-01' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'securityAlertPolicyName' => security_alert_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Creates or updates a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection + # policy. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseSecurityAlertPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection + # policy. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database's threat detection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which database + # Threat Detection policy is defined. + # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection + # policy. + # @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_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + security_alert_policy_name = 'default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + api_version = '2014-04-01' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'securityAlertPolicyName' => security_alert_policy_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_usages.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_usages.rb new file mode 100644 index 0000000000..1c68ab4ece --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_usages.rb @@ -0,0 +1,129 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class DatabaseUsages + include MsRestAzure + + # + # Creates and initializes a new instance of the DatabaseUsages class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns database usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseUsageListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns database usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Returns database usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseUsageListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/databases.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/databases.rb index eeea5f1c3e..04bd44a229 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/databases.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/databases.rb @@ -25,124 +25,73 @@ def initialize(client) attr_reader :client # - # Returns a database backup long term retention policy + # Imports a bacpac into a new database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. + # @param parameters [ImportRequest] The required parameters for importing a + # Bacpac into a database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [BackupLongTermRetentionPolicy] operation results. + # @return [ImportExportResponse] operation results. # - def get_backup_long_term_retention_policy(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_backup_long_term_retention_policy_async(resource_group_name, server_name, database_name, custom_headers).value! + def import(resource_group_name, server_name, parameters, custom_headers = nil) + response = import_async(resource_group_name, server_name, parameters, custom_headers).value! response.body unless response.nil? end - # - # Returns a database backup long term retention policy # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. + # @param parameters [ImportRequest] The required parameters for importing a + # Bacpac into a database. # @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_backup_long_term_retention_policy_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_backup_long_term_retention_policy_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Returns a database backup long term retention policy - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def get_backup_long_term_retention_policy_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - backup_long_term_retention_policy_name = 'Default' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'backupLongTermRetentionPolicyName' => backup_long_term_retention_policy_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end + def import_async(resource_group_name, server_name, parameters, custom_headers = nil) + # Send request + promise = begin_import_async(resource_group_name, server_name, parameters, custom_headers) - 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::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) end - result + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) end - promise.execute + promise end # - # Creates or updates a database backup long term retention policy + # Creates an import operation that imports a bacpac into an existing database. + # The existing database must be empty. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database - # @param parameters [BackupLongTermRetentionPolicy] The required parameters to - # update a backup long term retention policy + # @param database_name [String] The name of the database to import into + # @param parameters [ImportExtensionRequest] The required parameters for + # importing a Bacpac into a database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [BackupLongTermRetentionPolicy] operation results. + # @return [ImportExportResponse] operation results. # - def create_or_update_long_term_retention_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def create_import_operation(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! response.body unless response.nil? end @@ -151,23 +100,23 @@ def create_or_update_long_term_retention_policy(resource_group_name, server_name # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database - # @param parameters [BackupLongTermRetentionPolicy] The required parameters to - # update a backup long term retention policy + # @param database_name [String] The name of the database to import into + # @param parameters [ImportExtensionRequest] The required parameters for + # importing a Bacpac into a database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # - def create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + def create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) # Send request - promise = begin_create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers) + promise = begin_create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() parsed_response = @client.deserialize(result_mapper, parsed_response) end @@ -179,167 +128,118 @@ def create_or_update_long_term_retention_policy_async(resource_group_name, serve end # - # Gets a list of database restore points. + # Exports a database to a bacpac. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get available - # restore points. + # @param database_name [String] The name of the database to be exported. + # @param parameters [ExportRequest] The required parameters for exporting a + # database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [RestorePointListResult] operation results. + # @return [ImportExportResponse] operation results. # - def list_restore_points(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_restore_points_async(resource_group_name, server_name, database_name, custom_headers).value! + def export(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = export_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! response.body unless response.nil? end - # - # Gets a list of database restore points. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get available - # restore points. + # @param database_name [String] The name of the database to be exported. + # @param parameters [ExportRequest] The required parameters for exporting a + # database. # @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 list_restore_points_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_restore_points_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Gets a list of database restore points. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get available - # restore points. - # @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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def list_restore_points_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end + def export_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + # Send request + promise = begin_export_async(resource_group_name, server_name, database_name, parameters, custom_headers) - 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::ARM::SQL::Models::RestorePointListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) end - result + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) end - promise.execute + promise end # - # Gets a database's threat detection policy. + # Returns database metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. + # @param database_name [String] The name of the database. + # @param filter [String] An OData filter expression that describes a subset of + # metrics to return. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DatabaseSecurityAlertPolicy] operation results. + # @return [MetricListResult] operation results. # - def get_threat_detection_policy(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_threat_detection_policy_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_metrics(resource_group_name, server_name, database_name, filter, custom_headers = nil) + response = list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers).value! response.body unless response.nil? end # - # Gets a database's threat detection policy. + # Returns database metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. + # @param database_name [String] The name of the database. + # @param filter [String] An OData filter expression that describes a subset of + # metrics to return. # @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_threat_detection_policy_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_threat_detection_policy_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_metrics_with_http_info(resource_group_name, server_name, database_name, filter, custom_headers = nil) + list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers).value! end # - # Gets a database's threat detection policy. + # Returns database metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. + # @param database_name [String] The name of the database. + # @param filter [String] An OData filter expression that describes a subset of + # metrics to return. # @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_threat_detection_policy_async(resource_group_name, server_name, database_name, custom_headers = nil) + def list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers = nil) + api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? - security_alert_policy_name = 'default' - api_version = '2014-04-01' + fail ArgumentError, 'filter is nil' if filter.nil? request_headers = {} @@ -347,14 +247,14 @@ def get_threat_detection_policy_async(resource_group_name, server_name, database # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'securityAlertPolicyName' => security_alert_policy_name}, - query_params: {'api-version' => api_version}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version,'$filter' => filter}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } @@ -374,7 +274,7 @@ def get_threat_detection_policy_async(resource_group_name, server_name, database if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::MetricListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -388,70 +288,59 @@ def get_threat_detection_policy_async(resource_group_name, server_name, database end # - # Creates or updates a database's threat detection policy. + # Returns database metric definitions. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. - # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection - # policy. + # @param database_name [String] The name of the database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DatabaseSecurityAlertPolicy] operation results. + # @return [MetricDefinitionListResult] operation results. # - def create_or_update_threat_detection_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_threat_detection_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def list_metric_definitions(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers).value! response.body unless response.nil? end # - # Creates or updates a database's threat detection policy. + # Returns database metric definitions. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. - # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection - # policy. + # @param database_name [String] The name of the database. # @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_or_update_threat_detection_policy_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - create_or_update_threat_detection_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def list_metric_definitions_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers).value! end # - # Creates or updates a database's threat detection policy. + # Returns database metric definitions. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which database - # Threat Detection policy is defined. - # @param parameters [DatabaseSecurityAlertPolicy] The database Threat Detection - # policy. + # @param database_name [String] The name of the database. # @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_or_update_threat_detection_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + def list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? - security_alert_policy_name = 'default' - fail ArgumentError, 'parameters is nil' if parameters.nil? - api_version = '2014-04-01' request_headers = {} @@ -459,33 +348,24 @@ def create_or_update_threat_detection_policy_async(resource_group_name, server_n # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'securityAlertPolicyName' => security_alert_policy_name}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, query_params: {'api-version' => api_version}, - body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body - unless status_code == 200 || status_code == 201 + unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end @@ -495,17 +375,7 @@ def create_or_update_threat_detection_policy_async(resource_group_name, server_n if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseSecurityAlertPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::MetricDefinitionListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -519,2332 +389,252 @@ def create_or_update_threat_detection_policy_async(resource_group_name, server_n end # - # Creates or updates a database data masking policy + # Pauses a data warehouse. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [DataMaskingPolicy] Parameters for creating or updating a - # data masking policy. + # @param database_name [String] The name of the data warehouse to pause. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DataMaskingPolicy] operation results. - # - def create_or_update_data_masking_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_data_masking_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? + def pause(resource_group_name, server_name, database_name, custom_headers = nil) + response = pause_async(resource_group_name, server_name, database_name, custom_headers).value! + nil end - # - # Creates or updates a database data masking policy # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [DataMaskingPolicy] Parameters for creating or updating a - # data masking policy. + # @param database_name [String] The name of the data warehouse to pause. # @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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def create_or_update_data_masking_policy_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - create_or_update_data_masking_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - end - - # - # Creates or updates a database data masking policy - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [DataMaskingPolicy] Parameters for creating or updating a - # data masking policy. - # @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_or_update_data_masking_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - data_masking_policy_name = 'Default' - fail ArgumentError, 'parameters is nil' if parameters.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::DataMaskingPolicy.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.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 MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a database data masking policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DataMaskingPolicy] operation results. - # - def get_data_masking_policy(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_data_masking_policy_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a database data masking policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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_data_masking_policy_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_data_masking_policy_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Gets a database data masking policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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_data_masking_policy_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - data_masking_policy_name = 'Default' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Creates or updates a database data masking rule. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param data_masking_rule_name [String] The name of the data masking rule. - # @param parameters [DataMaskingRule] The required parameters for creating or - # updating a data masking rule. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DataMaskingRule] operation results. - # - def create_or_update_data_masking_rule(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) - response = create_or_update_data_masking_rule_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Creates or updates a database data masking rule. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param data_masking_rule_name [String] The name of the data masking rule. - # @param parameters [DataMaskingRule] The required parameters for creating or - # updating a data masking rule. - # @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_or_update_data_masking_rule_with_http_info(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) - create_or_update_data_masking_rule_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers).value! - end - - # - # Creates or updates a database data masking rule. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param data_masking_rule_name [String] The name of the data masking rule. - # @param parameters [DataMaskingRule] The required parameters for creating or - # updating a data masking rule. - # @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_or_update_data_masking_rule_async(resource_group_name, server_name, database_name, data_masking_rule_name, parameters, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - data_masking_policy_name = 'Default' - fail ArgumentError, 'data_masking_rule_name is nil' if data_masking_rule_name.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::DataMaskingRule.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name,'dataMaskingRuleName' => data_masking_rule_name}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.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 || status_code == 201 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingRule.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DataMaskingRule.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a list of database data masking rules. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DataMaskingRuleListResult] operation results. - # - def list_data_masking_rules(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_data_masking_rules_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a list of database data masking rules. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_data_masking_rules_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_data_masking_rules_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Gets a list of database data masking rules. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_data_masking_rules_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - data_masking_policy_name = 'Default' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'dataMaskingPolicyName' => data_masking_policy_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DataMaskingRuleListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Updates a database geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [GeoBackupPolicy] The required parameters for creating or - # updating the geo backup policy. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [GeoBackupPolicy] operation results. - # - def create_or_update_geo_backup_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_geo_backup_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Updates a database geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [GeoBackupPolicy] The required parameters for creating or - # updating the geo backup policy. - # @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_or_update_geo_backup_policy_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - create_or_update_geo_backup_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - end - - # - # Updates a database geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param parameters [GeoBackupPolicy] The required parameters for creating or - # updating the geo backup policy. - # @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_or_update_geo_backup_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - geo_backup_policy_name = 'Default' - fail ArgumentError, 'parameters is nil' if parameters.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::GeoBackupPolicy.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'geoBackupPolicyName' => geo_backup_policy_name}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.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 == 201 || status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 200 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::GeoBackupPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [GeoBackupPolicy] operation results. - # - def get_geo_backup_policy(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_geo_backup_policy_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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_geo_backup_policy_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_geo_backup_policy_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Gets a geo backup policy. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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_geo_backup_policy_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - geo_backup_policy_name = 'Default' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'geoBackupPolicyName' => geo_backup_policy_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns a list of geo backup policies. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [GeoBackupPolicyListResult] operation results. - # - def list_geo_backup_policies(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_geo_backup_policies_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns a list of geo backup policies. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_geo_backup_policies_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_geo_backup_policies_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Returns a list of geo backup policies. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_geo_backup_policies_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicyListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Imports a bacpac into a new database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ImportRequest] The required parameters for importing a - # Bacpac into a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ImportExportResponse] operation results. - # - def import(resource_group_name, server_name, parameters, custom_headers = nil) - response = import_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ImportRequest] The required parameters for importing a - # Bacpac into a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def import_async(resource_group_name, server_name, parameters, custom_headers = nil) - # Send request - promise = begin_import_async(resource_group_name, server_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Creates an import operation that imports a bacpac into an existing database. - # The existing database must be empty. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to import into - # @param parameters [ImportExtensionRequest] The required parameters for - # importing a Bacpac into a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ImportExportResponse] operation results. - # - def create_import_operation(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to import into - # @param parameters [ImportExtensionRequest] The required parameters for - # importing a Bacpac into a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_import_operation_async(resource_group_name, server_name, database_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Exports a database to a bacpac. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be exported. - # @param parameters [ExportRequest] The required parameters for exporting a - # database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ImportExportResponse] operation results. - # - def export(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = export_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be exported. - # @param parameters [ExportRequest] The required parameters for exporting a - # database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def export_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - # Send request - promise = begin_export_async(resource_group_name, server_name, database_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::ImportExportResponse.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Returns database metrics. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param filter [String] An OData filter expression that describes a subset of - # metrics to return. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MetricListResult] operation results. - # - def list_metrics(resource_group_name, server_name, database_name, filter, custom_headers = nil) - response = list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns database metrics. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param filter [String] An OData filter expression that describes a subset of - # metrics to return. - # @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 list_metrics_with_http_info(resource_group_name, server_name, database_name, filter, custom_headers = nil) - list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers).value! - end - - # - # Returns database metrics. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param filter [String] An OData filter expression that describes a subset of - # metrics to return. - # @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 list_metrics_async(resource_group_name, server_name, database_name, filter, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'filter is nil' if filter.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version,'$filter' => filter}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::MetricListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns database metric definitions. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MetricDefinitionListResult] operation results. - # - def list_metric_definitions(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns database metric definitions. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_metric_definitions_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Returns database metric definitions. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. - # @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 list_metric_definitions_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::MetricDefinitionListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Deletes a database replication link. Cannot be done during failover. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be dropped. - # @param link_id [String] The ID of the replication link to be deleted. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def delete_replication_link(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = delete_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - nil - end - - # - # Deletes a database replication link. Cannot be done during failover. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be dropped. - # @param link_id [String] The ID of the replication link to be deleted. - # @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_replication_link_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - delete_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - end - - # - # Deletes a database replication link. Cannot be done during failover. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be dropped. - # @param link_id [String] The ID of the replication link to be deleted. - # @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_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'link_id is nil' if link_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.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 || status_code == 204 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - - # - # Gets a database replication link. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get the link for. - # @param link_id [String] The replication link ID to be retrieved. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ReplicationLink] operation results. - # - def get_replication_link(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = get_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a database replication link. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get the link for. - # @param link_id [String] The replication link ID to be retrieved. - # @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_replication_link_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - get_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - end - - # - # Gets a database replication link. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to get the link for. - # @param link_id [String] The replication link ID to be retrieved. - # @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_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'link_id is nil' if link_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ReplicationLink.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - def failover_replication_link(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - nil - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - # Send request - promise = begin_failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. This operation might result in data loss. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - def failover_replication_link_allow_data_loss(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - nil - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - # Send request - promise = begin_failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Lists a database's replication links. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to retrieve links for. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ReplicationLinkListResult] operation results. - # - def list_replication_links(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_replication_links_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Lists a database's replication links. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to retrieve links for. - # @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 list_replication_links_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_replication_links_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Lists a database's replication links. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to retrieve links for. - # @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 list_replication_links_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ReplicationLinkListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Pauses a data warehouse. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the data warehouse to pause. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - def pause(resource_group_name, server_name, database_name, custom_headers = nil) - response = pause_async(resource_group_name, server_name, database_name, custom_headers).value! - nil - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the data warehouse to pause. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def pause_async(resource_group_name, server_name, database_name, custom_headers = nil) - # Send request - promise = begin_pause_async(resource_group_name, server_name, database_name, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Resumes a data warehouse. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the data warehouse to resume. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - def resume(resource_group_name, server_name, database_name, custom_headers = nil) - response = resume_async(resource_group_name, server_name, database_name, custom_headers).value! - nil - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the data warehouse to resume. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def resume_async(resource_group_name, server_name, database_name, custom_headers = nil) - # Send request - promise = begin_resume_async(resource_group_name, server_name, database_name, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Creates a new database or updates an existing database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be operated on - # (updated or created). - # @param parameters [Database] The required parameters for creating or updating - # a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Database] operation results. - # - def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be operated on - # (updated or created). - # @param parameters [Database] The required parameters for creating or updating - # a database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::Database.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Updates an existing database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be updated. - # @param parameters [DatabaseUpdate] The required parameters for updating a - # database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Database] operation results. - # - def update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be updated. - # @param parameters [DatabaseUpdate] The required parameters for updating a - # database. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - # Send request - promise = begin_update_async(resource_group_name, server_name, database_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::Database.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Deletes a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be deleted. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def delete(resource_group_name, server_name, database_name, custom_headers = nil) - response = delete_async(resource_group_name, server_name, database_name, custom_headers).value! - nil - end - - # - # Deletes a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be deleted. - # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - delete_async(resource_group_name, server_name, database_name, custom_headers).value! - end - - # - # Deletes a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be deleted. - # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.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 || status_code == 204 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - - # - # Gets a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be retrieved. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Database] operation results. - # - def get(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) - response = get_async(resource_group_name, server_name, database_name, expand, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be retrieved. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @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_with_http_info(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) - get_async(resource_group_name, server_name, database_name, expand, custom_headers).value! - end - - # - # Gets a database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database to be retrieved. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @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_async(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version,'$expand' => expand}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::Database.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns a list of databases in a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @param filter [String] An OData filter expression that describes a subset of - # databases to return. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DatabaseListResult] operation results. - # - def list_by_server(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) - response = list_by_server_async(resource_group_name, server_name, expand, filter, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns a list of databases in a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @param filter [String] An OData filter expression that describes a subset of - # databases to return. - # @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 list_by_server_with_http_info(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) - list_by_server_async(resource_group_name, server_name, expand, filter, custom_headers).value! - end - - # - # Returns a list of databases in a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param expand [String] A comma separated list of child objects to expand in - # the response. Possible properties: serviceTierAdvisors, - # transparentDataEncryption. - # @param filter [String] An OData filter expression that describes a subset of - # databases to return. - # @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 list_by_server_async(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, - query_params: {'api-version' => api_version,'$expand' => expand,'$filter' => filter}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end + def pause_async(resource_group_name, server_name, database_name, custom_headers = nil) + # Send request + promise = begin_pause_async(resource_group_name, server_name, database_name, custom_headers) - 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::ARM::SQL::Models::DatabaseListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| end - result + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) end - promise.execute + promise end # - # Gets a service tier advisor. + # Resumes a data warehouse. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. - # @param service_tier_advisor_name [String] The name of service tier advisor. + # @param database_name [String] The name of the data warehouse to resume. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServiceTierAdvisor] operation results. - # - def get_service_tier_advisor(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) - response = get_service_tier_advisor_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers).value! - response.body unless response.nil? + def resume(resource_group_name, server_name, database_name, custom_headers = nil) + response = resume_async(resource_group_name, server_name, database_name, custom_headers).value! + nil end - # - # Gets a service tier advisor. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. - # @param service_tier_advisor_name [String] The name of service tier advisor. + # @param database_name [String] The name of the data warehouse to resume. # @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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def get_service_tier_advisor_with_http_info(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) - get_service_tier_advisor_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers).value! + def resume_async(resource_group_name, server_name, database_name, custom_headers = nil) + # Send request + promise = begin_resume_async(resource_group_name, server_name, database_name, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise end # - # Gets a service tier advisor. + # Creates a new database or updates an existing database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. - # @param service_tier_advisor_name [String] The name of service tier advisor. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. + # @param database_name [String] The name of the database to be operated on + # (updated or created). + # @param parameters [Database] The required parameters for creating or updating + # a database. + # @param custom_headers [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. + # @return [Database] operation results. # - def get_service_tier_advisor_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'service_tier_advisor_name is nil' if service_tier_advisor_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/serviceTierAdvisors/{serviceTierAdvisorName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'serviceTierAdvisorName' => service_tier_advisor_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceTierAdvisor.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? end - # - # Returns service tier advisors for specified database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. + # @param database_name [String] The name of the database to be operated on + # (updated or created). + # @param parameters [Database] The required parameters for creating or updating + # a database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServiceTierAdvisorListResult] operation results. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def list_service_tier_advisors(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_service_tier_advisors_async(resource_group_name, server_name, database_name, custom_headers).value! - response.body unless response.nil? + def create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + # Send request + promise = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::Database.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise end # - # Returns service tier advisors for specified database. + # Updates an existing database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. + # @param database_name [String] The name of the database to be updated. + # @param parameters [DatabaseUpdate] The required parameters for updating a + # database. # @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. + # @return [Database] operation results. # - def list_service_tier_advisors_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_service_tier_advisors_async(resource_group_name, server_name, database_name, custom_headers).value! + def update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? end - # - # Returns service tier advisors for specified database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of database. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. + # @param database_name [String] The name of the database to be updated. + # @param parameters [DatabaseUpdate] The required parameters for updating a + # database. + # @param custom_headers [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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def list_service_tier_advisors_async(resource_group_name, server_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/serviceTierAdvisors' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end + def update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + # Send request + promise = begin_update_async(resource_group_name, server_name, database_name, parameters, custom_headers) - 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::ARM::SQL::Models::ServiceTierAdvisorListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::Database.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) end - result + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) end - promise.execute + promise end # - # Creates or updates a database's transparent data encryption configuration. + # Deletes a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which setting the - # transparent data encryption applies. - # @param parameters [TransparentDataEncryption] The required parameters for - # creating or updating transparent data encryption. + # @param database_name [String] The name of the database to be deleted. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [TransparentDataEncryption] operation results. # - def create_or_update_transparent_data_encryption_configuration(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! - response.body unless response.nil? + def delete(resource_group_name, server_name, database_name, custom_headers = nil) + response = delete_async(resource_group_name, server_name, database_name, custom_headers).value! + nil end # - # Creates or updates a database's transparent data encryption configuration. + # Deletes a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which setting the - # transparent data encryption applies. - # @param parameters [TransparentDataEncryption] The required parameters for - # creating or updating transparent data encryption. + # @param database_name [String] The name of the database to be deleted. # @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_or_update_transparent_data_encryption_configuration_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - create_or_update_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def delete_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + delete_async(resource_group_name, server_name, database_name, custom_headers).value! end # - # Creates or updates a database's transparent data encryption configuration. + # Deletes a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which setting the - # transparent data encryption applies. - # @param parameters [TransparentDataEncryption] The required parameters for - # creating or updating transparent data encryption. + # @param database_name [String] The name of the database to be deleted. # @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_or_update_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + def delete_async(resource_group_name, server_name, database_name, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? - transparent_data_encryption_name = 'current' - fail ArgumentError, 'parameters is nil' if parameters.nil? request_headers = {} @@ -2852,58 +642,29 @@ def create_or_update_transparent_data_encryption_configuration_async(resource_gr # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::TransparentDataEncryption.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, query_params: {'api-version' => api_version}, - body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.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 || status_code == 201 + unless status_code == 200 || status_code == 204 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::TransparentDataEncryption.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::TransparentDataEncryption.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end result end @@ -2912,63 +673,68 @@ def create_or_update_transparent_data_encryption_configuration_async(resource_gr end # - # Gets a database's transparent data encryption configuration. + # Gets a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param database_name [String] The name of the database to be retrieved. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [TransparentDataEncryption] operation results. + # @return [Database] operation results. # - def get_transparent_data_encryption_configuration(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, custom_headers).value! + def get(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, expand, custom_headers).value! response.body unless response.nil? end # - # Gets a database's transparent data encryption configuration. + # Gets a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param database_name [String] The name of the database to be retrieved. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. # @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_transparent_data_encryption_configuration_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, custom_headers).value! + def get_with_http_info(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, expand, custom_headers).value! end # - # Gets a database's transparent data encryption configuration. + # Gets a database. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param database_name [String] The name of the database to be retrieved. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. # @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_transparent_data_encryption_configuration_async(resource_group_name, server_name, database_name, custom_headers = nil) + def get_async(resource_group_name, server_name, database_name, expand = nil, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? - transparent_data_encryption_name = 'current' request_headers = {} @@ -2976,14 +742,14 @@ def get_transparent_data_encryption_configuration_async(resource_group_name, ser # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, - query_params: {'api-version' => api_version}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version,'$expand' => expand}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } @@ -3003,7 +769,7 @@ def get_transparent_data_encryption_configuration_async(resource_group_name, ser if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::TransparentDataEncryption.mapper() + result_mapper = Azure::ARM::SQL::Models::Database.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3017,63 +783,70 @@ def get_transparent_data_encryption_configuration_async(resource_group_name, ser end # - # Returns a database's transparent data encryption operation result. + # Returns a list of databases in a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. + # @param filter [String] An OData filter expression that describes a subset of + # databases to return. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [TransparentDataEncryptionActivityListResult] operation results. + # @return [DatabaseListResult] operation results. # - def list_transparent_data_encryption_activity(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_transparent_data_encryption_activity_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_by_server(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) + response = list_by_server_async(resource_group_name, server_name, expand, filter, custom_headers).value! response.body unless response.nil? end # - # Returns a database's transparent data encryption operation result. + # Returns a list of databases in a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. + # @param filter [String] An OData filter expression that describes a subset of + # databases to return. # @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 list_transparent_data_encryption_activity_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_transparent_data_encryption_activity_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_by_server_with_http_info(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) + list_by_server_async(resource_group_name, server_name, expand, filter, custom_headers).value! end # - # Returns a database's transparent data encryption operation result. + # Returns a list of databases in a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the - # transparent data encryption applies. + # @param expand [String] A comma separated list of child objects to expand in + # the response. Possible properties: serviceTierAdvisors, + # transparentDataEncryption. + # @param filter [String] An OData filter expression that describes a subset of + # databases to return. # @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 list_transparent_data_encryption_activity_async(resource_group_name, server_name, database_name, custom_headers = nil) + def list_by_server_async(resource_group_name, server_name, expand = nil, filter = nil, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - transparent_data_encryption_name = 'current' request_headers = {} @@ -3081,14 +854,14 @@ def list_transparent_data_encryption_activity_async(resource_group_name, server_ # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, - query_params: {'api-version' => api_version}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, + query_params: {'api-version' => api_version,'$expand' => expand,'$filter' => filter}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } @@ -3108,7 +881,7 @@ def list_transparent_data_encryption_activity_async(resource_group_name, server_ if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::TransparentDataEncryptionActivityListResult.mapper() + result_mapper = Azure::ARM::SQL::Models::DatabaseListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3122,58 +895,65 @@ def list_transparent_data_encryption_activity_async(resource_group_name, server_ end # - # Returns database usages. + # Gets a database inside of an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. + # @param database_name [String] The name of the database to be retrieved. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DatabaseUsageListResult] operation results. + # @return [Database] operation results. # - def list_usages(resource_group_name, server_name, database_name, custom_headers = nil) - response = list_usages_async(resource_group_name, server_name, database_name, custom_headers).value! + def get_by_elastic_pool(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) + response = get_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers).value! response.body unless response.nil? end # - # Returns database usages. + # Gets a database inside of an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. + # @param database_name [String] The name of the database to be retrieved. # @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 list_usages_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - list_usages_async(resource_group_name, server_name, database_name, custom_headers).value! + def get_by_elastic_pool_with_http_info(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) + get_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers).value! end # - # Returns database usages. + # Gets a database inside of an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. + # @param database_name [String] The name of the database to be retrieved. # @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 list_usages_async(resource_group_name, server_name, database_name, custom_headers = nil) + def get_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? @@ -3182,13 +962,13 @@ def list_usages_async(resource_group_name, server_name, database_name, custom_he # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases/{databaseName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name,'databaseName' => database_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url @@ -3209,7 +989,7 @@ def list_usages_async(resource_group_name, server_name, database_name, custom_he if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseUsageListResult.mapper() + result_mapper = Azure::ARM::SQL::Models::Database.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3223,63 +1003,62 @@ def list_usages_async(resource_group_name, server_name, database_name, custom_he end # - # Gets a database's blob auditing policy. + # Returns a list of databases in an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # audit policy is defined. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DatabaseBlobAuditingPolicy] operation results. + # @return [DatabaseListResult] operation results. # - def get_blob_auditing_policy(resource_group_name, server_name, database_name, custom_headers = nil) - response = get_blob_auditing_policy_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_by_elastic_pool(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + response = list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! response.body unless response.nil? end # - # Gets a database's blob auditing policy. + # Returns a list of databases in an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # audit policy is defined. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. # @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_blob_auditing_policy_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) - get_blob_auditing_policy_async(resource_group_name, server_name, database_name, custom_headers).value! + def list_by_elastic_pool_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! end # - # Gets a database's blob auditing policy. + # Returns a list of databases in an elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # audit policy is defined. + # @param elastic_pool_name [String] The name of the elastic pool to be + # retrieved. # @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_blob_auditing_policy_async(resource_group_name, server_name, database_name, custom_headers = nil) + def list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - blob_auditing_policy_name = 'default' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' + fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? request_headers = {} @@ -3287,13 +1066,13 @@ def get_blob_auditing_policy_async(resource_group_name, server_name, database_na # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'blobAuditingPolicyName' => blob_auditing_policy_name,'subscriptionId' => @client.subscription_id}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url @@ -3314,7 +1093,7 @@ def get_blob_auditing_policy_async(resource_group_name, server_name, database_na if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::DatabaseListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3328,70 +1107,66 @@ def get_blob_auditing_policy_async(resource_group_name, server_name, database_na end # - # Creates or updates a database's blob auditing policy. + # Gets a database inside of a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # auditing policy will be defined. - # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing - # policy. + # @param recommended_elastic_pool_name [String] The name of the elastic pool to + # be retrieved. + # @param database_name [String] The name of the database to be retrieved. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [DatabaseBlobAuditingPolicy] operation results. + # @return [Database] operation results. # - def create_or_update_blob_auditing_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = create_or_update_blob_auditing_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def get_by_recommended_elastic_pool(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) + response = get_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers).value! response.body unless response.nil? end # - # Creates or updates a database's blob auditing policy. + # Gets a database inside of a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # auditing policy will be defined. - # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing - # policy. + # @param recommended_elastic_pool_name [String] The name of the elastic pool to + # be retrieved. + # @param database_name [String] The name of the database to be retrieved. # @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_or_update_blob_auditing_policy_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - create_or_update_blob_auditing_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def get_by_recommended_elastic_pool_with_http_info(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) + get_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers).value! end # - # Creates or updates a database's blob auditing policy. + # Gets a database inside of a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database for which the blob - # auditing policy will be defined. - # @param parameters [DatabaseBlobAuditingPolicy] The database blob auditing - # policy. + # @param recommended_elastic_pool_name [String] The name of the elastic pool to + # be retrieved. + # @param database_name [String] The name of the database to be retrieved. # @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_or_update_blob_auditing_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + def get_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'recommended_elastic_pool_name is nil' if recommended_elastic_pool_name.nil? fail ArgumentError, 'database_name is nil' if database_name.nil? - blob_auditing_policy_name = 'default' - fail ArgumentError, 'parameters is nil' if parameters.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' request_headers = {} @@ -3399,33 +1174,24 @@ def create_or_update_blob_auditing_policy_async(resource_group_name, server_name # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'blobAuditingPolicyName' => blob_auditing_policy_name,'subscriptionId' => @client.subscription_id}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'recommendedElasticPoolName' => recommended_elastic_pool_name,'databaseName' => database_name}, query_params: {'api-version' => api_version}, - body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body - unless status_code == 200 || status_code == 201 + unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end @@ -3435,17 +1201,7 @@ def create_or_update_blob_auditing_policy_async(resource_group_name, server_name if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::DatabaseBlobAuditingPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::Database.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3459,67 +1215,62 @@ def create_or_update_blob_auditing_policy_async(resource_group_name, server_name end # - # Creates or updates a database backup long term retention policy + # Returns a list of databases inside a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database - # @param parameters [BackupLongTermRetentionPolicy] The required parameters to - # update a backup long term retention policy + # @param recommended_elastic_pool_name [String] The name of the recommended + # elastic pool to be retrieved. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [BackupLongTermRetentionPolicy] operation results. + # @return [DatabaseListResult] operation results. # - def begin_create_or_update_long_term_retention_policy(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - response = begin_create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def list_by_recommended_elastic_pool(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) + response = list_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers).value! response.body unless response.nil? end # - # Creates or updates a database backup long term retention policy + # Returns a list of databases inside a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database - # @param parameters [BackupLongTermRetentionPolicy] The required parameters to - # update a backup long term retention policy + # @param recommended_elastic_pool_name [String] The name of the recommended + # elastic pool to be retrieved. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # - def begin_create_or_update_long_term_retention_policy_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) - begin_create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + def list_by_recommended_elastic_pool_with_http_info(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) + list_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers).value! end # - # Creates or updates a database backup long term retention policy + # Returns a list of databases inside a recommented elastic pool. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database - # @param parameters [BackupLongTermRetentionPolicy] The required parameters to - # update a backup long term retention policy + # @param recommended_elastic_pool_name [String] The name of the recommended + # elastic pool to be retrieved. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # - def begin_create_or_update_long_term_retention_policy_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + def list_by_recommended_elastic_pool_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - backup_long_term_retention_policy_name = 'Default' - fail ArgumentError, 'parameters is nil' if parameters.nil? + fail ArgumentError, 'recommended_elastic_pool_name is nil' if recommended_elastic_pool_name.nil? request_headers = {} @@ -3527,33 +1278,24 @@ def begin_create_or_update_long_term_retention_policy_async(resource_group_name, # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'backupLongTermRetentionPolicyName' => backup_long_term_retention_policy_name}, + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'recommendedElasticPoolName' => recommended_elastic_pool_name}, query_params: {'api-version' => api_version}, - body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body - unless status_code == 200 || status_code == 201 || status_code == 202 + unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end @@ -3563,17 +1305,7 @@ def begin_create_or_update_long_term_retention_policy_async(resource_group_name, if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::DatabaseListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -3937,206 +1669,6 @@ def begin_export_async(resource_group_name, server_name, database_name, paramete promise.execute end - # - # Sets which replica database is primary by failing over from the current - # primary replica database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def begin_failover_replication_link(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = begin_failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - nil - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def begin_failover_replication_link_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - begin_failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def begin_failover_replication_link_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'link_id is nil' if link_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 204 || status_code == 202 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. This operation might result in data loss. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # - def begin_failover_replication_link_allow_data_loss(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - response = begin_failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - nil - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. This operation might result in data loss. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [MsRestAzure::AzureOperationResponse] HTTP response information. - # - def begin_failover_replication_link_allow_data_loss_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - begin_failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! - end - - # - # Sets which replica database is primary by failing over from the current - # primary replica database. This operation might result in data loss. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param database_name [String] The name of the database that has the - # replication link to be failed over. - # @param link_id [String] The ID of the replication link to be failed over. - # @param [Hash{String => String}] A hash of custom headers that will be added - # to the HTTP request. - # - # @return [Concurrent::Promise] Promise object which holds the HTTP response. - # - def begin_failover_replication_link_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - fail ArgumentError, 'link_id is nil' if link_id.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 204 || status_code == 202 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end - - result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? - - result - end - - promise.execute - end - # # Pauses a data warehouse. # diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_activities.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_activities.rb new file mode 100644 index 0000000000..558ceb0149 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_activities.rb @@ -0,0 +1,132 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ElasticPoolActivities + include MsRestAzure + + # + # Creates and initializes a new instance of the ElasticPoolActivities class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns elastic pool activities. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool for which to + # get the current activity. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ElasticPoolActivityListResult] operation results. + # + def list_by_elastic_pool(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + response = list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns elastic pool activities. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool for which to + # get the current activity. + # @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 list_by_elastic_pool_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! + end + + # + # Returns elastic pool activities. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool for which to + # get the current activity. + # @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 list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ElasticPoolActivityListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_database_activities.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_database_activities.rb new file mode 100644 index 0000000000..7913779f3f --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pool_database_activities.rb @@ -0,0 +1,129 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ElasticPoolDatabaseActivities + include MsRestAzure + + # + # Creates and initializes a new instance of the ElasticPoolDatabaseActivities class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns activity on databases inside of an elastic pool. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ElasticPoolDatabaseActivityListResult] operation results. + # + def list_by_elastic_pool(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + response = list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns activity on databases inside of an elastic pool. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool. + # @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 list_by_elastic_pool_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! + end + + # + # Returns activity on databases inside of an elastic pool. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param elastic_pool_name [String] The name of the elastic pool. + # @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 list_by_elastic_pool_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ElasticPoolDatabaseActivityListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pools.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pools.rb index 4542a80593..57e4761801 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pools.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/elastic_pools.rb @@ -630,423 +630,6 @@ def list_by_server_async(resource_group_name, server_name, custom_headers = nil) promise.execute end - # - # Returns elastic pool activities. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool for which to - # get the current activity. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ElasticPoolActivityListResult] operation results. - # - def list_activity(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - response = list_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns elastic pool activities. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool for which to - # get the current activity. - # @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 list_activity_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - list_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - end - - # - # Returns elastic pool activities. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool for which to - # get the current activity. - # @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 list_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ElasticPoolActivityListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns activity on databases inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ElasticPoolDatabaseActivityListResult] operation results. - # - def list_database_activity(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - response = list_database_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns activity on databases inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool. - # @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 list_database_activity_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - list_database_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - end - - # - # Returns activity on databases inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool. - # @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 list_database_activity_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ElasticPoolDatabaseActivityListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a database inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Database] operation results. - # - def get_database(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) - response = get_database_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a database inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @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_database_with_http_info(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) - get_database_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers).value! - end - - # - # Gets a database inside of an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @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_database_async(resource_group_name, server_name, elastic_pool_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases/{databaseName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::Database.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns a list of databases in an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DatabaseListResult] operation results. - # - def list_databases(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - response = list_databases_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns a list of databases in an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @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 list_databases_with_http_info(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - list_databases_async(resource_group_name, server_name, elastic_pool_name, custom_headers).value! - end - - # - # Returns a list of databases in an elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param elastic_pool_name [String] The name of the elastic pool to be - # retrieved. - # @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 list_databases_async(resource_group_name, server_name, elastic_pool_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'elastic_pool_name is nil' if elastic_pool_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'elasticPoolName' => elastic_pool_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - # # Creates a new elastic pool or updates an existing elastic pool. # diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/encryption_protectors.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/encryption_protectors.rb new file mode 100644 index 0000000000..d5cb1503dd --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/encryption_protectors.rb @@ -0,0 +1,498 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class EncryptionProtectors + include MsRestAzure + + # + # Creates and initializes a new instance of the EncryptionProtectors class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a list of server encryption protectors + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Array] operation results. + # + def list_by_server(resource_group_name, server_name, custom_headers = nil) + first_page = list_by_server_as_lazy(resource_group_name, server_name, custom_headers) + first_page.get_all_items + end + + # + # Gets a list of server encryption protectors + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_with_http_info(resource_group_name, server_name, custom_headers = nil) + list_by_server_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Gets a list of server encryption protectors + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_async(resource_group_name, server_name, custom_headers = nil) + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtectorListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a server encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [EncryptionProtector] operation results. + # + def get(resource_group_name, server_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a server encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_with_http_info(resource_group_name, server_name, custom_headers = nil) + get_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Gets a server encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_async(resource_group_name, server_name, custom_headers = nil) + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + encryption_protector_name = 'current' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'encryptionProtectorName' => encryption_protector_name,'subscriptionId' => @client.subscription_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtector.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Updates an existing encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [EncryptionProtector] The requested encryption protector + # resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [EncryptionProtector] operation results. + # + def create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [EncryptionProtector] The requested encryption protector + # resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + # Send request + promise = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::EncryptionProtector.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise + end + + # + # Updates an existing encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [EncryptionProtector] The requested encryption protector + # resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [EncryptionProtector] operation results. + # + def begin_create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Updates an existing encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [EncryptionProtector] The requested encryption protector + # resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [MsRestAzure::AzureOperationResponse] HTTP response information. + # + def begin_create_or_update_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) + begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + end + + # + # Updates an existing encryption protector. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [EncryptionProtector] The requested encryption protector + # resource state. + # @param [Hash{String => String}] A hash of custom headers that will be added + # to the HTTP request. + # + # @return [Concurrent::Promise] Promise object which holds the HTTP response. + # + def begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + encryption_protector_name = 'current' + fail ArgumentError, 'parameters is nil' if parameters.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::EncryptionProtector.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'encryptionProtectorName' => encryption_protector_name,'subscriptionId' => @client.subscription_id}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 202 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtector.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a list of server encryption protectors + # + # @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 [EncryptionProtectorListResult] operation results. + # + def list_by_server_next(next_page_link, custom_headers = nil) + response = list_by_server_next_async(next_page_link, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a list of server encryption protectors + # + # @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 list_by_server_next_with_http_info(next_page_link, custom_headers = nil) + list_by_server_next_async(next_page_link, custom_headers).value! + end + + # + # Gets a list of server encryption protectors + # + # @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 list_by_server_next_async(next_page_link, custom_headers = nil) + fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = '{nextLink}' + + request_url = @base_url || @client.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 = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtectorListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a list of server encryption protectors + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [EncryptionProtectorListResult] which provide lazy access to pages of + # the response. + # + def list_by_server_as_lazy(resource_group_name, server_name, custom_headers = nil) + response = list_by_server_async(resource_group_name, server_name, custom_headers).value! + unless response.nil? + page = response.body + page.next_method = Proc.new do |next_page_link| + list_by_server_next_async(next_page_link, custom_headers) + end + page + end + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/failover_groups.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/failover_groups.rb index 5f67f6d0ac..ee41817a30 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/failover_groups.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/failover_groups.rb @@ -235,7 +235,7 @@ def delete_async(resource_group_name, server_name, failover_group_name, custom_h # @param server_name [String] The name of the server containing the failover # group. # @param failover_group_name [String] The name of the failover group. - # @param parameters [FailoverGroup] The failover group parameters. + # @param parameters [FailoverGroupUpdate] The failover group parameters. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # @@ -253,7 +253,7 @@ def update(resource_group_name, server_name, failover_group_name, parameters, cu # @param server_name [String] The name of the server containing the failover # group. # @param failover_group_name [String] The name of the failover group. - # @param parameters [FailoverGroup] The failover group parameters. + # @param parameters [FailoverGroupUpdate] The failover group parameters. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # @@ -708,7 +708,7 @@ def begin_delete_async(resource_group_name, server_name, failover_group_name, cu # @param server_name [String] The name of the server containing the failover # group. # @param failover_group_name [String] The name of the failover group. - # @param parameters [FailoverGroup] The failover group parameters. + # @param parameters [FailoverGroupUpdate] The failover group parameters. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # @@ -728,7 +728,7 @@ def begin_update(resource_group_name, server_name, failover_group_name, paramete # @param server_name [String] The name of the server containing the failover # group. # @param failover_group_name [String] The name of the failover group. - # @param parameters [FailoverGroup] The failover group parameters. + # @param parameters [FailoverGroupUpdate] The failover group parameters. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # @@ -747,7 +747,7 @@ def begin_update_with_http_info(resource_group_name, server_name, failover_group # @param server_name [String] The name of the server containing the failover # group. # @param failover_group_name [String] The name of the failover group. - # @param parameters [FailoverGroup] The failover group parameters. + # @param parameters [FailoverGroupUpdate] The failover group parameters. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # @@ -771,7 +771,7 @@ def begin_update_async(resource_group_name, server_name, failover_group_name, pa request_headers['Content-Type'] = 'application/json; charset=utf-8' # Serialize Request - request_mapper = Azure::ARM::SQL::Models::FailoverGroup.mapper() + request_mapper = Azure::ARM::SQL::Models::FailoverGroupUpdate.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/geo_backup_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/geo_backup_policies.rb new file mode 100644 index 0000000000..6fc10ff22a --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/geo_backup_policies.rb @@ -0,0 +1,359 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class GeoBackupPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the GeoBackupPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Updates a database geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [GeoBackupPolicy] The required parameters for creating or + # updating the geo backup policy. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [GeoBackupPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Updates a database geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [GeoBackupPolicy] The required parameters for creating or + # updating the geo backup policy. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Updates a database geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param parameters [GeoBackupPolicy] The required parameters for creating or + # updating the geo backup policy. + # @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_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + geo_backup_policy_name = 'Default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::GeoBackupPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'geoBackupPolicyName' => geo_backup_policy_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 == 201 || status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 200 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::GeoBackupPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [GeoBackupPolicy] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a geo backup policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + geo_backup_policy_name = 'Default' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'geoBackupPolicyName' => geo_backup_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Returns a list of geo backup policies. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [GeoBackupPolicyListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns a list of geo backup policies. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Returns a list of geo backup policies. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::GeoBackupPolicyListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_usage.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_usage.rb index 7cb27b2e97..42bc49ea20 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_usage.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_usage.rb @@ -8,11 +8,14 @@ module Models # # The database usages. # - class DatabaseUsage < SubResource + class DatabaseUsage include MsRestAzure include MsRest::JSONable + # @return [String] The name of the usage metric. + attr_accessor :name + # @return [String] The name of the resource. attr_accessor :resource_name @@ -53,14 +56,6 @@ def self.mapper() name: 'String' } }, - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, resource_name: { required: false, read_only: true, diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/encryption_protector.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/encryption_protector.rb index e2bb778a36..589007b2b9 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/encryption_protector.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/encryption_protector.rb @@ -13,9 +13,8 @@ class EncryptionProtector < ProxyResource include MsRestAzure include MsRest::JSONable - # @return [Enum] Kind of encryption protector. This is metadata used for - # the Azure portal experience. Possible values include: '', - # 'azurekeyvault', 'servicemanaged' + # @return [String] Kind of encryption protector. This is metadata used + # for the Azure portal experience. attr_accessor :kind # @return [String] Resource location. @@ -106,7 +105,7 @@ def self.mapper() } }, server_key_type: { - required: false, + required: true, serialized_name: 'properties.serverKeyType', type: { name: 'String' diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group.rb index e9affc1a92..841b28587d 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group.rb @@ -102,7 +102,7 @@ def self.mapper() } }, read_write_endpoint: { - required: false, + required: true, serialized_name: 'properties.readWriteEndpoint', type: { name: 'Composite', @@ -134,7 +134,7 @@ def self.mapper() } }, partner_servers: { - required: false, + required: true, serialized_name: 'properties.partnerServers', type: { name: 'Sequence', diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb index d7a4b85900..f3ed33252f 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb @@ -14,12 +14,14 @@ class FailoverGroupReadWriteEndpoint include MsRest::JSONable # @return [ReadWriteEndpointFailoverPolicy] Failover policy of the - # read-write endpoint for the failover group. Possible values include: - # 'Manual', 'Automatic' + # read-write endpoint for the failover group. If failoverPolicy is + # Automatic then failoverWithDataLossGracePeriodMinutes is required. + # Possible values include: 'Manual', 'Automatic' attr_accessor :failover_policy # @return [Integer] Grace period before failover with data loss is - # attempted for the read-write endpoint. + # attempted for the read-write endpoint. If failoverPolicy is Automatic + # then failoverWithDataLossGracePeriodMinutes is required. attr_accessor :failover_with_data_loss_grace_period_minutes @@ -36,7 +38,7 @@ def self.mapper() class_name: 'FailoverGroupReadWriteEndpoint', model_properties: { failover_policy: { - required: false, + required: true, serialized_name: 'failoverPolicy', type: { name: 'String' diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_update.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_update.rb new file mode 100644 index 0000000000..2e0682f4a3 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/failover_group_update.rb @@ -0,0 +1,93 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + module Models + # + # A failover group update request. + # + class FailoverGroupUpdate + + include MsRestAzure + + include MsRest::JSONable + # @return [FailoverGroupReadWriteEndpoint] Read-write endpoint of the + # failover group instance. + attr_accessor :read_write_endpoint + + # @return [FailoverGroupReadOnlyEndpoint] Read-only endpoint of the + # failover group instance. + attr_accessor :read_only_endpoint + + # @return [Array] List of databases in the failover group. + attr_accessor :databases + + # @return [Hash{String => String}] Resource tags. + attr_accessor :tags + + + # + # Mapper for FailoverGroupUpdate class as Ruby Hash. + # This will be used for serialization/deserialization. + # + def self.mapper() + { + required: false, + serialized_name: 'FailoverGroupUpdate', + type: { + name: 'Composite', + class_name: 'FailoverGroupUpdate', + model_properties: { + read_write_endpoint: { + required: false, + serialized_name: 'properties.readWriteEndpoint', + type: { + name: 'Composite', + class_name: 'FailoverGroupReadWriteEndpoint' + } + }, + read_only_endpoint: { + required: false, + serialized_name: 'properties.readOnlyEndpoint', + type: { + name: 'Composite', + class_name: 'FailoverGroupReadOnlyEndpoint' + } + }, + databases: { + required: false, + serialized_name: 'properties.databases', + type: { + name: 'Sequence', + element: { + required: false, + serialized_name: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + tags: { + required: false, + serialized_name: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serialized_name: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + } + end + end + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/firewall_rule.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/firewall_rule.rb index 78fa508065..3c47c324f1 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/firewall_rule.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/firewall_rule.rb @@ -8,7 +8,7 @@ module Models # # Represents a server firewall rule. # - class FirewallRule < SubResource + class FirewallRule < ProxyResource include MsRestAzure @@ -20,9 +20,6 @@ class FirewallRule < SubResource # rule. attr_accessor :location - # @return [String] Type of resource this is. - attr_accessor :type - # @return [String] The start IP address of the firewall rule. Must be # IPv4 format. Use value '0.0.0.0' to represent all Azure-internal IP # addresses. @@ -46,42 +43,42 @@ def self.mapper() name: 'Composite', class_name: 'FirewallRule', model_properties: { - name: { + id: { required: false, read_only: true, - serialized_name: 'name', + serialized_name: 'id', type: { name: 'String' } }, - id: { + name: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'name', type: { name: 'String' } }, - kind: { + type: { required: false, read_only: true, - serialized_name: 'kind', + serialized_name: 'type', type: { name: 'String' } }, - location: { + kind: { required: false, read_only: true, - serialized_name: 'location', + serialized_name: 'kind', type: { name: 'String' } }, - type: { + location: { required: false, read_only: true, - serialized_name: 'type', + serialized_name: 'location', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/metric_value.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/metric_value.rb index b8973ebcb8..6b14a86312 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/metric_value.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/metric_value.rb @@ -8,7 +8,7 @@ module Models # # Represents database metrics. # - class MetricValue < SubResource + class MetricValue include MsRestAzure @@ -44,22 +44,6 @@ def self.mapper() name: 'Composite', class_name: 'MetricValue', model_properties: { - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - }, count: { required: false, read_only: true, diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/partner_info.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/partner_info.rb index 81b16f25b5..d819d273b0 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/partner_info.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/partner_info.rb @@ -37,7 +37,7 @@ def self.mapper() class_name: 'PartnerInfo', model_properties: { id: { - required: false, + required: true, serialized_name: 'id', type: { name: 'String' diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/replication_link.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/replication_link.rb index 1bf0d02f2b..f4d148c5ef 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/replication_link.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/replication_link.rb @@ -8,7 +8,7 @@ module Models # # Represents a database replication link. # - class ReplicationLink < SubResource + class ReplicationLink < ProxyResource include MsRestAzure @@ -17,9 +17,6 @@ class ReplicationLink < SubResource # rule. attr_accessor :location - # @return [String] Type of resource this is. - attr_accessor :type - # @return [Boolean] Legacy value indicating whether termination is # allowed. Currently always returns true. attr_accessor :is_termination_allowed @@ -71,34 +68,34 @@ def self.mapper() name: 'Composite', class_name: 'ReplicationLink', model_properties: { - name: { + id: { required: false, read_only: true, - serialized_name: 'name', + serialized_name: 'id', type: { name: 'String' } }, - id: { + name: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'name', type: { name: 'String' } }, - location: { + type: { required: false, read_only: true, - serialized_name: 'location', + serialized_name: 'type', type: { name: 'String' } }, - type: { + location: { required: false, read_only: true, - serialized_name: 'type', + serialized_name: 'location', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_azure_adadministrator.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_azure_adadministrator.rb index 8b82b0d1dc..7e12358bf8 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_azure_adadministrator.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_azure_adadministrator.rb @@ -8,7 +8,7 @@ module Models # # An server Active Directory Administrator. # - class ServerAzureADAdministrator < SqlSubResource + class ServerAzureADAdministrator < ProxyResource include MsRestAzure @@ -39,6 +39,14 @@ def self.mapper() name: 'Composite', class_name: 'ServerAzureADAdministrator', model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, name: { required: false, read_only: true, @@ -47,10 +55,10 @@ def self.mapper() name: 'String' } }, - id: { + type: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'type', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_key.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_key.rb index 727b5efe50..ddf30c33dc 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_key.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/server_key.rb @@ -13,9 +13,8 @@ class ServerKey < ProxyResource include MsRestAzure include MsRest::JSONable - # @return [Enum] Kind of encryption protector. This is metadata used for - # the Azure portal experience. Possible values include: '', - # 'azurekeyvault', 'servicemanaged' + # @return [String] Kind of encryption protector. This is metadata used + # for the Azure portal experience. attr_accessor :kind # @return [String] Resource location. @@ -99,7 +98,7 @@ def self.mapper() } }, server_key_type: { - required: false, + required: true, serialized_name: 'properties.serverKeyType', type: { name: 'String' diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_objective.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_objective.rb index a10ed02330..ede08ad6f2 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_objective.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_objective.rb @@ -8,7 +8,7 @@ module Models # # Represents a database service objective. # - class ServiceObjective < SubResource + class ServiceObjective < ProxyResource include MsRestAzure @@ -43,6 +43,14 @@ def self.mapper() name: 'Composite', class_name: 'ServiceObjective', model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, name: { required: false, read_only: true, @@ -51,10 +59,10 @@ def self.mapper() name: 'String' } }, - id: { + type: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'type', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_tier_advisor.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_tier_advisor.rb index 2daa7b65ec..a0154e4804 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_tier_advisor.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/service_tier_advisor.rb @@ -8,7 +8,7 @@ module Models # # Represents a Service Tier Advisor. # - class ServiceTierAdvisor < SubResource + class ServiceTierAdvisor < ProxyResource include MsRestAzure @@ -98,6 +98,14 @@ def self.mapper() name: 'Composite', class_name: 'ServiceTierAdvisor', model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, name: { required: false, read_only: true, @@ -106,10 +114,10 @@ def self.mapper() name: 'String' } }, - id: { + type: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'type', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sql_sub_resource.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sql_sub_resource.rb deleted file mode 100644 index da8b01633c..0000000000 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sql_sub_resource.rb +++ /dev/null @@ -1,57 +0,0 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Azure::ARM::SQL - module Models - # - # Subresource properties - # - class SqlSubResource - - include MsRestAzure - - include MsRest::JSONable - # @return [String] Resource name - attr_accessor :name - - # @return [String] Resource Id - attr_accessor :id - - - # - # Mapper for SqlSubResource class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'SqlSubResource', - type: { - name: 'Composite', - class_name: 'SqlSubResource', - model_properties: { - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sub_resource.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sub_resource.rb deleted file mode 100644 index 9f1a03a607..0000000000 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/sub_resource.rb +++ /dev/null @@ -1,54 +0,0 @@ -# encoding: utf-8 -# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. - -module Azure::ARM::SQL - module Models - # - # Subresource properties - # - class SubResource < MsRestAzure::SubResource - - include MsRestAzure - - include MsRest::JSONable - # @return [String] Resource name - attr_accessor :name - - - # - # Mapper for SubResource class as Ruby Hash. - # This will be used for serialization/deserialization. - # - def self.mapper() - { - required: false, - serialized_name: 'SubResource', - type: { - name: 'Composite', - class_name: 'SubResource', - model_properties: { - name: { - required: false, - read_only: true, - serialized_name: 'name', - type: { - name: 'String' - } - }, - id: { - required: false, - read_only: true, - serialized_name: 'id', - type: { - name: 'String' - } - } - } - } - } - end - end - end -end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption.rb index 422ee51e0f..610e91a93b 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption.rb @@ -8,11 +8,14 @@ module Models # # Represents a database transparent data encryption configuration. # - class TransparentDataEncryption < SubResource + class TransparentDataEncryption < ProxyResource include MsRestAzure include MsRest::JSONable + # @return [String] Resource location. + attr_accessor :location + # @return [TransparentDataEncryptionStatus] The status of the database # transparent data encryption. Possible values include: 'Enabled', # 'Disabled' @@ -31,6 +34,14 @@ def self.mapper() name: 'Composite', class_name: 'TransparentDataEncryption', model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, name: { required: false, read_only: true, @@ -39,10 +50,18 @@ def self.mapper() name: 'String' } }, - id: { + type: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + read_only: true, + serialized_name: 'location', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption_activity.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption_activity.rb index 0a88ca7201..e81d911a29 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption_activity.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/transparent_data_encryption_activity.rb @@ -8,11 +8,14 @@ module Models # # Represents a database transparent data encryption Scan. # - class TransparentDataEncryptionActivity < SubResource + class TransparentDataEncryptionActivity < ProxyResource include MsRestAzure include MsRest::JSONable + # @return [String] Resource location. + attr_accessor :location + # @return [TransparentDataEncryptionActivityStatus] The status of the # database. Possible values include: 'Encrypting', 'Decrypting' attr_accessor :status @@ -34,6 +37,14 @@ def self.mapper() name: 'Composite', class_name: 'TransparentDataEncryptionActivity', model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, name: { required: false, read_only: true, @@ -42,10 +53,18 @@ def self.mapper() name: 'String' } }, - id: { + type: { required: false, read_only: true, - serialized_name: 'id', + serialized_name: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + read_only: true, + serialized_name: 'location', type: { name: 'String' } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule.rb index ef04d52d33..351f8de3f7 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule.rb @@ -13,9 +13,18 @@ class VirtualNetworkRule < ProxyResource include MsRestAzure include MsRest::JSONable - # @return [String] The resource ID of the virtual network subnet + # @return [String] The ARM resource id of the virtual network subnet. attr_accessor :virtual_network_subnet_id + # @return [Boolean] Create firewall rule before the virtual network has + # private access enabled. + attr_accessor :ignore_vnet_private_access_configuration + + # @return [VirtualNetworkRuleState] Virtual network rule state. Possible + # values include: 'Initializing', 'InProgress', 'Ready', 'Deleting', + # 'Unknown' + attr_accessor :state + # # Mapper for VirtualNetworkRule class as Ruby Hash. @@ -54,11 +63,26 @@ def self.mapper() } }, virtual_network_subnet_id: { - required: false, + required: true, serialized_name: 'properties.virtualNetworkSubnetId', type: { name: 'String' } + }, + ignore_vnet_private_access_configuration: { + required: false, + serialized_name: 'properties.ignoreVnetPrivateAccessConfiguration', + type: { + name: 'Boolean' + } + }, + state: { + required: false, + read_only: true, + serialized_name: 'properties.state', + type: { + name: 'String' + } } } } diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule_state.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule_state.rb new file mode 100644 index 0000000000..f2350c861a --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/virtual_network_rule_state.rb @@ -0,0 +1,19 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + module Models + # + # Defines values for VirtualNetworkRuleState + # + module VirtualNetworkRuleState + Initializing = "Initializing" + InProgress = "InProgress" + Ready = "Ready" + Deleting = "Deleting" + Unknown = "Unknown" + end + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/recommended_elastic_pools.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/recommended_elastic_pools.rb index 6fca827f29..589be6e516 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/recommended_elastic_pools.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/recommended_elastic_pools.rb @@ -128,114 +128,6 @@ def get_async(resource_group_name, server_name, recommended_elastic_pool_name, c promise.execute end - # - # Gets a database inside of a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the elastic pool to - # be retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Database] operation results. - # - def get_databases(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) - response = get_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a database inside of a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the elastic pool to - # be retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @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_databases_with_http_info(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) - get_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers).value! - end - - # - # Gets a database inside of a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the elastic pool to - # be retrieved. - # @param database_name [String] The name of the database to be retrieved. - # @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_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'recommended_elastic_pool_name is nil' if recommended_elastic_pool_name.nil? - fail ArgumentError, 'database_name is nil' if database_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'recommendedElasticPoolName' => recommended_elastic_pool_name,'databaseName' => database_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::Database.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - # # Returns recommended elastic pools. # @@ -334,111 +226,7 @@ def list_by_server_async(resource_group_name, server_name, custom_headers = nil) end # - # Returns a list of databases inside a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the recommended - # elastic pool to be retrieved. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [DatabaseListResult] operation results. - # - def list_databases(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) - response = list_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns a list of databases inside a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the recommended - # elastic pool to be retrieved. - # @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 list_databases_with_http_info(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) - list_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers).value! - end - - # - # Returns a list of databases inside a recommented elastic pool. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param recommended_elastic_pool_name [String] The name of the recommended - # elastic pool to be retrieved. - # @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 list_databases_async(resource_group_name, server_name, recommended_elastic_pool_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'recommended_elastic_pool_name is nil' if recommended_elastic_pool_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'recommendedElasticPoolName' => recommended_elastic_pool_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::DatabaseListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns a recommented elastic pool metrics. + # Returns recommented elastic pool metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -457,7 +245,7 @@ def list_metrics(resource_group_name, server_name, recommended_elastic_pool_name end # - # Returns a recommented elastic pool metrics. + # Returns recommented elastic pool metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -475,7 +263,7 @@ def list_metrics_with_http_info(resource_group_name, server_name, recommended_el end # - # Returns a recommented elastic pool metrics. + # Returns recommented elastic pool metrics. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/replication_links.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/replication_links.rb new file mode 100644 index 0000000000..c522e0dbcb --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/replication_links.rb @@ -0,0 +1,629 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ReplicationLinks + include MsRestAzure + + # + # Creates and initializes a new instance of the ReplicationLinks class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Deletes a database replication link. Cannot be done during failover. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be dropped. + # @param link_id [String] The ID of the replication link to be deleted. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # + def delete(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = delete_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + nil + end + + # + # Deletes a database replication link. Cannot be done during failover. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be dropped. + # @param link_id [String] The ID of the replication link to be deleted. + # @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_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + delete_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + end + + # + # Deletes a database replication link. Cannot be done during failover. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be dropped. + # @param link_id [String] The ID of the replication link to be deleted. + # @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_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + fail ArgumentError, 'link_id is nil' if link_id.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 204 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) + end + + result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? + + result + end + + promise.execute + end + + # + # Gets a database replication link. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get the link for. + # @param link_id [String] The replication link ID to be retrieved. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ReplicationLink] operation results. + # + def get(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database replication link. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get the link for. + # @param link_id [String] The replication link ID to be retrieved. + # @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_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + end + + # + # Gets a database replication link. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get the link for. + # @param link_id [String] The replication link ID to be retrieved. + # @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_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + fail ArgumentError, 'link_id is nil' if link_id.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ReplicationLink.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + def failover(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = failover_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + nil + end + + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def failover_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + # Send request + promise = begin_failover_async(resource_group_name, server_name, database_name, link_id, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. This operation might result in data loss. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + def failover_allow_data_loss(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + nil + end + + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + # Send request + promise = begin_failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise + end + + # + # Lists a database's replication links. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to retrieve links for. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ReplicationLinkListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Lists a database's replication links. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to retrieve links for. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Lists a database's replication links. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to retrieve links for. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ReplicationLinkListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # + def begin_failover(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = begin_failover_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + nil + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [MsRestAzure::AzureOperationResponse] HTTP response information. + # + def begin_failover_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + begin_failover_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param [Hash{String => String}] A hash of custom headers that will be added + # to the HTTP request. + # + # @return [Concurrent::Promise] Promise object which holds the HTTP response. + # + def begin_failover_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + fail ArgumentError, 'link_id is nil' if link_id.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:post, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 204 || status_code == 202 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) + end + + result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? + + result + end + + promise.execute + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. This operation might result in data loss. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # + def begin_failover_allow_data_loss(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + response = begin_failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + nil + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. This operation might result in data loss. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [MsRestAzure::AzureOperationResponse] HTTP response information. + # + def begin_failover_allow_data_loss_with_http_info(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + begin_failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers).value! + end + + # + # Sets which replica database is primary by failing over from the current + # primary replica database. This operation might result in data loss. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database that has the + # replication link to be failed over. + # @param link_id [String] The ID of the replication link to be failed over. + # @param [Hash{String => String}] A hash of custom headers that will be added + # to the HTTP request. + # + # @return [Concurrent::Promise] Promise object which holds the HTTP response. + # + def begin_failover_allow_data_loss_async(resource_group_name, server_name, database_name, link_id, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + fail ArgumentError, 'link_id is nil' if link_id.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'linkId' => link_id}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:post, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 204 || status_code == 202 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) + end + + result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/restore_points.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/restore_points.rb new file mode 100644 index 0000000000..f97e73a260 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/restore_points.rb @@ -0,0 +1,132 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class RestorePoints + include MsRestAzure + + # + # Creates and initializes a new instance of the RestorePoints class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a list of database restore points. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get available + # restore points. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [RestorePointListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a list of database restore points. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get available + # restore points. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a list of database restore points. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database to get available + # restore points. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::RestorePointListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_azure_adadministrators.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_azure_adadministrators.rb index 1f190c8c2c..95b9a92ff3 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_azure_adadministrators.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_azure_adadministrators.rb @@ -231,8 +231,8 @@ def get_async(resource_group_name, server_name, custom_headers = nil) # # @return [ServerAdministratorListResult] operation results. # - def list(resource_group_name, server_name, custom_headers = nil) - response = list_async(resource_group_name, server_name, custom_headers).value! + def list_by_server(resource_group_name, server_name, custom_headers = nil) + response = list_by_server_async(resource_group_name, server_name, custom_headers).value! response.body unless response.nil? end @@ -248,8 +248,8 @@ def list(resource_group_name, server_name, custom_headers = nil) # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # - def list_with_http_info(resource_group_name, server_name, custom_headers = nil) - list_async(resource_group_name, server_name, custom_headers).value! + def list_by_server_with_http_info(resource_group_name, server_name, custom_headers = nil) + list_by_server_async(resource_group_name, server_name, custom_headers).value! end # @@ -264,7 +264,7 @@ def list_with_http_info(resource_group_name, server_name, custom_headers = nil) # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # - def list_async(resource_group_name, server_name, custom_headers = nil) + def list_by_server_async(resource_group_name, server_name, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_connection_policies.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_connection_policies.rb new file mode 100644 index 0000000000..5efd30df59 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_connection_policies.rb @@ -0,0 +1,250 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ServerConnectionPolicies + include MsRestAzure + + # + # Creates and initializes a new instance of the ServerConnectionPolicies class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Creates or updates the server's connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [ServerConnectionPolicy] The required parameters for + # updating a secure connection policy. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServerConnectionPolicy] operation results. + # + def create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates the server's connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [ServerConnectionPolicy] The required parameters for + # updating a secure connection policy. + # @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_or_update_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! + end + + # + # Creates or updates the server's connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [ServerConnectionPolicy] The required parameters for + # updating a secure connection policy. + # @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_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + connection_policy_name = 'default' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'connectionPolicyName' => connection_policy_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerConnectionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets the server's secure connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServerConnectionPolicy] operation results. + # + def get(resource_group_name, server_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets the server's secure connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_with_http_info(resource_group_name, server_name, custom_headers = nil) + get_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Gets the server's secure connection policy. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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_async(resource_group_name, server_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + connection_policy_name = 'default' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'connectionPolicyName' => connection_policy_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerConnectionPolicy.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_keys.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_keys.rb index 11824fa519..7b42b7ce59 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_keys.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_keys.rb @@ -25,7 +25,7 @@ def initialize(client) attr_reader :client # - # Returns a list of server keys. + # Gets a list of server keys. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -42,7 +42,7 @@ def list_by_server(resource_group_name, server_name, custom_headers = nil) end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -58,7 +58,7 @@ def list_by_server_with_http_info(resource_group_name, server_name, custom_heade end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -122,7 +122,7 @@ def list_by_server_async(resource_group_name, server_name, custom_headers = nil) end # - # Returns a server key. + # Gets a server key. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -140,7 +140,7 @@ def get(resource_group_name, server_name, key_name, custom_headers = nil) end # - # Returns a server key. + # Gets a server key. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -157,7 +157,7 @@ def get_with_http_info(resource_group_name, server_name, key_name, custom_header end # - # Returns a server key. + # Gets a server key. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -556,7 +556,7 @@ def begin_delete_async(resource_group_name, server_name, key_name, custom_header end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. @@ -571,7 +571,7 @@ def list_by_server_next(next_page_link, custom_headers = nil) end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. @@ -585,7 +585,7 @@ def list_by_server_next_with_http_info(next_page_link, custom_headers = nil) end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. @@ -643,7 +643,7 @@ def list_by_server_next_async(next_page_link, custom_headers = nil) end # - # Returns a list of server keys. + # Gets a list of server keys. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_usages.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_usages.rb new file mode 100644 index 0000000000..585b0d8421 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/server_usages.rb @@ -0,0 +1,125 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ServerUsages + include MsRestAzure + + # + # Creates and initializes a new instance of the ServerUsages class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns server usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServerUsageListResult] operation results. + # + def list_by_server(resource_group_name, server_name, custom_headers = nil) + response = list_by_server_async(resource_group_name, server_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns server usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_with_http_info(resource_group_name, server_name, custom_headers = nil) + list_by_server_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Returns server usages. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_async(resource_group_name, server_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerUsageListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/servers.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/servers.rb index 630de86e12..e9b6e2039c 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/servers.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/servers.rb @@ -25,210 +25,47 @@ def initialize(client) attr_reader :client # - # Gets a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [BackupLongTermRetentionVault] operation results. - # - def get_backup_long_term_retention_vault(resource_group_name, server_name, custom_headers = nil) - response = get_backup_long_term_retention_vault_async(resource_group_name, server_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_backup_long_term_retention_vault_with_http_info(resource_group_name, server_name, custom_headers = nil) - get_backup_long_term_retention_vault_async(resource_group_name, server_name, custom_headers).value! - end - - # - # Gets a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_backup_long_term_retention_vault_async(resource_group_name, server_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - backup_long_term_retention_vault_name = 'RegisteredVault' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'backupLongTermRetentionVaultName' => backup_long_term_retention_vault_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Updates a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [BackupLongTermRetentionVault] The required parameters to - # update a backup long term retention vault - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [BackupLongTermRetentionVault] operation results. - # - def create_backup_long_term_retention_vault(resource_group_name, server_name, parameters, custom_headers = nil) - response = create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [BackupLongTermRetentionVault] The required parameters to - # update a backup long term retention vault - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Creates or updates the server's connection policy. + # Determines whether a resource can be created with the specified name. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ServerConnectionPolicy] The required parameters for - # updating a secure connection policy. + # @param parameters [CheckNameAvailabilityRequest] The parameters to request + # for name availability. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServerConnectionPolicy] operation results. + # @return [CheckNameAvailabilityResponse] operation results. # - def create_or_update_connection_policy(resource_group_name, server_name, parameters, custom_headers = nil) - response = create_or_update_connection_policy_async(resource_group_name, server_name, parameters, custom_headers).value! + def check_name_availability(parameters, custom_headers = nil) + response = check_name_availability_async(parameters, custom_headers).value! response.body unless response.nil? end # - # Creates or updates the server's connection policy. + # Determines whether a resource can be created with the specified name. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ServerConnectionPolicy] The required parameters for - # updating a secure connection policy. + # @param parameters [CheckNameAvailabilityRequest] The parameters to request + # for name availability. # @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_or_update_connection_policy_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) - create_or_update_connection_policy_async(resource_group_name, server_name, parameters, custom_headers).value! + def check_name_availability_with_http_info(parameters, custom_headers = nil) + check_name_availability_async(parameters, custom_headers).value! end # - # Creates or updates the server's connection policy. + # Determines whether a resource can be created with the specified name. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ServerConnectionPolicy] The required parameters for - # updating a secure connection policy. + # @param parameters [CheckNameAvailabilityRequest] The parameters to request + # for name availability. # @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_or_update_connection_policy_async(resource_group_name, server_name, parameters, custom_headers = nil) + def check_name_availability_async(parameters, custom_headers = nil) api_version = '2014-04-01' fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - connection_policy_name = 'default' fail ArgumentError, 'parameters is nil' if parameters.nil? @@ -241,29 +78,29 @@ def create_or_update_connection_policy_async(resource_group_name, server_name, p request_headers['Content-Type'] = 'application/json; charset=utf-8' # Serialize Request - request_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() + request_mapper = Azure::ARM::SQL::Models::CheckNameAvailabilityRequest.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}' + path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'connectionPolicyName' => connection_policy_name}, + path_params: {'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.make_request_async(:post, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body - unless status_code == 200 || status_code == 201 + unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end @@ -273,17 +110,7 @@ def create_or_update_connection_policy_async(resource_group_name, server_name, p if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::CheckNameAvailabilityResponse.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -297,56 +124,41 @@ def create_or_update_connection_policy_async(resource_group_name, server_name, p end # - # Gets the server's secure connection policy. + # Gets a list of all servers in the subscription. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServerConnectionPolicy] operation results. + # @return [Array] operation results. # - def get_connection_policy(resource_group_name, server_name, custom_headers = nil) - response = get_connection_policy_async(resource_group_name, server_name, custom_headers).value! - response.body unless response.nil? + def list(custom_headers = nil) + first_page = list_as_lazy(custom_headers) + first_page.get_all_items end # - # Gets the server's secure connection policy. + # Gets a list of all servers in the subscription. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. # @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_connection_policy_with_http_info(resource_group_name, server_name, custom_headers = nil) - get_connection_policy_async(resource_group_name, server_name, custom_headers).value! + def list_with_http_info(custom_headers = nil) + list_async(custom_headers).value! end # - # Gets the server's secure connection policy. + # Gets a list of all servers in the subscription. # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. # @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_connection_policy_async(resource_group_name, server_name, custom_headers = nil) - api_version = '2014-04-01' + def list_async(custom_headers = nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - connection_policy_name = 'default' + api_version = '2015-05-01-preview' request_headers = {} @@ -354,13 +166,13 @@ def get_connection_policy_async(resource_group_name, server_name, custom_headers # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}' + path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'connectionPolicyName' => connection_policy_name}, + path_params: {'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url @@ -381,7 +193,7 @@ def get_connection_policy_async(resource_group_name, server_name, custom_headers if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::ServerConnectionPolicy.mapper() + result_mapper = Azure::ARM::SQL::Models::ServerListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -395,62 +207,51 @@ def get_connection_policy_async(resource_group_name, server_name, custom_headers end # - # Gets a database service objective. + # Gets a list of servers in a resource groups. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param service_objective_name [String] The name of the service objective to - # retrieve. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServiceObjective] operation results. + # @return [Array] operation results. # - def get_service_objective(resource_group_name, server_name, service_objective_name, custom_headers = nil) - response = get_service_objective_async(resource_group_name, server_name, service_objective_name, custom_headers).value! - response.body unless response.nil? + def list_by_resource_group(resource_group_name, custom_headers = nil) + first_page = list_by_resource_group_as_lazy(resource_group_name, custom_headers) + first_page.get_all_items end # - # Gets a database service objective. + # Gets a list of servers in a resource groups. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param service_objective_name [String] The name of the service objective to - # retrieve. # @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_service_objective_with_http_info(resource_group_name, server_name, service_objective_name, custom_headers = nil) - get_service_objective_async(resource_group_name, server_name, service_objective_name, custom_headers).value! + def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil) + list_by_resource_group_async(resource_group_name, custom_headers).value! end # - # Gets a database service objective. + # Gets a list of servers in a resource groups. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param service_objective_name [String] The name of the service objective to - # retrieve. # @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_service_objective_async(resource_group_name, server_name, service_objective_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + def list_by_resource_group_async(resource_group_name, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, 'service_objective_name is nil' if service_objective_name.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' request_headers = {} @@ -458,13 +259,13 @@ def get_service_objective_async(resource_group_name, server_name, service_object # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}' + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'serviceObjectiveName' => service_objective_name}, + path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url @@ -485,7 +286,7 @@ def get_service_objective_async(resource_group_name, server_name, service_object if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::ServiceObjective.mapper() + result_mapper = Azure::ARM::SQL::Models::ServerListResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -499,7 +300,7 @@ def get_service_objective_async(resource_group_name, server_name, service_object end # - # Returns database service objectives. + # Gets a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -508,15 +309,15 @@ def get_service_objective_async(resource_group_name, server_name, service_object # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [ServiceObjectiveListResult] operation results. + # @return [Server] operation results. # - def list_service_objectives(resource_group_name, server_name, custom_headers = nil) - response = list_service_objectives_async(resource_group_name, server_name, custom_headers).value! + def get(resource_group_name, server_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, custom_headers).value! response.body unless response.nil? end # - # Returns database service objectives. + # Gets a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -527,12 +328,12 @@ def list_service_objectives(resource_group_name, server_name, custom_headers = n # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # - def list_service_objectives_with_http_info(resource_group_name, server_name, custom_headers = nil) - list_service_objectives_async(resource_group_name, server_name, custom_headers).value! + def get_with_http_info(resource_group_name, server_name, custom_headers = nil) + get_async(resource_group_name, server_name, custom_headers).value! end # - # Returns database service objectives. + # Gets a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource @@ -543,1002 +344,36 @@ def list_service_objectives_with_http_info(resource_group_name, server_name, cus # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # - def list_service_objectives_async(resource_group_name, server_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + def get_async(resource_group_name, server_name, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2015-05-01-preview' request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceObjectiveListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Determines whether a resource can be created with the specified name. - # - # @param parameters [CheckNameAvailabilityRequest] The parameters to request - # for name availability. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [CheckNameAvailabilityResponse] operation results. - # - def check_name_availability(parameters, custom_headers = nil) - response = check_name_availability_async(parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Determines whether a resource can be created with the specified name. - # - # @param parameters [CheckNameAvailabilityRequest] The parameters to request - # for name availability. - # @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 check_name_availability_with_http_info(parameters, custom_headers = nil) - check_name_availability_async(parameters, custom_headers).value! - end - - # - # Determines whether a resource can be created with the specified name. - # - # @param parameters [CheckNameAvailabilityRequest] The parameters to request - # for name availability. - # @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 check_name_availability_async(parameters, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'parameters is nil' if parameters.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::CheckNameAvailabilityRequest.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:post, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::CheckNameAvailabilityResponse.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns server usages. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [ServerUsageListResult] operation results. - # - def list_usages(resource_group_name, server_name, custom_headers = nil) - response = list_usages_async(resource_group_name, server_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns server usages. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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 list_usages_with_http_info(resource_group_name, server_name, custom_headers = nil) - list_usages_async(resource_group_name, server_name, custom_headers).value! - end - - # - # Returns server usages. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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 list_usages_async(resource_group_name, server_name, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerUsageListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns a list of the server encryption protectors - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def list_encryption_protectors(resource_group_name, server_name, custom_headers = nil) - first_page = list_encryption_protectors_as_lazy(resource_group_name, server_name, custom_headers) - first_page.get_all_items - end - - # - # Returns a list of the server encryption protectors - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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 list_encryption_protectors_with_http_info(resource_group_name, server_name, custom_headers = nil) - list_encryption_protectors_async(resource_group_name, server_name, custom_headers).value! - end - - # - # Returns a list of the server encryption protectors - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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 list_encryption_protectors_async(resource_group_name, server_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtectorListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Returns the server encryption protector. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [EncryptionProtector] operation results. - # - def get_encryption_protector(resource_group_name, server_name, custom_headers = nil) - response = get_encryption_protector_async(resource_group_name, server_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns the server encryption protector. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_encryption_protector_with_http_info(resource_group_name, server_name, custom_headers = nil) - get_encryption_protector_async(resource_group_name, server_name, custom_headers).value! - end - - # - # Returns the server encryption protector. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_encryption_protector_async(resource_group_name, server_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - encryption_protector_name = 'current' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'encryptionProtectorName' => encryption_protector_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtector.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Updates an existing encryption protector. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [EncryptionProtector] The requested encryption protector - # resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [EncryptionProtector] operation results. - # - def create_or_update_encryption_protector(resource_group_name, server_name, parameters, custom_headers = nil) - response = create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [EncryptionProtector] The requested encryption protector - # resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::EncryptionProtector.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Gets a list of all servers in the subscription. - # - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def list(custom_headers = nil) - first_page = list_as_lazy(custom_headers) - first_page.get_all_items - end - - # - # Gets a list of all servers in the subscription. - # - # @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 list_with_http_info(custom_headers = nil) - list_async(custom_headers).value! - end - - # - # Gets a list of all servers in the subscription. - # - # @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 list_async(custom_headers = nil) - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a list of servers in a resource groups. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Array] operation results. - # - def list_by_resource_group(resource_group_name, custom_headers = nil) - first_page = list_by_resource_group_as_lazy(resource_group_name, custom_headers) - first_page.get_all_items - end - - # - # Gets a list of servers in a resource groups. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @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 list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil) - list_by_resource_group_async(resource_group_name, custom_headers).value! - end - - # - # Gets a list of servers in a resource groups. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @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 list_by_resource_group_async(resource_group_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServerListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Gets a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Server] operation results. - # - def get(resource_group_name, server_name, custom_headers = nil) - response = get_async(resource_group_name, server_name, custom_headers).value! - response.body unless response.nil? - end - - # - # Gets a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_with_http_info(resource_group_name, server_name, custom_headers = nil) - get_async(resource_group_name, server_name, custom_headers).value! - end - - # - # Gets a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @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_async(resource_group_name, server_name, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}' - - request_url = @base_url || @client.base_url - - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::Server.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - - # - # Creates or updates a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [Server] The requested server resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Server] operation results. - # - def create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) - response = create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [Server] The requested server resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) - # Send request - promise = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::Server.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Deletes a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - def delete(resource_group_name, server_name, custom_headers = nil) - response = delete_async(resource_group_name, server_name, custom_headers).value! - nil - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def delete_async(resource_group_name, server_name, custom_headers = nil) - # Send request - promise = begin_delete_async(resource_group_name, server_name, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Updates a server. - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ServerUpdate] The requested server resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Server] operation results. - # - def update(resource_group_name, server_name, parameters, custom_headers = nil) - response = update_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [ServerUpdate] The requested server resource state. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [Concurrent::Promise] promise which provides async access to http - # response. - # - def update_async(resource_group_name, server_name, parameters, custom_headers = nil) - # Send request - promise = begin_update_async(resource_group_name, server_name, parameters, custom_headers) - - promise = promise.then do |response| - # Defining deserialization method. - deserialize_method = lambda do |parsed_response| - result_mapper = Azure::ARM::SQL::Models::Server.mapper() - parsed_response = @client.deserialize(result_mapper, parsed_response) - end - - # Waiting for response. - @client.get_long_running_operation_result(response, deserialize_method) - end - - promise - end - - # - # Updates a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [BackupLongTermRetentionVault] The required parameters to - # update a backup long term retention vault - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [BackupLongTermRetentionVault] operation results. - # - def begin_create_backup_long_term_retention_vault(resource_group_name, server_name, parameters, custom_headers = nil) - response = begin_create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers).value! - response.body unless response.nil? - end - - # - # Updates a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [BackupLongTermRetentionVault] The required parameters to - # update a backup long term retention 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 begin_create_backup_long_term_retention_vault_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) - begin_create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers).value! - end - - # - # Updates a server backup long term retention vault - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param parameters [BackupLongTermRetentionVault] The required parameters to - # update a backup long term retention 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 begin_create_backup_long_term_retention_vault_async(resource_group_name, server_name, parameters, custom_headers = nil) - api_version = '2014-04-01' - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - backup_long_term_retention_vault_name = 'RegisteredVault' - fail ArgumentError, 'parameters is nil' if parameters.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - - request_headers['Content-Type'] = 'application/json; charset=utf-8' - - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil - - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}' + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'backupLongTermRetentionVaultName' => backup_long_term_retention_vault_name}, + path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => api_version}, - body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } - promise = @client.make_request_async(:put, path_template, options) + promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body - unless status_code == 200 || status_code == 201 || status_code == 202 + unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end @@ -1548,17 +383,7 @@ def begin_create_backup_long_term_retention_vault_async(resource_group_name, ser if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - # Deserialize Response - if status_code == 201 - begin - parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) - result_mapper = Azure::ARM::SQL::Models::BackupLongTermRetentionVault.mapper() + result_mapper = Azure::ARM::SQL::Models::Server.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) @@ -1572,117 +397,141 @@ def begin_create_backup_long_term_retention_vault_async(resource_group_name, ser end # - # Updates an existing encryption protector. + # Creates or updates a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param parameters [EncryptionProtector] The requested encryption protector - # resource state. + # @param parameters [Server] The requested server resource state. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # - # @return [EncryptionProtector] operation results. + # @return [Server] operation results. # - def begin_create_or_update_encryption_protector(resource_group_name, server_name, parameters, custom_headers = nil) - response = begin_create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers).value! + def create_or_update(resource_group_name, server_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, parameters, custom_headers).value! response.body unless response.nil? end - # - # Updates an existing encryption protector. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param parameters [EncryptionProtector] The requested encryption protector - # resource state. + # @param parameters [Server] The requested server resource state. # @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. + # @return [Concurrent::Promise] promise which provides async access to http + # response. # - def begin_create_or_update_encryption_protector_with_http_info(resource_group_name, server_name, parameters, custom_headers = nil) - begin_create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers).value! + def create_or_update_async(resource_group_name, server_name, parameters, custom_headers = nil) + # Send request + promise = begin_create_or_update_async(resource_group_name, server_name, parameters, custom_headers) + + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::Server.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) + end + + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end + + promise end # - # Updates an existing encryption protector. + # Deletes a server. # # @param resource_group_name [String] The name of the resource group that # contains the resource. You can obtain this value from the Azure Resource # Manager API or the portal. # @param server_name [String] The name of the server. - # @param parameters [EncryptionProtector] The requested encryption protector - # resource state. - # @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. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. # - def begin_create_or_update_encryption_protector_async(resource_group_name, server_name, parameters, custom_headers = nil) - fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? - fail ArgumentError, 'server_name is nil' if server_name.nil? - encryption_protector_name = 'current' - fail ArgumentError, 'parameters is nil' if parameters.nil? - fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? - api_version = '2015-05-01-preview' - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + def delete(resource_group_name, server_name, custom_headers = nil) + response = delete_async(resource_group_name, server_name, custom_headers).value! + nil + end - request_headers['Content-Type'] = 'application/json; charset=utf-8' + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def delete_async(resource_group_name, server_name, custom_headers = nil) + # Send request + promise = begin_delete_async(resource_group_name, server_name, custom_headers) - # Serialize Request - request_mapper = Azure::ARM::SQL::Models::EncryptionProtector.mapper() - request_content = @client.serialize(request_mapper, parameters) - request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + end - path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}' + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) + end - request_url = @base_url || @client.base_url + promise + end - options = { - middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'encryptionProtectorName' => encryption_protector_name,'subscriptionId' => @client.subscription_id}, - query_params: {'api-version' => api_version}, - body: request_content, - headers: request_headers.merge(custom_headers || {}), - base_url: request_url - } - promise = @client.make_request_async(:put, path_template, options) + # + # Updates a server. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [ServerUpdate] The requested server resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Server] operation results. + # + def update(resource_group_name, server_name, parameters, custom_headers = nil) + response = update_async(resource_group_name, server_name, parameters, custom_headers).value! + response.body unless response.nil? + end - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 || status_code == 202 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) - end + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param parameters [ServerUpdate] The requested server resource state. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [Concurrent::Promise] promise which provides async access to http + # response. + # + def update_async(resource_group_name, server_name, parameters, custom_headers = nil) + # Send request + promise = begin_update_async(resource_group_name, server_name, parameters, custom_headers) - 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::ARM::SQL::Models::EncryptionProtector.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end + promise = promise.then do |response| + # Defining deserialization method. + deserialize_method = lambda do |parsed_response| + result_mapper = Azure::ARM::SQL::Models::Server.mapper() + parsed_response = @client.deserialize(result_mapper, parsed_response) end - result + # Waiting for response. + @client.get_long_running_operation_result(response, deserialize_method) end - promise.execute + promise end # @@ -2001,93 +850,6 @@ def begin_update_async(resource_group_name, server_name, parameters, custom_head promise.execute end - # - # Returns a list of the server encryption protectors - # - # @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 [EncryptionProtectorListResult] operation results. - # - def list_encryption_protectors_next(next_page_link, custom_headers = nil) - response = list_encryption_protectors_next_async(next_page_link, custom_headers).value! - response.body unless response.nil? - end - - # - # Returns a list of the server encryption protectors - # - # @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 list_encryption_protectors_next_with_http_info(next_page_link, custom_headers = nil) - list_encryption_protectors_next_async(next_page_link, custom_headers).value! - end - - # - # Returns a list of the server encryption protectors - # - # @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 list_encryption_protectors_next_async(next_page_link, custom_headers = nil) - fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? - - - request_headers = {} - - # Set Headers - request_headers['x-ms-client-request-id'] = SecureRandom.uuid - request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - path_template = '{nextLink}' - - request_url = @base_url || @client.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 = @client.make_request_async(:get, path_template, options) - - promise = promise.then do |result| - http_response = result.response - status_code = http_response.status - response_content = http_response.body - unless status_code == 200 - error_model = JSON.load(response_content) - fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::EncryptionProtectorListResult.mapper() - result.body = @client.deserialize(result_mapper, parsed_response) - rescue Exception => e - fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) - end - end - - result - end - - promise.execute - end - # # Gets a list of all servers in the subscription. # @@ -2262,30 +1024,6 @@ def list_by_resource_group_next_async(next_page_link, custom_headers = nil) promise.execute end - # - # Returns a list of the server encryption protectors - # - # @param resource_group_name [String] The name of the resource group that - # contains the resource. You can obtain this value from the Azure Resource - # Manager API or the portal. - # @param server_name [String] The name of the server. - # @param custom_headers [Hash{String => String}] A hash of custom headers that - # will be added to the HTTP request. - # - # @return [EncryptionProtectorListResult] which provide lazy access to pages of - # the response. - # - def list_encryption_protectors_as_lazy(resource_group_name, server_name, custom_headers = nil) - response = list_encryption_protectors_async(resource_group_name, server_name, custom_headers).value! - unless response.nil? - page = response.body - page.next_method = Proc.new do |next_page_link| - list_encryption_protectors_next_async(next_page_link, custom_headers) - end - page - end - end - # # Gets a list of all servers in the subscription. # diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_objectives.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_objectives.rb new file mode 100644 index 0000000000..ee7e0f9847 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_objectives.rb @@ -0,0 +1,229 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ServiceObjectives + include MsRestAzure + + # + # Creates and initializes a new instance of the ServiceObjectives class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a database service objective. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param service_objective_name [String] The name of the service objective to + # retrieve. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServiceObjective] operation results. + # + def get(resource_group_name, server_name, service_objective_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, service_objective_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database service objective. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param service_objective_name [String] The name of the service objective to + # retrieve. + # @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_with_http_info(resource_group_name, server_name, service_objective_name, custom_headers = nil) + get_async(resource_group_name, server_name, service_objective_name, custom_headers).value! + end + + # + # Gets a database service objective. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param service_objective_name [String] The name of the service objective to + # retrieve. + # @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_async(resource_group_name, server_name, service_objective_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'service_objective_name is nil' if service_objective_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'serviceObjectiveName' => service_objective_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceObjective.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Returns database service objectives. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServiceObjectiveListResult] operation results. + # + def list_by_server(resource_group_name, server_name, custom_headers = nil) + response = list_by_server_async(resource_group_name, server_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns database service objectives. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_with_http_info(resource_group_name, server_name, custom_headers = nil) + list_by_server_async(resource_group_name, server_name, custom_headers).value! + end + + # + # Returns database service objectives. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @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 list_by_server_async(resource_group_name, server_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceObjectiveListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_tier_advisors.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_tier_advisors.rb new file mode 100644 index 0000000000..3d9294e43e --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/service_tier_advisors.rb @@ -0,0 +1,234 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class ServiceTierAdvisors + include MsRestAzure + + # + # Creates and initializes a new instance of the ServiceTierAdvisors class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Gets a service tier advisor. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @param service_tier_advisor_name [String] The name of service tier advisor. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServiceTierAdvisor] operation results. + # + def get(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a service tier advisor. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @param service_tier_advisor_name [String] The name of service tier advisor. + # @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_with_http_info(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers).value! + end + + # + # Gets a service tier advisor. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @param service_tier_advisor_name [String] The name of service tier advisor. + # @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_async(resource_group_name, server_name, database_name, service_tier_advisor_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + fail ArgumentError, 'service_tier_advisor_name is nil' if service_tier_advisor_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/serviceTierAdvisors/{serviceTierAdvisorName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'serviceTierAdvisorName' => service_tier_advisor_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceTierAdvisor.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Returns service tier advisors for specified database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [ServiceTierAdvisorListResult] operation results. + # + def list_by_database(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns service tier advisors for specified database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @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 list_by_database_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_database_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Returns service tier advisors for specified database. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of database. + # @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 list_by_database_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/serviceTierAdvisors' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::ServiceTierAdvisorListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/sql_management_client.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/sql_management_client.rb index 565af17b44..83ecbeeffb 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/sql_management_client.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/sql_management_client.rb @@ -32,11 +32,15 @@ class SqlManagementClient < MsRestAzure::AzureServiceClient # is generated and included in each request. Default is true. attr_accessor :generate_client_request_id - # @return [Databases] databases - attr_reader :databases + # @return [BackupLongTermRetentionPolicies] + # backup_long_term_retention_policies + attr_reader :backup_long_term_retention_policies - # @return [Servers] servers - attr_reader :servers + # @return [BackupLongTermRetentionVaults] backup_long_term_retention_vaults + attr_reader :backup_long_term_retention_vaults + + # @return [RestorePoints] restore_points + attr_reader :restore_points # @return [RecoverableDatabases] recoverable_databases attr_reader :recoverable_databases @@ -47,24 +51,80 @@ class SqlManagementClient < MsRestAzure::AzureServiceClient # @return [Capabilities] capabilities attr_reader :capabilities + # @return [ServerConnectionPolicies] server_connection_policies + attr_reader :server_connection_policies + + # @return [DatabaseThreatDetectionPolicies] + # database_threat_detection_policies + attr_reader :database_threat_detection_policies + + # @return [DataMaskingPolicies] data_masking_policies + attr_reader :data_masking_policies + + # @return [DataMaskingRules] data_masking_rules + attr_reader :data_masking_rules + # @return [FirewallRules] firewall_rules attr_reader :firewall_rules + # @return [GeoBackupPolicies] geo_backup_policies + attr_reader :geo_backup_policies + + # @return [Databases] databases + attr_reader :databases + # @return [ElasticPools] elastic_pools attr_reader :elastic_pools # @return [Operations] operations attr_reader :operations + # @return [ReplicationLinks] replication_links + attr_reader :replication_links + # @return [ServerAzureADAdministrators] server_azure_adadministrators attr_reader :server_azure_adadministrators # @return [ServerCommunicationLinks] server_communication_links attr_reader :server_communication_links + # @return [ServiceObjectives] service_objectives + attr_reader :service_objectives + + # @return [Servers] servers + attr_reader :servers + + # @return [ElasticPoolActivities] elastic_pool_activities + attr_reader :elastic_pool_activities + + # @return [ElasticPoolDatabaseActivities] elastic_pool_database_activities + attr_reader :elastic_pool_database_activities + # @return [RecommendedElasticPools] recommended_elastic_pools attr_reader :recommended_elastic_pools + # @return [ServiceTierAdvisors] service_tier_advisors + attr_reader :service_tier_advisors + + # @return [TransparentDataEncryptions] transparent_data_encryptions + attr_reader :transparent_data_encryptions + + # @return [TransparentDataEncryptionActivities] + # transparent_data_encryption_activities + attr_reader :transparent_data_encryption_activities + + # @return [ServerUsages] server_usages + attr_reader :server_usages + + # @return [DatabaseUsages] database_usages + attr_reader :database_usages + + # @return [DatabaseBlobAuditingPolicies] database_blob_auditing_policies + attr_reader :database_blob_auditing_policies + + # @return [EncryptionProtectors] encryption_protectors + attr_reader :encryption_protectors + # @return [FailoverGroups] failover_groups attr_reader :failover_groups @@ -87,17 +147,36 @@ def initialize(credentials = nil, base_url = nil, options = nil) fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil? @credentials = credentials - @databases = Databases.new(self) - @servers = Servers.new(self) + @backup_long_term_retention_policies = BackupLongTermRetentionPolicies.new(self) + @backup_long_term_retention_vaults = BackupLongTermRetentionVaults.new(self) + @restore_points = RestorePoints.new(self) @recoverable_databases = RecoverableDatabases.new(self) @restorable_dropped_databases = RestorableDroppedDatabases.new(self) @capabilities = Capabilities.new(self) + @server_connection_policies = ServerConnectionPolicies.new(self) + @database_threat_detection_policies = DatabaseThreatDetectionPolicies.new(self) + @data_masking_policies = DataMaskingPolicies.new(self) + @data_masking_rules = DataMaskingRules.new(self) @firewall_rules = FirewallRules.new(self) + @geo_backup_policies = GeoBackupPolicies.new(self) + @databases = Databases.new(self) @elastic_pools = ElasticPools.new(self) @operations = Operations.new(self) + @replication_links = ReplicationLinks.new(self) @server_azure_adadministrators = ServerAzureADAdministrators.new(self) @server_communication_links = ServerCommunicationLinks.new(self) + @service_objectives = ServiceObjectives.new(self) + @servers = Servers.new(self) + @elastic_pool_activities = ElasticPoolActivities.new(self) + @elastic_pool_database_activities = ElasticPoolDatabaseActivities.new(self) @recommended_elastic_pools = RecommendedElasticPools.new(self) + @service_tier_advisors = ServiceTierAdvisors.new(self) + @transparent_data_encryptions = TransparentDataEncryptions.new(self) + @transparent_data_encryption_activities = TransparentDataEncryptionActivities.new(self) + @server_usages = ServerUsages.new(self) + @database_usages = DatabaseUsages.new(self) + @database_blob_auditing_policies = DatabaseBlobAuditingPolicies.new(self) + @encryption_protectors = EncryptionProtectors.new(self) @failover_groups = FailoverGroups.new(self) @server_keys = ServerKeys.new(self) @virtual_network_rules = VirtualNetworkRules.new(self) diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryption_activities.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryption_activities.rb new file mode 100644 index 0000000000..6bb0d2b56a --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryption_activities.rb @@ -0,0 +1,133 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class TransparentDataEncryptionActivities + include MsRestAzure + + # + # Creates and initializes a new instance of the TransparentDataEncryptionActivities class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Returns a database's transparent data encryption operation result. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [TransparentDataEncryptionActivityListResult] operation results. + # + def list_by_configuration(resource_group_name, server_name, database_name, custom_headers = nil) + response = list_by_configuration_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Returns a database's transparent data encryption operation result. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @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 list_by_configuration_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + list_by_configuration_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Returns a database's transparent data encryption operation result. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @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 list_by_configuration_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + transparent_data_encryption_name = 'current' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::TransparentDataEncryptionActivityListResult.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryptions.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryptions.rb new file mode 100644 index 0000000000..4b5abd5337 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/transparent_data_encryptions.rb @@ -0,0 +1,264 @@ +# encoding: utf-8 +# Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. + +module Azure::ARM::SQL + # + # The Azure SQL Database management API provides a RESTful set of web + # services that interact with Azure SQL Database services to manage your + # databases. The API enables you to create, retrieve, update, and delete + # databases. + # + class TransparentDataEncryptions + include MsRestAzure + + # + # Creates and initializes a new instance of the TransparentDataEncryptions class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Creates or updates a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which setting the + # transparent data encryption applies. + # @param parameters [TransparentDataEncryption] The required parameters for + # creating or updating transparent data encryption. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [TransparentDataEncryption] operation results. + # + def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + response.body unless response.nil? + end + + # + # Creates or updates a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which setting the + # transparent data encryption applies. + # @param parameters [TransparentDataEncryption] The required parameters for + # creating or updating transparent data encryption. + # @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_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers).value! + end + + # + # Creates or updates a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which setting the + # transparent data encryption applies. + # @param parameters [TransparentDataEncryption] The required parameters for + # creating or updating transparent data encryption. + # @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_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + transparent_data_encryption_name = 'current' + fail ArgumentError, 'parameters is nil' if parameters.nil? + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + + request_headers['Content-Type'] = 'application/json; charset=utf-8' + + # Serialize Request + request_mapper = Azure::ARM::SQL::Models::TransparentDataEncryption.mapper() + request_content = @client.serialize(request_mapper, parameters) + request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil + + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, + query_params: {'api-version' => api_version}, + body: request_content, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.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 || status_code == 201 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::TransparentDataEncryption.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + # Deserialize Response + if status_code == 201 + begin + parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) + result_mapper = Azure::ARM::SQL::Models::TransparentDataEncryption.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + # + # Gets a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [TransparentDataEncryption] operation results. + # + def get(resource_group_name, server_name, database_name, custom_headers = nil) + response = get_async(resource_group_name, server_name, database_name, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @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_with_http_info(resource_group_name, server_name, database_name, custom_headers = nil) + get_async(resource_group_name, server_name, database_name, custom_headers).value! + end + + # + # Gets a database's transparent data encryption configuration. + # + # @param resource_group_name [String] The name of the resource group that + # contains the resource. You can obtain this value from the Azure Resource + # Manager API or the portal. + # @param server_name [String] The name of the server. + # @param database_name [String] The name of the database for which the + # transparent data encryption applies. + # @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_async(resource_group_name, server_name, database_name, custom_headers = nil) + api_version = '2014-04-01' + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? + fail ArgumentError, 'server_name is nil' if server_name.nil? + fail ArgumentError, 'database_name is nil' if database_name.nil? + transparent_data_encryption_name = 'current' + + + request_headers = {} + + # Set Headers + request_headers['x-ms-client-request-id'] = SecureRandom.uuid + request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? + path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}' + + request_url = @base_url || @client.base_url + + options = { + middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], + path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name,'transparentDataEncryptionName' => transparent_data_encryption_name}, + query_params: {'api-version' => api_version}, + headers: request_headers.merge(custom_headers || {}), + base_url: request_url + } + promise = @client.make_request_async(:get, path_template, options) + + promise = promise.then do |result| + http_response = result.response + status_code = http_response.status + response_content = http_response.body + unless status_code == 200 + error_model = JSON.load(response_content) + fail MsRestAzure::AzureOperationError.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::ARM::SQL::Models::TransparentDataEncryption.mapper() + result.body = @client.deserialize(result_mapper, parsed_response) + rescue Exception => e + fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) + end + end + + result + end + + promise.execute + end + + end +end