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/autorest/validation" 25 "net/http" 26) 27 28// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 29// DataMaskingRulesClient is the the Azure SQL Database management API provides a RESTful set of web services that 30// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, 31// and delete databases. 32type DataMaskingRulesClient struct { 33 BaseClient 34} 35 36// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 37// NewDataMaskingRulesClient creates an instance of the DataMaskingRulesClient client. 38func NewDataMaskingRulesClient(subscriptionID string) DataMaskingRulesClient { 39 return NewDataMaskingRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) 40} 41 42// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 43// NewDataMaskingRulesClientWithBaseURI creates an instance of the DataMaskingRulesClient client. 44func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { 45 return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} 46} 47 48// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 49// CreateOrUpdate creates or updates a database data masking rule. 50// 51// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from 52// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of 53// the database. dataMaskingRuleName is the name of the data masking rule. parameters is the required parameters 54// for creating or updating a data masking rule. 55func (client DataMaskingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (result DataMaskingRule, err error) { 56 if err := validation.Validate([]validation.Validation{ 57 {TargetValue: parameters, 58 Constraints: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties", Name: validation.Null, Rule: false, 59 Chain: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties.SchemaName", Name: validation.Null, Rule: true, Chain: nil}, 60 {Target: "parameters.DataMaskingRuleProperties.TableName", Name: validation.Null, Rule: true, Chain: nil}, 61 {Target: "parameters.DataMaskingRuleProperties.ColumnName", Name: validation.Null, Rule: true, Chain: nil}, 62 }}}}}); err != nil { 63 return result, validation.NewError("sql.DataMaskingRulesClient", "CreateOrUpdate", err.Error()) 64 } 65 66 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.CreateOrUpdateSender(req) 73 if err != nil { 74 result.Response = autorest.Response{Response: resp} 75 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure sending request") 76 return 77 } 78 79 result, err = client.CreateOrUpdateResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure responding to request") 82 } 83 84 return 85} 86 87// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 88// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 89func (client DataMaskingRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (*http.Request, error) { 90 pathParameters := map[string]interface{}{ 91 "databaseName": autorest.Encode("path", databaseName), 92 "dataMaskingPolicyName": autorest.Encode("path", "Default"), 93 "dataMaskingRuleName": autorest.Encode("path", dataMaskingRuleName), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "serverName": autorest.Encode("path", serverName), 96 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 97 } 98 99 const APIVersion = "2014-04-01" 100 queryParameters := map[string]interface{}{ 101 "api-version": APIVersion, 102 } 103 104 preparer := autorest.CreatePreparer( 105 autorest.AsContentType("application/json; charset=utf-8"), 106 autorest.AsPut(), 107 autorest.WithBaseURL(client.BaseURI), 108 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", pathParameters), 109 autorest.WithJSON(parameters), 110 autorest.WithQueryParameters(queryParameters)) 111 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 112} 113 114// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 115// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 116// http.Response Body if it receives an error. 117func (client DataMaskingRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 118 return autorest.SendWithSender(client, req, 119 azure.DoRetryWithRegistration(client.Client)) 120} 121 122// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 123// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 124// closes the http.Response Body. 125func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { 126 err = autorest.Respond( 127 resp, 128 client.ByInspecting(), 129 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 130 autorest.ByUnmarshallingJSON(&result), 131 autorest.ByClosing()) 132 result.Response = autorest.Response{Response: resp} 133 return 134} 135 136// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 137// ListByDatabase gets a list of database data masking rules. 138// 139// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from 140// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of 141// the database. 142func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { 143 req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", nil, "Failure preparing request") 146 return 147 } 148 149 resp, err := client.ListByDatabaseSender(req) 150 if err != nil { 151 result.Response = autorest.Response{Response: resp} 152 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure sending request") 153 return 154 } 155 156 result, err = client.ListByDatabaseResponder(resp) 157 if err != nil { 158 err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure responding to request") 159 } 160 161 return 162} 163 164// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 165// ListByDatabasePreparer prepares the ListByDatabase request. 166func (client DataMaskingRulesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { 167 pathParameters := map[string]interface{}{ 168 "databaseName": autorest.Encode("path", databaseName), 169 "dataMaskingPolicyName": autorest.Encode("path", "Default"), 170 "resourceGroupName": autorest.Encode("path", resourceGroupName), 171 "serverName": autorest.Encode("path", serverName), 172 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 173 } 174 175 const APIVersion = "2014-04-01" 176 queryParameters := map[string]interface{}{ 177 "api-version": APIVersion, 178 } 179 180 preparer := autorest.CreatePreparer( 181 autorest.AsGet(), 182 autorest.WithBaseURL(client.BaseURI), 183 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", pathParameters), 184 autorest.WithQueryParameters(queryParameters)) 185 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 186} 187 188// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 189// ListByDatabaseSender sends the ListByDatabase request. The method will close the 190// http.Response Body if it receives an error. 191func (client DataMaskingRulesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { 192 return autorest.SendWithSender(client, req, 193 azure.DoRetryWithRegistration(client.Client)) 194} 195 196// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 197// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always 198// closes the http.Response Body. 199func (client DataMaskingRulesClient) ListByDatabaseResponder(resp *http.Response) (result DataMaskingRuleListResult, err error) { 200 err = autorest.Respond( 201 resp, 202 client.ByInspecting(), 203 azure.WithErrorUnlessStatusCode(http.StatusOK), 204 autorest.ByUnmarshallingJSON(&result), 205 autorest.ByClosing()) 206 result.Response = autorest.Response{Response: resp} 207 return 208} 209