1package sql 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// ElasticPoolActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web services that 18// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, 19// and delete databases. 20type ElasticPoolActivitiesClient struct { 21 BaseClient 22} 23 24// NewElasticPoolActivitiesClient creates an instance of the ElasticPoolActivitiesClient client. 25func NewElasticPoolActivitiesClient(subscriptionID string) ElasticPoolActivitiesClient { 26 return NewElasticPoolActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewElasticPoolActivitiesClientWithBaseURI creates an instance of the ElasticPoolActivitiesClient client using a 30// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, 31// Azure stack). 32func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { 33 return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} 34} 35 36// ListByElasticPool returns elastic pool activities. 37// Parameters: 38// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 39// from the Azure Resource Manager API or the portal. 40// serverName - the name of the server. 41// elasticPoolName - the name of the elastic pool for which to get the current activity. 42func (client ElasticPoolActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolActivityListResult, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolActivitiesClient.ListByElasticPool") 45 defer func() { 46 sc := -1 47 if result.Response.Response != nil { 48 sc = result.Response.Response.StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) 54 if err != nil { 55 err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") 56 return 57 } 58 59 resp, err := client.ListByElasticPoolSender(req) 60 if err != nil { 61 result.Response = autorest.Response{Response: resp} 62 err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure sending request") 63 return 64 } 65 66 result, err = client.ListByElasticPoolResponder(resp) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") 69 return 70 } 71 72 return 73} 74 75// ListByElasticPoolPreparer prepares the ListByElasticPool request. 76func (client ElasticPoolActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { 77 pathParameters := map[string]interface{}{ 78 "elasticPoolName": autorest.Encode("path", elasticPoolName), 79 "resourceGroupName": autorest.Encode("path", resourceGroupName), 80 "serverName": autorest.Encode("path", serverName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2014-04-01" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsGet(), 91 autorest.WithBaseURL(client.BaseURI), 92 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity", pathParameters), 93 autorest.WithQueryParameters(queryParameters)) 94 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 95} 96 97// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the 98// http.Response Body if it receives an error. 99func (client ElasticPoolActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { 100 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 101} 102 103// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always 104// closes the http.Response Body. 105func (client ElasticPoolActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolActivityListResult, err error) { 106 err = autorest.Respond( 107 resp, 108 azure.WithErrorUnlessStatusCode(http.StatusOK), 109 autorest.ByUnmarshallingJSON(&result), 110 autorest.ByClosing()) 111 result.Response = autorest.Response{Response: resp} 112 return 113} 114