1package synapse 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/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// SQLPoolGeoBackupPoliciesClient is the azure Synapse Analytics Management Client 19type SQLPoolGeoBackupPoliciesClient struct { 20 BaseClient 21} 22 23// NewSQLPoolGeoBackupPoliciesClient creates an instance of the SQLPoolGeoBackupPoliciesClient client. 24func NewSQLPoolGeoBackupPoliciesClient(subscriptionID string) SQLPoolGeoBackupPoliciesClient { 25 return NewSQLPoolGeoBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewSQLPoolGeoBackupPoliciesClientWithBaseURI creates an instance of the SQLPoolGeoBackupPoliciesClient client using 29// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 30// clouds, Azure stack). 31func NewSQLPoolGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) SQLPoolGeoBackupPoliciesClient { 32 return SQLPoolGeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Get get the specified SQL pool geo backup policy 36// Parameters: 37// resourceGroupName - the name of the resource group. The name is case insensitive. 38// workspaceName - the name of the workspace 39// SQLPoolName - SQL pool name 40func (client SQLPoolGeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (result GeoBackupPolicy, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolGeoBackupPoliciesClient.Get") 43 defer func() { 44 sc := -1 45 if result.Response.Response != nil { 46 sc = result.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: client.SubscriptionID, 53 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 54 {TargetValue: resourceGroupName, 55 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 56 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 57 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 58 return result, validation.NewError("synapse.SQLPoolGeoBackupPoliciesClient", "Get", err.Error()) 59 } 60 61 req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, SQLPoolName) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "Get", nil, "Failure preparing request") 64 return 65 } 66 67 resp, err := client.GetSender(req) 68 if err != nil { 69 result.Response = autorest.Response{Response: resp} 70 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "Get", resp, "Failure sending request") 71 return 72 } 73 74 result, err = client.GetResponder(resp) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "Get", resp, "Failure responding to request") 77 return 78 } 79 80 return 81} 82 83// GetPreparer prepares the Get request. 84func (client SQLPoolGeoBackupPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (*http.Request, error) { 85 pathParameters := map[string]interface{}{ 86 "geoBackupPolicyName": autorest.Encode("path", "Default"), 87 "resourceGroupName": autorest.Encode("path", resourceGroupName), 88 "sqlPoolName": autorest.Encode("path", SQLPoolName), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 "workspaceName": autorest.Encode("path", workspaceName), 91 } 92 93 const APIVersion = "2019-06-01-preview" 94 queryParameters := map[string]interface{}{ 95 "api-version": APIVersion, 96 } 97 98 preparer := autorest.CreatePreparer( 99 autorest.AsGet(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}", pathParameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// GetSender sends the Get request. The method will close the 107// http.Response Body if it receives an error. 108func (client SQLPoolGeoBackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { 109 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 110} 111 112// GetResponder handles the response to the Get request. The method always 113// closes the http.Response Body. 114func (client SQLPoolGeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { 115 err = autorest.Respond( 116 resp, 117 azure.WithErrorUnlessStatusCode(http.StatusOK), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// List get list of SQL pool geo backup policies 125// Parameters: 126// resourceGroupName - the name of the resource group. The name is case insensitive. 127// workspaceName - the name of the workspace 128// SQLPoolName - SQL pool name 129func (client SQLPoolGeoBackupPoliciesClient) List(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (result GeoBackupPolicyListResult, err error) { 130 if tracing.IsEnabled() { 131 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolGeoBackupPoliciesClient.List") 132 defer func() { 133 sc := -1 134 if result.Response.Response != nil { 135 sc = result.Response.Response.StatusCode 136 } 137 tracing.EndSpan(ctx, sc, err) 138 }() 139 } 140 if err := validation.Validate([]validation.Validation{ 141 {TargetValue: client.SubscriptionID, 142 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 143 {TargetValue: resourceGroupName, 144 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 145 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 146 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 147 return result, validation.NewError("synapse.SQLPoolGeoBackupPoliciesClient", "List", err.Error()) 148 } 149 150 req, err := client.ListPreparer(ctx, resourceGroupName, workspaceName, SQLPoolName) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "List", nil, "Failure preparing request") 153 return 154 } 155 156 resp, err := client.ListSender(req) 157 if err != nil { 158 result.Response = autorest.Response{Response: resp} 159 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "List", resp, "Failure sending request") 160 return 161 } 162 163 result, err = client.ListResponder(resp) 164 if err != nil { 165 err = autorest.NewErrorWithError(err, "synapse.SQLPoolGeoBackupPoliciesClient", "List", resp, "Failure responding to request") 166 return 167 } 168 169 return 170} 171 172// ListPreparer prepares the List request. 173func (client SQLPoolGeoBackupPoliciesClient) ListPreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (*http.Request, error) { 174 pathParameters := map[string]interface{}{ 175 "resourceGroupName": autorest.Encode("path", resourceGroupName), 176 "sqlPoolName": autorest.Encode("path", SQLPoolName), 177 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 178 "workspaceName": autorest.Encode("path", workspaceName), 179 } 180 181 const APIVersion = "2019-06-01-preview" 182 queryParameters := map[string]interface{}{ 183 "api-version": APIVersion, 184 } 185 186 preparer := autorest.CreatePreparer( 187 autorest.AsGet(), 188 autorest.WithBaseURL(client.BaseURI), 189 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies", pathParameters), 190 autorest.WithQueryParameters(queryParameters)) 191 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 192} 193 194// ListSender sends the List request. The method will close the 195// http.Response Body if it receives an error. 196func (client SQLPoolGeoBackupPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { 197 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 198} 199 200// ListResponder handles the response to the List request. The method always 201// closes the http.Response Body. 202func (client SQLPoolGeoBackupPoliciesClient) ListResponder(resp *http.Response) (result GeoBackupPolicyListResult, err error) { 203 err = autorest.Respond( 204 resp, 205 azure.WithErrorUnlessStatusCode(http.StatusOK), 206 autorest.ByUnmarshallingJSON(&result), 207 autorest.ByClosing()) 208 result.Response = autorest.Response{Response: resp} 209 return 210} 211