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// SQLPoolRestorePointsClient is the azure Synapse Analytics Management Client 19type SQLPoolRestorePointsClient struct { 20 BaseClient 21} 22 23// NewSQLPoolRestorePointsClient creates an instance of the SQLPoolRestorePointsClient client. 24func NewSQLPoolRestorePointsClient(subscriptionID string) SQLPoolRestorePointsClient { 25 return NewSQLPoolRestorePointsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewSQLPoolRestorePointsClientWithBaseURI creates an instance of the SQLPoolRestorePointsClient client using a custom 29// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 30// stack). 31func NewSQLPoolRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) SQLPoolRestorePointsClient { 32 return SQLPoolRestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Create creates a restore point for a data warehouse. 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 40// parameters - the definition for creating the restore point of this Sql pool. 41func (client SQLPoolRestorePointsClient) Create(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, parameters CreateSQLPoolRestorePointDefinition) (result SQLPoolRestorePointsCreateFuture, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolRestorePointsClient.Create") 44 defer func() { 45 sc := -1 46 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 47 sc = result.FutureAPI.Response().StatusCode 48 } 49 tracing.EndSpan(ctx, sc, err) 50 }() 51 } 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: client.SubscriptionID, 54 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 55 {TargetValue: resourceGroupName, 56 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 57 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 58 {TargetValue: parameters, 59 Constraints: []validation.Constraint{{Target: "parameters.RestorePointLabel", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 60 return result, validation.NewError("synapse.SQLPoolRestorePointsClient", "Create", err.Error()) 61 } 62 63 req, err := client.CreatePreparer(ctx, resourceGroupName, workspaceName, SQLPoolName, parameters) 64 if err != nil { 65 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Create", nil, "Failure preparing request") 66 return 67 } 68 69 result, err = client.CreateSender(req) 70 if err != nil { 71 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Create", nil, "Failure sending request") 72 return 73 } 74 75 return 76} 77 78// CreatePreparer prepares the Create request. 79func (client SQLPoolRestorePointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, parameters CreateSQLPoolRestorePointDefinition) (*http.Request, error) { 80 pathParameters := map[string]interface{}{ 81 "resourceGroupName": autorest.Encode("path", resourceGroupName), 82 "sqlPoolName": autorest.Encode("path", SQLPoolName), 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 "workspaceName": autorest.Encode("path", workspaceName), 85 } 86 87 const APIVersion = "2021-06-01-preview" 88 queryParameters := map[string]interface{}{ 89 "api-version": APIVersion, 90 } 91 92 preparer := autorest.CreatePreparer( 93 autorest.AsContentType("application/json; charset=utf-8"), 94 autorest.AsPost(), 95 autorest.WithBaseURL(client.BaseURI), 96 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints", pathParameters), 97 autorest.WithJSON(parameters), 98 autorest.WithQueryParameters(queryParameters)) 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// CreateSender sends the Create request. The method will close the 103// http.Response Body if it receives an error. 104func (client SQLPoolRestorePointsClient) CreateSender(req *http.Request) (future SQLPoolRestorePointsCreateFuture, err error) { 105 var resp *http.Response 106 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 107 if err != nil { 108 return 109 } 110 var azf azure.Future 111 azf, err = azure.NewFutureFromResponse(resp) 112 future.FutureAPI = &azf 113 future.Result = future.result 114 return 115} 116 117// CreateResponder handles the response to the Create request. The method always 118// closes the http.Response Body. 119func (client SQLPoolRestorePointsClient) CreateResponder(resp *http.Response) (result RestorePoint, err error) { 120 err = autorest.Respond( 121 resp, 122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), 123 autorest.ByUnmarshallingJSON(&result), 124 autorest.ByClosing()) 125 result.Response = autorest.Response{Response: resp} 126 return 127} 128 129// Delete deletes a restore point. 130// Parameters: 131// resourceGroupName - the name of the resource group. The name is case insensitive. 132// workspaceName - the name of the workspace 133// SQLPoolName - SQL pool name 134// restorePointName - the name of the restore point. 135func (client SQLPoolRestorePointsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, restorePointName string) (result autorest.Response, err error) { 136 if tracing.IsEnabled() { 137 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolRestorePointsClient.Delete") 138 defer func() { 139 sc := -1 140 if result.Response != nil { 141 sc = result.Response.StatusCode 142 } 143 tracing.EndSpan(ctx, sc, err) 144 }() 145 } 146 if err := validation.Validate([]validation.Validation{ 147 {TargetValue: client.SubscriptionID, 148 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 149 {TargetValue: resourceGroupName, 150 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 151 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 152 return result, validation.NewError("synapse.SQLPoolRestorePointsClient", "Delete", err.Error()) 153 } 154 155 req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName, SQLPoolName, restorePointName) 156 if err != nil { 157 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Delete", nil, "Failure preparing request") 158 return 159 } 160 161 resp, err := client.DeleteSender(req) 162 if err != nil { 163 result.Response = resp 164 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Delete", resp, "Failure sending request") 165 return 166 } 167 168 result, err = client.DeleteResponder(resp) 169 if err != nil { 170 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Delete", resp, "Failure responding to request") 171 return 172 } 173 174 return 175} 176 177// DeletePreparer prepares the Delete request. 178func (client SQLPoolRestorePointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, restorePointName string) (*http.Request, error) { 179 pathParameters := map[string]interface{}{ 180 "resourceGroupName": autorest.Encode("path", resourceGroupName), 181 "restorePointName": autorest.Encode("path", restorePointName), 182 "sqlPoolName": autorest.Encode("path", SQLPoolName), 183 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 184 "workspaceName": autorest.Encode("path", workspaceName), 185 } 186 187 const APIVersion = "2021-06-01-preview" 188 queryParameters := map[string]interface{}{ 189 "api-version": APIVersion, 190 } 191 192 preparer := autorest.CreatePreparer( 193 autorest.AsDelete(), 194 autorest.WithBaseURL(client.BaseURI), 195 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}", pathParameters), 196 autorest.WithQueryParameters(queryParameters)) 197 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 198} 199 200// DeleteSender sends the Delete request. The method will close the 201// http.Response Body if it receives an error. 202func (client SQLPoolRestorePointsClient) DeleteSender(req *http.Request) (*http.Response, error) { 203 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 204} 205 206// DeleteResponder handles the response to the Delete request. The method always 207// closes the http.Response Body. 208func (client SQLPoolRestorePointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 209 err = autorest.Respond( 210 resp, 211 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 212 autorest.ByClosing()) 213 result.Response = resp 214 return 215} 216 217// Get gets a restore point. 218// Parameters: 219// resourceGroupName - the name of the resource group. The name is case insensitive. 220// workspaceName - the name of the workspace 221// SQLPoolName - SQL pool name 222// restorePointName - the name of the restore point. 223func (client SQLPoolRestorePointsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, restorePointName string) (result RestorePoint, err error) { 224 if tracing.IsEnabled() { 225 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolRestorePointsClient.Get") 226 defer func() { 227 sc := -1 228 if result.Response.Response != nil { 229 sc = result.Response.Response.StatusCode 230 } 231 tracing.EndSpan(ctx, sc, err) 232 }() 233 } 234 if err := validation.Validate([]validation.Validation{ 235 {TargetValue: client.SubscriptionID, 236 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 237 {TargetValue: resourceGroupName, 238 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 239 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 240 return result, validation.NewError("synapse.SQLPoolRestorePointsClient", "Get", err.Error()) 241 } 242 243 req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, SQLPoolName, restorePointName) 244 if err != nil { 245 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Get", nil, "Failure preparing request") 246 return 247 } 248 249 resp, err := client.GetSender(req) 250 if err != nil { 251 result.Response = autorest.Response{Response: resp} 252 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Get", resp, "Failure sending request") 253 return 254 } 255 256 result, err = client.GetResponder(resp) 257 if err != nil { 258 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "Get", resp, "Failure responding to request") 259 return 260 } 261 262 return 263} 264 265// GetPreparer prepares the Get request. 266func (client SQLPoolRestorePointsClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string, restorePointName string) (*http.Request, error) { 267 pathParameters := map[string]interface{}{ 268 "resourceGroupName": autorest.Encode("path", resourceGroupName), 269 "restorePointName": autorest.Encode("path", restorePointName), 270 "sqlPoolName": autorest.Encode("path", SQLPoolName), 271 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 272 "workspaceName": autorest.Encode("path", workspaceName), 273 } 274 275 const APIVersion = "2021-06-01-preview" 276 queryParameters := map[string]interface{}{ 277 "api-version": APIVersion, 278 } 279 280 preparer := autorest.CreatePreparer( 281 autorest.AsGet(), 282 autorest.WithBaseURL(client.BaseURI), 283 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}", pathParameters), 284 autorest.WithQueryParameters(queryParameters)) 285 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 286} 287 288// GetSender sends the Get request. The method will close the 289// http.Response Body if it receives an error. 290func (client SQLPoolRestorePointsClient) GetSender(req *http.Request) (*http.Response, error) { 291 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 292} 293 294// GetResponder handles the response to the Get request. The method always 295// closes the http.Response Body. 296func (client SQLPoolRestorePointsClient) GetResponder(resp *http.Response) (result RestorePoint, err error) { 297 err = autorest.Respond( 298 resp, 299 azure.WithErrorUnlessStatusCode(http.StatusOK), 300 autorest.ByUnmarshallingJSON(&result), 301 autorest.ByClosing()) 302 result.Response = autorest.Response{Response: resp} 303 return 304} 305 306// List get SQL pool backup information 307// Parameters: 308// resourceGroupName - the name of the resource group. The name is case insensitive. 309// workspaceName - the name of the workspace 310// SQLPoolName - SQL pool name 311func (client SQLPoolRestorePointsClient) List(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (result RestorePointListResultPage, err error) { 312 if tracing.IsEnabled() { 313 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolRestorePointsClient.List") 314 defer func() { 315 sc := -1 316 if result.rplr.Response.Response != nil { 317 sc = result.rplr.Response.Response.StatusCode 318 } 319 tracing.EndSpan(ctx, sc, err) 320 }() 321 } 322 if err := validation.Validate([]validation.Validation{ 323 {TargetValue: client.SubscriptionID, 324 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 325 {TargetValue: resourceGroupName, 326 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 327 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 328 return result, validation.NewError("synapse.SQLPoolRestorePointsClient", "List", err.Error()) 329 } 330 331 result.fn = client.listNextResults 332 req, err := client.ListPreparer(ctx, resourceGroupName, workspaceName, SQLPoolName) 333 if err != nil { 334 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "List", nil, "Failure preparing request") 335 return 336 } 337 338 resp, err := client.ListSender(req) 339 if err != nil { 340 result.rplr.Response = autorest.Response{Response: resp} 341 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "List", resp, "Failure sending request") 342 return 343 } 344 345 result.rplr, err = client.ListResponder(resp) 346 if err != nil { 347 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "List", resp, "Failure responding to request") 348 return 349 } 350 if result.rplr.hasNextLink() && result.rplr.IsEmpty() { 351 err = result.NextWithContext(ctx) 352 return 353 } 354 355 return 356} 357 358// ListPreparer prepares the List request. 359func (client SQLPoolRestorePointsClient) ListPreparer(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (*http.Request, error) { 360 pathParameters := map[string]interface{}{ 361 "resourceGroupName": autorest.Encode("path", resourceGroupName), 362 "sqlPoolName": autorest.Encode("path", SQLPoolName), 363 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 364 "workspaceName": autorest.Encode("path", workspaceName), 365 } 366 367 const APIVersion = "2021-06-01-preview" 368 queryParameters := map[string]interface{}{ 369 "api-version": APIVersion, 370 } 371 372 preparer := autorest.CreatePreparer( 373 autorest.AsGet(), 374 autorest.WithBaseURL(client.BaseURI), 375 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints", pathParameters), 376 autorest.WithQueryParameters(queryParameters)) 377 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 378} 379 380// ListSender sends the List request. The method will close the 381// http.Response Body if it receives an error. 382func (client SQLPoolRestorePointsClient) ListSender(req *http.Request) (*http.Response, error) { 383 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 384} 385 386// ListResponder handles the response to the List request. The method always 387// closes the http.Response Body. 388func (client SQLPoolRestorePointsClient) ListResponder(resp *http.Response) (result RestorePointListResult, err error) { 389 err = autorest.Respond( 390 resp, 391 azure.WithErrorUnlessStatusCode(http.StatusOK), 392 autorest.ByUnmarshallingJSON(&result), 393 autorest.ByClosing()) 394 result.Response = autorest.Response{Response: resp} 395 return 396} 397 398// listNextResults retrieves the next set of results, if any. 399func (client SQLPoolRestorePointsClient) listNextResults(ctx context.Context, lastResults RestorePointListResult) (result RestorePointListResult, err error) { 400 req, err := lastResults.restorePointListResultPreparer(ctx) 401 if err != nil { 402 return result, autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "listNextResults", nil, "Failure preparing next results request") 403 } 404 if req == nil { 405 return 406 } 407 resp, err := client.ListSender(req) 408 if err != nil { 409 result.Response = autorest.Response{Response: resp} 410 return result, autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "listNextResults", resp, "Failure sending next results request") 411 } 412 result, err = client.ListResponder(resp) 413 if err != nil { 414 err = autorest.NewErrorWithError(err, "synapse.SQLPoolRestorePointsClient", "listNextResults", resp, "Failure responding to next results request") 415 } 416 return 417} 418 419// ListComplete enumerates all values, automatically crossing page boundaries as required. 420func (client SQLPoolRestorePointsClient) ListComplete(ctx context.Context, resourceGroupName string, workspaceName string, SQLPoolName string) (result RestorePointListResultIterator, err error) { 421 if tracing.IsEnabled() { 422 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolRestorePointsClient.List") 423 defer func() { 424 sc := -1 425 if result.Response().Response.Response != nil { 426 sc = result.page.Response().Response.Response.StatusCode 427 } 428 tracing.EndSpan(ctx, sc, err) 429 }() 430 } 431 result.page, err = client.List(ctx, resourceGroupName, workspaceName, SQLPoolName) 432 return 433} 434