1package sql 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// TransparentDataEncryptionActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web 29// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, 30// retrieve, update, and delete databases. 31type TransparentDataEncryptionActivitiesClient struct { 32 BaseClient 33} 34 35// NewTransparentDataEncryptionActivitiesClient creates an instance of the TransparentDataEncryptionActivitiesClient 36// client. 37func NewTransparentDataEncryptionActivitiesClient(subscriptionID string) TransparentDataEncryptionActivitiesClient { 38 return NewTransparentDataEncryptionActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) 39} 40 41// NewTransparentDataEncryptionActivitiesClientWithBaseURI creates an instance of the 42// TransparentDataEncryptionActivitiesClient client using a custom endpoint. Use this when interacting with an Azure 43// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 44func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { 45 return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} 46} 47 48// ListByConfiguration returns a database's transparent data encryption operation result. 49// Parameters: 50// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 51// from the Azure Resource Manager API or the portal. 52// serverName - the name of the server. 53// databaseName - the name of the database for which the transparent data encryption applies. 54func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { 55 if tracing.IsEnabled() { 56 ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionActivitiesClient.ListByConfiguration") 57 defer func() { 58 sc := -1 59 if result.Response.Response != nil { 60 sc = result.Response.Response.StatusCode 61 } 62 tracing.EndSpan(ctx, sc, err) 63 }() 64 } 65 req, err := client.ListByConfigurationPreparer(ctx, resourceGroupName, serverName, databaseName) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", nil, "Failure preparing request") 68 return 69 } 70 71 resp, err := client.ListByConfigurationSender(req) 72 if err != nil { 73 result.Response = autorest.Response{Response: resp} 74 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure sending request") 75 return 76 } 77 78 result, err = client.ListByConfigurationResponder(resp) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure responding to request") 81 return 82 } 83 84 return 85} 86 87// ListByConfigurationPreparer prepares the ListByConfiguration request. 88func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "databaseName": autorest.Encode("path", databaseName), 91 "resourceGroupName": autorest.Encode("path", resourceGroupName), 92 "serverName": autorest.Encode("path", serverName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 "transparentDataEncryptionName": autorest.Encode("path", "current"), 95 } 96 97 const APIVersion = "2014-04-01" 98 queryParameters := map[string]interface{}{ 99 "api-version": APIVersion, 100 } 101 102 preparer := autorest.CreatePreparer( 103 autorest.AsGet(), 104 autorest.WithBaseURL(client.BaseURI), 105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults", pathParameters), 106 autorest.WithQueryParameters(queryParameters)) 107 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 108} 109 110// ListByConfigurationSender sends the ListByConfiguration request. The method will close the 111// http.Response Body if it receives an error. 112func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationSender(req *http.Request) (*http.Response, error) { 113 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 114} 115 116// ListByConfigurationResponder handles the response to the ListByConfiguration request. The method always 117// closes the http.Response Body. 118func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationResponder(resp *http.Response) (result TransparentDataEncryptionActivityListResult, err error) { 119 err = autorest.Respond( 120 resp, 121 azure.WithErrorUnlessStatusCode(http.StatusOK), 122 autorest.ByUnmarshallingJSON(&result), 123 autorest.ByClosing()) 124 result.Response = autorest.Response{Response: resp} 125 return 126} 127