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 e2a5cab1b4..ffe31fd80b 100644 --- a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql.rb @@ -56,84 +56,86 @@ module Azure::ARM::SQL autoload :SyncGroups, 'generated/azure_mgmt_sql/sync_groups.rb' autoload :SyncMembers, 'generated/azure_mgmt_sql/sync_members.rb' autoload :VirtualNetworkRules, 'generated/azure_mgmt_sql/virtual_network_rules.rb' + autoload :DatabaseOperations, 'generated/azure_mgmt_sql/database_operations.rb' autoload :SqlManagementClient, 'generated/azure_mgmt_sql/sql_management_client.rb' module Models - autoload :RecommendedElasticPoolListResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_result.rb' autoload :RecommendedElasticPoolListMetricsResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_metrics_result.rb' - autoload :SyncDatabaseIdListResult, 'generated/azure_mgmt_sql/models/sync_database_id_list_result.rb' - autoload :ReplicationLinkListResult, 'generated/azure_mgmt_sql/models/replication_link_list_result.rb' - autoload :SyncMemberListResult, 'generated/azure_mgmt_sql/models/sync_member_list_result.rb' - autoload :SyncDatabaseIdProperties, 'generated/azure_mgmt_sql/models/sync_database_id_properties.rb' - autoload :SyncGroupListResult, 'generated/azure_mgmt_sql/models/sync_group_list_result.rb' + autoload :SloUsageMetric, 'generated/azure_mgmt_sql/models/slo_usage_metric.rb' + autoload :CheckNameAvailabilityResponse, 'generated/azure_mgmt_sql/models/check_name_availability_response.rb' + autoload :RecommendedElasticPoolMetric, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_metric.rb' + autoload :FailoverGroupListResult, 'generated/azure_mgmt_sql/models/failover_group_list_result.rb' autoload :ServerAdministratorListResult, 'generated/azure_mgmt_sql/models/server_administrator_list_result.rb' - autoload :SyncGroupSchema, 'generated/azure_mgmt_sql/models/sync_group_schema.rb' - autoload :SyncAgentLinkedDatabaseListResult, 'generated/azure_mgmt_sql/models/sync_agent_linked_database_list_result.rb' - autoload :MaxSizeCapability, 'generated/azure_mgmt_sql/models/max_size_capability.rb' + autoload :RestorePointListResult, 'generated/azure_mgmt_sql/models/restore_point_list_result.rb' + autoload :FailoverGroupUpdate, 'generated/azure_mgmt_sql/models/failover_group_update.rb' + autoload :RecoverableDatabaseListResult, 'generated/azure_mgmt_sql/models/recoverable_database_list_result.rb' autoload :ServerCommunicationLinkListResult, 'generated/azure_mgmt_sql/models/server_communication_link_list_result.rb' - autoload :EditionCapability, 'generated/azure_mgmt_sql/models/edition_capability.rb' - autoload :SyncAgentKeyProperties, 'generated/azure_mgmt_sql/models/sync_agent_key_properties.rb' - autoload :ElasticPoolPerDatabaseMaxDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_max_dtu_capability.rb' + autoload :RestorableDroppedDatabaseListResult, 'generated/azure_mgmt_sql/models/restorable_dropped_database_list_result.rb' + autoload :SyncGroupLogListResult, 'generated/azure_mgmt_sql/models/sync_group_log_list_result.rb' + autoload :ServiceObjectiveCapability, 'generated/azure_mgmt_sql/models/service_objective_capability.rb' autoload :ServiceObjectiveListResult, 'generated/azure_mgmt_sql/models/service_objective_list_result.rb' - autoload :ElasticPoolEditionCapability, 'generated/azure_mgmt_sql/models/elastic_pool_edition_capability.rb' + autoload :ElasticPoolPerDatabaseMinDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_min_dtu_capability.rb' autoload :CheckNameAvailabilityRequest, 'generated/azure_mgmt_sql/models/check_name_availability_request.rb' + autoload :ElasticPoolDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_dtu_capability.rb' + autoload :ElasticPoolEditionCapability, 'generated/azure_mgmt_sql/models/elastic_pool_edition_capability.rb' + autoload :FailoverGroupReadOnlyEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_only_endpoint.rb' autoload :LocationCapabilities, 'generated/azure_mgmt_sql/models/location_capabilities.rb' - autoload :CheckNameAvailabilityResponse, 'generated/azure_mgmt_sql/models/check_name_availability_response.rb' - autoload :SyncGroupSchemaTableColumn, 'generated/azure_mgmt_sql/models/sync_group_schema_table_column.rb' - autoload :RecommendedElasticPoolMetric, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_metric.rb' - autoload :SyncGroupLogProperties, 'generated/azure_mgmt_sql/models/sync_group_log_properties.rb' - autoload :SloUsageMetric, 'generated/azure_mgmt_sql/models/slo_usage_metric.rb' + autoload :PartnerInfo, 'generated/azure_mgmt_sql/models/partner_info.rb' + autoload :ServerListResult, 'generated/azure_mgmt_sql/models/server_list_result.rb' autoload :SyncFullSchemaPropertiesListResult, 'generated/azure_mgmt_sql/models/sync_full_schema_properties_list_result.rb' - autoload :SyncAgentListResult, 'generated/azure_mgmt_sql/models/sync_agent_list_result.rb' - autoload :SyncFullSchemaProperties, 'generated/azure_mgmt_sql/models/sync_full_schema_properties.rb' - autoload :ServerUpdate, 'generated/azure_mgmt_sql/models/server_update.rb' - autoload :ImportExtensionRequest, 'generated/azure_mgmt_sql/models/import_extension_request.rb' - autoload :OperationImpact, 'generated/azure_mgmt_sql/models/operation_impact.rb' + autoload :FailoverGroupReadWriteEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb' + autoload :DataMaskingRuleListResult, 'generated/azure_mgmt_sql/models/data_masking_rule_list_result.rb' autoload :SyncFullSchemaTableColumn, 'generated/azure_mgmt_sql/models/sync_full_schema_table_column.rb' - autoload :ServerListResult, 'generated/azure_mgmt_sql/models/server_list_result.rb' - autoload :MetricValue, 'generated/azure_mgmt_sql/models/metric_value.rb' - autoload :ResourceIdentity, 'generated/azure_mgmt_sql/models/resource_identity.rb' - autoload :Metric, 'generated/azure_mgmt_sql/models/metric.rb' - autoload :ServerKeyListResult, 'generated/azure_mgmt_sql/models/server_key_list_result.rb' - autoload :MetricAvailability, 'generated/azure_mgmt_sql/models/metric_availability.rb' + autoload :FirewallRuleListResult, 'generated/azure_mgmt_sql/models/firewall_rule_list_result.rb' + autoload :SyncDatabaseIdListResult, 'generated/azure_mgmt_sql/models/sync_database_id_list_result.rb' + autoload :GeoBackupPolicyListResult, 'generated/azure_mgmt_sql/models/geo_backup_policy_list_result.rb' + autoload :OperationImpact, 'generated/azure_mgmt_sql/models/operation_impact.rb' + autoload :OperationListResult, 'generated/azure_mgmt_sql/models/operation_list_result.rb' + autoload :SyncDatabaseIdProperties, 'generated/azure_mgmt_sql/models/sync_database_id_properties.rb' + autoload :ExportRequest, 'generated/azure_mgmt_sql/models/export_request.rb' + autoload :SyncAgentLinkedDatabaseListResult, 'generated/azure_mgmt_sql/models/sync_agent_linked_database_list_result.rb' + autoload :MetricName, 'generated/azure_mgmt_sql/models/metric_name.rb' + autoload :SyncFullSchemaTable, 'generated/azure_mgmt_sql/models/sync_full_schema_table.rb' + autoload :MetricListResult, 'generated/azure_mgmt_sql/models/metric_list_result.rb' + autoload :RecommendedElasticPoolListResult, 'generated/azure_mgmt_sql/models/recommended_elastic_pool_list_result.rb' autoload :MetricDefinition, 'generated/azure_mgmt_sql/models/metric_definition.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 :VirtualNetworkRuleListResult, 'generated/azure_mgmt_sql/models/virtual_network_rule_list_result.rb' - autoload :OperationListResult, 'generated/azure_mgmt_sql/models/operation_list_result.rb' - autoload :RecoverableDatabaseListResult, 'generated/azure_mgmt_sql/models/recoverable_database_list_result.rb' - autoload :Operation, 'generated/azure_mgmt_sql/models/operation.rb' - autoload :ServiceObjectiveCapability, 'generated/azure_mgmt_sql/models/service_objective_capability.rb' - autoload :OperationDisplay, 'generated/azure_mgmt_sql/models/operation_display.rb' - autoload :ElasticPoolDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_dtu_capability.rb' + autoload :ReplicationLinkListResult, 'generated/azure_mgmt_sql/models/replication_link_list_result.rb' + autoload :SyncAgentListResult, 'generated/azure_mgmt_sql/models/sync_agent_list_result.rb' + autoload :DatabaseOperationListResult, 'generated/azure_mgmt_sql/models/database_operation_list_result.rb' + autoload :MaxSizeCapability, 'generated/azure_mgmt_sql/models/max_size_capability.rb' autoload :ElasticPoolListResult, 'generated/azure_mgmt_sql/models/elastic_pool_list_result.rb' - autoload :SyncGroupSchemaTable, 'generated/azure_mgmt_sql/models/sync_group_schema_table.rb' - autoload :FailoverGroupListResult, 'generated/azure_mgmt_sql/models/failover_group_list_result.rb' - autoload :DataMaskingRuleListResult, 'generated/azure_mgmt_sql/models/data_masking_rule_list_result.rb' + autoload :ElasticPoolPerDatabaseMaxDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_max_dtu_capability.rb' + autoload :VirtualNetworkRuleListResult, 'generated/azure_mgmt_sql/models/virtual_network_rule_list_result.rb' + autoload :ServerUpdate, 'generated/azure_mgmt_sql/models/server_update.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 :FailoverGroupUpdate, 'generated/azure_mgmt_sql/models/failover_group_update.rb' - autoload :ExportRequest, 'generated/azure_mgmt_sql/models/export_request.rb' + autoload :ServerKeyListResult, 'generated/azure_mgmt_sql/models/server_key_list_result.rb' + autoload :SyncMemberListResult, 'generated/azure_mgmt_sql/models/sync_member_list_result.rb' + autoload :ImportExtensionRequest, 'generated/azure_mgmt_sql/models/import_extension_request.rb' autoload :ElasticPoolDatabaseActivityListResult, 'generated/azure_mgmt_sql/models/elastic_pool_database_activity_list_result.rb' - autoload :MetricListResult, 'generated/azure_mgmt_sql/models/metric_list_result.rb' - autoload :PartnerInfo, 'generated/azure_mgmt_sql/models/partner_info.rb' - autoload :RestorePointListResult, 'generated/azure_mgmt_sql/models/restore_point_list_result.rb' + autoload :MetricValue, 'generated/azure_mgmt_sql/models/metric_value.rb' + autoload :SyncGroupListResult, 'generated/azure_mgmt_sql/models/sync_group_list_result.rb' + autoload :MetricAvailability, 'generated/azure_mgmt_sql/models/metric_availability.rb' autoload :DatabaseListResult, 'generated/azure_mgmt_sql/models/database_list_result.rb' - autoload :ElasticPoolPerDatabaseMinDtuCapability, 'generated/azure_mgmt_sql/models/elastic_pool_per_database_min_dtu_capability.rb' + autoload :SyncAgentKeyProperties, 'generated/azure_mgmt_sql/models/sync_agent_key_properties.rb' autoload :ServiceTierAdvisorListResult, 'generated/azure_mgmt_sql/models/service_tier_advisor_list_result.rb' - autoload :SyncGroupLogListResult, 'generated/azure_mgmt_sql/models/sync_group_log_list_result.rb' - autoload :FailoverGroupReadOnlyEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_only_endpoint.rb' - autoload :SyncFullSchemaTable, 'generated/azure_mgmt_sql/models/sync_full_schema_table.rb' + autoload :EditionCapability, 'generated/azure_mgmt_sql/models/edition_capability.rb' + autoload :SyncGroupSchema, 'generated/azure_mgmt_sql/models/sync_group_schema.rb' + autoload :ResourceIdentity, 'generated/azure_mgmt_sql/models/resource_identity.rb' autoload :TransparentDataEncryptionActivityListResult, 'generated/azure_mgmt_sql/models/transparent_data_encryption_activity_list_result.rb' - autoload :MetricDefinitionListResult, 'generated/azure_mgmt_sql/models/metric_definition_list_result.rb' + autoload :Operation, 'generated/azure_mgmt_sql/models/operation.rb' autoload :ServerUsage, 'generated/azure_mgmt_sql/models/server_usage.rb' - autoload :ServerVersionCapability, 'generated/azure_mgmt_sql/models/server_version_capability.rb' + autoload :OperationDisplay, 'generated/azure_mgmt_sql/models/operation_display.rb' autoload :ServerUsageListResult, 'generated/azure_mgmt_sql/models/server_usage_list_result.rb' - autoload :MetricName, 'generated/azure_mgmt_sql/models/metric_name.rb' + autoload :ServerVersionCapability, 'generated/azure_mgmt_sql/models/server_version_capability.rb' autoload :DatabaseUsage, 'generated/azure_mgmt_sql/models/database_usage.rb' - autoload :FirewallRuleListResult, 'generated/azure_mgmt_sql/models/firewall_rule_list_result.rb' + autoload :Metric, 'generated/azure_mgmt_sql/models/metric.rb' autoload :DatabaseUsageListResult, 'generated/azure_mgmt_sql/models/database_usage_list_result.rb' - autoload :RestorableDroppedDatabaseListResult, 'generated/azure_mgmt_sql/models/restorable_dropped_database_list_result.rb' - autoload :FailoverGroupReadWriteEndpoint, 'generated/azure_mgmt_sql/models/failover_group_read_write_endpoint.rb' + autoload :SyncGroupLogProperties, 'generated/azure_mgmt_sql/models/sync_group_log_properties.rb' + autoload :SyncGroupSchemaTable, 'generated/azure_mgmt_sql/models/sync_group_schema_table.rb' + autoload :SyncFullSchemaProperties, 'generated/azure_mgmt_sql/models/sync_full_schema_properties.rb' + autoload :SyncGroupSchemaTableColumn, 'generated/azure_mgmt_sql/models/sync_group_schema_table_column.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' @@ -174,6 +176,7 @@ module Models autoload :SyncGroup, 'generated/azure_mgmt_sql/models/sync_group.rb' autoload :SyncMember, 'generated/azure_mgmt_sql/models/sync_member.rb' autoload :VirtualNetworkRule, 'generated/azure_mgmt_sql/models/virtual_network_rule.rb' + autoload :DatabaseOperation, 'generated/azure_mgmt_sql/models/database_operation.rb' autoload :BackupLongTermRetentionPolicyState, 'generated/azure_mgmt_sql/models/backup_long_term_retention_policy_state.rb' autoload :RestorePointType, 'generated/azure_mgmt_sql/models/restore_point_type.rb' autoload :CapabilityStatus, 'generated/azure_mgmt_sql/models/capability_status.rb' @@ -221,5 +224,6 @@ module Models autoload :SyncGroupState, 'generated/azure_mgmt_sql/models/sync_group_state.rb' autoload :SyncDirection, 'generated/azure_mgmt_sql/models/sync_direction.rb' autoload :SyncMemberState, 'generated/azure_mgmt_sql/models/sync_member_state.rb' + autoload :ManagementOperationState, 'generated/azure_mgmt_sql/models/management_operation_state.rb' end end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_operations.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_operations.rb new file mode 100644 index 0000000000..6116783887 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/database_operations.rb @@ -0,0 +1,335 @@ +# 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 DatabaseOperations + include MsRestAzure + + # + # Creates and initializes a new instance of the DatabaseOperations class. + # @param client service class for accessing basic functionality. + # + def initialize(client) + @client = client + end + + # @return [SqlManagementClient] reference to the SqlManagementClient + attr_reader :client + + # + # Cancels the asynchronous operation on the 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 operation_id The operation identifier. + # @param custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # + def cancel(resource_group_name, server_name, database_name, operation_id, custom_headers = nil) + response = cancel_async(resource_group_name, server_name, database_name, operation_id, custom_headers).value! + nil + end + + # + # Cancels the asynchronous operation on the 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 operation_id The operation identifier. + # @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 cancel_with_http_info(resource_group_name, server_name, database_name, operation_id, custom_headers = nil) + cancel_async(resource_group_name, server_name, database_name, operation_id, custom_headers).value! + end + + # + # Cancels the asynchronous operation on the 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 operation_id The operation identifier. + # @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 cancel_async(resource_group_name, server_name, database_name, operation_id, 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? + fail ArgumentError, 'operation_id is nil' if operation_id.nil? + fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2017-03-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}/operations/{operationId}/cancel' + + 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,'operationId' => operation_id,'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(: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? + + result + end + + promise.execute + end + + # + # Gets a list of operations performed on the 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 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_database(resource_group_name, server_name, database_name, custom_headers = nil) + first_page = list_by_database_as_lazy(resource_group_name, server_name, database_name, custom_headers) + first_page.get_all_items + end + + # + # Gets a list of operations performed on the 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 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 operations performed on the 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 [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) + 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, '@client.subscription_id is nil' if @client.subscription_id.nil? + api_version = '2017-03-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}/operations' + + 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,'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::DatabaseOperationListResult.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 operations performed on the database. + # + # @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 [DatabaseOperationListResult] operation results. + # + def list_by_database_next(next_page_link, custom_headers = nil) + response = list_by_database_next_async(next_page_link, custom_headers).value! + response.body unless response.nil? + end + + # + # Gets a list of operations performed on the database. + # + # @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_database_next_with_http_info(next_page_link, custom_headers = nil) + list_by_database_next_async(next_page_link, custom_headers).value! + end + + # + # Gets a list of operations performed on the database. + # + # @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_database_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::DatabaseOperationListResult.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 operations performed on the 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 custom_headers [Hash{String => String}] A hash of custom headers that + # will be added to the HTTP request. + # + # @return [DatabaseOperationListResult] which provide lazy access to pages of + # the response. + # + def list_by_database_as_lazy(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! + unless response.nil? + page = response.body + page.next_method = Proc.new do |next_page_link| + list_by_database_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/models/database_operation.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_operation.rb new file mode 100644 index 0000000000..2f1dbb2d4f --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_operation.rb @@ -0,0 +1,183 @@ +# 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 database operation. + # + class DatabaseOperation < ProxyResource + + include MsRestAzure + + include MsRest::JSONable + # @return [String] The name of the database the operation is being + # performed on. + attr_accessor :database_name + + # @return [String] The name of operation. + attr_accessor :operation + + # @return [String] The friendly name of operation. + attr_accessor :operation_friendly_name + + # @return [Integer] The percentage of the operation completed. + attr_accessor :percent_complete + + # @return [String] The name of the server. + attr_accessor :server_name + + # @return [DateTime] The operation start time. + attr_accessor :start_time + + # @return [ManagementOperationState] The operation state. Possible values + # include: 'Pending', 'InProgress', 'Succeeded', 'Failed', + # 'CancelInProgress', 'Cancelled' + attr_accessor :state + + # @return [Integer] The operation error code. + attr_accessor :error_code + + # @return [String] The operation error description. + attr_accessor :error_description + + # @return [Integer] The operation error severity. + attr_accessor :error_severity + + # @return [Boolean] Whether or not the error is a user error. + attr_accessor :is_user_error + + + # + # Mapper for DatabaseOperation class as Ruby Hash. + # This will be used for serialization/deserialization. + # + def self.mapper() + { + required: false, + serialized_name: 'DatabaseOperation', + type: { + name: 'Composite', + class_name: 'DatabaseOperation', + model_properties: { + id: { + required: false, + read_only: true, + serialized_name: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + read_only: true, + serialized_name: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + read_only: true, + serialized_name: 'type', + type: { + name: 'String' + } + }, + database_name: { + required: false, + read_only: true, + serialized_name: 'properties.databaseName', + type: { + name: 'String' + } + }, + operation: { + required: false, + read_only: true, + serialized_name: 'properties.operation', + type: { + name: 'String' + } + }, + operation_friendly_name: { + required: false, + read_only: true, + serialized_name: 'properties.operationFriendlyName', + type: { + name: 'String' + } + }, + percent_complete: { + required: false, + read_only: true, + serialized_name: 'properties.percentComplete', + type: { + name: 'Number' + } + }, + server_name: { + required: false, + read_only: true, + serialized_name: 'properties.serverName', + type: { + name: 'String' + } + }, + start_time: { + required: false, + read_only: true, + serialized_name: 'properties.startTime', + type: { + name: 'DateTime' + } + }, + state: { + required: false, + read_only: true, + serialized_name: 'properties.state', + type: { + name: 'String' + } + }, + error_code: { + required: false, + read_only: true, + serialized_name: 'properties.errorCode', + type: { + name: 'Number' + } + }, + error_description: { + required: false, + read_only: true, + serialized_name: 'properties.errorDescription', + type: { + name: 'String' + } + }, + error_severity: { + required: false, + read_only: true, + serialized_name: 'properties.errorSeverity', + type: { + name: 'Number' + } + }, + is_user_error: { + required: false, + read_only: true, + serialized_name: 'properties.isUserError', + type: { + name: 'Boolean' + } + } + } + } + } + end + end + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_operation_list_result.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_operation_list_result.rb new file mode 100644 index 0000000000..66830c760f --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/database_operation_list_result.rb @@ -0,0 +1,96 @@ +# 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 + # + # The response to a list database operations request + # + class DatabaseOperationListResult + + include MsRestAzure + + include MsRest::JSONable + # @return [Array] Array of results. + attr_accessor :value + + # @return [String] Link to retrieve next page of results. + attr_accessor :next_link + + # return [Proc] with next page method call. + attr_accessor :next_method + + # + # Gets the rest of the items for the request, enabling auto-pagination. + # + # @return [Array] operation results. + # + def get_all_items + items = @value + page = self + while page.next_link != nil do + page = page.get_next_page + items.concat(page.value) + end + items + end + + # + # Gets the next page of results. + # + # @return [DatabaseOperationListResult] with next page content. + # + def get_next_page + response = @next_method.call(@next_link).value! unless @next_method.nil? + unless response.nil? + @next_link = response.body.next_link + @value = response.body.value + self + end + end + + # + # Mapper for DatabaseOperationListResult class as Ruby Hash. + # This will be used for serialization/deserialization. + # + def self.mapper() + { + required: false, + serialized_name: 'DatabaseOperationListResult', + type: { + name: 'Composite', + class_name: 'DatabaseOperationListResult', + model_properties: { + value: { + required: false, + read_only: true, + serialized_name: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serialized_name: 'DatabaseOperationElementType', + type: { + name: 'Composite', + class_name: 'DatabaseOperation' + } + } + } + }, + next_link: { + required: false, + read_only: true, + serialized_name: 'nextLink', + type: { + name: 'String' + } + } + } + } + } + end + end + end +end diff --git a/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/management_operation_state.rb b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/management_operation_state.rb new file mode 100644 index 0000000000..a4995de964 --- /dev/null +++ b/management/azure_mgmt_sql/lib/generated/azure_mgmt_sql/models/management_operation_state.rb @@ -0,0 +1,20 @@ +# 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 ManagementOperationState + # + module ManagementOperationState + Pending = "Pending" + InProgress = "InProgress" + Succeeded = "Succeeded" + Failed = "Failed" + CancelInProgress = "CancelInProgress" + Cancelled = "Cancelled" + 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 b6209d2e6c..d880dd37c8 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 @@ -143,6 +143,9 @@ class SqlManagementClient < MsRestAzure::AzureServiceClient # @return [VirtualNetworkRules] virtual_network_rules attr_reader :virtual_network_rules + # @return [DatabaseOperations] database_operations + attr_reader :database_operations + # # Creates initializes a new instance of the SqlManagementClient class. # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. @@ -192,6 +195,7 @@ def initialize(credentials = nil, base_url = nil, options = nil) @sync_groups = SyncGroups.new(self) @sync_members = SyncMembers.new(self) @virtual_network_rules = VirtualNetworkRules.new(self) + @database_operations = DatabaseOperations.new(self) @accept_language = 'en-US' @long_running_operation_retry_timeout = 30 @generate_client_request_id = true