...

Source file src/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-03-15/documentdb/mongodbresources.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-03-15/documentdb

     1  package 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  
     9  import (
    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  // MongoDBResourcesClient is the azure Cosmos DB Database Service Resource Provider REST API
    19  type MongoDBResourcesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewMongoDBResourcesClient creates an instance of the MongoDBResourcesClient client.
    24  func NewMongoDBResourcesClient(subscriptionID string) MongoDBResourcesClient {
    25  	return NewMongoDBResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewMongoDBResourcesClientWithBaseURI creates an instance of the MongoDBResourcesClient 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).
    31  func NewMongoDBResourcesClientWithBaseURI(baseURI string, subscriptionID string) MongoDBResourcesClient {
    32  	return MongoDBResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateUpdateMongoDBCollection create or update an Azure Cosmos DB MongoDB Collection
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group. The name is case insensitive.
    38  // accountName - cosmos DB database account name.
    39  // databaseName - cosmos DB database name.
    40  // collectionName - cosmos DB collection name.
    41  // createUpdateMongoDBCollectionParameters - the parameters to provide for the current MongoDB Collection.
    42  func (client MongoDBResourcesClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBCollection")
    45  		defer func() {
    46  			sc := -1
    47  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    48  				sc = result.FutureAPI.Response().StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: client.SubscriptionID,
    55  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    56  		{TargetValue: resourceGroupName,
    57  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    58  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    59  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    60  		{TargetValue: accountName,
    61  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    62  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
    63  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
    64  		{TargetValue: createUpdateMongoDBCollectionParameters,
    65  			Constraints: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties", Name: validation.Null, Rule: true,
    66  				Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true,
    67  					Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}},
    68  				}}}}}); err != nil {
    69  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", err.Error())
    70  	}
    71  
    72  	req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters)
    73  	if err != nil {
    74  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request")
    75  		return
    76  	}
    77  
    78  	result, err = client.CreateUpdateMongoDBCollectionSender(req)
    79  	if err != nil {
    80  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", result.Response(), "Failure sending request")
    81  		return
    82  	}
    83  
    84  	return
    85  }
    86  
    87  // CreateUpdateMongoDBCollectionPreparer prepares the CreateUpdateMongoDBCollection request.
    88  func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (*http.Request, error) {
    89  	pathParameters := map[string]interface{}{
    90  		"accountName":       autorest.Encode("path", accountName),
    91  		"collectionName":    autorest.Encode("path", collectionName),
    92  		"databaseName":      autorest.Encode("path", databaseName),
    93  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    94  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    95  	}
    96  
    97  	const APIVersion = "2021-03-15"
    98  	queryParameters := map[string]interface{}{
    99  		"api-version": APIVersion,
   100  	}
   101  
   102  	preparer := autorest.CreatePreparer(
   103  		autorest.AsContentType("application/json; charset=utf-8"),
   104  		autorest.AsPut(),
   105  		autorest.WithBaseURL(client.BaseURI),
   106  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
   107  		autorest.WithJSON(createUpdateMongoDBCollectionParameters),
   108  		autorest.WithQueryParameters(queryParameters))
   109  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   110  }
   111  
   112  // CreateUpdateMongoDBCollectionSender sends the CreateUpdateMongoDBCollection request. The method will close the
   113  // http.Response Body if it receives an error.
   114  func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) {
   115  	var resp *http.Response
   116  	future.FutureAPI = &azure.Future{}
   117  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   118  	if err != nil {
   119  		return
   120  	}
   121  	var azf azure.Future
   122  	azf, err = azure.NewFutureFromResponse(resp)
   123  	future.FutureAPI = &azf
   124  	future.Result = future.result
   125  	return
   126  }
   127  
   128  // CreateUpdateMongoDBCollectionResponder handles the response to the CreateUpdateMongoDBCollection request. The method always
   129  // closes the http.Response Body.
   130  func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) {
   131  	err = autorest.Respond(
   132  		resp,
   133  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   134  		autorest.ByUnmarshallingJSON(&result),
   135  		autorest.ByClosing())
   136  	result.Response = autorest.Response{Response: resp}
   137  	return
   138  }
   139  
   140  // CreateUpdateMongoDBDatabase create or updates Azure Cosmos DB MongoDB database
   141  // Parameters:
   142  // resourceGroupName - the name of the resource group. The name is case insensitive.
   143  // accountName - cosmos DB database account name.
   144  // databaseName - cosmos DB database name.
   145  // createUpdateMongoDBDatabaseParameters - the parameters to provide for the current MongoDB database.
   146  func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) {
   147  	if tracing.IsEnabled() {
   148  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBDatabase")
   149  		defer func() {
   150  			sc := -1
   151  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   152  				sc = result.FutureAPI.Response().StatusCode
   153  			}
   154  			tracing.EndSpan(ctx, sc, err)
   155  		}()
   156  	}
   157  	if err := validation.Validate([]validation.Validation{
   158  		{TargetValue: client.SubscriptionID,
   159  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   160  		{TargetValue: resourceGroupName,
   161  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   162  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   163  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   164  		{TargetValue: accountName,
   165  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   166  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   167  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
   168  		{TargetValue: createUpdateMongoDBDatabaseParameters,
   169  			Constraints: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true,
   170  				Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true,
   171  					Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}},
   172  				}}}}}); err != nil {
   173  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", err.Error())
   174  	}
   175  
   176  	req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters)
   177  	if err != nil {
   178  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request")
   179  		return
   180  	}
   181  
   182  	result, err = client.CreateUpdateMongoDBDatabaseSender(req)
   183  	if err != nil {
   184  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", result.Response(), "Failure sending request")
   185  		return
   186  	}
   187  
   188  	return
   189  }
   190  
   191  // CreateUpdateMongoDBDatabasePreparer prepares the CreateUpdateMongoDBDatabase request.
   192  func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (*http.Request, error) {
   193  	pathParameters := map[string]interface{}{
   194  		"accountName":       autorest.Encode("path", accountName),
   195  		"databaseName":      autorest.Encode("path", databaseName),
   196  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   197  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   198  	}
   199  
   200  	const APIVersion = "2021-03-15"
   201  	queryParameters := map[string]interface{}{
   202  		"api-version": APIVersion,
   203  	}
   204  
   205  	preparer := autorest.CreatePreparer(
   206  		autorest.AsContentType("application/json; charset=utf-8"),
   207  		autorest.AsPut(),
   208  		autorest.WithBaseURL(client.BaseURI),
   209  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
   210  		autorest.WithJSON(createUpdateMongoDBDatabaseParameters),
   211  		autorest.WithQueryParameters(queryParameters))
   212  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   213  }
   214  
   215  // CreateUpdateMongoDBDatabaseSender sends the CreateUpdateMongoDBDatabase request. The method will close the
   216  // http.Response Body if it receives an error.
   217  func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) {
   218  	var resp *http.Response
   219  	future.FutureAPI = &azure.Future{}
   220  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   221  	if err != nil {
   222  		return
   223  	}
   224  	var azf azure.Future
   225  	azf, err = azure.NewFutureFromResponse(resp)
   226  	future.FutureAPI = &azf
   227  	future.Result = future.result
   228  	return
   229  }
   230  
   231  // CreateUpdateMongoDBDatabaseResponder handles the response to the CreateUpdateMongoDBDatabase request. The method always
   232  // closes the http.Response Body.
   233  func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) {
   234  	err = autorest.Respond(
   235  		resp,
   236  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   237  		autorest.ByUnmarshallingJSON(&result),
   238  		autorest.ByClosing())
   239  	result.Response = autorest.Response{Response: resp}
   240  	return
   241  }
   242  
   243  // DeleteMongoDBCollection deletes an existing Azure Cosmos DB MongoDB Collection.
   244  // Parameters:
   245  // resourceGroupName - the name of the resource group. The name is case insensitive.
   246  // accountName - cosmos DB database account name.
   247  // databaseName - cosmos DB database name.
   248  // collectionName - cosmos DB collection name.
   249  func (client MongoDBResourcesClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesDeleteMongoDBCollectionFuture, err error) {
   250  	if tracing.IsEnabled() {
   251  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBCollection")
   252  		defer func() {
   253  			sc := -1
   254  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   255  				sc = result.FutureAPI.Response().StatusCode
   256  			}
   257  			tracing.EndSpan(ctx, sc, err)
   258  		}()
   259  	}
   260  	if err := validation.Validate([]validation.Validation{
   261  		{TargetValue: client.SubscriptionID,
   262  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   263  		{TargetValue: resourceGroupName,
   264  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   265  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   266  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   267  		{TargetValue: accountName,
   268  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   269  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   270  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   271  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", err.Error())
   272  	}
   273  
   274  	req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
   275  	if err != nil {
   276  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure preparing request")
   277  		return
   278  	}
   279  
   280  	result, err = client.DeleteMongoDBCollectionSender(req)
   281  	if err != nil {
   282  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", result.Response(), "Failure sending request")
   283  		return
   284  	}
   285  
   286  	return
   287  }
   288  
   289  // DeleteMongoDBCollectionPreparer prepares the DeleteMongoDBCollection request.
   290  func (client MongoDBResourcesClient) DeleteMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
   291  	pathParameters := map[string]interface{}{
   292  		"accountName":       autorest.Encode("path", accountName),
   293  		"collectionName":    autorest.Encode("path", collectionName),
   294  		"databaseName":      autorest.Encode("path", databaseName),
   295  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   296  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   297  	}
   298  
   299  	const APIVersion = "2021-03-15"
   300  	queryParameters := map[string]interface{}{
   301  		"api-version": APIVersion,
   302  	}
   303  
   304  	preparer := autorest.CreatePreparer(
   305  		autorest.AsDelete(),
   306  		autorest.WithBaseURL(client.BaseURI),
   307  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
   308  		autorest.WithQueryParameters(queryParameters))
   309  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   310  }
   311  
   312  // DeleteMongoDBCollectionSender sends the DeleteMongoDBCollection request. The method will close the
   313  // http.Response Body if it receives an error.
   314  func (client MongoDBResourcesClient) DeleteMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBCollectionFuture, err error) {
   315  	var resp *http.Response
   316  	future.FutureAPI = &azure.Future{}
   317  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   318  	if err != nil {
   319  		return
   320  	}
   321  	var azf azure.Future
   322  	azf, err = azure.NewFutureFromResponse(resp)
   323  	future.FutureAPI = &azf
   324  	future.Result = future.result
   325  	return
   326  }
   327  
   328  // DeleteMongoDBCollectionResponder handles the response to the DeleteMongoDBCollection request. The method always
   329  // closes the http.Response Body.
   330  func (client MongoDBResourcesClient) DeleteMongoDBCollectionResponder(resp *http.Response) (result autorest.Response, err error) {
   331  	err = autorest.Respond(
   332  		resp,
   333  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   334  		autorest.ByClosing())
   335  	result.Response = resp
   336  	return
   337  }
   338  
   339  // DeleteMongoDBDatabase deletes an existing Azure Cosmos DB MongoDB database.
   340  // Parameters:
   341  // resourceGroupName - the name of the resource group. The name is case insensitive.
   342  // accountName - cosmos DB database account name.
   343  // databaseName - cosmos DB database name.
   344  func (client MongoDBResourcesClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) {
   345  	if tracing.IsEnabled() {
   346  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBDatabase")
   347  		defer func() {
   348  			sc := -1
   349  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   350  				sc = result.FutureAPI.Response().StatusCode
   351  			}
   352  			tracing.EndSpan(ctx, sc, err)
   353  		}()
   354  	}
   355  	if err := validation.Validate([]validation.Validation{
   356  		{TargetValue: client.SubscriptionID,
   357  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   358  		{TargetValue: resourceGroupName,
   359  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   360  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   361  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   362  		{TargetValue: accountName,
   363  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   364  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   365  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   366  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", err.Error())
   367  	}
   368  
   369  	req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName)
   370  	if err != nil {
   371  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure preparing request")
   372  		return
   373  	}
   374  
   375  	result, err = client.DeleteMongoDBDatabaseSender(req)
   376  	if err != nil {
   377  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", result.Response(), "Failure sending request")
   378  		return
   379  	}
   380  
   381  	return
   382  }
   383  
   384  // DeleteMongoDBDatabasePreparer prepares the DeleteMongoDBDatabase request.
   385  func (client MongoDBResourcesClient) DeleteMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
   386  	pathParameters := map[string]interface{}{
   387  		"accountName":       autorest.Encode("path", accountName),
   388  		"databaseName":      autorest.Encode("path", databaseName),
   389  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   390  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   391  	}
   392  
   393  	const APIVersion = "2021-03-15"
   394  	queryParameters := map[string]interface{}{
   395  		"api-version": APIVersion,
   396  	}
   397  
   398  	preparer := autorest.CreatePreparer(
   399  		autorest.AsDelete(),
   400  		autorest.WithBaseURL(client.BaseURI),
   401  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
   402  		autorest.WithQueryParameters(queryParameters))
   403  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   404  }
   405  
   406  // DeleteMongoDBDatabaseSender sends the DeleteMongoDBDatabase request. The method will close the
   407  // http.Response Body if it receives an error.
   408  func (client MongoDBResourcesClient) DeleteMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) {
   409  	var resp *http.Response
   410  	future.FutureAPI = &azure.Future{}
   411  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   412  	if err != nil {
   413  		return
   414  	}
   415  	var azf azure.Future
   416  	azf, err = azure.NewFutureFromResponse(resp)
   417  	future.FutureAPI = &azf
   418  	future.Result = future.result
   419  	return
   420  }
   421  
   422  // DeleteMongoDBDatabaseResponder handles the response to the DeleteMongoDBDatabase request. The method always
   423  // closes the http.Response Body.
   424  func (client MongoDBResourcesClient) DeleteMongoDBDatabaseResponder(resp *http.Response) (result autorest.Response, err error) {
   425  	err = autorest.Respond(
   426  		resp,
   427  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   428  		autorest.ByClosing())
   429  	result.Response = resp
   430  	return
   431  }
   432  
   433  // GetMongoDBCollection gets the MongoDB collection under an existing Azure Cosmos DB database account.
   434  // Parameters:
   435  // resourceGroupName - the name of the resource group. The name is case insensitive.
   436  // accountName - cosmos DB database account name.
   437  // databaseName - cosmos DB database name.
   438  // collectionName - cosmos DB collection name.
   439  func (client MongoDBResourcesClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollectionGetResults, err error) {
   440  	if tracing.IsEnabled() {
   441  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollection")
   442  		defer func() {
   443  			sc := -1
   444  			if result.Response.Response != nil {
   445  				sc = result.Response.Response.StatusCode
   446  			}
   447  			tracing.EndSpan(ctx, sc, err)
   448  		}()
   449  	}
   450  	if err := validation.Validate([]validation.Validation{
   451  		{TargetValue: client.SubscriptionID,
   452  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   453  		{TargetValue: resourceGroupName,
   454  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   455  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   456  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   457  		{TargetValue: accountName,
   458  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   459  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   460  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   461  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollection", err.Error())
   462  	}
   463  
   464  	req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
   465  	if err != nil {
   466  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", nil, "Failure preparing request")
   467  		return
   468  	}
   469  
   470  	resp, err := client.GetMongoDBCollectionSender(req)
   471  	if err != nil {
   472  		result.Response = autorest.Response{Response: resp}
   473  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure sending request")
   474  		return
   475  	}
   476  
   477  	result, err = client.GetMongoDBCollectionResponder(resp)
   478  	if err != nil {
   479  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure responding to request")
   480  		return
   481  	}
   482  
   483  	return
   484  }
   485  
   486  // GetMongoDBCollectionPreparer prepares the GetMongoDBCollection request.
   487  func (client MongoDBResourcesClient) GetMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
   488  	pathParameters := map[string]interface{}{
   489  		"accountName":       autorest.Encode("path", accountName),
   490  		"collectionName":    autorest.Encode("path", collectionName),
   491  		"databaseName":      autorest.Encode("path", databaseName),
   492  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   493  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   494  	}
   495  
   496  	const APIVersion = "2021-03-15"
   497  	queryParameters := map[string]interface{}{
   498  		"api-version": APIVersion,
   499  	}
   500  
   501  	preparer := autorest.CreatePreparer(
   502  		autorest.AsGet(),
   503  		autorest.WithBaseURL(client.BaseURI),
   504  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
   505  		autorest.WithQueryParameters(queryParameters))
   506  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   507  }
   508  
   509  // GetMongoDBCollectionSender sends the GetMongoDBCollection request. The method will close the
   510  // http.Response Body if it receives an error.
   511  func (client MongoDBResourcesClient) GetMongoDBCollectionSender(req *http.Request) (*http.Response, error) {
   512  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   513  }
   514  
   515  // GetMongoDBCollectionResponder handles the response to the GetMongoDBCollection request. The method always
   516  // closes the http.Response Body.
   517  func (client MongoDBResourcesClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) {
   518  	err = autorest.Respond(
   519  		resp,
   520  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   521  		autorest.ByUnmarshallingJSON(&result),
   522  		autorest.ByClosing())
   523  	result.Response = autorest.Response{Response: resp}
   524  	return
   525  }
   526  
   527  // GetMongoDBCollectionThroughput gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB
   528  // database account with the provided name.
   529  // Parameters:
   530  // resourceGroupName - the name of the resource group. The name is case insensitive.
   531  // accountName - cosmos DB database account name.
   532  // databaseName - cosmos DB database name.
   533  // collectionName - cosmos DB collection name.
   534  func (client MongoDBResourcesClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result ThroughputSettingsGetResults, err error) {
   535  	if tracing.IsEnabled() {
   536  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollectionThroughput")
   537  		defer func() {
   538  			sc := -1
   539  			if result.Response.Response != nil {
   540  				sc = result.Response.Response.StatusCode
   541  			}
   542  			tracing.EndSpan(ctx, sc, err)
   543  		}()
   544  	}
   545  	if err := validation.Validate([]validation.Validation{
   546  		{TargetValue: client.SubscriptionID,
   547  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   548  		{TargetValue: resourceGroupName,
   549  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   550  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   551  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   552  		{TargetValue: accountName,
   553  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   554  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   555  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   556  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", err.Error())
   557  	}
   558  
   559  	req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
   560  	if err != nil {
   561  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", nil, "Failure preparing request")
   562  		return
   563  	}
   564  
   565  	resp, err := client.GetMongoDBCollectionThroughputSender(req)
   566  	if err != nil {
   567  		result.Response = autorest.Response{Response: resp}
   568  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request")
   569  		return
   570  	}
   571  
   572  	result, err = client.GetMongoDBCollectionThroughputResponder(resp)
   573  	if err != nil {
   574  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request")
   575  		return
   576  	}
   577  
   578  	return
   579  }
   580  
   581  // GetMongoDBCollectionThroughputPreparer prepares the GetMongoDBCollectionThroughput request.
   582  func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
   583  	pathParameters := map[string]interface{}{
   584  		"accountName":       autorest.Encode("path", accountName),
   585  		"collectionName":    autorest.Encode("path", collectionName),
   586  		"databaseName":      autorest.Encode("path", databaseName),
   587  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   588  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   589  	}
   590  
   591  	const APIVersion = "2021-03-15"
   592  	queryParameters := map[string]interface{}{
   593  		"api-version": APIVersion,
   594  	}
   595  
   596  	preparer := autorest.CreatePreparer(
   597  		autorest.AsGet(),
   598  		autorest.WithBaseURL(client.BaseURI),
   599  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters),
   600  		autorest.WithQueryParameters(queryParameters))
   601  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   602  }
   603  
   604  // GetMongoDBCollectionThroughputSender sends the GetMongoDBCollectionThroughput request. The method will close the
   605  // http.Response Body if it receives an error.
   606  func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputSender(req *http.Request) (*http.Response, error) {
   607  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   608  }
   609  
   610  // GetMongoDBCollectionThroughputResponder handles the response to the GetMongoDBCollectionThroughput request. The method always
   611  // closes the http.Response Body.
   612  func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
   613  	err = autorest.Respond(
   614  		resp,
   615  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   616  		autorest.ByUnmarshallingJSON(&result),
   617  		autorest.ByClosing())
   618  	result.Response = autorest.Response{Response: resp}
   619  	return
   620  }
   621  
   622  // GetMongoDBDatabase gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided
   623  // name.
   624  // Parameters:
   625  // resourceGroupName - the name of the resource group. The name is case insensitive.
   626  // accountName - cosmos DB database account name.
   627  // databaseName - cosmos DB database name.
   628  func (client MongoDBResourcesClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabaseGetResults, err error) {
   629  	if tracing.IsEnabled() {
   630  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabase")
   631  		defer func() {
   632  			sc := -1
   633  			if result.Response.Response != nil {
   634  				sc = result.Response.Response.StatusCode
   635  			}
   636  			tracing.EndSpan(ctx, sc, err)
   637  		}()
   638  	}
   639  	if err := validation.Validate([]validation.Validation{
   640  		{TargetValue: client.SubscriptionID,
   641  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   642  		{TargetValue: resourceGroupName,
   643  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   644  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   645  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   646  		{TargetValue: accountName,
   647  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   648  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   649  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   650  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", err.Error())
   651  	}
   652  
   653  	req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName)
   654  	if err != nil {
   655  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", nil, "Failure preparing request")
   656  		return
   657  	}
   658  
   659  	resp, err := client.GetMongoDBDatabaseSender(req)
   660  	if err != nil {
   661  		result.Response = autorest.Response{Response: resp}
   662  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure sending request")
   663  		return
   664  	}
   665  
   666  	result, err = client.GetMongoDBDatabaseResponder(resp)
   667  	if err != nil {
   668  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure responding to request")
   669  		return
   670  	}
   671  
   672  	return
   673  }
   674  
   675  // GetMongoDBDatabasePreparer prepares the GetMongoDBDatabase request.
   676  func (client MongoDBResourcesClient) GetMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
   677  	pathParameters := map[string]interface{}{
   678  		"accountName":       autorest.Encode("path", accountName),
   679  		"databaseName":      autorest.Encode("path", databaseName),
   680  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   681  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   682  	}
   683  
   684  	const APIVersion = "2021-03-15"
   685  	queryParameters := map[string]interface{}{
   686  		"api-version": APIVersion,
   687  	}
   688  
   689  	preparer := autorest.CreatePreparer(
   690  		autorest.AsGet(),
   691  		autorest.WithBaseURL(client.BaseURI),
   692  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
   693  		autorest.WithQueryParameters(queryParameters))
   694  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   695  }
   696  
   697  // GetMongoDBDatabaseSender sends the GetMongoDBDatabase request. The method will close the
   698  // http.Response Body if it receives an error.
   699  func (client MongoDBResourcesClient) GetMongoDBDatabaseSender(req *http.Request) (*http.Response, error) {
   700  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   701  }
   702  
   703  // GetMongoDBDatabaseResponder handles the response to the GetMongoDBDatabase request. The method always
   704  // closes the http.Response Body.
   705  func (client MongoDBResourcesClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) {
   706  	err = autorest.Respond(
   707  		resp,
   708  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   709  		autorest.ByUnmarshallingJSON(&result),
   710  		autorest.ByClosing())
   711  	result.Response = autorest.Response{Response: resp}
   712  	return
   713  }
   714  
   715  // GetMongoDBDatabaseThroughput gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB
   716  // database account with the provided name.
   717  // Parameters:
   718  // resourceGroupName - the name of the resource group. The name is case insensitive.
   719  // accountName - cosmos DB database account name.
   720  // databaseName - cosmos DB database name.
   721  func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) {
   722  	if tracing.IsEnabled() {
   723  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabaseThroughput")
   724  		defer func() {
   725  			sc := -1
   726  			if result.Response.Response != nil {
   727  				sc = result.Response.Response.StatusCode
   728  			}
   729  			tracing.EndSpan(ctx, sc, err)
   730  		}()
   731  	}
   732  	if err := validation.Validate([]validation.Validation{
   733  		{TargetValue: client.SubscriptionID,
   734  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   735  		{TargetValue: resourceGroupName,
   736  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   737  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   738  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   739  		{TargetValue: accountName,
   740  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   741  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   742  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   743  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", err.Error())
   744  	}
   745  
   746  	req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName)
   747  	if err != nil {
   748  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", nil, "Failure preparing request")
   749  		return
   750  	}
   751  
   752  	resp, err := client.GetMongoDBDatabaseThroughputSender(req)
   753  	if err != nil {
   754  		result.Response = autorest.Response{Response: resp}
   755  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request")
   756  		return
   757  	}
   758  
   759  	result, err = client.GetMongoDBDatabaseThroughputResponder(resp)
   760  	if err != nil {
   761  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request")
   762  		return
   763  	}
   764  
   765  	return
   766  }
   767  
   768  // GetMongoDBDatabaseThroughputPreparer prepares the GetMongoDBDatabaseThroughput request.
   769  func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
   770  	pathParameters := map[string]interface{}{
   771  		"accountName":       autorest.Encode("path", accountName),
   772  		"databaseName":      autorest.Encode("path", databaseName),
   773  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   774  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   775  	}
   776  
   777  	const APIVersion = "2021-03-15"
   778  	queryParameters := map[string]interface{}{
   779  		"api-version": APIVersion,
   780  	}
   781  
   782  	preparer := autorest.CreatePreparer(
   783  		autorest.AsGet(),
   784  		autorest.WithBaseURL(client.BaseURI),
   785  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters),
   786  		autorest.WithQueryParameters(queryParameters))
   787  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   788  }
   789  
   790  // GetMongoDBDatabaseThroughputSender sends the GetMongoDBDatabaseThroughput request. The method will close the
   791  // http.Response Body if it receives an error.
   792  func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputSender(req *http.Request) (*http.Response, error) {
   793  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   794  }
   795  
   796  // GetMongoDBDatabaseThroughputResponder handles the response to the GetMongoDBDatabaseThroughput request. The method always
   797  // closes the http.Response Body.
   798  func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
   799  	err = autorest.Respond(
   800  		resp,
   801  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   802  		autorest.ByUnmarshallingJSON(&result),
   803  		autorest.ByClosing())
   804  	result.Response = autorest.Response{Response: resp}
   805  	return
   806  }
   807  
   808  // ListMongoDBCollections lists the MongoDB collection under an existing Azure Cosmos DB database account.
   809  // Parameters:
   810  // resourceGroupName - the name of the resource group. The name is case insensitive.
   811  // accountName - cosmos DB database account name.
   812  // databaseName - cosmos DB database name.
   813  func (client MongoDBResourcesClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) {
   814  	if tracing.IsEnabled() {
   815  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBCollections")
   816  		defer func() {
   817  			sc := -1
   818  			if result.Response.Response != nil {
   819  				sc = result.Response.Response.StatusCode
   820  			}
   821  			tracing.EndSpan(ctx, sc, err)
   822  		}()
   823  	}
   824  	if err := validation.Validate([]validation.Validation{
   825  		{TargetValue: client.SubscriptionID,
   826  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   827  		{TargetValue: resourceGroupName,
   828  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   829  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   830  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   831  		{TargetValue: accountName,
   832  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   833  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   834  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   835  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBCollections", err.Error())
   836  	}
   837  
   838  	req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName)
   839  	if err != nil {
   840  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", nil, "Failure preparing request")
   841  		return
   842  	}
   843  
   844  	resp, err := client.ListMongoDBCollectionsSender(req)
   845  	if err != nil {
   846  		result.Response = autorest.Response{Response: resp}
   847  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure sending request")
   848  		return
   849  	}
   850  
   851  	result, err = client.ListMongoDBCollectionsResponder(resp)
   852  	if err != nil {
   853  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure responding to request")
   854  		return
   855  	}
   856  
   857  	return
   858  }
   859  
   860  // ListMongoDBCollectionsPreparer prepares the ListMongoDBCollections request.
   861  func (client MongoDBResourcesClient) ListMongoDBCollectionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
   862  	pathParameters := map[string]interface{}{
   863  		"accountName":       autorest.Encode("path", accountName),
   864  		"databaseName":      autorest.Encode("path", databaseName),
   865  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   866  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   867  	}
   868  
   869  	const APIVersion = "2021-03-15"
   870  	queryParameters := map[string]interface{}{
   871  		"api-version": APIVersion,
   872  	}
   873  
   874  	preparer := autorest.CreatePreparer(
   875  		autorest.AsGet(),
   876  		autorest.WithBaseURL(client.BaseURI),
   877  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", pathParameters),
   878  		autorest.WithQueryParameters(queryParameters))
   879  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   880  }
   881  
   882  // ListMongoDBCollectionsSender sends the ListMongoDBCollections request. The method will close the
   883  // http.Response Body if it receives an error.
   884  func (client MongoDBResourcesClient) ListMongoDBCollectionsSender(req *http.Request) (*http.Response, error) {
   885  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   886  }
   887  
   888  // ListMongoDBCollectionsResponder handles the response to the ListMongoDBCollections request. The method always
   889  // closes the http.Response Body.
   890  func (client MongoDBResourcesClient) ListMongoDBCollectionsResponder(resp *http.Response) (result MongoDBCollectionListResult, err error) {
   891  	err = autorest.Respond(
   892  		resp,
   893  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   894  		autorest.ByUnmarshallingJSON(&result),
   895  		autorest.ByClosing())
   896  	result.Response = autorest.Response{Response: resp}
   897  	return
   898  }
   899  
   900  // ListMongoDBDatabases lists the MongoDB databases under an existing Azure Cosmos DB database account.
   901  // Parameters:
   902  // resourceGroupName - the name of the resource group. The name is case insensitive.
   903  // accountName - cosmos DB database account name.
   904  func (client MongoDBResourcesClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) {
   905  	if tracing.IsEnabled() {
   906  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBDatabases")
   907  		defer func() {
   908  			sc := -1
   909  			if result.Response.Response != nil {
   910  				sc = result.Response.Response.StatusCode
   911  			}
   912  			tracing.EndSpan(ctx, sc, err)
   913  		}()
   914  	}
   915  	if err := validation.Validate([]validation.Validation{
   916  		{TargetValue: client.SubscriptionID,
   917  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   918  		{TargetValue: resourceGroupName,
   919  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   920  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   921  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   922  		{TargetValue: accountName,
   923  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   924  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   925  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   926  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", err.Error())
   927  	}
   928  
   929  	req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName)
   930  	if err != nil {
   931  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", nil, "Failure preparing request")
   932  		return
   933  	}
   934  
   935  	resp, err := client.ListMongoDBDatabasesSender(req)
   936  	if err != nil {
   937  		result.Response = autorest.Response{Response: resp}
   938  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure sending request")
   939  		return
   940  	}
   941  
   942  	result, err = client.ListMongoDBDatabasesResponder(resp)
   943  	if err != nil {
   944  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure responding to request")
   945  		return
   946  	}
   947  
   948  	return
   949  }
   950  
   951  // ListMongoDBDatabasesPreparer prepares the ListMongoDBDatabases request.
   952  func (client MongoDBResourcesClient) ListMongoDBDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   953  	pathParameters := map[string]interface{}{
   954  		"accountName":       autorest.Encode("path", accountName),
   955  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   956  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   957  	}
   958  
   959  	const APIVersion = "2021-03-15"
   960  	queryParameters := map[string]interface{}{
   961  		"api-version": APIVersion,
   962  	}
   963  
   964  	preparer := autorest.CreatePreparer(
   965  		autorest.AsGet(),
   966  		autorest.WithBaseURL(client.BaseURI),
   967  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", pathParameters),
   968  		autorest.WithQueryParameters(queryParameters))
   969  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   970  }
   971  
   972  // ListMongoDBDatabasesSender sends the ListMongoDBDatabases request. The method will close the
   973  // http.Response Body if it receives an error.
   974  func (client MongoDBResourcesClient) ListMongoDBDatabasesSender(req *http.Request) (*http.Response, error) {
   975  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   976  }
   977  
   978  // ListMongoDBDatabasesResponder handles the response to the ListMongoDBDatabases request. The method always
   979  // closes the http.Response Body.
   980  func (client MongoDBResourcesClient) ListMongoDBDatabasesResponder(resp *http.Response) (result MongoDBDatabaseListResult, err error) {
   981  	err = autorest.Respond(
   982  		resp,
   983  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   984  		autorest.ByUnmarshallingJSON(&result),
   985  		autorest.ByClosing())
   986  	result.Response = autorest.Response{Response: resp}
   987  	return
   988  }
   989  
   990  // MigrateMongoDBCollectionToAutoscale migrate an Azure Cosmos DB MongoDB collection from manual throughput to
   991  // autoscale
   992  // Parameters:
   993  // resourceGroupName - the name of the resource group. The name is case insensitive.
   994  // accountName - cosmos DB database account name.
   995  // databaseName - cosmos DB database name.
   996  // collectionName - cosmos DB collection name.
   997  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) {
   998  	if tracing.IsEnabled() {
   999  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToAutoscale")
  1000  		defer func() {
  1001  			sc := -1
  1002  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1003  				sc = result.FutureAPI.Response().StatusCode
  1004  			}
  1005  			tracing.EndSpan(ctx, sc, err)
  1006  		}()
  1007  	}
  1008  	if err := validation.Validate([]validation.Validation{
  1009  		{TargetValue: client.SubscriptionID,
  1010  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1011  		{TargetValue: resourceGroupName,
  1012  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1013  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1014  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1015  		{TargetValue: accountName,
  1016  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1017  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1018  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
  1019  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", err.Error())
  1020  	}
  1021  
  1022  	req, err := client.MigrateMongoDBCollectionToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
  1023  	if err != nil {
  1024  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure preparing request")
  1025  		return
  1026  	}
  1027  
  1028  	result, err = client.MigrateMongoDBCollectionToAutoscaleSender(req)
  1029  	if err != nil {
  1030  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", result.Response(), "Failure sending request")
  1031  		return
  1032  	}
  1033  
  1034  	return
  1035  }
  1036  
  1037  // MigrateMongoDBCollectionToAutoscalePreparer prepares the MigrateMongoDBCollectionToAutoscale request.
  1038  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
  1039  	pathParameters := map[string]interface{}{
  1040  		"accountName":       autorest.Encode("path", accountName),
  1041  		"collectionName":    autorest.Encode("path", collectionName),
  1042  		"databaseName":      autorest.Encode("path", databaseName),
  1043  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1044  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1045  	}
  1046  
  1047  	const APIVersion = "2021-03-15"
  1048  	queryParameters := map[string]interface{}{
  1049  		"api-version": APIVersion,
  1050  	}
  1051  
  1052  	preparer := autorest.CreatePreparer(
  1053  		autorest.AsPost(),
  1054  		autorest.WithBaseURL(client.BaseURI),
  1055  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", pathParameters),
  1056  		autorest.WithQueryParameters(queryParameters))
  1057  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1058  }
  1059  
  1060  // MigrateMongoDBCollectionToAutoscaleSender sends the MigrateMongoDBCollectionToAutoscale request. The method will close the
  1061  // http.Response Body if it receives an error.
  1062  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) {
  1063  	var resp *http.Response
  1064  	future.FutureAPI = &azure.Future{}
  1065  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1066  	if err != nil {
  1067  		return
  1068  	}
  1069  	var azf azure.Future
  1070  	azf, err = azure.NewFutureFromResponse(resp)
  1071  	future.FutureAPI = &azf
  1072  	future.Result = future.result
  1073  	return
  1074  }
  1075  
  1076  // MigrateMongoDBCollectionToAutoscaleResponder handles the response to the MigrateMongoDBCollectionToAutoscale request. The method always
  1077  // closes the http.Response Body.
  1078  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1079  	err = autorest.Respond(
  1080  		resp,
  1081  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1082  		autorest.ByUnmarshallingJSON(&result),
  1083  		autorest.ByClosing())
  1084  	result.Response = autorest.Response{Response: resp}
  1085  	return
  1086  }
  1087  
  1088  // MigrateMongoDBCollectionToManualThroughput migrate an Azure Cosmos DB MongoDB collection from autoscale to manual
  1089  // throughput
  1090  // Parameters:
  1091  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1092  // accountName - cosmos DB database account name.
  1093  // databaseName - cosmos DB database name.
  1094  // collectionName - cosmos DB collection name.
  1095  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) {
  1096  	if tracing.IsEnabled() {
  1097  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToManualThroughput")
  1098  		defer func() {
  1099  			sc := -1
  1100  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1101  				sc = result.FutureAPI.Response().StatusCode
  1102  			}
  1103  			tracing.EndSpan(ctx, sc, err)
  1104  		}()
  1105  	}
  1106  	if err := validation.Validate([]validation.Validation{
  1107  		{TargetValue: client.SubscriptionID,
  1108  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1109  		{TargetValue: resourceGroupName,
  1110  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1111  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1112  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1113  		{TargetValue: accountName,
  1114  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1115  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1116  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
  1117  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", err.Error())
  1118  	}
  1119  
  1120  	req, err := client.MigrateMongoDBCollectionToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
  1121  	if err != nil {
  1122  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure preparing request")
  1123  		return
  1124  	}
  1125  
  1126  	result, err = client.MigrateMongoDBCollectionToManualThroughputSender(req)
  1127  	if err != nil {
  1128  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", result.Response(), "Failure sending request")
  1129  		return
  1130  	}
  1131  
  1132  	return
  1133  }
  1134  
  1135  // MigrateMongoDBCollectionToManualThroughputPreparer prepares the MigrateMongoDBCollectionToManualThroughput request.
  1136  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
  1137  	pathParameters := map[string]interface{}{
  1138  		"accountName":       autorest.Encode("path", accountName),
  1139  		"collectionName":    autorest.Encode("path", collectionName),
  1140  		"databaseName":      autorest.Encode("path", databaseName),
  1141  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1142  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1143  	}
  1144  
  1145  	const APIVersion = "2021-03-15"
  1146  	queryParameters := map[string]interface{}{
  1147  		"api-version": APIVersion,
  1148  	}
  1149  
  1150  	preparer := autorest.CreatePreparer(
  1151  		autorest.AsPost(),
  1152  		autorest.WithBaseURL(client.BaseURI),
  1153  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", pathParameters),
  1154  		autorest.WithQueryParameters(queryParameters))
  1155  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1156  }
  1157  
  1158  // MigrateMongoDBCollectionToManualThroughputSender sends the MigrateMongoDBCollectionToManualThroughput request. The method will close the
  1159  // http.Response Body if it receives an error.
  1160  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) {
  1161  	var resp *http.Response
  1162  	future.FutureAPI = &azure.Future{}
  1163  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1164  	if err != nil {
  1165  		return
  1166  	}
  1167  	var azf azure.Future
  1168  	azf, err = azure.NewFutureFromResponse(resp)
  1169  	future.FutureAPI = &azf
  1170  	future.Result = future.result
  1171  	return
  1172  }
  1173  
  1174  // MigrateMongoDBCollectionToManualThroughputResponder handles the response to the MigrateMongoDBCollectionToManualThroughput request. The method always
  1175  // closes the http.Response Body.
  1176  func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1177  	err = autorest.Respond(
  1178  		resp,
  1179  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1180  		autorest.ByUnmarshallingJSON(&result),
  1181  		autorest.ByClosing())
  1182  	result.Response = autorest.Response{Response: resp}
  1183  	return
  1184  }
  1185  
  1186  // MigrateMongoDBDatabaseToAutoscale migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale
  1187  // Parameters:
  1188  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1189  // accountName - cosmos DB database account name.
  1190  // databaseName - cosmos DB database name.
  1191  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) {
  1192  	if tracing.IsEnabled() {
  1193  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToAutoscale")
  1194  		defer func() {
  1195  			sc := -1
  1196  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1197  				sc = result.FutureAPI.Response().StatusCode
  1198  			}
  1199  			tracing.EndSpan(ctx, sc, err)
  1200  		}()
  1201  	}
  1202  	if err := validation.Validate([]validation.Validation{
  1203  		{TargetValue: client.SubscriptionID,
  1204  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1205  		{TargetValue: resourceGroupName,
  1206  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1207  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1208  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1209  		{TargetValue: accountName,
  1210  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1211  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1212  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
  1213  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", err.Error())
  1214  	}
  1215  
  1216  	req, err := client.MigrateMongoDBDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName)
  1217  	if err != nil {
  1218  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure preparing request")
  1219  		return
  1220  	}
  1221  
  1222  	result, err = client.MigrateMongoDBDatabaseToAutoscaleSender(req)
  1223  	if err != nil {
  1224  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", result.Response(), "Failure sending request")
  1225  		return
  1226  	}
  1227  
  1228  	return
  1229  }
  1230  
  1231  // MigrateMongoDBDatabaseToAutoscalePreparer prepares the MigrateMongoDBDatabaseToAutoscale request.
  1232  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
  1233  	pathParameters := map[string]interface{}{
  1234  		"accountName":       autorest.Encode("path", accountName),
  1235  		"databaseName":      autorest.Encode("path", databaseName),
  1236  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1237  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1238  	}
  1239  
  1240  	const APIVersion = "2021-03-15"
  1241  	queryParameters := map[string]interface{}{
  1242  		"api-version": APIVersion,
  1243  	}
  1244  
  1245  	preparer := autorest.CreatePreparer(
  1246  		autorest.AsPost(),
  1247  		autorest.WithBaseURL(client.BaseURI),
  1248  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters),
  1249  		autorest.WithQueryParameters(queryParameters))
  1250  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1251  }
  1252  
  1253  // MigrateMongoDBDatabaseToAutoscaleSender sends the MigrateMongoDBDatabaseToAutoscale request. The method will close the
  1254  // http.Response Body if it receives an error.
  1255  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) {
  1256  	var resp *http.Response
  1257  	future.FutureAPI = &azure.Future{}
  1258  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1259  	if err != nil {
  1260  		return
  1261  	}
  1262  	var azf azure.Future
  1263  	azf, err = azure.NewFutureFromResponse(resp)
  1264  	future.FutureAPI = &azf
  1265  	future.Result = future.result
  1266  	return
  1267  }
  1268  
  1269  // MigrateMongoDBDatabaseToAutoscaleResponder handles the response to the MigrateMongoDBDatabaseToAutoscale request. The method always
  1270  // closes the http.Response Body.
  1271  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1272  	err = autorest.Respond(
  1273  		resp,
  1274  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1275  		autorest.ByUnmarshallingJSON(&result),
  1276  		autorest.ByClosing())
  1277  	result.Response = autorest.Response{Response: resp}
  1278  	return
  1279  }
  1280  
  1281  // MigrateMongoDBDatabaseToManualThroughput migrate an Azure Cosmos DB MongoDB database from autoscale to manual
  1282  // throughput
  1283  // Parameters:
  1284  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1285  // accountName - cosmos DB database account name.
  1286  // databaseName - cosmos DB database name.
  1287  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) {
  1288  	if tracing.IsEnabled() {
  1289  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToManualThroughput")
  1290  		defer func() {
  1291  			sc := -1
  1292  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1293  				sc = result.FutureAPI.Response().StatusCode
  1294  			}
  1295  			tracing.EndSpan(ctx, sc, err)
  1296  		}()
  1297  	}
  1298  	if err := validation.Validate([]validation.Validation{
  1299  		{TargetValue: client.SubscriptionID,
  1300  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1301  		{TargetValue: resourceGroupName,
  1302  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1303  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1304  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1305  		{TargetValue: accountName,
  1306  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1307  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1308  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
  1309  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", err.Error())
  1310  	}
  1311  
  1312  	req, err := client.MigrateMongoDBDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName)
  1313  	if err != nil {
  1314  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure preparing request")
  1315  		return
  1316  	}
  1317  
  1318  	result, err = client.MigrateMongoDBDatabaseToManualThroughputSender(req)
  1319  	if err != nil {
  1320  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", result.Response(), "Failure sending request")
  1321  		return
  1322  	}
  1323  
  1324  	return
  1325  }
  1326  
  1327  // MigrateMongoDBDatabaseToManualThroughputPreparer prepares the MigrateMongoDBDatabaseToManualThroughput request.
  1328  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
  1329  	pathParameters := map[string]interface{}{
  1330  		"accountName":       autorest.Encode("path", accountName),
  1331  		"databaseName":      autorest.Encode("path", databaseName),
  1332  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1333  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1334  	}
  1335  
  1336  	const APIVersion = "2021-03-15"
  1337  	queryParameters := map[string]interface{}{
  1338  		"api-version": APIVersion,
  1339  	}
  1340  
  1341  	preparer := autorest.CreatePreparer(
  1342  		autorest.AsPost(),
  1343  		autorest.WithBaseURL(client.BaseURI),
  1344  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters),
  1345  		autorest.WithQueryParameters(queryParameters))
  1346  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1347  }
  1348  
  1349  // MigrateMongoDBDatabaseToManualThroughputSender sends the MigrateMongoDBDatabaseToManualThroughput request. The method will close the
  1350  // http.Response Body if it receives an error.
  1351  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) {
  1352  	var resp *http.Response
  1353  	future.FutureAPI = &azure.Future{}
  1354  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1355  	if err != nil {
  1356  		return
  1357  	}
  1358  	var azf azure.Future
  1359  	azf, err = azure.NewFutureFromResponse(resp)
  1360  	future.FutureAPI = &azf
  1361  	future.Result = future.result
  1362  	return
  1363  }
  1364  
  1365  // MigrateMongoDBDatabaseToManualThroughputResponder handles the response to the MigrateMongoDBDatabaseToManualThroughput request. The method always
  1366  // closes the http.Response Body.
  1367  func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1368  	err = autorest.Respond(
  1369  		resp,
  1370  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1371  		autorest.ByUnmarshallingJSON(&result),
  1372  		autorest.ByClosing())
  1373  	result.Response = autorest.Response{Response: resp}
  1374  	return
  1375  }
  1376  
  1377  // UpdateMongoDBCollectionThroughput update the RUs per second of an Azure Cosmos DB MongoDB collection
  1378  // Parameters:
  1379  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1380  // accountName - cosmos DB database account name.
  1381  // databaseName - cosmos DB database name.
  1382  // collectionName - cosmos DB collection name.
  1383  // updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB
  1384  // collection.
  1385  func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) {
  1386  	if tracing.IsEnabled() {
  1387  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBCollectionThroughput")
  1388  		defer func() {
  1389  			sc := -1
  1390  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1391  				sc = result.FutureAPI.Response().StatusCode
  1392  			}
  1393  			tracing.EndSpan(ctx, sc, err)
  1394  		}()
  1395  	}
  1396  	if err := validation.Validate([]validation.Validation{
  1397  		{TargetValue: client.SubscriptionID,
  1398  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1399  		{TargetValue: resourceGroupName,
  1400  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1401  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1402  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1403  		{TargetValue: accountName,
  1404  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1405  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1406  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
  1407  		{TargetValue: updateThroughputParameters,
  1408  			Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true,
  1409  				Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true,
  1410  					Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false,
  1411  						Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}},
  1412  					}},
  1413  				}}}}}); err != nil {
  1414  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", err.Error())
  1415  	}
  1416  
  1417  	req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters)
  1418  	if err != nil {
  1419  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request")
  1420  		return
  1421  	}
  1422  
  1423  	result, err = client.UpdateMongoDBCollectionThroughputSender(req)
  1424  	if err != nil {
  1425  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", result.Response(), "Failure sending request")
  1426  		return
  1427  	}
  1428  
  1429  	return
  1430  }
  1431  
  1432  // UpdateMongoDBCollectionThroughputPreparer prepares the UpdateMongoDBCollectionThroughput request.
  1433  func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) {
  1434  	pathParameters := map[string]interface{}{
  1435  		"accountName":       autorest.Encode("path", accountName),
  1436  		"collectionName":    autorest.Encode("path", collectionName),
  1437  		"databaseName":      autorest.Encode("path", databaseName),
  1438  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1439  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1440  	}
  1441  
  1442  	const APIVersion = "2021-03-15"
  1443  	queryParameters := map[string]interface{}{
  1444  		"api-version": APIVersion,
  1445  	}
  1446  
  1447  	preparer := autorest.CreatePreparer(
  1448  		autorest.AsContentType("application/json; charset=utf-8"),
  1449  		autorest.AsPut(),
  1450  		autorest.WithBaseURL(client.BaseURI),
  1451  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters),
  1452  		autorest.WithJSON(updateThroughputParameters),
  1453  		autorest.WithQueryParameters(queryParameters))
  1454  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1455  }
  1456  
  1457  // UpdateMongoDBCollectionThroughputSender sends the UpdateMongoDBCollectionThroughput request. The method will close the
  1458  // http.Response Body if it receives an error.
  1459  func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) {
  1460  	var resp *http.Response
  1461  	future.FutureAPI = &azure.Future{}
  1462  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1463  	if err != nil {
  1464  		return
  1465  	}
  1466  	var azf azure.Future
  1467  	azf, err = azure.NewFutureFromResponse(resp)
  1468  	future.FutureAPI = &azf
  1469  	future.Result = future.result
  1470  	return
  1471  }
  1472  
  1473  // UpdateMongoDBCollectionThroughputResponder handles the response to the UpdateMongoDBCollectionThroughput request. The method always
  1474  // closes the http.Response Body.
  1475  func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1476  	err = autorest.Respond(
  1477  		resp,
  1478  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1479  		autorest.ByUnmarshallingJSON(&result),
  1480  		autorest.ByClosing())
  1481  	result.Response = autorest.Response{Response: resp}
  1482  	return
  1483  }
  1484  
  1485  // UpdateMongoDBDatabaseThroughput update RUs per second of the an Azure Cosmos DB MongoDB database
  1486  // Parameters:
  1487  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1488  // accountName - cosmos DB database account name.
  1489  // databaseName - cosmos DB database name.
  1490  // updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB
  1491  // database.
  1492  func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) {
  1493  	if tracing.IsEnabled() {
  1494  		ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBDatabaseThroughput")
  1495  		defer func() {
  1496  			sc := -1
  1497  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1498  				sc = result.FutureAPI.Response().StatusCode
  1499  			}
  1500  			tracing.EndSpan(ctx, sc, err)
  1501  		}()
  1502  	}
  1503  	if err := validation.Validate([]validation.Validation{
  1504  		{TargetValue: client.SubscriptionID,
  1505  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1506  		{TargetValue: resourceGroupName,
  1507  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1508  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1509  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
  1510  		{TargetValue: accountName,
  1511  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1512  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
  1513  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
  1514  		{TargetValue: updateThroughputParameters,
  1515  			Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true,
  1516  				Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true,
  1517  					Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false,
  1518  						Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}},
  1519  					}},
  1520  				}}}}}); err != nil {
  1521  		return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", err.Error())
  1522  	}
  1523  
  1524  	req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters)
  1525  	if err != nil {
  1526  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request")
  1527  		return
  1528  	}
  1529  
  1530  	result, err = client.UpdateMongoDBDatabaseThroughputSender(req)
  1531  	if err != nil {
  1532  		err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", result.Response(), "Failure sending request")
  1533  		return
  1534  	}
  1535  
  1536  	return
  1537  }
  1538  
  1539  // UpdateMongoDBDatabaseThroughputPreparer prepares the UpdateMongoDBDatabaseThroughput request.
  1540  func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) {
  1541  	pathParameters := map[string]interface{}{
  1542  		"accountName":       autorest.Encode("path", accountName),
  1543  		"databaseName":      autorest.Encode("path", databaseName),
  1544  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1545  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1546  	}
  1547  
  1548  	const APIVersion = "2021-03-15"
  1549  	queryParameters := map[string]interface{}{
  1550  		"api-version": APIVersion,
  1551  	}
  1552  
  1553  	preparer := autorest.CreatePreparer(
  1554  		autorest.AsContentType("application/json; charset=utf-8"),
  1555  		autorest.AsPut(),
  1556  		autorest.WithBaseURL(client.BaseURI),
  1557  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters),
  1558  		autorest.WithJSON(updateThroughputParameters),
  1559  		autorest.WithQueryParameters(queryParameters))
  1560  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1561  }
  1562  
  1563  // UpdateMongoDBDatabaseThroughputSender sends the UpdateMongoDBDatabaseThroughput request. The method will close the
  1564  // http.Response Body if it receives an error.
  1565  func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) {
  1566  	var resp *http.Response
  1567  	future.FutureAPI = &azure.Future{}
  1568  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1569  	if err != nil {
  1570  		return
  1571  	}
  1572  	var azf azure.Future
  1573  	azf, err = azure.NewFutureFromResponse(resp)
  1574  	future.FutureAPI = &azf
  1575  	future.Result = future.result
  1576  	return
  1577  }
  1578  
  1579  // UpdateMongoDBDatabaseThroughputResponder handles the response to the UpdateMongoDBDatabaseThroughput request. The method always
  1580  // closes the http.Response Body.
  1581  func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
  1582  	err = autorest.Respond(
  1583  		resp,
  1584  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1585  		autorest.ByUnmarshallingJSON(&result),
  1586  		autorest.ByClosing())
  1587  	result.Response = autorest.Response{Response: resp}
  1588  	return
  1589  }
  1590  

View as plain text