...

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

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

View as plain text