1package documentdb 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// TableResourcesClient is the azure Cosmos DB Database Service Resource Provider REST API 19type TableResourcesClient struct { 20 BaseClient 21} 22 23// NewTableResourcesClient creates an instance of the TableResourcesClient client. 24func NewTableResourcesClient(subscriptionID string) TableResourcesClient { 25 return NewTableResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewTableResourcesClientWithBaseURI creates an instance of the TableResourcesClient client using a custom endpoint. 29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) TableResourcesClient { 31 return TableResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateUpdateTable create or update an Azure Cosmos DB Table 35// Parameters: 36// resourceGroupName - name of an Azure resource group. 37// accountName - cosmos DB database account name. 38// tableName - cosmos DB table name. 39// createUpdateTableParameters - the parameters to provide for the current Table. 40func (client TableResourcesClient) CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (result TableResourcesCreateUpdateTableFuture, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.CreateUpdateTable") 43 defer func() { 44 sc := -1 45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 46 sc = result.FutureAPI.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}}}, 58 {TargetValue: accountName, 59 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 60 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 61 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 62 {TargetValue: createUpdateTableParameters, 63 Constraints: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties", Name: validation.Null, Rule: true, 64 Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, 65 Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, 66 {Target: "createUpdateTableParameters.TableCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, 67 }}}}}); err != nil { 68 return result, validation.NewError("documentdb.TableResourcesClient", "CreateUpdateTable", err.Error()) 69 } 70 71 req, err := client.CreateUpdateTablePreparer(ctx, resourceGroupName, accountName, tableName, createUpdateTableParameters) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure preparing request") 74 return 75 } 76 77 result, err = client.CreateUpdateTableSender(req) 78 if err != nil { 79 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure sending request") 80 return 81 } 82 83 return 84} 85 86// CreateUpdateTablePreparer prepares the CreateUpdateTable request. 87func (client TableResourcesClient) CreateUpdateTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (*http.Request, error) { 88 pathParameters := map[string]interface{}{ 89 "accountName": autorest.Encode("path", accountName), 90 "resourceGroupName": autorest.Encode("path", resourceGroupName), 91 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 92 "tableName": autorest.Encode("path", tableName), 93 } 94 95 const APIVersion = "2019-08-01" 96 queryParameters := map[string]interface{}{ 97 "api-version": APIVersion, 98 } 99 100 preparer := autorest.CreatePreparer( 101 autorest.AsContentType("application/json; charset=utf-8"), 102 autorest.AsPut(), 103 autorest.WithBaseURL(client.BaseURI), 104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), 105 autorest.WithJSON(createUpdateTableParameters), 106 autorest.WithQueryParameters(queryParameters)) 107 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 108} 109 110// CreateUpdateTableSender sends the CreateUpdateTable request. The method will close the 111// http.Response Body if it receives an error. 112func (client TableResourcesClient) CreateUpdateTableSender(req *http.Request) (future TableResourcesCreateUpdateTableFuture, err error) { 113 var resp *http.Response 114 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 115 if err != nil { 116 return 117 } 118 var azf azure.Future 119 azf, err = azure.NewFutureFromResponse(resp) 120 future.FutureAPI = &azf 121 future.Result = future.result 122 return 123} 124 125// CreateUpdateTableResponder handles the response to the CreateUpdateTable request. The method always 126// closes the http.Response Body. 127func (client TableResourcesClient) CreateUpdateTableResponder(resp *http.Response) (result TableGetResults, err error) { 128 err = autorest.Respond( 129 resp, 130 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 131 autorest.ByUnmarshallingJSON(&result), 132 autorest.ByClosing()) 133 result.Response = autorest.Response{Response: resp} 134 return 135} 136 137// DeleteTable deletes an existing Azure Cosmos DB Table. 138// Parameters: 139// resourceGroupName - name of an Azure resource group. 140// accountName - cosmos DB database account name. 141// tableName - cosmos DB table name. 142func (client TableResourcesClient) DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesDeleteTableFuture, err error) { 143 if tracing.IsEnabled() { 144 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.DeleteTable") 145 defer func() { 146 sc := -1 147 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 148 sc = result.FutureAPI.Response().StatusCode 149 } 150 tracing.EndSpan(ctx, sc, err) 151 }() 152 } 153 if err := validation.Validate([]validation.Validation{ 154 {TargetValue: client.SubscriptionID, 155 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 156 {TargetValue: resourceGroupName, 157 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 158 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 159 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 160 {TargetValue: accountName, 161 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 162 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 163 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 164 return result, validation.NewError("documentdb.TableResourcesClient", "DeleteTable", err.Error()) 165 } 166 167 req, err := client.DeleteTablePreparer(ctx, resourceGroupName, accountName, tableName) 168 if err != nil { 169 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure preparing request") 170 return 171 } 172 173 result, err = client.DeleteTableSender(req) 174 if err != nil { 175 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure sending request") 176 return 177 } 178 179 return 180} 181 182// DeleteTablePreparer prepares the DeleteTable request. 183func (client TableResourcesClient) DeleteTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { 184 pathParameters := map[string]interface{}{ 185 "accountName": autorest.Encode("path", accountName), 186 "resourceGroupName": autorest.Encode("path", resourceGroupName), 187 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 188 "tableName": autorest.Encode("path", tableName), 189 } 190 191 const APIVersion = "2019-08-01" 192 queryParameters := map[string]interface{}{ 193 "api-version": APIVersion, 194 } 195 196 preparer := autorest.CreatePreparer( 197 autorest.AsDelete(), 198 autorest.WithBaseURL(client.BaseURI), 199 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), 200 autorest.WithQueryParameters(queryParameters)) 201 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 202} 203 204// DeleteTableSender sends the DeleteTable request. The method will close the 205// http.Response Body if it receives an error. 206func (client TableResourcesClient) DeleteTableSender(req *http.Request) (future TableResourcesDeleteTableFuture, err error) { 207 var resp *http.Response 208 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 209 if err != nil { 210 return 211 } 212 var azf azure.Future 213 azf, err = azure.NewFutureFromResponse(resp) 214 future.FutureAPI = &azf 215 future.Result = future.result 216 return 217} 218 219// DeleteTableResponder handles the response to the DeleteTable request. The method always 220// closes the http.Response Body. 221func (client TableResourcesClient) DeleteTableResponder(resp *http.Response) (result autorest.Response, err error) { 222 err = autorest.Respond( 223 resp, 224 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 225 autorest.ByClosing()) 226 result.Response = resp 227 return 228} 229 230// GetTable gets the Tables under an existing Azure Cosmos DB database account with the provided name. 231// Parameters: 232// resourceGroupName - name of an Azure resource group. 233// accountName - cosmos DB database account name. 234// tableName - cosmos DB table name. 235func (client TableResourcesClient) GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableGetResults, err error) { 236 if tracing.IsEnabled() { 237 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTable") 238 defer func() { 239 sc := -1 240 if result.Response.Response != nil { 241 sc = result.Response.Response.StatusCode 242 } 243 tracing.EndSpan(ctx, sc, err) 244 }() 245 } 246 if err := validation.Validate([]validation.Validation{ 247 {TargetValue: client.SubscriptionID, 248 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 249 {TargetValue: resourceGroupName, 250 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 251 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 252 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 253 {TargetValue: accountName, 254 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 255 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 256 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 257 return result, validation.NewError("documentdb.TableResourcesClient", "GetTable", err.Error()) 258 } 259 260 req, err := client.GetTablePreparer(ctx, resourceGroupName, accountName, tableName) 261 if err != nil { 262 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", nil, "Failure preparing request") 263 return 264 } 265 266 resp, err := client.GetTableSender(req) 267 if err != nil { 268 result.Response = autorest.Response{Response: resp} 269 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure sending request") 270 return 271 } 272 273 result, err = client.GetTableResponder(resp) 274 if err != nil { 275 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure responding to request") 276 return 277 } 278 279 return 280} 281 282// GetTablePreparer prepares the GetTable request. 283func (client TableResourcesClient) GetTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { 284 pathParameters := map[string]interface{}{ 285 "accountName": autorest.Encode("path", accountName), 286 "resourceGroupName": autorest.Encode("path", resourceGroupName), 287 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 288 "tableName": autorest.Encode("path", tableName), 289 } 290 291 const APIVersion = "2019-08-01" 292 queryParameters := map[string]interface{}{ 293 "api-version": APIVersion, 294 } 295 296 preparer := autorest.CreatePreparer( 297 autorest.AsGet(), 298 autorest.WithBaseURL(client.BaseURI), 299 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), 300 autorest.WithQueryParameters(queryParameters)) 301 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 302} 303 304// GetTableSender sends the GetTable request. The method will close the 305// http.Response Body if it receives an error. 306func (client TableResourcesClient) GetTableSender(req *http.Request) (*http.Response, error) { 307 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 308} 309 310// GetTableResponder handles the response to the GetTable request. The method always 311// closes the http.Response Body. 312func (client TableResourcesClient) GetTableResponder(resp *http.Response) (result TableGetResults, err error) { 313 err = autorest.Respond( 314 resp, 315 azure.WithErrorUnlessStatusCode(http.StatusOK), 316 autorest.ByUnmarshallingJSON(&result), 317 autorest.ByClosing()) 318 result.Response = autorest.Response{Response: resp} 319 return 320} 321 322// GetTableThroughput gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the 323// provided name. 324// Parameters: 325// resourceGroupName - name of an Azure resource group. 326// accountName - cosmos DB database account name. 327// tableName - cosmos DB table name. 328func (client TableResourcesClient) GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result ThroughputSettingsGetResults, err error) { 329 if tracing.IsEnabled() { 330 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTableThroughput") 331 defer func() { 332 sc := -1 333 if result.Response.Response != nil { 334 sc = result.Response.Response.StatusCode 335 } 336 tracing.EndSpan(ctx, sc, err) 337 }() 338 } 339 if err := validation.Validate([]validation.Validation{ 340 {TargetValue: client.SubscriptionID, 341 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 342 {TargetValue: resourceGroupName, 343 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 344 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 345 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 346 {TargetValue: accountName, 347 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 348 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 349 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 350 return result, validation.NewError("documentdb.TableResourcesClient", "GetTableThroughput", err.Error()) 351 } 352 353 req, err := client.GetTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName) 354 if err != nil { 355 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", nil, "Failure preparing request") 356 return 357 } 358 359 resp, err := client.GetTableThroughputSender(req) 360 if err != nil { 361 result.Response = autorest.Response{Response: resp} 362 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure sending request") 363 return 364 } 365 366 result, err = client.GetTableThroughputResponder(resp) 367 if err != nil { 368 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure responding to request") 369 return 370 } 371 372 return 373} 374 375// GetTableThroughputPreparer prepares the GetTableThroughput request. 376func (client TableResourcesClient) GetTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { 377 pathParameters := map[string]interface{}{ 378 "accountName": autorest.Encode("path", accountName), 379 "resourceGroupName": autorest.Encode("path", resourceGroupName), 380 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 381 "tableName": autorest.Encode("path", tableName), 382 } 383 384 const APIVersion = "2019-08-01" 385 queryParameters := map[string]interface{}{ 386 "api-version": APIVersion, 387 } 388 389 preparer := autorest.CreatePreparer( 390 autorest.AsGet(), 391 autorest.WithBaseURL(client.BaseURI), 392 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), 393 autorest.WithQueryParameters(queryParameters)) 394 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 395} 396 397// GetTableThroughputSender sends the GetTableThroughput request. The method will close the 398// http.Response Body if it receives an error. 399func (client TableResourcesClient) GetTableThroughputSender(req *http.Request) (*http.Response, error) { 400 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 401} 402 403// GetTableThroughputResponder handles the response to the GetTableThroughput request. The method always 404// closes the http.Response Body. 405func (client TableResourcesClient) GetTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 406 err = autorest.Respond( 407 resp, 408 azure.WithErrorUnlessStatusCode(http.StatusOK), 409 autorest.ByUnmarshallingJSON(&result), 410 autorest.ByClosing()) 411 result.Response = autorest.Response{Response: resp} 412 return 413} 414 415// ListTables lists the Tables under an existing Azure Cosmos DB database account. 416// Parameters: 417// resourceGroupName - name of an Azure resource group. 418// accountName - cosmos DB database account name. 419func (client TableResourcesClient) ListTables(ctx context.Context, resourceGroupName string, accountName string) (result TableListResult, err error) { 420 if tracing.IsEnabled() { 421 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.ListTables") 422 defer func() { 423 sc := -1 424 if result.Response.Response != nil { 425 sc = result.Response.Response.StatusCode 426 } 427 tracing.EndSpan(ctx, sc, err) 428 }() 429 } 430 if err := validation.Validate([]validation.Validation{ 431 {TargetValue: client.SubscriptionID, 432 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 433 {TargetValue: resourceGroupName, 434 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 435 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 436 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 437 {TargetValue: accountName, 438 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 439 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 440 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 441 return result, validation.NewError("documentdb.TableResourcesClient", "ListTables", err.Error()) 442 } 443 444 req, err := client.ListTablesPreparer(ctx, resourceGroupName, accountName) 445 if err != nil { 446 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", nil, "Failure preparing request") 447 return 448 } 449 450 resp, err := client.ListTablesSender(req) 451 if err != nil { 452 result.Response = autorest.Response{Response: resp} 453 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure sending request") 454 return 455 } 456 457 result, err = client.ListTablesResponder(resp) 458 if err != nil { 459 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure responding to request") 460 return 461 } 462 463 return 464} 465 466// ListTablesPreparer prepares the ListTables request. 467func (client TableResourcesClient) ListTablesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 468 pathParameters := map[string]interface{}{ 469 "accountName": autorest.Encode("path", accountName), 470 "resourceGroupName": autorest.Encode("path", resourceGroupName), 471 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 472 } 473 474 const APIVersion = "2019-08-01" 475 queryParameters := map[string]interface{}{ 476 "api-version": APIVersion, 477 } 478 479 preparer := autorest.CreatePreparer( 480 autorest.AsGet(), 481 autorest.WithBaseURL(client.BaseURI), 482 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", pathParameters), 483 autorest.WithQueryParameters(queryParameters)) 484 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 485} 486 487// ListTablesSender sends the ListTables request. The method will close the 488// http.Response Body if it receives an error. 489func (client TableResourcesClient) ListTablesSender(req *http.Request) (*http.Response, error) { 490 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 491} 492 493// ListTablesResponder handles the response to the ListTables request. The method always 494// closes the http.Response Body. 495func (client TableResourcesClient) ListTablesResponder(resp *http.Response) (result TableListResult, err error) { 496 err = autorest.Respond( 497 resp, 498 azure.WithErrorUnlessStatusCode(http.StatusOK), 499 autorest.ByUnmarshallingJSON(&result), 500 autorest.ByClosing()) 501 result.Response = autorest.Response{Response: resp} 502 return 503} 504 505// UpdateTableThroughput update RUs per second of an Azure Cosmos DB Table 506// Parameters: 507// resourceGroupName - name of an Azure resource group. 508// accountName - cosmos DB database account name. 509// tableName - cosmos DB table name. 510// updateThroughputParameters - the parameters to provide for the RUs per second of the current Table. 511func (client TableResourcesClient) UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result TableResourcesUpdateTableThroughputFuture, err error) { 512 if tracing.IsEnabled() { 513 ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.UpdateTableThroughput") 514 defer func() { 515 sc := -1 516 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 517 sc = result.FutureAPI.Response().StatusCode 518 } 519 tracing.EndSpan(ctx, sc, err) 520 }() 521 } 522 if err := validation.Validate([]validation.Validation{ 523 {TargetValue: client.SubscriptionID, 524 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 525 {TargetValue: resourceGroupName, 526 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 527 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 528 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 529 {TargetValue: accountName, 530 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 531 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 532 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 533 {TargetValue: updateThroughputParameters, 534 Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, 535 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, 536 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, 537 }}}}}); err != nil { 538 return result, validation.NewError("documentdb.TableResourcesClient", "UpdateTableThroughput", err.Error()) 539 } 540 541 req, err := client.UpdateTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName, updateThroughputParameters) 542 if err != nil { 543 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure preparing request") 544 return 545 } 546 547 result, err = client.UpdateTableThroughputSender(req) 548 if err != nil { 549 err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure sending request") 550 return 551 } 552 553 return 554} 555 556// UpdateTableThroughputPreparer prepares the UpdateTableThroughput request. 557func (client TableResourcesClient) UpdateTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { 558 pathParameters := map[string]interface{}{ 559 "accountName": autorest.Encode("path", accountName), 560 "resourceGroupName": autorest.Encode("path", resourceGroupName), 561 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 562 "tableName": autorest.Encode("path", tableName), 563 } 564 565 const APIVersion = "2019-08-01" 566 queryParameters := map[string]interface{}{ 567 "api-version": APIVersion, 568 } 569 570 preparer := autorest.CreatePreparer( 571 autorest.AsContentType("application/json; charset=utf-8"), 572 autorest.AsPut(), 573 autorest.WithBaseURL(client.BaseURI), 574 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), 575 autorest.WithJSON(updateThroughputParameters), 576 autorest.WithQueryParameters(queryParameters)) 577 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 578} 579 580// UpdateTableThroughputSender sends the UpdateTableThroughput request. The method will close the 581// http.Response Body if it receives an error. 582func (client TableResourcesClient) UpdateTableThroughputSender(req *http.Request) (future TableResourcesUpdateTableThroughputFuture, err error) { 583 var resp *http.Response 584 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 585 if err != nil { 586 return 587 } 588 var azf azure.Future 589 azf, err = azure.NewFutureFromResponse(resp) 590 future.FutureAPI = &azf 591 future.Result = future.result 592 return 593} 594 595// UpdateTableThroughputResponder handles the response to the UpdateTableThroughput request. The method always 596// closes the http.Response Body. 597func (client TableResourcesClient) UpdateTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 598 err = autorest.Respond( 599 resp, 600 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 601 autorest.ByUnmarshallingJSON(&result), 602 autorest.ByClosing()) 603 result.Response = autorest.Response{Response: resp} 604 return 605} 606