2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-04 19:03:46 +00:00
restic/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/databases.go

1299 lines
55 KiB
Go
Raw Normal View History

2017-08-05 18:30:20 +00:00
package sql
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
2017-08-05 18:30:20 +00:00
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// DatabasesClient is the 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.
2017-08-05 18:30:20 +00:00
type DatabasesClient struct {
ManagementClient
}
// NewDatabasesClient creates an instance of the DatabasesClient client.
func NewDatabasesClient(subscriptionID string) DatabasesClient {
return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client.
2017-08-05 18:30:20 +00:00
func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient {
return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateImportOperation creates an import operation that imports a bacpac into an existing database. The existing
// database must be empty. This method may poll for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to import into extensionName is the name of the operation to perform parameters is the required parameters
// for importing a Bacpac into a database.
func (client DatabasesClient) CreateImportOperation(resourceGroupName string, serverName string, databaseName string, extensionName string, parameters ImportExtensionRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) {
2017-08-05 18:30:20 +00:00
resultChan := make(chan ImportExportResponse, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.ImportExtensionProperties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.ImportExtensionProperties.OperationMode", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "CreateImportOperation")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result ImportExportResponse
defer func() {
if err != nil {
errChan <- err
}
2017-08-05 18:30:20 +00:00
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.CreateImportOperationPreparer(resourceGroupName, serverName, databaseName, extensionName, parameters, cancel)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", nil, "Failure preparing request")
return
}
resp, err := client.CreateImportOperationSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", resp, "Failure sending request")
return
}
result, err = client.CreateImportOperationResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreateImportOperationPreparer prepares the CreateImportOperation request.
func (client DatabasesClient) CreateImportOperationPreparer(resourceGroupName string, serverName string, databaseName string, extensionName string, parameters ImportExtensionRequest, cancel <-chan struct{}) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"extensionName": autorest.Encode("path", extensionName),
2017-08-05 18:30:20 +00:00
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateImportOperationSender sends the CreateImportOperation request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) CreateImportOperationSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateImportOperationResponder handles the response to the CreateImportOperation request. The method always
// closes the http.Response Body.
func (client DatabasesClient) CreateImportOperationResponder(resp *http.Response) (result ImportExportResponse, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateOrUpdate creates a new database or updates an existing database. This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to be operated on (updated or created). parameters is the required parameters for creating or updating a
// database.
2017-08-05 18:30:20 +00:00
func (client DatabasesClient) CreateOrUpdate(resourceGroupName string, serverName string, databaseName string, parameters Database, cancel <-chan struct{}) (<-chan Database, <-chan error) {
resultChan := make(chan Database, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result Database
defer func() {
if err != nil {
errChan <- err
}
2017-08-05 18:30:20 +00:00
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, databaseName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client DatabasesClient) CreateOrUpdatePreparer(resourceGroupName string, serverName string, databaseName string, parameters Database, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes a database.
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to be deleted.
2017-08-05 18:30:20 +00:00
func (client DatabasesClient) Delete(resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, serverName, databaseName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client DatabasesClient) DeletePreparer(resourceGroupName string, serverName string, databaseName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
2017-08-05 18:30:20 +00:00
autorest.ByClosing())
result.Response = resp
2017-08-05 18:30:20 +00:00
return
}
// Export exports a database to a bacpac. This method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to be exported. parameters is the required parameters for exporting a database.
func (client DatabasesClient) Export(resourceGroupName string, serverName string, databaseName string, parameters ExportRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) {
resultChan := make(chan ImportExportResponse, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "Export")
close(errChan)
close(resultChan)
return resultChan, errChan
2017-08-05 18:30:20 +00:00
}
go func() {
var err error
var result ImportExportResponse
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.ExportPreparer(resourceGroupName, serverName, databaseName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure preparing request")
return
}
2017-08-05 18:30:20 +00:00
resp, err := client.ExportSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", resp, "Failure sending request")
return
}
2017-08-05 18:30:20 +00:00
result, err = client.ExportResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", resp, "Failure responding to request")
}
}()
return resultChan, errChan
2017-08-05 18:30:20 +00:00
}
// ExportPreparer prepares the Export request.
func (client DatabasesClient) ExportPreparer(resourceGroupName string, serverName string, databaseName string, parameters ExportRequest, cancel <-chan struct{}) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
2017-08-05 18:30:20 +00:00
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export", pathParameters),
autorest.WithJSON(parameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
2017-08-05 18:30:20 +00:00
}
// ExportSender sends the Export request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ExportSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
2017-08-05 18:30:20 +00:00
}
// ExportResponder handles the response to the Export request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ExportResponder(resp *http.Response) (result ImportExportResponse, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
2017-08-05 18:30:20 +00:00
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Get gets a database.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to be retrieved. expand is a comma separated list of child objects to expand in the response. Possible
// properties: serviceTierAdvisors, transparentDataEncryption.
func (client DatabasesClient) Get(resourceGroupName string, serverName string, databaseName string, expand string) (result Database, err error) {
req, err := client.GetPreparer(resourceGroupName, serverName, databaseName, expand)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.GetSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.GetResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// GetPreparer prepares the Get request.
func (client DatabasesClient) GetPreparer(resourceGroupName string, serverName string, databaseName string, expand string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
2017-08-05 18:30:20 +00:00
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand)
}
2017-08-05 18:30:20 +00:00
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) GetSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetByElasticPool gets a database inside of an elastic pool.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name of the
// elastic pool to be retrieved. databaseName is the name of the database to be retrieved.
func (client DatabasesClient) GetByElasticPool(resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (result Database, err error) {
req, err := client.GetByElasticPoolPreparer(resourceGroupName, serverName, elasticPoolName, databaseName)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.GetByElasticPoolSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.GetByElasticPoolResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// GetByElasticPoolPreparer prepares the GetByElasticPool request.
func (client DatabasesClient) GetByElasticPoolPreparer(resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"elasticPoolName": autorest.Encode("path", elasticPoolName),
2017-08-05 18:30:20 +00:00
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases/{databaseName}", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetByElasticPoolSender sends the GetByElasticPool request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) GetByElasticPoolSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// GetByElasticPoolResponder handles the response to the GetByElasticPool request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) GetByElasticPoolResponder(resp *http.Response) (result Database, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetByRecommendedElasticPool gets a database inside of a recommented elastic pool.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName is the
// name of the elastic pool to be retrieved. databaseName is the name of the database to be retrieved.
func (client DatabasesClient) GetByRecommendedElasticPool(resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (result Database, err error) {
req, err := client.GetByRecommendedElasticPoolPreparer(resourceGroupName, serverName, recommendedElasticPoolName, databaseName)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.GetByRecommendedElasticPoolSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.GetByRecommendedElasticPoolResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// GetByRecommendedElasticPoolPreparer prepares the GetByRecommendedElasticPool request.
func (client DatabasesClient) GetByRecommendedElasticPoolPreparer(resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
2017-08-05 18:30:20 +00:00
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetByRecommendedElasticPoolSender sends the GetByRecommendedElasticPool request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) GetByRecommendedElasticPoolSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// GetByRecommendedElasticPoolResponder handles the response to the GetByRecommendedElasticPool request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) GetByRecommendedElasticPoolResponder(resp *http.Response) (result Database, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Import imports a bacpac into a new database. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the required
2017-08-05 18:30:20 +00:00
// parameters for importing a Bacpac into a database.
func (client DatabasesClient) Import(resourceGroupName string, serverName string, parameters ImportRequest, cancel <-chan struct{}) (<-chan ImportExportResponse, <-chan error) {
resultChan := make(chan ImportExportResponse, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.DatabaseName", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.MaxSizeBytes", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "sql.DatabasesClient", "Import")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result ImportExportResponse
defer func() {
if err != nil {
errChan <- err
}
2017-08-05 18:30:20 +00:00
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.ImportPreparer(resourceGroupName, serverName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", nil, "Failure preparing request")
return
}
resp, err := client.ImportSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", resp, "Failure sending request")
return
}
result, err = client.ImportResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// ImportPreparer prepares the Import request.
func (client DatabasesClient) ImportPreparer(resourceGroupName string, serverName string, parameters ImportRequest, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// ImportSender sends the Import request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) ImportSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// ImportResponder handles the response to the Import request. The method always
// closes the http.Response Body.
func (client DatabasesClient) ImportResponder(resp *http.Response) (result ImportExportResponse, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
2017-08-05 18:30:20 +00:00
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByElasticPool returns a list of databases in an elastic pool.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name of the
// elastic pool to be retrieved.
func (client DatabasesClient) ListByElasticPool(resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResult, err error) {
req, err := client.ListByElasticPoolPreparer(resourceGroupName, serverName, elasticPoolName)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.ListByElasticPoolSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.ListByElasticPoolResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// ListByElasticPoolPreparer prepares the ListByElasticPool request.
func (client DatabasesClient) ListByElasticPoolPreparer(resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"elasticPoolName": autorest.Encode("path", elasticPoolName),
2017-08-05 18:30:20 +00:00
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ListByElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByRecommendedElasticPool returns a list of databases inside a recommented elastic pool.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName is the
// name of the recommended elastic pool to be retrieved.
func (client DatabasesClient) ListByRecommendedElasticPool(resourceGroupName string, serverName string, recommendedElasticPoolName string) (result DatabaseListResult, err error) {
req, err := client.ListByRecommendedElasticPoolPreparer(resourceGroupName, serverName, recommendedElasticPoolName)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.ListByRecommendedElasticPoolSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.ListByRecommendedElasticPoolResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// ListByRecommendedElasticPoolPreparer prepares the ListByRecommendedElasticPool request.
func (client DatabasesClient) ListByRecommendedElasticPoolPreparer(resourceGroupName string, serverName string, recommendedElasticPoolName string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
2017-08-05 18:30:20 +00:00
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByRecommendedElasticPoolSender sends the ListByRecommendedElasticPool request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ListByRecommendedElasticPoolSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// ListByRecommendedElasticPoolResponder handles the response to the ListByRecommendedElasticPool request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ListByRecommendedElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByServer returns a list of databases in a server.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. expand is a comma separated list of
// child objects to expand in the response. Possible properties: serviceTierAdvisors, transparentDataEncryption. filter
// is an OData filter expression that describes a subset of databases to return.
func (client DatabasesClient) ListByServer(resourceGroupName string, serverName string, expand string, filter string) (result DatabaseListResult, err error) {
req, err := client.ListByServerPreparer(resourceGroupName, serverName, expand, filter)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.ListByServerSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.ListByServerResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// ListByServerPreparer prepares the ListByServer request.
func (client DatabasesClient) ListByServerPreparer(resourceGroupName string, serverName string, expand string, filter string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand)
2017-08-05 18:30:20 +00:00
}
if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter)
2017-08-05 18:30:20 +00:00
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByServerSender sends the ListByServer request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// ListByServerResponder handles the response to the ListByServer request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListMetricDefinitions returns database metric definitions.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database.
func (client DatabasesClient) ListMetricDefinitions(resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) {
req, err := client.ListMetricDefinitionsPreparer(resourceGroupName, serverName, databaseName)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.ListMetricDefinitionsSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.ListMetricDefinitionsResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request.
func (client DatabasesClient) ListMetricDefinitionsPreparer(resourceGroupName string, serverName string, databaseName string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListMetrics returns database metrics.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database. filter is an OData filter expression that describes a subset of metrics to return.
func (client DatabasesClient) ListMetrics(resourceGroupName string, serverName string, databaseName string, filter string) (result MetricListResult, err error) {
req, err := client.ListMetricsPreparer(resourceGroupName, serverName, databaseName, filter)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", nil, "Failure preparing request")
2017-08-05 18:30:20 +00:00
return
}
resp, err := client.ListMetricsSender(req)
2017-08-05 18:30:20 +00:00
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure sending request")
2017-08-05 18:30:20 +00:00
return
}
result, err = client.ListMetricsResponder(resp)
2017-08-05 18:30:20 +00:00
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure responding to request")
2017-08-05 18:30:20 +00:00
}
return
}
// ListMetricsPreparer prepares the ListMetrics request.
func (client DatabasesClient) ListMetricsPreparer(resourceGroupName string, serverName string, databaseName string, filter string) (*http.Request, error) {
2017-08-05 18:30:20 +00:00
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"$filter": autorest.Encode("query", filter),
2017-08-05 18:30:20 +00:00
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics", pathParameters),
2017-08-05 18:30:20 +00:00
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListMetricsSender sends the ListMetrics request. The method will close the
2017-08-05 18:30:20 +00:00
// http.Response Body if it receives an error.
func (client DatabasesClient) ListMetricsSender(req *http.Request) (*http.Response, error) {
2017-08-05 18:30:20 +00:00
return autorest.SendWithSender(client, req)
}
// ListMetricsResponder handles the response to the ListMetrics request. The method always
2017-08-05 18:30:20 +00:00
// closes the http.Response Body.
func (client DatabasesClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) {
2017-08-05 18:30:20 +00:00
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Pause pauses a data warehouse. This method may poll for completion. Polling can be canceled by passing the cancel
// channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the data
// warehouse to pause.
2017-08-05 18:30:20 +00:00
func (client DatabasesClient) Pause(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
if err != nil {
errChan <- err
}
2017-08-05 18:30:20 +00:00
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.PausePreparer(resourceGroupName, serverName, databaseName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request")
return
}
resp, err := client.PauseSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", resp, "Failure sending request")
return
}
result, err = client.PauseResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// PausePreparer prepares the Pause request.
func (client DatabasesClient) PausePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// PauseSender sends the Pause request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) PauseSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// PauseResponder handles the response to the Pause request. The method always
// closes the http.Response Body.
func (client DatabasesClient) PauseResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// Resume resumes a data warehouse. This method may poll for completion. Polling can be canceled by passing the cancel
// channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
2017-08-05 18:30:20 +00:00
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the data
// warehouse to resume.
2017-08-05 18:30:20 +00:00
func (client DatabasesClient) Resume(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
if err != nil {
errChan <- err
}
2017-08-05 18:30:20 +00:00
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.ResumePreparer(resourceGroupName, serverName, databaseName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request")
return
}
resp, err := client.ResumeSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", resp, "Failure sending request")
return
}
result, err = client.ResumeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// ResumePreparer prepares the Resume request.
func (client DatabasesClient) ResumePreparer(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// ResumeSender sends the Resume request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) ResumeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// ResumeResponder handles the response to the Resume request. The method always
// closes the http.Response Body.
func (client DatabasesClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Update updates an existing database. This method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the
// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the
// database to be updated. parameters is the required parameters for updating a database.
func (client DatabasesClient) Update(resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate, cancel <-chan struct{}) (<-chan Database, <-chan error) {
resultChan := make(chan Database, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result Database
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.UpdatePreparer(resourceGroupName, serverName, databaseName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpdatePreparer prepares the Update request.
func (client DatabasesClient) UpdatePreparer(resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"databaseName": autorest.Encode("path", databaseName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serverName": autorest.Encode("path", serverName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2014-04-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client DatabasesClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}