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// TransparentDataEncryptionActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web 18// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, 19// retrieve, update, and delete databases. 20type TransparentDataEncryptionActivitiesClient struct { 21 BaseClient 22} 23 24// NewTransparentDataEncryptionActivitiesClient creates an instance of the TransparentDataEncryptionActivitiesClient 25// client. 26func NewTransparentDataEncryptionActivitiesClient(subscriptionID string) TransparentDataEncryptionActivitiesClient { 27 return NewTransparentDataEncryptionActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) 28} 29 30// NewTransparentDataEncryptionActivitiesClientWithBaseURI creates an instance of the 31// TransparentDataEncryptionActivitiesClient client using a custom endpoint. Use this when interacting with an Azure 32// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 33func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { 34 return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} 35} 36 37// ListByConfiguration returns a database's transparent data encryption operation result. 38// Parameters: 39// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 40// from the Azure Resource Manager API or the portal. 41// serverName - the name of the server. 42// databaseName - the name of the database for which the transparent data encryption applies. 43func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionActivitiesClient.ListByConfiguration") 46 defer func() { 47 sc := -1 48 if result.Response.Response != nil { 49 sc = result.Response.Response.StatusCode 50 } 51 tracing.EndSpan(ctx, sc, err) 52 }() 53 } 54 req, err := client.ListByConfigurationPreparer(ctx, resourceGroupName, serverName, databaseName) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", nil, "Failure preparing request") 57 return 58 } 59 60 resp, err := client.ListByConfigurationSender(req) 61 if err != nil { 62 result.Response = autorest.Response{Response: resp} 63 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure sending request") 64 return 65 } 66 67 result, err = client.ListByConfigurationResponder(resp) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure responding to request") 70 return 71 } 72 73 return 74} 75 76// ListByConfigurationPreparer prepares the ListByConfiguration request. 77func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "databaseName": autorest.Encode("path", databaseName), 80 "resourceGroupName": autorest.Encode("path", resourceGroupName), 81 "serverName": autorest.Encode("path", serverName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 "transparentDataEncryptionName": autorest.Encode("path", "current"), 84 } 85 86 const APIVersion = "2014-04-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsGet(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// ListByConfigurationSender sends the ListByConfiguration request. The method will close the 100// http.Response Body if it receives an error. 101func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationSender(req *http.Request) (*http.Response, error) { 102 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 103} 104 105// ListByConfigurationResponder handles the response to the ListByConfiguration request. The method always 106// closes the http.Response Body. 107func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationResponder(resp *http.Response) (result TransparentDataEncryptionActivityListResult, err error) { 108 err = autorest.Respond( 109 resp, 110 azure.WithErrorUnlessStatusCode(http.StatusOK), 111 autorest.ByUnmarshallingJSON(&result), 112 autorest.ByClosing()) 113 result.Response = autorest.Response{Response: resp} 114 return 115} 116