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// GremlinResourcesClient is the azure Cosmos DB Database Service Resource Provider REST API 19type GremlinResourcesClient struct { 20 BaseClient 21} 22 23// NewGremlinResourcesClient creates an instance of the GremlinResourcesClient client. 24func NewGremlinResourcesClient(subscriptionID string) GremlinResourcesClient { 25 return NewGremlinResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewGremlinResourcesClientWithBaseURI creates an instance of the GremlinResourcesClient 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 NewGremlinResourcesClientWithBaseURI(baseURI string, subscriptionID string) GremlinResourcesClient { 32 return GremlinResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateUpdateGremlinDatabase create or update an Azure Cosmos DB Gremlin database 36// Parameters: 37// resourceGroupName - name of an Azure resource group. 38// accountName - cosmos DB database account name. 39// databaseName - cosmos DB database name. 40// createUpdateGremlinDatabaseParameters - the parameters to provide for the current Gremlin database. 41func (client GremlinResourcesClient) CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinDatabase") 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 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 59 {TargetValue: accountName, 60 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 61 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 62 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 63 {TargetValue: createUpdateGremlinDatabaseParameters, 64 Constraints: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, 65 Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, 66 Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, 67 {Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, 68 }}}}}); err != nil { 69 return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", err.Error()) 70 } 71 72 req, err := client.CreateUpdateGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure preparing request") 75 return 76 } 77 78 result, err = client.CreateUpdateGremlinDatabaseSender(req) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure sending request") 81 return 82 } 83 84 return 85} 86 87// CreateUpdateGremlinDatabasePreparer prepares the CreateUpdateGremlinDatabase request. 88func (client GremlinResourcesClient) CreateUpdateGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "accountName": autorest.Encode("path", accountName), 91 "databaseName": autorest.Encode("path", databaseName), 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 } 95 96 const APIVersion = "2019-08-01" 97 queryParameters := map[string]interface{}{ 98 "api-version": APIVersion, 99 } 100 101 preparer := autorest.CreatePreparer( 102 autorest.AsContentType("application/json; charset=utf-8"), 103 autorest.AsPut(), 104 autorest.WithBaseURL(client.BaseURI), 105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), 106 autorest.WithJSON(createUpdateGremlinDatabaseParameters), 107 autorest.WithQueryParameters(queryParameters)) 108 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 109} 110 111// CreateUpdateGremlinDatabaseSender sends the CreateUpdateGremlinDatabase request. The method will close the 112// http.Response Body if it receives an error. 113func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { 114 var resp *http.Response 115 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 116 if err != nil { 117 return 118 } 119 var azf azure.Future 120 azf, err = azure.NewFutureFromResponse(resp) 121 future.FutureAPI = &azf 122 future.Result = future.result 123 return 124} 125 126// CreateUpdateGremlinDatabaseResponder handles the response to the CreateUpdateGremlinDatabase request. The method always 127// closes the http.Response Body. 128func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { 129 err = autorest.Respond( 130 resp, 131 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 132 autorest.ByUnmarshallingJSON(&result), 133 autorest.ByClosing()) 134 result.Response = autorest.Response{Response: resp} 135 return 136} 137 138// CreateUpdateGremlinGraph create or update an Azure Cosmos DB Gremlin graph 139// Parameters: 140// resourceGroupName - name of an Azure resource group. 141// accountName - cosmos DB database account name. 142// databaseName - cosmos DB database name. 143// graphName - cosmos DB graph name. 144// createUpdateGremlinGraphParameters - the parameters to provide for the current Gremlin graph. 145func (client GremlinResourcesClient) CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { 146 if tracing.IsEnabled() { 147 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinGraph") 148 defer func() { 149 sc := -1 150 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 151 sc = result.FutureAPI.Response().StatusCode 152 } 153 tracing.EndSpan(ctx, sc, err) 154 }() 155 } 156 if err := validation.Validate([]validation.Validation{ 157 {TargetValue: client.SubscriptionID, 158 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 159 {TargetValue: resourceGroupName, 160 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 161 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 162 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 163 {TargetValue: accountName, 164 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 165 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 166 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 167 {TargetValue: createUpdateGremlinGraphParameters, 168 Constraints: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties", Name: validation.Null, Rule: true, 169 Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, 170 Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, 171 {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, 172 Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, 173 Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, 174 {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 175 }}, 176 }}, 177 }}, 178 {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, 179 }}}}}); err != nil { 180 return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", err.Error()) 181 } 182 183 req, err := client.CreateUpdateGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters) 184 if err != nil { 185 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure preparing request") 186 return 187 } 188 189 result, err = client.CreateUpdateGremlinGraphSender(req) 190 if err != nil { 191 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure sending request") 192 return 193 } 194 195 return 196} 197 198// CreateUpdateGremlinGraphPreparer prepares the CreateUpdateGremlinGraph request. 199func (client GremlinResourcesClient) CreateUpdateGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (*http.Request, error) { 200 pathParameters := map[string]interface{}{ 201 "accountName": autorest.Encode("path", accountName), 202 "databaseName": autorest.Encode("path", databaseName), 203 "graphName": autorest.Encode("path", graphName), 204 "resourceGroupName": autorest.Encode("path", resourceGroupName), 205 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 206 } 207 208 const APIVersion = "2019-08-01" 209 queryParameters := map[string]interface{}{ 210 "api-version": APIVersion, 211 } 212 213 preparer := autorest.CreatePreparer( 214 autorest.AsContentType("application/json; charset=utf-8"), 215 autorest.AsPut(), 216 autorest.WithBaseURL(client.BaseURI), 217 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), 218 autorest.WithJSON(createUpdateGremlinGraphParameters), 219 autorest.WithQueryParameters(queryParameters)) 220 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 221} 222 223// CreateUpdateGremlinGraphSender sends the CreateUpdateGremlinGraph request. The method will close the 224// http.Response Body if it receives an error. 225func (client GremlinResourcesClient) CreateUpdateGremlinGraphSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { 226 var resp *http.Response 227 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 228 if err != nil { 229 return 230 } 231 var azf azure.Future 232 azf, err = azure.NewFutureFromResponse(resp) 233 future.FutureAPI = &azf 234 future.Result = future.result 235 return 236} 237 238// CreateUpdateGremlinGraphResponder handles the response to the CreateUpdateGremlinGraph request. The method always 239// closes the http.Response Body. 240func (client GremlinResourcesClient) CreateUpdateGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { 241 err = autorest.Respond( 242 resp, 243 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 244 autorest.ByUnmarshallingJSON(&result), 245 autorest.ByClosing()) 246 result.Response = autorest.Response{Response: resp} 247 return 248} 249 250// DeleteGremlinDatabase deletes an existing Azure Cosmos DB Gremlin database. 251// Parameters: 252// resourceGroupName - name of an Azure resource group. 253// accountName - cosmos DB database account name. 254// databaseName - cosmos DB database name. 255func (client GremlinResourcesClient) DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesDeleteGremlinDatabaseFuture, err error) { 256 if tracing.IsEnabled() { 257 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinDatabase") 258 defer func() { 259 sc := -1 260 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 261 sc = result.FutureAPI.Response().StatusCode 262 } 263 tracing.EndSpan(ctx, sc, err) 264 }() 265 } 266 if err := validation.Validate([]validation.Validation{ 267 {TargetValue: client.SubscriptionID, 268 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 269 {TargetValue: resourceGroupName, 270 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 271 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 272 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 273 {TargetValue: accountName, 274 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 275 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 276 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 277 return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", err.Error()) 278 } 279 280 req, err := client.DeleteGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) 281 if err != nil { 282 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure preparing request") 283 return 284 } 285 286 result, err = client.DeleteGremlinDatabaseSender(req) 287 if err != nil { 288 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure sending request") 289 return 290 } 291 292 return 293} 294 295// DeleteGremlinDatabasePreparer prepares the DeleteGremlinDatabase request. 296func (client GremlinResourcesClient) DeleteGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { 297 pathParameters := map[string]interface{}{ 298 "accountName": autorest.Encode("path", accountName), 299 "databaseName": autorest.Encode("path", databaseName), 300 "resourceGroupName": autorest.Encode("path", resourceGroupName), 301 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 302 } 303 304 const APIVersion = "2019-08-01" 305 queryParameters := map[string]interface{}{ 306 "api-version": APIVersion, 307 } 308 309 preparer := autorest.CreatePreparer( 310 autorest.AsDelete(), 311 autorest.WithBaseURL(client.BaseURI), 312 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), 313 autorest.WithQueryParameters(queryParameters)) 314 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 315} 316 317// DeleteGremlinDatabaseSender sends the DeleteGremlinDatabase request. The method will close the 318// http.Response Body if it receives an error. 319func (client GremlinResourcesClient) DeleteGremlinDatabaseSender(req *http.Request) (future GremlinResourcesDeleteGremlinDatabaseFuture, err error) { 320 var resp *http.Response 321 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 322 if err != nil { 323 return 324 } 325 var azf azure.Future 326 azf, err = azure.NewFutureFromResponse(resp) 327 future.FutureAPI = &azf 328 future.Result = future.result 329 return 330} 331 332// DeleteGremlinDatabaseResponder handles the response to the DeleteGremlinDatabase request. The method always 333// closes the http.Response Body. 334func (client GremlinResourcesClient) DeleteGremlinDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { 335 err = autorest.Respond( 336 resp, 337 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 338 autorest.ByClosing()) 339 result.Response = resp 340 return 341} 342 343// DeleteGremlinGraph deletes an existing Azure Cosmos DB Gremlin graph. 344// Parameters: 345// resourceGroupName - name of an Azure resource group. 346// accountName - cosmos DB database account name. 347// databaseName - cosmos DB database name. 348// graphName - cosmos DB graph name. 349func (client GremlinResourcesClient) DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesDeleteGremlinGraphFuture, err error) { 350 if tracing.IsEnabled() { 351 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinGraph") 352 defer func() { 353 sc := -1 354 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 355 sc = result.FutureAPI.Response().StatusCode 356 } 357 tracing.EndSpan(ctx, sc, err) 358 }() 359 } 360 if err := validation.Validate([]validation.Validation{ 361 {TargetValue: client.SubscriptionID, 362 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 363 {TargetValue: resourceGroupName, 364 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 365 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 366 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 367 {TargetValue: accountName, 368 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 369 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 370 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 371 return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinGraph", err.Error()) 372 } 373 374 req, err := client.DeleteGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) 375 if err != nil { 376 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure preparing request") 377 return 378 } 379 380 result, err = client.DeleteGremlinGraphSender(req) 381 if err != nil { 382 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure sending request") 383 return 384 } 385 386 return 387} 388 389// DeleteGremlinGraphPreparer prepares the DeleteGremlinGraph request. 390func (client GremlinResourcesClient) DeleteGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { 391 pathParameters := map[string]interface{}{ 392 "accountName": autorest.Encode("path", accountName), 393 "databaseName": autorest.Encode("path", databaseName), 394 "graphName": autorest.Encode("path", graphName), 395 "resourceGroupName": autorest.Encode("path", resourceGroupName), 396 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 397 } 398 399 const APIVersion = "2019-08-01" 400 queryParameters := map[string]interface{}{ 401 "api-version": APIVersion, 402 } 403 404 preparer := autorest.CreatePreparer( 405 autorest.AsDelete(), 406 autorest.WithBaseURL(client.BaseURI), 407 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), 408 autorest.WithQueryParameters(queryParameters)) 409 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 410} 411 412// DeleteGremlinGraphSender sends the DeleteGremlinGraph request. The method will close the 413// http.Response Body if it receives an error. 414func (client GremlinResourcesClient) DeleteGremlinGraphSender(req *http.Request) (future GremlinResourcesDeleteGremlinGraphFuture, err error) { 415 var resp *http.Response 416 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 417 if err != nil { 418 return 419 } 420 var azf azure.Future 421 azf, err = azure.NewFutureFromResponse(resp) 422 future.FutureAPI = &azf 423 future.Result = future.result 424 return 425} 426 427// DeleteGremlinGraphResponder handles the response to the DeleteGremlinGraph request. The method always 428// closes the http.Response Body. 429func (client GremlinResourcesClient) DeleteGremlinGraphResponder(resp *http.Response) (result autorest.Response, err error) { 430 err = autorest.Respond( 431 resp, 432 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 433 autorest.ByClosing()) 434 result.Response = resp 435 return 436} 437 438// GetGremlinDatabase gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided 439// name. 440// Parameters: 441// resourceGroupName - name of an Azure resource group. 442// accountName - cosmos DB database account name. 443// databaseName - cosmos DB database name. 444func (client GremlinResourcesClient) GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinDatabaseGetResults, err error) { 445 if tracing.IsEnabled() { 446 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabase") 447 defer func() { 448 sc := -1 449 if result.Response.Response != nil { 450 sc = result.Response.Response.StatusCode 451 } 452 tracing.EndSpan(ctx, sc, err) 453 }() 454 } 455 if err := validation.Validate([]validation.Validation{ 456 {TargetValue: client.SubscriptionID, 457 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 458 {TargetValue: resourceGroupName, 459 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 460 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 461 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 462 {TargetValue: accountName, 463 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 464 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 465 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 466 return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabase", err.Error()) 467 } 468 469 req, err := client.GetGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) 470 if err != nil { 471 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", nil, "Failure preparing request") 472 return 473 } 474 475 resp, err := client.GetGremlinDatabaseSender(req) 476 if err != nil { 477 result.Response = autorest.Response{Response: resp} 478 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure sending request") 479 return 480 } 481 482 result, err = client.GetGremlinDatabaseResponder(resp) 483 if err != nil { 484 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure responding to request") 485 return 486 } 487 488 return 489} 490 491// GetGremlinDatabasePreparer prepares the GetGremlinDatabase request. 492func (client GremlinResourcesClient) GetGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { 493 pathParameters := map[string]interface{}{ 494 "accountName": autorest.Encode("path", accountName), 495 "databaseName": autorest.Encode("path", databaseName), 496 "resourceGroupName": autorest.Encode("path", resourceGroupName), 497 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 498 } 499 500 const APIVersion = "2019-08-01" 501 queryParameters := map[string]interface{}{ 502 "api-version": APIVersion, 503 } 504 505 preparer := autorest.CreatePreparer( 506 autorest.AsGet(), 507 autorest.WithBaseURL(client.BaseURI), 508 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), 509 autorest.WithQueryParameters(queryParameters)) 510 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 511} 512 513// GetGremlinDatabaseSender sends the GetGremlinDatabase request. The method will close the 514// http.Response Body if it receives an error. 515func (client GremlinResourcesClient) GetGremlinDatabaseSender(req *http.Request) (*http.Response, error) { 516 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 517} 518 519// GetGremlinDatabaseResponder handles the response to the GetGremlinDatabase request. The method always 520// closes the http.Response Body. 521func (client GremlinResourcesClient) GetGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { 522 err = autorest.Respond( 523 resp, 524 azure.WithErrorUnlessStatusCode(http.StatusOK), 525 autorest.ByUnmarshallingJSON(&result), 526 autorest.ByClosing()) 527 result.Response = autorest.Response{Response: resp} 528 return 529} 530 531// GetGremlinDatabaseThroughput gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB 532// database account with the provided name. 533// Parameters: 534// resourceGroupName - name of an Azure resource group. 535// accountName - cosmos DB database account name. 536// databaseName - cosmos DB database name. 537func (client GremlinResourcesClient) GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { 538 if tracing.IsEnabled() { 539 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabaseThroughput") 540 defer func() { 541 sc := -1 542 if result.Response.Response != nil { 543 sc = result.Response.Response.StatusCode 544 } 545 tracing.EndSpan(ctx, sc, err) 546 }() 547 } 548 if err := validation.Validate([]validation.Validation{ 549 {TargetValue: client.SubscriptionID, 550 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 551 {TargetValue: resourceGroupName, 552 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 553 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 554 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 555 {TargetValue: accountName, 556 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 557 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 558 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 559 return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", err.Error()) 560 } 561 562 req, err := client.GetGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) 563 if err != nil { 564 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", nil, "Failure preparing request") 565 return 566 } 567 568 resp, err := client.GetGremlinDatabaseThroughputSender(req) 569 if err != nil { 570 result.Response = autorest.Response{Response: resp} 571 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure sending request") 572 return 573 } 574 575 result, err = client.GetGremlinDatabaseThroughputResponder(resp) 576 if err != nil { 577 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure responding to request") 578 return 579 } 580 581 return 582} 583 584// GetGremlinDatabaseThroughputPreparer prepares the GetGremlinDatabaseThroughput request. 585func (client GremlinResourcesClient) GetGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { 586 pathParameters := map[string]interface{}{ 587 "accountName": autorest.Encode("path", accountName), 588 "databaseName": autorest.Encode("path", databaseName), 589 "resourceGroupName": autorest.Encode("path", resourceGroupName), 590 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 591 } 592 593 const APIVersion = "2019-08-01" 594 queryParameters := map[string]interface{}{ 595 "api-version": APIVersion, 596 } 597 598 preparer := autorest.CreatePreparer( 599 autorest.AsGet(), 600 autorest.WithBaseURL(client.BaseURI), 601 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), 602 autorest.WithQueryParameters(queryParameters)) 603 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 604} 605 606// GetGremlinDatabaseThroughputSender sends the GetGremlinDatabaseThroughput request. The method will close the 607// http.Response Body if it receives an error. 608func (client GremlinResourcesClient) GetGremlinDatabaseThroughputSender(req *http.Request) (*http.Response, error) { 609 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 610} 611 612// GetGremlinDatabaseThroughputResponder handles the response to the GetGremlinDatabaseThroughput request. The method always 613// closes the http.Response Body. 614func (client GremlinResourcesClient) GetGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 615 err = autorest.Respond( 616 resp, 617 azure.WithErrorUnlessStatusCode(http.StatusOK), 618 autorest.ByUnmarshallingJSON(&result), 619 autorest.ByClosing()) 620 result.Response = autorest.Response{Response: resp} 621 return 622} 623 624// GetGremlinGraph gets the Gremlin graph under an existing Azure Cosmos DB database account. 625// Parameters: 626// resourceGroupName - name of an Azure resource group. 627// accountName - cosmos DB database account name. 628// databaseName - cosmos DB database name. 629// graphName - cosmos DB graph name. 630func (client GremlinResourcesClient) GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinGraphGetResults, err error) { 631 if tracing.IsEnabled() { 632 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraph") 633 defer func() { 634 sc := -1 635 if result.Response.Response != nil { 636 sc = result.Response.Response.StatusCode 637 } 638 tracing.EndSpan(ctx, sc, err) 639 }() 640 } 641 if err := validation.Validate([]validation.Validation{ 642 {TargetValue: client.SubscriptionID, 643 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 644 {TargetValue: resourceGroupName, 645 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 646 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 647 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 648 {TargetValue: accountName, 649 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 650 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 651 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 652 return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraph", err.Error()) 653 } 654 655 req, err := client.GetGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) 656 if err != nil { 657 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", nil, "Failure preparing request") 658 return 659 } 660 661 resp, err := client.GetGremlinGraphSender(req) 662 if err != nil { 663 result.Response = autorest.Response{Response: resp} 664 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure sending request") 665 return 666 } 667 668 result, err = client.GetGremlinGraphResponder(resp) 669 if err != nil { 670 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure responding to request") 671 return 672 } 673 674 return 675} 676 677// GetGremlinGraphPreparer prepares the GetGremlinGraph request. 678func (client GremlinResourcesClient) GetGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { 679 pathParameters := map[string]interface{}{ 680 "accountName": autorest.Encode("path", accountName), 681 "databaseName": autorest.Encode("path", databaseName), 682 "graphName": autorest.Encode("path", graphName), 683 "resourceGroupName": autorest.Encode("path", resourceGroupName), 684 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 685 } 686 687 const APIVersion = "2019-08-01" 688 queryParameters := map[string]interface{}{ 689 "api-version": APIVersion, 690 } 691 692 preparer := autorest.CreatePreparer( 693 autorest.AsGet(), 694 autorest.WithBaseURL(client.BaseURI), 695 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), 696 autorest.WithQueryParameters(queryParameters)) 697 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 698} 699 700// GetGremlinGraphSender sends the GetGremlinGraph request. The method will close the 701// http.Response Body if it receives an error. 702func (client GremlinResourcesClient) GetGremlinGraphSender(req *http.Request) (*http.Response, error) { 703 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 704} 705 706// GetGremlinGraphResponder handles the response to the GetGremlinGraph request. The method always 707// closes the http.Response Body. 708func (client GremlinResourcesClient) GetGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { 709 err = autorest.Respond( 710 resp, 711 azure.WithErrorUnlessStatusCode(http.StatusOK), 712 autorest.ByUnmarshallingJSON(&result), 713 autorest.ByClosing()) 714 result.Response = autorest.Response{Response: resp} 715 return 716} 717 718// GetGremlinGraphThroughput gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with 719// the provided name. 720// Parameters: 721// resourceGroupName - name of an Azure resource group. 722// accountName - cosmos DB database account name. 723// databaseName - cosmos DB database name. 724// graphName - cosmos DB graph name. 725func (client GremlinResourcesClient) GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result ThroughputSettingsGetResults, err error) { 726 if tracing.IsEnabled() { 727 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraphThroughput") 728 defer func() { 729 sc := -1 730 if result.Response.Response != nil { 731 sc = result.Response.Response.StatusCode 732 } 733 tracing.EndSpan(ctx, sc, err) 734 }() 735 } 736 if err := validation.Validate([]validation.Validation{ 737 {TargetValue: client.SubscriptionID, 738 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 739 {TargetValue: resourceGroupName, 740 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 741 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 742 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 743 {TargetValue: accountName, 744 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 745 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 746 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 747 return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", err.Error()) 748 } 749 750 req, err := client.GetGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) 751 if err != nil { 752 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", nil, "Failure preparing request") 753 return 754 } 755 756 resp, err := client.GetGremlinGraphThroughputSender(req) 757 if err != nil { 758 result.Response = autorest.Response{Response: resp} 759 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure sending request") 760 return 761 } 762 763 result, err = client.GetGremlinGraphThroughputResponder(resp) 764 if err != nil { 765 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure responding to request") 766 return 767 } 768 769 return 770} 771 772// GetGremlinGraphThroughputPreparer prepares the GetGremlinGraphThroughput request. 773func (client GremlinResourcesClient) GetGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { 774 pathParameters := map[string]interface{}{ 775 "accountName": autorest.Encode("path", accountName), 776 "databaseName": autorest.Encode("path", databaseName), 777 "graphName": autorest.Encode("path", graphName), 778 "resourceGroupName": autorest.Encode("path", resourceGroupName), 779 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 780 } 781 782 const APIVersion = "2019-08-01" 783 queryParameters := map[string]interface{}{ 784 "api-version": APIVersion, 785 } 786 787 preparer := autorest.CreatePreparer( 788 autorest.AsGet(), 789 autorest.WithBaseURL(client.BaseURI), 790 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), 791 autorest.WithQueryParameters(queryParameters)) 792 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 793} 794 795// GetGremlinGraphThroughputSender sends the GetGremlinGraphThroughput request. The method will close the 796// http.Response Body if it receives an error. 797func (client GremlinResourcesClient) GetGremlinGraphThroughputSender(req *http.Request) (*http.Response, error) { 798 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 799} 800 801// GetGremlinGraphThroughputResponder handles the response to the GetGremlinGraphThroughput request. The method always 802// closes the http.Response Body. 803func (client GremlinResourcesClient) GetGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 804 err = autorest.Respond( 805 resp, 806 azure.WithErrorUnlessStatusCode(http.StatusOK), 807 autorest.ByUnmarshallingJSON(&result), 808 autorest.ByClosing()) 809 result.Response = autorest.Response{Response: resp} 810 return 811} 812 813// ListGremlinDatabases lists the Gremlin databases under an existing Azure Cosmos DB database account. 814// Parameters: 815// resourceGroupName - name of an Azure resource group. 816// accountName - cosmos DB database account name. 817func (client GremlinResourcesClient) ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result GremlinDatabaseListResult, err error) { 818 if tracing.IsEnabled() { 819 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinDatabases") 820 defer func() { 821 sc := -1 822 if result.Response.Response != nil { 823 sc = result.Response.Response.StatusCode 824 } 825 tracing.EndSpan(ctx, sc, err) 826 }() 827 } 828 if err := validation.Validate([]validation.Validation{ 829 {TargetValue: client.SubscriptionID, 830 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 831 {TargetValue: resourceGroupName, 832 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 833 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 834 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 835 {TargetValue: accountName, 836 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 837 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 838 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 839 return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinDatabases", err.Error()) 840 } 841 842 req, err := client.ListGremlinDatabasesPreparer(ctx, resourceGroupName, accountName) 843 if err != nil { 844 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", nil, "Failure preparing request") 845 return 846 } 847 848 resp, err := client.ListGremlinDatabasesSender(req) 849 if err != nil { 850 result.Response = autorest.Response{Response: resp} 851 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure sending request") 852 return 853 } 854 855 result, err = client.ListGremlinDatabasesResponder(resp) 856 if err != nil { 857 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure responding to request") 858 return 859 } 860 861 return 862} 863 864// ListGremlinDatabasesPreparer prepares the ListGremlinDatabases request. 865func (client GremlinResourcesClient) ListGremlinDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 866 pathParameters := map[string]interface{}{ 867 "accountName": autorest.Encode("path", accountName), 868 "resourceGroupName": autorest.Encode("path", resourceGroupName), 869 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 870 } 871 872 const APIVersion = "2019-08-01" 873 queryParameters := map[string]interface{}{ 874 "api-version": APIVersion, 875 } 876 877 preparer := autorest.CreatePreparer( 878 autorest.AsGet(), 879 autorest.WithBaseURL(client.BaseURI), 880 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases", pathParameters), 881 autorest.WithQueryParameters(queryParameters)) 882 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 883} 884 885// ListGremlinDatabasesSender sends the ListGremlinDatabases request. The method will close the 886// http.Response Body if it receives an error. 887func (client GremlinResourcesClient) ListGremlinDatabasesSender(req *http.Request) (*http.Response, error) { 888 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 889} 890 891// ListGremlinDatabasesResponder handles the response to the ListGremlinDatabases request. The method always 892// closes the http.Response Body. 893func (client GremlinResourcesClient) ListGremlinDatabasesResponder(resp *http.Response) (result GremlinDatabaseListResult, err error) { 894 err = autorest.Respond( 895 resp, 896 azure.WithErrorUnlessStatusCode(http.StatusOK), 897 autorest.ByUnmarshallingJSON(&result), 898 autorest.ByClosing()) 899 result.Response = autorest.Response{Response: resp} 900 return 901} 902 903// ListGremlinGraphs lists the Gremlin graph under an existing Azure Cosmos DB database account. 904// Parameters: 905// resourceGroupName - name of an Azure resource group. 906// accountName - cosmos DB database account name. 907// databaseName - cosmos DB database name. 908func (client GremlinResourcesClient) ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinGraphListResult, err error) { 909 if tracing.IsEnabled() { 910 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinGraphs") 911 defer func() { 912 sc := -1 913 if result.Response.Response != nil { 914 sc = result.Response.Response.StatusCode 915 } 916 tracing.EndSpan(ctx, sc, err) 917 }() 918 } 919 if err := validation.Validate([]validation.Validation{ 920 {TargetValue: client.SubscriptionID, 921 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 922 {TargetValue: resourceGroupName, 923 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 924 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 925 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 926 {TargetValue: accountName, 927 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 928 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 929 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { 930 return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinGraphs", err.Error()) 931 } 932 933 req, err := client.ListGremlinGraphsPreparer(ctx, resourceGroupName, accountName, databaseName) 934 if err != nil { 935 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", nil, "Failure preparing request") 936 return 937 } 938 939 resp, err := client.ListGremlinGraphsSender(req) 940 if err != nil { 941 result.Response = autorest.Response{Response: resp} 942 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure sending request") 943 return 944 } 945 946 result, err = client.ListGremlinGraphsResponder(resp) 947 if err != nil { 948 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure responding to request") 949 return 950 } 951 952 return 953} 954 955// ListGremlinGraphsPreparer prepares the ListGremlinGraphs request. 956func (client GremlinResourcesClient) ListGremlinGraphsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { 957 pathParameters := map[string]interface{}{ 958 "accountName": autorest.Encode("path", accountName), 959 "databaseName": autorest.Encode("path", databaseName), 960 "resourceGroupName": autorest.Encode("path", resourceGroupName), 961 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 962 } 963 964 const APIVersion = "2019-08-01" 965 queryParameters := map[string]interface{}{ 966 "api-version": APIVersion, 967 } 968 969 preparer := autorest.CreatePreparer( 970 autorest.AsGet(), 971 autorest.WithBaseURL(client.BaseURI), 972 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", pathParameters), 973 autorest.WithQueryParameters(queryParameters)) 974 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 975} 976 977// ListGremlinGraphsSender sends the ListGremlinGraphs request. The method will close the 978// http.Response Body if it receives an error. 979func (client GremlinResourcesClient) ListGremlinGraphsSender(req *http.Request) (*http.Response, error) { 980 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 981} 982 983// ListGremlinGraphsResponder handles the response to the ListGremlinGraphs request. The method always 984// closes the http.Response Body. 985func (client GremlinResourcesClient) ListGremlinGraphsResponder(resp *http.Response) (result GremlinGraphListResult, err error) { 986 err = autorest.Respond( 987 resp, 988 azure.WithErrorUnlessStatusCode(http.StatusOK), 989 autorest.ByUnmarshallingJSON(&result), 990 autorest.ByClosing()) 991 result.Response = autorest.Response{Response: resp} 992 return 993} 994 995// UpdateGremlinDatabaseThroughput update RUs per second of an Azure Cosmos DB Gremlin database 996// Parameters: 997// resourceGroupName - name of an Azure resource group. 998// accountName - cosmos DB database account name. 999// databaseName - cosmos DB database name. 1000// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin 1001// database. 1002func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { 1003 if tracing.IsEnabled() { 1004 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinDatabaseThroughput") 1005 defer func() { 1006 sc := -1 1007 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 1008 sc = result.FutureAPI.Response().StatusCode 1009 } 1010 tracing.EndSpan(ctx, sc, err) 1011 }() 1012 } 1013 if err := validation.Validate([]validation.Validation{ 1014 {TargetValue: client.SubscriptionID, 1015 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1016 {TargetValue: resourceGroupName, 1017 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 1018 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1019 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 1020 {TargetValue: accountName, 1021 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1022 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 1023 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 1024 {TargetValue: updateThroughputParameters, 1025 Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, 1026 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, 1027 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, 1028 }}}}}); err != nil { 1029 return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", err.Error()) 1030 } 1031 1032 req, err := client.UpdateGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) 1033 if err != nil { 1034 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure preparing request") 1035 return 1036 } 1037 1038 result, err = client.UpdateGremlinDatabaseThroughputSender(req) 1039 if err != nil { 1040 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure sending request") 1041 return 1042 } 1043 1044 return 1045} 1046 1047// UpdateGremlinDatabaseThroughputPreparer prepares the UpdateGremlinDatabaseThroughput request. 1048func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { 1049 pathParameters := map[string]interface{}{ 1050 "accountName": autorest.Encode("path", accountName), 1051 "databaseName": autorest.Encode("path", databaseName), 1052 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1053 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1054 } 1055 1056 const APIVersion = "2019-08-01" 1057 queryParameters := map[string]interface{}{ 1058 "api-version": APIVersion, 1059 } 1060 1061 preparer := autorest.CreatePreparer( 1062 autorest.AsContentType("application/json; charset=utf-8"), 1063 autorest.AsPut(), 1064 autorest.WithBaseURL(client.BaseURI), 1065 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), 1066 autorest.WithJSON(updateThroughputParameters), 1067 autorest.WithQueryParameters(queryParameters)) 1068 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1069} 1070 1071// UpdateGremlinDatabaseThroughputSender sends the UpdateGremlinDatabaseThroughput request. The method will close the 1072// http.Response Body if it receives an error. 1073func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { 1074 var resp *http.Response 1075 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1076 if err != nil { 1077 return 1078 } 1079 var azf azure.Future 1080 azf, err = azure.NewFutureFromResponse(resp) 1081 future.FutureAPI = &azf 1082 future.Result = future.result 1083 return 1084} 1085 1086// UpdateGremlinDatabaseThroughputResponder handles the response to the UpdateGremlinDatabaseThroughput request. The method always 1087// closes the http.Response Body. 1088func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 1089 err = autorest.Respond( 1090 resp, 1091 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1092 autorest.ByUnmarshallingJSON(&result), 1093 autorest.ByClosing()) 1094 result.Response = autorest.Response{Response: resp} 1095 return 1096} 1097 1098// UpdateGremlinGraphThroughput update RUs per second of an Azure Cosmos DB Gremlin graph 1099// Parameters: 1100// resourceGroupName - name of an Azure resource group. 1101// accountName - cosmos DB database account name. 1102// databaseName - cosmos DB database name. 1103// graphName - cosmos DB graph name. 1104// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin graph. 1105func (client GremlinResourcesClient) UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { 1106 if tracing.IsEnabled() { 1107 ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinGraphThroughput") 1108 defer func() { 1109 sc := -1 1110 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 1111 sc = result.FutureAPI.Response().StatusCode 1112 } 1113 tracing.EndSpan(ctx, sc, err) 1114 }() 1115 } 1116 if err := validation.Validate([]validation.Validation{ 1117 {TargetValue: client.SubscriptionID, 1118 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 1119 {TargetValue: resourceGroupName, 1120 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 1121 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1122 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 1123 {TargetValue: accountName, 1124 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1125 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, 1126 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, 1127 {TargetValue: updateThroughputParameters, 1128 Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, 1129 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, 1130 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, 1131 }}}}}); err != nil { 1132 return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", err.Error()) 1133 } 1134 1135 req, err := client.UpdateGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters) 1136 if err != nil { 1137 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure preparing request") 1138 return 1139 } 1140 1141 result, err = client.UpdateGremlinGraphThroughputSender(req) 1142 if err != nil { 1143 err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure sending request") 1144 return 1145 } 1146 1147 return 1148} 1149 1150// UpdateGremlinGraphThroughputPreparer prepares the UpdateGremlinGraphThroughput request. 1151func (client GremlinResourcesClient) UpdateGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { 1152 pathParameters := map[string]interface{}{ 1153 "accountName": autorest.Encode("path", accountName), 1154 "databaseName": autorest.Encode("path", databaseName), 1155 "graphName": autorest.Encode("path", graphName), 1156 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1157 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1158 } 1159 1160 const APIVersion = "2019-08-01" 1161 queryParameters := map[string]interface{}{ 1162 "api-version": APIVersion, 1163 } 1164 1165 preparer := autorest.CreatePreparer( 1166 autorest.AsContentType("application/json; charset=utf-8"), 1167 autorest.AsPut(), 1168 autorest.WithBaseURL(client.BaseURI), 1169 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), 1170 autorest.WithJSON(updateThroughputParameters), 1171 autorest.WithQueryParameters(queryParameters)) 1172 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1173} 1174 1175// UpdateGremlinGraphThroughputSender sends the UpdateGremlinGraphThroughput request. The method will close the 1176// http.Response Body if it receives an error. 1177func (client GremlinResourcesClient) UpdateGremlinGraphThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { 1178 var resp *http.Response 1179 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1180 if err != nil { 1181 return 1182 } 1183 var azf azure.Future 1184 azf, err = azure.NewFutureFromResponse(resp) 1185 future.FutureAPI = &azf 1186 future.Result = future.result 1187 return 1188} 1189 1190// UpdateGremlinGraphThroughputResponder handles the response to the UpdateGremlinGraphThroughput request. The method always 1191// closes the http.Response Body. 1192func (client GremlinResourcesClient) UpdateGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { 1193 err = autorest.Respond( 1194 resp, 1195 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1196 autorest.ByUnmarshallingJSON(&result), 1197 autorest.ByClosing()) 1198 result.Response = autorest.Response{Response: resp} 1199 return 1200} 1201