diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/CHANGELOG.md b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/CHANGELOG.md new file mode 100644 index 000000000000..9ce03508242f --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/8e3bd3dd78414dfa127adef6573c81db80e6ae96/specification/cosmos-db/resource-manager/readme.md tag: `package-2021-03-preview` + +Code generator + + diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraclusters.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraclusters.go new file mode 100644 index 000000000000..31f515edb104 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraclusters.go @@ -0,0 +1,1046 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CassandraClustersClient is the client for the CassandraClusters methods of the Documentdb service. +type CassandraClustersClient struct { + BaseClient +} + +// NewCassandraClustersClient creates an instance of the CassandraClustersClient client. +func NewCassandraClustersClient(subscriptionID string) CassandraClustersClient { + return NewCassandraClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCassandraClustersClientWithBaseURI creates an instance of the CassandraClustersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCassandraClustersClientWithBaseURI(baseURI string, subscriptionID string) CassandraClustersClient { + return CassandraClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdate create or update a managed Cassandra cluster. When updating, you must specify all writable properties. +// To update only some properties, use PATCH. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// body - the properties specifying the desired state of the managed Cassandra cluster. +func (client CassandraClustersClient) CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersCreateUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.CreateUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "CreateUpdate", err.Error()) + } + + req, err := client.CreateUpdatePreparer(ctx, resourceGroupName, clusterName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdatePreparer prepares the CreateUpdate request. +func (client CassandraClustersClient) CreateUpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSender sends the CreateUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) CreateUpdateSender(req *http.Request) (future CassandraClustersCreateUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraClustersClient) (cr ClusterResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersCreateUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersCreateUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + cr.Response.Response, err = future.GetResult(sender) + if cr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersCreateUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && cr.Response.Response.StatusCode != http.StatusNoContent { + cr, err = client.CreateUpdateResponder(cr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersCreateUpdateFuture", "Result", cr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateResponder handles the response to the CreateUpdate request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) CreateUpdateResponder(resp *http.Response) (result ClusterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed Cassandra cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +func (client CassandraClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CassandraClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) DeleteSender(req *http.Request) (future CassandraClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FetchNodeStatus request the status of all nodes in the cluster (as returned by 'nodetool status'). +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +func (client CassandraClustersClient) FetchNodeStatus(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersFetchNodeStatusFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.FetchNodeStatus") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "FetchNodeStatus", err.Error()) + } + + req, err := client.FetchNodeStatusPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "FetchNodeStatus", nil, "Failure preparing request") + return + } + + result, err = client.FetchNodeStatusSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "FetchNodeStatus", nil, "Failure sending request") + return + } + + return +} + +// FetchNodeStatusPreparer prepares the FetchNodeStatus request. +func (client CassandraClustersClient) FetchNodeStatusPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/fetchNodeStatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FetchNodeStatusSender sends the FetchNodeStatus request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) FetchNodeStatusSender(req *http.Request) (future CassandraClustersFetchNodeStatusFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraClustersClient) (cns ClusterNodeStatus, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersFetchNodeStatusFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersFetchNodeStatusFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + cns.Response.Response, err = future.GetResult(sender) + if cns.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersFetchNodeStatusFuture", "Result", nil, "received nil response and error") + } + if err == nil && cns.Response.Response.StatusCode != http.StatusNoContent { + cns, err = client.FetchNodeStatusResponder(cns.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersFetchNodeStatusFuture", "Result", cns.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// FetchNodeStatusResponder handles the response to the FetchNodeStatus request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) FetchNodeStatusResponder(resp *http.Response) (result ClusterNodeStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the properties of a managed Cassandra cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +func (client CassandraClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result ClusterResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client CassandraClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) GetResponder(resp *http.Response) (result ClusterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetBackup get the properties of an individual backup of this cluster that is available to restore. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// backupID - id of a restorable backup of a Cassandra cluster. +func (client CassandraClustersClient) GetBackup(ctx context.Context, resourceGroupName string, clusterName string, backupID string) (result BackupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.GetBackup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: backupID, + Constraints: []validation.Constraint{{Target: "backupID", Name: validation.MaxLength, Rule: 15, Chain: nil}, + {Target: "backupID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "backupID", Name: validation.Pattern, Rule: `^[0-9]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "GetBackup", err.Error()) + } + + req, err := client.GetBackupPreparer(ctx, resourceGroupName, clusterName, backupID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", nil, "Failure preparing request") + return + } + + resp, err := client.GetBackupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", resp, "Failure sending request") + return + } + + result, err = client.GetBackupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", resp, "Failure responding to request") + return + } + + return +} + +// GetBackupPreparer prepares the GetBackup request. +func (client CassandraClustersClient) GetBackupPreparer(ctx context.Context, resourceGroupName string, clusterName string, backupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupId": autorest.Encode("path", backupID), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetBackupSender sends the GetBackup request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) GetBackupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetBackupResponder handles the response to the GetBackup request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) GetBackupResponder(resp *http.Response) (result BackupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBackupsMethod list the backups of this cluster that are available to restore. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +func (client CassandraClustersClient) ListBackupsMethod(ctx context.Context, resourceGroupName string, clusterName string) (result ListBackups, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListBackupsMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "ListBackupsMethod", err.Error()) + } + + req, err := client.ListBackupsMethodPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", nil, "Failure preparing request") + return + } + + resp, err := client.ListBackupsMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", resp, "Failure sending request") + return + } + + result, err = client.ListBackupsMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", resp, "Failure responding to request") + return + } + + return +} + +// ListBackupsMethodPreparer prepares the ListBackupsMethod request. +func (client CassandraClustersClient) ListBackupsMethodPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBackupsMethodSender sends the ListBackupsMethod request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) ListBackupsMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBackupsMethodResponder handles the response to the ListBackupsMethod request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) ListBackupsMethodResponder(resp *http.Response) (result ListBackups, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list all managed Cassandra clusters in this resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client CassandraClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListClusters, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client CassandraClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ListClusters, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription list all managed Cassandra clusters in this subscription. +func (client CassandraClustersClient) ListBySubscription(ctx context.Context) (result ListClusters, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client CassandraClustersClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) ListBySubscriptionResponder(resp *http.Response) (result ListClusters, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RequestRepair request that repair begin on this cluster as soon as possible. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// body - specification of what keyspaces and tables to run repair on. +func (client CassandraClustersClient) RequestRepair(ctx context.Context, resourceGroupName string, clusterName string, body RepairPostBody) (result CassandraClustersRequestRepairFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.RequestRepair") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Keyspace", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "RequestRepair", err.Error()) + } + + req, err := client.RequestRepairPreparer(ctx, resourceGroupName, clusterName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "RequestRepair", nil, "Failure preparing request") + return + } + + result, err = client.RequestRepairSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "RequestRepair", nil, "Failure sending request") + return + } + + return +} + +// RequestRepairPreparer prepares the RequestRepair request. +func (client CassandraClustersClient) RequestRepairPreparer(ctx context.Context, resourceGroupName string, clusterName string, body RepairPostBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/repair", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RequestRepairSender sends the RequestRepair request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) RequestRepairSender(req *http.Request) (future CassandraClustersRequestRepairFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersRequestRepairFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersRequestRepairFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// RequestRepairResponder handles the response to the RequestRepair request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) RequestRepairResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates some of the properties of a managed Cassandra cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// body - parameters to provide for specifying the managed Cassandra cluster. +func (client CassandraClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CassandraClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraClustersClient) UpdateSender(req *http.Request) (future CassandraClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraClustersClient) (cr ClusterResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + cr.Response.Response, err = future.GetResult(sender) + if cr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && cr.Response.Response.StatusCode != http.StatusNoContent { + cr, err = client.UpdateResponder(cr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersUpdateFuture", "Result", cr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CassandraClustersClient) UpdateResponder(resp *http.Response) (result ClusterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandradatacenters.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandradatacenters.go new file mode 100644 index 000000000000..ba9afde18d0b --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandradatacenters.go @@ -0,0 +1,589 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CassandraDataCentersClient is the client for the CassandraDataCenters methods of the Documentdb service. +type CassandraDataCentersClient struct { + BaseClient +} + +// NewCassandraDataCentersClient creates an instance of the CassandraDataCentersClient client. +func NewCassandraDataCentersClient(subscriptionID string) CassandraDataCentersClient { + return NewCassandraDataCentersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCassandraDataCentersClientWithBaseURI creates an instance of the CassandraDataCentersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCassandraDataCentersClientWithBaseURI(baseURI string, subscriptionID string) CassandraDataCentersClient { + return CassandraDataCentersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdate create or update a managed Cassandra data center. When updating, overwrite all properties. To update +// only some properties, use PATCH. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// dataCenterName - data center name in a managed Cassandra cluster. +// body - parameters specifying the managed Cassandra data center. +func (client CassandraDataCentersClient) CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (result CassandraDataCentersCreateUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.CreateUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: dataCenterName, + Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraDataCentersClient", "CreateUpdate", err.Error()) + } + + req, err := client.CreateUpdatePreparer(ctx, resourceGroupName, clusterName, dataCenterName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "CreateUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "CreateUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdatePreparer prepares the CreateUpdate request. +func (client CassandraDataCentersClient) CreateUpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "dataCenterName": autorest.Encode("path", dataCenterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSender sends the CreateUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraDataCentersClient) CreateUpdateSender(req *http.Request) (future CassandraDataCentersCreateUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraDataCentersClient) (dcr DataCenterResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersCreateUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersCreateUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + dcr.Response.Response, err = future.GetResult(sender) + if dcr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersCreateUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && dcr.Response.Response.StatusCode != http.StatusNoContent { + dcr, err = client.CreateUpdateResponder(dcr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersCreateUpdateFuture", "Result", dcr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateResponder handles the response to the CreateUpdate request. The method always +// closes the http.Response Body. +func (client CassandraDataCentersClient) CreateUpdateResponder(resp *http.Response) (result DataCenterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a managed Cassandra data center. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// dataCenterName - data center name in a managed Cassandra cluster. +func (client CassandraDataCentersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result CassandraDataCentersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: dataCenterName, + Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraDataCentersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, dataCenterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CassandraDataCentersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "dataCenterName": autorest.Encode("path", dataCenterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraDataCentersClient) DeleteSender(req *http.Request) (future CassandraDataCentersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraDataCentersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CassandraDataCentersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the properties of a managed Cassandra data center. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// dataCenterName - data center name in a managed Cassandra cluster. +func (client CassandraDataCentersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result DataCenterResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: dataCenterName, + Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraDataCentersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, dataCenterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client CassandraDataCentersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "dataCenterName": autorest.Encode("path", dataCenterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraDataCentersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CassandraDataCentersClient) GetResponder(resp *http.Response) (result DataCenterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all data centers in a particular managed Cassandra cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +func (client CassandraDataCentersClient) List(ctx context.Context, resourceGroupName string, clusterName string) (result ListDataCenters, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraDataCentersClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client CassandraDataCentersClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraDataCentersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CassandraDataCentersClient) ListResponder(resp *http.Response) (result ListDataCenters, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update some of the properties of a managed Cassandra data center. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - managed Cassandra cluster name. +// dataCenterName - data center name in a managed Cassandra cluster. +// body - parameters to provide for specifying the managed Cassandra data center. +func (client CassandraDataCentersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (result CassandraDataCentersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}, + {TargetValue: dataCenterName, + Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraDataCentersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, dataCenterName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CassandraDataCentersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "dataCenterName": autorest.Encode("path", dataCenterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraDataCentersClient) UpdateSender(req *http.Request) (future CassandraDataCentersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraDataCentersClient) (dcr DataCenterResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + dcr.Response.Response, err = future.GetResult(sender) + if dcr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && dcr.Response.Response.StatusCode != http.StatusNoContent { + dcr, err = client.UpdateResponder(dcr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersUpdateFuture", "Result", dcr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CassandraDataCentersClient) UpdateResponder(resp *http.Response) (result DataCenterResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraresources.go new file mode 100644 index 000000000000..bcfdde973695 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/cassandraresources.go @@ -0,0 +1,1800 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CassandraResourcesClient is the client for the CassandraResources methods of the Documentdb service. +type CassandraResourcesClient struct { + BaseClient +} + +// NewCassandraResourcesClient creates an instance of the CassandraResourcesClient client. +func NewCassandraResourcesClient(subscriptionID string) CassandraResourcesClient { + return NewCassandraResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCassandraResourcesClientWithBaseURI creates an instance of the CassandraResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCassandraResourcesClientWithBaseURI(baseURI string, subscriptionID string) CassandraResourcesClient { + return CassandraResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateCassandraKeyspace create or update an Azure Cosmos DB Cassandra keyspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// createUpdateCassandraKeyspaceParameters - the parameters to provide for the current Cassandra keyspace. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraKeyspace") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateCassandraKeyspaceParameters, + Constraints: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", err.Error()) + } + + req, err := client.CreateUpdateCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateCassandraKeyspaceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateCassandraKeyspacePreparer prepares the CreateUpdateCassandraKeyspace request. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithJSON(createUpdateCassandraKeyspaceParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateCassandraKeyspaceSender sends the CreateUpdateCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (ckgr CassandraKeyspaceGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + ckgr.Response.Response, err = future.GetResult(sender) + if ckgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", nil, "received nil response and error") + } + if err == nil && ckgr.Response.Response.StatusCode != http.StatusNoContent { + ckgr, err = client.CreateUpdateCassandraKeyspaceResponder(ckgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", ckgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateCassandraKeyspaceResponder handles the response to the CreateUpdateCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateCassandraTable create or update an Azure Cosmos DB Cassandra Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +// createUpdateCassandraTableParameters - the parameters to provide for the current Cassandra Table. +func (client CassandraResourcesClient) CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateCassandraTableParameters, + Constraints: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", err.Error()) + } + + req, err := client.CreateUpdateCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateCassandraTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateCassandraTablePreparer prepares the CreateUpdateCassandraTable request. +func (client CassandraResourcesClient) CreateUpdateCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithJSON(createUpdateCassandraTableParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateCassandraTableSender sends the CreateUpdateCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) CreateUpdateCassandraTableSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (ctgr CassandraTableGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraTableFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + ctgr.Response.Response, err = future.GetResult(sender) + if ctgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", nil, "received nil response and error") + } + if err == nil && ctgr.Response.Response.StatusCode != http.StatusNoContent { + ctgr, err = client.CreateUpdateCassandraTableResponder(ctgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", ctgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateCassandraTableResponder handles the response to the CreateUpdateCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) CreateUpdateCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteCassandraKeyspace deletes an existing Azure Cosmos DB Cassandra keyspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraKeyspace") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", err.Error()) + } + + req, err := client.DeleteCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", nil, "Failure preparing request") + return + } + + result, err = client.DeleteCassandraKeyspaceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", nil, "Failure sending request") + return + } + + return +} + +// DeleteCassandraKeyspacePreparer prepares the DeleteCassandraKeyspace request. +func (client CassandraResourcesClient) DeleteCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteCassandraKeyspaceSender sends the DeleteCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) DeleteCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteCassandraKeyspaceResponder handles the response to the DeleteCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) DeleteCassandraKeyspaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteCassandraTable deletes an existing Azure Cosmos DB Cassandra table. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesDeleteCassandraTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraTable", err.Error()) + } + + req, err := client.DeleteCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", nil, "Failure preparing request") + return + } + + result, err = client.DeleteCassandraTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", nil, "Failure sending request") + return + } + + return +} + +// DeleteCassandraTablePreparer prepares the DeleteCassandraTable request. +func (client CassandraResourcesClient) DeleteCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteCassandraTableSender sends the DeleteCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) DeleteCassandraTableSender(req *http.Request) (future CassandraResourcesDeleteCassandraTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraTableFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteCassandraTableResponder handles the response to the DeleteCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) DeleteCassandraTableResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetCassandraKeyspace gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the +// provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraKeyspaceGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspace") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspace", err.Error()) + } + + req, err := client.GetCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraKeyspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraKeyspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraKeyspacePreparer prepares the GetCassandraKeyspace request. +func (client CassandraResourcesClient) GetCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraKeyspaceSender sends the GetCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraKeyspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraKeyspaceResponder handles the response to the GetCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraKeyspaceThroughput gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspaceThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", err.Error()) + } + + req, err := client.GetCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraKeyspaceThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraKeyspaceThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraKeyspaceThroughputPreparer prepares the GetCassandraKeyspaceThroughput request. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraKeyspaceThroughputSender sends the GetCassandraKeyspaceThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraKeyspaceThroughputResponder handles the response to the GetCassandraKeyspaceThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraTable gets the Cassandra table under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraTableGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTable") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTable", err.Error()) + } + + req, err := client.GetCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraTablePreparer prepares the GetCassandraTable request. +func (client CassandraResourcesClient) GetCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraTableSender sends the GetCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraTableResponder handles the response to the GetCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraTableThroughput gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTableThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", err.Error()) + } + + req, err := client.GetCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraTableThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraTableThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraTableThroughputPreparer prepares the GetCassandraTableThroughput request. +func (client CassandraResourcesClient) GetCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraTableThroughputSender sends the GetCassandraTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraTableThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraTableThroughputResponder handles the response to the GetCassandraTableThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCassandraKeyspaces lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client CassandraResourcesClient) ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result CassandraKeyspaceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraKeyspaces") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", err.Error()) + } + + req, err := client.ListCassandraKeyspacesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", nil, "Failure preparing request") + return + } + + resp, err := client.ListCassandraKeyspacesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure sending request") + return + } + + result, err = client.ListCassandraKeyspacesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure responding to request") + return + } + + return +} + +// ListCassandraKeyspacesPreparer prepares the ListCassandraKeyspaces request. +func (client CassandraResourcesClient) ListCassandraKeyspacesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCassandraKeyspacesSender sends the ListCassandraKeyspaces request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) ListCassandraKeyspacesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCassandraKeyspacesResponder handles the response to the ListCassandraKeyspaces request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) ListCassandraKeyspacesResponder(resp *http.Response) (result CassandraKeyspaceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCassandraTables lists the Cassandra table under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraTableListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraTables") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraTables", err.Error()) + } + + req, err := client.ListCassandraTablesPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", nil, "Failure preparing request") + return + } + + resp, err := client.ListCassandraTablesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure sending request") + return + } + + result, err = client.ListCassandraTablesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure responding to request") + return + } + + return +} + +// ListCassandraTablesPreparer prepares the ListCassandraTables request. +func (client CassandraResourcesClient) ListCassandraTablesPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCassandraTablesSender sends the ListCassandraTables request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) ListCassandraTablesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCassandraTablesResponder handles the response to the ListCassandraTables request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) ListCassandraTablesResponder(resp *http.Response) (result CassandraTableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraKeyspaceToAutoscale migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to +// autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", err.Error()) + } + + req, err := client.MigrateCassandraKeyspaceToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraKeyspaceToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraKeyspaceToAutoscalePreparer prepares the MigrateCassandraKeyspaceToAutoscale request. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraKeyspaceToAutoscaleSender sends the MigrateCassandraKeyspaceToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraKeyspaceToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateCassandraKeyspaceToAutoscaleResponder handles the response to the MigrateCassandraKeyspaceToAutoscale request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraKeyspaceToManualThroughput migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", err.Error()) + } + + req, err := client.MigrateCassandraKeyspaceToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraKeyspaceToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraKeyspaceToManualThroughputPreparer prepares the MigrateCassandraKeyspaceToManualThroughput request. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraKeyspaceToManualThroughputSender sends the MigrateCassandraKeyspaceToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraKeyspaceToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateCassandraKeyspaceToManualThroughputResponder handles the response to the MigrateCassandraKeyspaceToManualThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraTableToAutoscale migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", err.Error()) + } + + req, err := client.MigrateCassandraTableToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraTableToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraTableToAutoscalePreparer prepares the MigrateCassandraTableToAutoscale request. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraTableToAutoscaleSender sends the MigrateCassandraTableToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraTableToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateCassandraTableToAutoscaleResponder handles the response to the MigrateCassandraTableToAutoscale request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraTableToManualThroughput migrate an Azure Cosmos DB Cassandra table from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", err.Error()) + } + + req, err := client.MigrateCassandraTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraTableToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraTableToManualThroughputPreparer prepares the MigrateCassandraTableToManualThroughput request. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraTableToManualThroughputSender sends the MigrateCassandraTableToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraTableToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateCassandraTableToManualThroughputResponder handles the response to the MigrateCassandraTableToManualThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateCassandraKeyspaceThroughput update RUs per second of an Azure Cosmos DB Cassandra Keyspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra +// Keyspace. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraKeyspaceThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", err.Error()) + } + + req, err := client.UpdateCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateCassandraKeyspaceThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateCassandraKeyspaceThroughputPreparer prepares the UpdateCassandraKeyspaceThroughput request. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateCassandraKeyspaceThroughputSender sends the UpdateCassandraKeyspaceThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateCassandraKeyspaceThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateCassandraKeyspaceThroughputResponder handles the response to the UpdateCassandraKeyspaceThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateCassandraTableThroughput update RUs per second of an Azure Cosmos DB Cassandra table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra +// table. +func (client CassandraResourcesClient) UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraTableThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", err.Error()) + } + + req, err := client.UpdateCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateCassandraTableThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateCassandraTableThroughputPreparer prepares the UpdateCassandraTableThroughput request. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateCassandraTableThroughputSender sends the UpdateCassandraTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateCassandraTableThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateCassandraTableThroughputResponder handles the response to the UpdateCassandraTableThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/client.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/client.go new file mode 100644 index 000000000000..00ef6acacd3f --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/client.go @@ -0,0 +1,52 @@ +// Package documentdb implements the Azure ARM Documentdb service API version 2021-03-01-preview. +// +// +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Documentdb + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Documentdb. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collection.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collection.go new file mode 100644 index 000000000000..94fc95ff39d2 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collection.go @@ -0,0 +1,334 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionClient is the client for the Collection methods of the Documentdb service. +type CollectionClient struct { + BaseClient +} + +// NewCollectionClient creates an instance of the CollectionClient client. +func NewCollectionClient(subscriptionID string) CollectionClient { + return NewCollectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionClientWithBaseURI creates an instance of the CollectionClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCollectionClientWithBaseURI(baseURI string, subscriptionID string) CollectionClient { + return CollectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetricDefinitions retrieves metric definitions for the given collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +func (client CollectionClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client CollectionClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent storage data) for the given collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client CollectionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client CollectionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartition.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartition.go new file mode 100644 index 000000000000..0e86d8735a58 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartition.go @@ -0,0 +1,241 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionPartitionClient is the client for the CollectionPartition methods of the Documentdb service. +type CollectionPartitionClient struct { + BaseClient +} + +// NewCollectionPartitionClient creates an instance of the CollectionPartitionClient client. +func NewCollectionPartitionClient(subscriptionID string) CollectionPartitionClient { + return NewCollectionPartitionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionPartitionClientWithBaseURI creates an instance of the CollectionPartitionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCollectionPartitionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionClient { + return CollectionPartitionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given collection, split by partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionPartitionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionPartitionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionPartitionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionPartitionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent storage data) for the given collection, split by partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client CollectionPartitionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionUsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client CollectionPartitionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionPartitionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client CollectionPartitionClient) ListUsagesResponder(resp *http.Response) (result PartitionUsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartitionregion.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartitionregion.go new file mode 100644 index 000000000000..7d4b8a6052b1 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionpartitionregion.go @@ -0,0 +1,145 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionPartitionRegionClient is the client for the CollectionPartitionRegion methods of the Documentdb service. +type CollectionPartitionRegionClient struct { + BaseClient +} + +// NewCollectionPartitionRegionClient creates an instance of the CollectionPartitionRegionClient client. +func NewCollectionPartitionRegionClient(subscriptionID string) CollectionPartitionRegionClient { + return NewCollectionPartitionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionPartitionRegionClientWithBaseURI creates an instance of the CollectionPartitionRegionClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewCollectionPartitionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionRegionClient { + return CollectionPartitionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given collection and region, split by +// partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionPartitionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionPartitionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionPartitionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionPartitionRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionregion.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionregion.go new file mode 100644 index 000000000000..702c0a819c45 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/collectionregion.go @@ -0,0 +1,145 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionRegionClient is the client for the CollectionRegion methods of the Documentdb service. +type CollectionRegionClient struct { + BaseClient +} + +// NewCollectionRegionClient creates an instance of the CollectionRegionClient client. +func NewCollectionRegionClient(subscriptionID string) CollectionRegionClient { + return NewCollectionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionRegionClientWithBaseURI creates an instance of the CollectionRegionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCollectionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionRegionClient { + return CollectionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account, collection and +// region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/database.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/database.go new file mode 100644 index 000000000000..3041d77fbf86 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/database.go @@ -0,0 +1,328 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseClient is the client for the Database methods of the Documentdb service. +type DatabaseClient struct { + BaseClient +} + +// NewDatabaseClient creates an instance of the DatabaseClient client. +func NewDatabaseClient(subscriptionID string) DatabaseClient { + return NewDatabaseClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseClientWithBaseURI creates an instance of the DatabaseClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseClientWithBaseURI(baseURI string, subscriptionID string) DatabaseClient { + return DatabaseClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetricDefinitions retrieves metric definitions for the given database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +func (client DatabaseClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabaseClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent data) for the given database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client DatabaseClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client DatabaseClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccountregion.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccountregion.go new file mode 100644 index 000000000000..eeaf2beaf00b --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccountregion.go @@ -0,0 +1,140 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAccountRegionClient is the client for the DatabaseAccountRegion methods of the Documentdb service. +type DatabaseAccountRegionClient struct { + BaseClient +} + +// NewDatabaseAccountRegionClient creates an instance of the DatabaseAccountRegionClient client. +func NewDatabaseAccountRegionClient(subscriptionID string) DatabaseAccountRegionClient { + return NewDatabaseAccountRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAccountRegionClientWithBaseURI creates an instance of the DatabaseAccountRegionClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDatabaseAccountRegionClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountRegionClient { + return DatabaseAccountRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseAccountRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseAccountRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseAccountRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccounts.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccounts.go new file mode 100644 index 000000000000..89b98c55ca78 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/databaseaccounts.go @@ -0,0 +1,1792 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAccountsClient is the client for the DatabaseAccounts methods of the Documentdb service. +type DatabaseAccountsClient struct { + BaseClient +} + +// NewDatabaseAccountsClient creates an instance of the DatabaseAccountsClient client. +func NewDatabaseAccountsClient(subscriptionID string) DatabaseAccountsClient { + return NewDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAccountsClientWithBaseURI creates an instance of the DatabaseAccountsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountsClient { + return DatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameExists checks that the Azure Cosmos DB account name already exists. A valid account name may contain only +// lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. +// Parameters: +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) CheckNameExists(ctx context.Context, accountName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CheckNameExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "CheckNameExists", err.Error()) + } + + req, err := client.CheckNameExistsPreparer(ctx, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure sending request") + return + } + + result, err = client.CheckNameExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameExistsPreparer prepares the CheckNameExists request. +func (client DatabaseAccountsClient) CheckNameExistsPreparer(ctx context.Context, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameExistsSender sends the CheckNameExists request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) CheckNameExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CheckNameExistsResponder handles the response to the CheckNameExists request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) CheckNameExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when +// performing updates on an account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateParameters - the parameters to provide for the current database account. +func (client DatabaseAccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (result DatabaseAccountsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, createUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseAccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithJSON(createUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) CreateOrUpdateSender(req *http.Request) (future DatabaseAccountsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + dagr.Response.Response, err = future.GetResult(sender) + if dagr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { + dagr, err = client.CreateOrUpdateResponder(dagr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) DeleteSender(req *http.Request) (future DatabaseAccountsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverPriorityChange changes the failover priority for the Azure Cosmos DB database account. A failover priority +// of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover +// priority values must be unique for each of the regions in which the database account exists. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// failoverParameters - the new failover policies for the database account. +func (client DatabaseAccountsClient) FailoverPriorityChange(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (result DatabaseAccountsFailoverPriorityChangeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.FailoverPriorityChange") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: failoverParameters, + Constraints: []validation.Constraint{{Target: "failoverParameters.FailoverPolicies", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "FailoverPriorityChange", err.Error()) + } + + req, err := client.FailoverPriorityChangePreparer(ctx, resourceGroupName, accountName, failoverParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure preparing request") + return + } + + result, err = client.FailoverPriorityChangeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure sending request") + return + } + + return +} + +// FailoverPriorityChangePreparer prepares the FailoverPriorityChange request. +func (client DatabaseAccountsClient) FailoverPriorityChangePreparer(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", pathParameters), + autorest.WithJSON(failoverParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverPriorityChangeSender sends the FailoverPriorityChange request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) FailoverPriorityChangeSender(req *http.Request) (future DatabaseAccountsFailoverPriorityChangeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsFailoverPriorityChangeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsFailoverPriorityChangeFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// FailoverPriorityChangeResponder handles the response to the FailoverPriorityChange request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) FailoverPriorityChangeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieves the properties of an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) GetResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) GetReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.GetReadOnlyKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", err.Error()) + } + + req, err := client.GetReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", nil, "Failure preparing request") + return + } + + resp, err := client.GetReadOnlyKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure sending request") + return + } + + result, err = client.GetReadOnlyKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure responding to request") + return + } + + return +} + +// GetReadOnlyKeysPreparer prepares the GetReadOnlyKeys request. +func (client DatabaseAccountsClient) GetReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetReadOnlyKeysSender sends the GetReadOnlyKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) GetReadOnlyKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetReadOnlyKeysResponder handles the response to the GetReadOnlyKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) GetReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the Azure Cosmos DB database accounts available under the subscription. +func (client DatabaseAccountsClient) List(ctx context.Context) (result DatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists all the Azure Cosmos DB database accounts available under the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DatabaseAccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DatabaseAccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListByResourceGroupResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListConnectionStrings lists the connection strings for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListConnectionStrings(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListConnectionStringsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListConnectionStrings") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListConnectionStrings", err.Error()) + } + + req, err := client.ListConnectionStringsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionStringsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionStringsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure responding to request") + return + } + + return +} + +// ListConnectionStringsPreparer prepares the ListConnectionStrings request. +func (client DatabaseAccountsClient) ListConnectionStringsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionStringsSender sends the ListConnectionStrings request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListConnectionStringsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionStringsResponder handles the response to the ListConnectionStrings request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListConnectionStringsResponder(resp *http.Response) (result DatabaseAccountListConnectionStringsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListKeys lists the access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListKeys", err.Error()) + } + + req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client DatabaseAccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListKeysResponder(resp *http.Response) (result DatabaseAccountListKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions retrieves metric definitions for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabaseAccountsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseAccountsClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseAccountsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListReadOnlyKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", err.Error()) + } + + req, err := client.ListReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListReadOnlyKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure sending request") + return + } + + result, err = client.ListReadOnlyKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListReadOnlyKeysPreparer prepares the ListReadOnlyKeys request. +func (client DatabaseAccountsClient) ListReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListReadOnlyKeysSender sends the ListReadOnlyKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListReadOnlyKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListReadOnlyKeysResponder handles the response to the ListReadOnlyKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent data) for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client DatabaseAccountsClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client DatabaseAccountsClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// OfflineRegion offline the specified region for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// regionParameterForOffline - cosmos DB region to offline for the database account. +func (client DatabaseAccountsClient) OfflineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (result DatabaseAccountsOfflineRegionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OfflineRegion") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: regionParameterForOffline, + Constraints: []validation.Constraint{{Target: "regionParameterForOffline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "OfflineRegion", err.Error()) + } + + req, err := client.OfflineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOffline) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", nil, "Failure preparing request") + return + } + + result, err = client.OfflineRegionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", nil, "Failure sending request") + return + } + + return +} + +// OfflineRegionPreparer prepares the OfflineRegion request. +func (client DatabaseAccountsClient) OfflineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion", pathParameters), + autorest.WithJSON(regionParameterForOffline), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// OfflineRegionSender sends the OfflineRegion request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) OfflineRegionSender(req *http.Request) (future DatabaseAccountsOfflineRegionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOfflineRegionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOfflineRegionFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// OfflineRegionResponder handles the response to the OfflineRegion request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) OfflineRegionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// OnlineRegion online the specified region for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// regionParameterForOnline - cosmos DB region to online for the database account. +func (client DatabaseAccountsClient) OnlineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (result DatabaseAccountsOnlineRegionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OnlineRegion") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: regionParameterForOnline, + Constraints: []validation.Constraint{{Target: "regionParameterForOnline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "OnlineRegion", err.Error()) + } + + req, err := client.OnlineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOnline) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", nil, "Failure preparing request") + return + } + + result, err = client.OnlineRegionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", nil, "Failure sending request") + return + } + + return +} + +// OnlineRegionPreparer prepares the OnlineRegion request. +func (client DatabaseAccountsClient) OnlineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion", pathParameters), + autorest.WithJSON(regionParameterForOnline), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// OnlineRegionSender sends the OnlineRegion request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) OnlineRegionSender(req *http.Request) (future DatabaseAccountsOnlineRegionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOnlineRegionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOnlineRegionFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// OnlineRegionResponder handles the response to the OnlineRegion request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) OnlineRegionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateKey regenerates an access key for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyToRegenerate - the name of the key to regenerate. +func (client DatabaseAccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (result DatabaseAccountsRegenerateKeyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.RegenerateKey") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, keyToRegenerate) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateKeySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure sending request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client DatabaseAccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey", pathParameters), + autorest.WithJSON(keyToRegenerate), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) RegenerateKeySender(req *http.Request) (future DatabaseAccountsRegenerateKeyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsRegenerateKeyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsRegenerateKeyFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) RegenerateKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates the properties of an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// updateParameters - the parameters to provide for the current database account. +func (client DatabaseAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (result DatabaseAccountsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, updateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithJSON(updateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) UpdateSender(req *http.Request) (future DatabaseAccountsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + dagr.Response.Response, err = future.GetResult(sender) + if dagr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { + dagr, err = client.UpdateResponder(dagr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) UpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/documentdbapi/interfaces.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/documentdbapi/interfaces.go new file mode 100644 index 000000000000..e20f43ec25c5 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/documentdbapi/interfaces.go @@ -0,0 +1,369 @@ +package documentdbapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb" + "github.com/Azure/go-autorest/autorest" +) + +// DatabaseAccountsClientAPI contains the set of methods on the DatabaseAccountsClient type. +type DatabaseAccountsClientAPI interface { + CheckNameExists(ctx context.Context, accountName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters documentdb.DatabaseAccountCreateUpdateParameters) (result documentdb.DatabaseAccountsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountsDeleteFuture, err error) + FailoverPriorityChange(ctx context.Context, resourceGroupName string, accountName string, failoverParameters documentdb.FailoverPolicies) (result documentdb.DatabaseAccountsFailoverPriorityChangeFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountGetResults, err error) + GetReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListReadOnlyKeysResult, err error) + List(ctx context.Context) (result documentdb.DatabaseAccountsListResult, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result documentdb.DatabaseAccountsListResult, err error) + ListConnectionStrings(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListConnectionStringsResult, err error) + ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListKeysResult, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.MetricListResult, err error) + ListReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListReadOnlyKeysResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.UsagesResult, err error) + OfflineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline documentdb.RegionForOnlineOffline) (result documentdb.DatabaseAccountsOfflineRegionFuture, err error) + OnlineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline documentdb.RegionForOnlineOffline) (result documentdb.DatabaseAccountsOnlineRegionFuture, err error) + RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate documentdb.DatabaseAccountRegenerateKeyParameters) (result documentdb.DatabaseAccountsRegenerateKeyFuture, err error) + Update(ctx context.Context, resourceGroupName string, accountName string, updateParameters documentdb.DatabaseAccountUpdateParameters) (result documentdb.DatabaseAccountsUpdateFuture, err error) +} + +var _ DatabaseAccountsClientAPI = (*documentdb.DatabaseAccountsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result documentdb.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result documentdb.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*documentdb.OperationsClient)(nil) + +// DatabaseClientAPI contains the set of methods on the DatabaseClient type. +type DatabaseClientAPI interface { + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result documentdb.MetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result documentdb.UsagesResult, err error) +} + +var _ DatabaseClientAPI = (*documentdb.DatabaseClient)(nil) + +// CollectionClientAPI contains the set of methods on the CollectionClient type. +type CollectionClientAPI interface { + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.MetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.UsagesResult, err error) +} + +var _ CollectionClientAPI = (*documentdb.CollectionClient)(nil) + +// CollectionRegionClientAPI contains the set of methods on the CollectionRegionClient type. +type CollectionRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result documentdb.MetricListResult, err error) +} + +var _ CollectionRegionClientAPI = (*documentdb.CollectionRegionClient)(nil) + +// DatabaseAccountRegionClientAPI contains the set of methods on the DatabaseAccountRegionClient type. +type DatabaseAccountRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (result documentdb.MetricListResult, err error) +} + +var _ DatabaseAccountRegionClientAPI = (*documentdb.DatabaseAccountRegionClient)(nil) + +// PercentileSourceTargetClientAPI contains the set of methods on the PercentileSourceTargetClient type. +type PercentileSourceTargetClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileSourceTargetClientAPI = (*documentdb.PercentileSourceTargetClient)(nil) + +// PercentileTargetClientAPI contains the set of methods on the PercentileTargetClient type. +type PercentileTargetClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileTargetClientAPI = (*documentdb.PercentileTargetClient)(nil) + +// PercentileClientAPI contains the set of methods on the PercentileClient type. +type PercentileClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileClientAPI = (*documentdb.PercentileClient)(nil) + +// CollectionPartitionRegionClientAPI contains the set of methods on the CollectionPartitionRegionClient type. +type CollectionPartitionRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ CollectionPartitionRegionClientAPI = (*documentdb.CollectionPartitionRegionClient)(nil) + +// CollectionPartitionClientAPI contains the set of methods on the CollectionPartitionClient type. +type CollectionPartitionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionMetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionUsagesResult, err error) +} + +var _ CollectionPartitionClientAPI = (*documentdb.CollectionPartitionClient)(nil) + +// PartitionKeyRangeIDClientAPI contains the set of methods on the PartitionKeyRangeIDClient type. +type PartitionKeyRangeIDClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ PartitionKeyRangeIDClientAPI = (*documentdb.PartitionKeyRangeIDClient)(nil) + +// PartitionKeyRangeIDRegionClientAPI contains the set of methods on the PartitionKeyRangeIDRegionClient type. +type PartitionKeyRangeIDRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ PartitionKeyRangeIDRegionClientAPI = (*documentdb.PartitionKeyRangeIDRegionClient)(nil) + +// SQLResourcesClientAPI contains the set of methods on the SQLResourcesClient type. +type SQLResourcesClientAPI interface { + CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters documentdb.SQLContainerCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLContainerFuture, err error) + CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters documentdb.SQLDatabaseCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture, err error) + CreateUpdateSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters documentdb.SQLRoleAssignmentCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) + CreateUpdateSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters documentdb.SQLRoleDefinitionCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) + CreateUpdateSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters documentdb.SQLStoredProcedureCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) + CreateUpdateSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters documentdb.SQLTriggerCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLTriggerFuture, err error) + CreateUpdateSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters documentdb.SQLUserDefinedFunctionCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) + DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesDeleteSQLContainerFuture, err error) + DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesDeleteSQLDatabaseFuture, err error) + DeleteSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture, err error) + DeleteSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture, err error) + DeleteSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result documentdb.SQLResourcesDeleteSQLStoredProcedureFuture, err error) + DeleteSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result documentdb.SQLResourcesDeleteSQLTriggerFuture, err error) + DeleteSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) + GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLContainerGetResults, err error) + GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLDatabaseGetResults, err error) + GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result documentdb.SQLRoleAssignmentGetResults, err error) + GetSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result documentdb.SQLRoleDefinitionGetResults, err error) + GetSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result documentdb.SQLStoredProcedureGetResults, err error) + GetSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result documentdb.SQLTriggerGetResults, err error) + GetSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result documentdb.SQLUserDefinedFunctionGetResults, err error) + ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLContainerListResult, err error) + ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLDatabaseListResult, err error) + ListSQLRoleAssignments(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLRoleAssignmentListResult, err error) + ListSQLRoleDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLRoleDefinitionListResult, err error) + ListSQLStoredProcedures(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLStoredProcedureListResult, err error) + ListSQLTriggers(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLTriggerListResult, err error) + ListSQLUserDefinedFunctions(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLUserDefinedFunctionListResult, err error) + MigrateSQLContainerToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) + MigrateSQLContainerToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) + MigrateSQLDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) + MigrateSQLDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) + UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.SQLResourcesUpdateSQLContainerThroughputFuture, err error) + UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) +} + +var _ SQLResourcesClientAPI = (*documentdb.SQLResourcesClient)(nil) + +// MongoDBResourcesClientAPI contains the set of methods on the MongoDBResourcesClient type. +type MongoDBResourcesClientAPI interface { + CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters documentdb.MongoDBCollectionCreateUpdateParameters) (result documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) + CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters documentdb.MongoDBDatabaseCreateUpdateParameters) (result documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) + DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture, err error) + DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) + GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBCollectionGetResults, err error) + GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBDatabaseGetResults, err error) + GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBCollectionListResult, err error) + ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.MongoDBDatabaseListResult, err error) + MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) + MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) + MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) + MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) + UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) + UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) +} + +var _ MongoDBResourcesClientAPI = (*documentdb.MongoDBResourcesClient)(nil) + +// TableResourcesClientAPI contains the set of methods on the TableResourcesClient type. +type TableResourcesClientAPI interface { + CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters documentdb.TableCreateUpdateParameters) (result documentdb.TableResourcesCreateUpdateTableFuture, err error) + DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesDeleteTableFuture, err error) + GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableGetResults, err error) + GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListTables(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.TableListResult, err error) + MigrateTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesMigrateTableToAutoscaleFuture, err error) + MigrateTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesMigrateTableToManualThroughputFuture, err error) + UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.TableResourcesUpdateTableThroughputFuture, err error) +} + +var _ TableResourcesClientAPI = (*documentdb.TableResourcesClient)(nil) + +// CassandraResourcesClientAPI contains the set of methods on the CassandraResourcesClient type. +type CassandraResourcesClientAPI interface { + CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters documentdb.CassandraKeyspaceCreateUpdateParameters) (result documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) + CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters documentdb.CassandraTableCreateUpdateParameters) (result documentdb.CassandraResourcesCreateUpdateCassandraTableFuture, err error) + DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture, err error) + DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesDeleteCassandraTableFuture, err error) + GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraKeyspaceGetResults, err error) + GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraTableGetResults, err error) + GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.CassandraKeyspaceListResult, err error) + ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraTableListResult, err error) + MigrateCassandraKeyspaceToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) + MigrateCassandraKeyspaceToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) + MigrateCassandraTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) + MigrateCassandraTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) + UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) + UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture, err error) +} + +var _ CassandraResourcesClientAPI = (*documentdb.CassandraResourcesClient)(nil) + +// GremlinResourcesClientAPI contains the set of methods on the GremlinResourcesClient type. +type GremlinResourcesClientAPI interface { + CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters documentdb.GremlinDatabaseCreateUpdateParameters) (result documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) + CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters documentdb.GremlinGraphCreateUpdateParameters) (result documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture, err error) + DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesDeleteGremlinDatabaseFuture, err error) + DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesDeleteGremlinGraphFuture, err error) + GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinDatabaseGetResults, err error) + GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinGraphGetResults, err error) + GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.GremlinDatabaseListResult, err error) + ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinGraphListResult, err error) + MigrateGremlinDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) + MigrateGremlinDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) + MigrateGremlinGraphToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) + MigrateGremlinGraphToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) + UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) + UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) +} + +var _ GremlinResourcesClientAPI = (*documentdb.GremlinResourcesClient)(nil) + +// RestorableDatabaseAccountsClientAPI contains the set of methods on the RestorableDatabaseAccountsClient type. +type RestorableDatabaseAccountsClientAPI interface { + GetByLocation(ctx context.Context, location string, instanceID string) (result documentdb.RestorableDatabaseAccountGetResult, err error) + List(ctx context.Context) (result documentdb.RestorableDatabaseAccountsListResult, err error) + ListByLocation(ctx context.Context, location string) (result documentdb.RestorableDatabaseAccountsListResult, err error) +} + +var _ RestorableDatabaseAccountsClientAPI = (*documentdb.RestorableDatabaseAccountsClient)(nil) + +// NotebookWorkspacesClientAPI contains the set of methods on the NotebookWorkspacesClient type. +type NotebookWorkspacesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters documentdb.NotebookWorkspaceCreateUpdateParameters) (result documentdb.NotebookWorkspacesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspace, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceListResult, err error) + ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceConnectionInfoResult, err error) + RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesRegenerateAuthTokenFuture, err error) + Start(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesStartFuture, err error) +} + +var _ NotebookWorkspacesClientAPI = (*documentdb.NotebookWorkspacesClient)(nil) + +// RestorableSQLDatabasesClientAPI contains the set of methods on the RestorableSQLDatabasesClient type. +type RestorableSQLDatabasesClientAPI interface { + List(ctx context.Context, location string, instanceID string) (result documentdb.RestorableSQLDatabasesListResult, err error) +} + +var _ RestorableSQLDatabasesClientAPI = (*documentdb.RestorableSQLDatabasesClient)(nil) + +// RestorableSQLContainersClientAPI contains the set of methods on the RestorableSQLContainersClient type. +type RestorableSQLContainersClientAPI interface { + List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string) (result documentdb.RestorableSQLContainersListResult, err error) +} + +var _ RestorableSQLContainersClientAPI = (*documentdb.RestorableSQLContainersClient)(nil) + +// RestorableSQLResourcesClientAPI contains the set of methods on the RestorableSQLResourcesClient type. +type RestorableSQLResourcesClientAPI interface { + List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result documentdb.RestorableSQLResourcesListResult, err error) +} + +var _ RestorableSQLResourcesClientAPI = (*documentdb.RestorableSQLResourcesClient)(nil) + +// RestorableMongodbDatabasesClientAPI contains the set of methods on the RestorableMongodbDatabasesClient type. +type RestorableMongodbDatabasesClientAPI interface { + List(ctx context.Context, location string, instanceID string) (result documentdb.RestorableMongodbDatabasesListResult, err error) +} + +var _ RestorableMongodbDatabasesClientAPI = (*documentdb.RestorableMongodbDatabasesClient)(nil) + +// RestorableMongodbCollectionsClientAPI contains the set of methods on the RestorableMongodbCollectionsClient type. +type RestorableMongodbCollectionsClientAPI interface { + List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result documentdb.RestorableMongodbCollectionsListResult, err error) +} + +var _ RestorableMongodbCollectionsClientAPI = (*documentdb.RestorableMongodbCollectionsClient)(nil) + +// RestorableMongodbResourcesClientAPI contains the set of methods on the RestorableMongodbResourcesClient type. +type RestorableMongodbResourcesClientAPI interface { + List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result documentdb.RestorableMongodbResourcesListResult, err error) +} + +var _ RestorableMongodbResourcesClientAPI = (*documentdb.RestorableMongodbResourcesClient)(nil) + +// CassandraClustersClientAPI contains the set of methods on the CassandraClustersClient type. +type CassandraClustersClientAPI interface { + CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, body documentdb.ClusterResource) (result documentdb.CassandraClustersCreateUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string) (result documentdb.CassandraClustersDeleteFuture, err error) + FetchNodeStatus(ctx context.Context, resourceGroupName string, clusterName string) (result documentdb.CassandraClustersFetchNodeStatusFuture, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string) (result documentdb.ClusterResource, err error) + GetBackup(ctx context.Context, resourceGroupName string, clusterName string, backupID string) (result documentdb.BackupResource, err error) + ListBackupsMethod(ctx context.Context, resourceGroupName string, clusterName string) (result documentdb.ListBackups, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result documentdb.ListClusters, err error) + ListBySubscription(ctx context.Context) (result documentdb.ListClusters, err error) + RequestRepair(ctx context.Context, resourceGroupName string, clusterName string, body documentdb.RepairPostBody) (result documentdb.CassandraClustersRequestRepairFuture, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, body documentdb.ClusterResource) (result documentdb.CassandraClustersUpdateFuture, err error) +} + +var _ CassandraClustersClientAPI = (*documentdb.CassandraClustersClient)(nil) + +// CassandraDataCentersClientAPI contains the set of methods on the CassandraDataCentersClient type. +type CassandraDataCentersClientAPI interface { + CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body documentdb.DataCenterResource) (result documentdb.CassandraDataCentersCreateUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result documentdb.CassandraDataCentersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result documentdb.DataCenterResource, err error) + List(ctx context.Context, resourceGroupName string, clusterName string) (result documentdb.ListDataCenters, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body documentdb.DataCenterResource) (result documentdb.CassandraDataCentersUpdateFuture, err error) +} + +var _ CassandraDataCentersClientAPI = (*documentdb.CassandraDataCentersClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result documentdb.PrivateLinkResource, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*documentdb.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters documentdb.PrivateEndpointConnection) (result documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result documentdb.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result documentdb.PrivateEndpointConnection, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.PrivateEndpointConnectionListResult, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*documentdb.PrivateEndpointConnectionsClient)(nil) diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/enums.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/enums.go new file mode 100644 index 000000000000..c7ad84f26740 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/enums.go @@ -0,0 +1,619 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// APIType enumerates the values for api type. +type APIType string + +const ( + // Cassandra ... + Cassandra APIType = "Cassandra" + // Gremlin ... + Gremlin APIType = "Gremlin" + // GremlinV2 ... + GremlinV2 APIType = "GremlinV2" + // MongoDB ... + MongoDB APIType = "MongoDB" + // SQL ... + SQL APIType = "Sql" + // Table ... + Table APIType = "Table" +) + +// PossibleAPITypeValues returns an array of possible values for the APIType const type. +func PossibleAPITypeValues() []APIType { + return []APIType{Cassandra, Gremlin, GremlinV2, MongoDB, SQL, Table} +} + +// AuthenticationMethod enumerates the values for authentication method. +type AuthenticationMethod string + +const ( + // AuthenticationMethodCassandra ... + AuthenticationMethodCassandra AuthenticationMethod = "Cassandra" + // AuthenticationMethodNone ... + AuthenticationMethodNone AuthenticationMethod = "None" +) + +// PossibleAuthenticationMethodValues returns an array of possible values for the AuthenticationMethod const type. +func PossibleAuthenticationMethodValues() []AuthenticationMethod { + return []AuthenticationMethod{AuthenticationMethodCassandra, AuthenticationMethodNone} +} + +// BackupPolicyType enumerates the values for backup policy type. +type BackupPolicyType string + +const ( + // Continuous ... + Continuous BackupPolicyType = "Continuous" + // Periodic ... + Periodic BackupPolicyType = "Periodic" +) + +// PossibleBackupPolicyTypeValues returns an array of possible values for the BackupPolicyType const type. +func PossibleBackupPolicyTypeValues() []BackupPolicyType { + return []BackupPolicyType{Continuous, Periodic} +} + +// BackupStorageRedundancy enumerates the values for backup storage redundancy. +type BackupStorageRedundancy string + +const ( + // Geo ... + Geo BackupStorageRedundancy = "Geo" + // Local ... + Local BackupStorageRedundancy = "Local" + // Zone ... + Zone BackupStorageRedundancy = "Zone" +) + +// PossibleBackupStorageRedundancyValues returns an array of possible values for the BackupStorageRedundancy const type. +func PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy { + return []BackupStorageRedundancy{Geo, Local, Zone} +} + +// CompositePathSortOrder enumerates the values for composite path sort order. +type CompositePathSortOrder string + +const ( + // Ascending ... + Ascending CompositePathSortOrder = "ascending" + // Descending ... + Descending CompositePathSortOrder = "descending" +) + +// PossibleCompositePathSortOrderValues returns an array of possible values for the CompositePathSortOrder const type. +func PossibleCompositePathSortOrderValues() []CompositePathSortOrder { + return []CompositePathSortOrder{Ascending, Descending} +} + +// ConflictResolutionMode enumerates the values for conflict resolution mode. +type ConflictResolutionMode string + +const ( + // Custom ... + Custom ConflictResolutionMode = "Custom" + // LastWriterWins ... + LastWriterWins ConflictResolutionMode = "LastWriterWins" +) + +// PossibleConflictResolutionModeValues returns an array of possible values for the ConflictResolutionMode const type. +func PossibleConflictResolutionModeValues() []ConflictResolutionMode { + return []ConflictResolutionMode{Custom, LastWriterWins} +} + +// ConnectorOffer enumerates the values for connector offer. +type ConnectorOffer string + +const ( + // Small ... + Small ConnectorOffer = "Small" +) + +// PossibleConnectorOfferValues returns an array of possible values for the ConnectorOffer const type. +func PossibleConnectorOfferValues() []ConnectorOffer { + return []ConnectorOffer{Small} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // Default ... + Default CreateMode = "Default" + // Restore ... + Restore CreateMode = "Restore" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{Default, Restore} +} + +// CreateModeBasicDatabaseAccountCreateUpdateProperties enumerates the values for create mode basic database +// account create update properties. +type CreateModeBasicDatabaseAccountCreateUpdateProperties string + +const ( + // CreateModeDatabaseAccountCreateUpdateProperties ... + CreateModeDatabaseAccountCreateUpdateProperties CreateModeBasicDatabaseAccountCreateUpdateProperties = "DatabaseAccountCreateUpdateProperties" + // CreateModeDefault ... + CreateModeDefault CreateModeBasicDatabaseAccountCreateUpdateProperties = "Default" + // CreateModeRestore ... + CreateModeRestore CreateModeBasicDatabaseAccountCreateUpdateProperties = "Restore" +) + +// PossibleCreateModeBasicDatabaseAccountCreateUpdatePropertiesValues returns an array of possible values for the CreateModeBasicDatabaseAccountCreateUpdateProperties const type. +func PossibleCreateModeBasicDatabaseAccountCreateUpdatePropertiesValues() []CreateModeBasicDatabaseAccountCreateUpdateProperties { + return []CreateModeBasicDatabaseAccountCreateUpdateProperties{CreateModeDatabaseAccountCreateUpdateProperties, CreateModeDefault, CreateModeRestore} +} + +// DatabaseAccountKind enumerates the values for database account kind. +type DatabaseAccountKind string + +const ( + // DatabaseAccountKindGlobalDocumentDB ... + DatabaseAccountKindGlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" + // DatabaseAccountKindMongoDB ... + DatabaseAccountKindMongoDB DatabaseAccountKind = "MongoDB" + // DatabaseAccountKindParse ... + DatabaseAccountKindParse DatabaseAccountKind = "Parse" +) + +// PossibleDatabaseAccountKindValues returns an array of possible values for the DatabaseAccountKind const type. +func PossibleDatabaseAccountKindValues() []DatabaseAccountKind { + return []DatabaseAccountKind{DatabaseAccountKindGlobalDocumentDB, DatabaseAccountKindMongoDB, DatabaseAccountKindParse} +} + +// DatabaseAccountOfferType enumerates the values for database account offer type. +type DatabaseAccountOfferType string + +const ( + // Standard ... + Standard DatabaseAccountOfferType = "Standard" +) + +// PossibleDatabaseAccountOfferTypeValues returns an array of possible values for the DatabaseAccountOfferType const type. +func PossibleDatabaseAccountOfferTypeValues() []DatabaseAccountOfferType { + return []DatabaseAccountOfferType{Standard} +} + +// DataType enumerates the values for data type. +type DataType string + +const ( + // LineString ... + LineString DataType = "LineString" + // MultiPolygon ... + MultiPolygon DataType = "MultiPolygon" + // Number ... + Number DataType = "Number" + // Point ... + Point DataType = "Point" + // Polygon ... + Polygon DataType = "Polygon" + // String ... + String DataType = "String" +) + +// PossibleDataTypeValues returns an array of possible values for the DataType const type. +func PossibleDataTypeValues() []DataType { + return []DataType{LineString, MultiPolygon, Number, Point, Polygon, String} +} + +// DefaultConsistencyLevel enumerates the values for default consistency level. +type DefaultConsistencyLevel string + +const ( + // BoundedStaleness ... + BoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" + // ConsistentPrefix ... + ConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" + // Eventual ... + Eventual DefaultConsistencyLevel = "Eventual" + // Session ... + Session DefaultConsistencyLevel = "Session" + // Strong ... + Strong DefaultConsistencyLevel = "Strong" +) + +// PossibleDefaultConsistencyLevelValues returns an array of possible values for the DefaultConsistencyLevel const type. +func PossibleDefaultConsistencyLevelValues() []DefaultConsistencyLevel { + return []DefaultConsistencyLevel{BoundedStaleness, ConsistentPrefix, Eventual, Session, Strong} +} + +// IndexingMode enumerates the values for indexing mode. +type IndexingMode string + +const ( + // Consistent ... + Consistent IndexingMode = "consistent" + // Lazy ... + Lazy IndexingMode = "lazy" + // None ... + None IndexingMode = "none" +) + +// PossibleIndexingModeValues returns an array of possible values for the IndexingMode const type. +func PossibleIndexingModeValues() []IndexingMode { + return []IndexingMode{Consistent, Lazy, None} +} + +// IndexKind enumerates the values for index kind. +type IndexKind string + +const ( + // Hash ... + Hash IndexKind = "Hash" + // Range ... + Range IndexKind = "Range" + // Spatial ... + Spatial IndexKind = "Spatial" +) + +// PossibleIndexKindValues returns an array of possible values for the IndexKind const type. +func PossibleIndexKindValues() []IndexKind { + return []IndexKind{Hash, Range, Spatial} +} + +// KeyKind enumerates the values for key kind. +type KeyKind string + +const ( + // Primary ... + Primary KeyKind = "primary" + // PrimaryReadonly ... + PrimaryReadonly KeyKind = "primaryReadonly" + // Secondary ... + Secondary KeyKind = "secondary" + // SecondaryReadonly ... + SecondaryReadonly KeyKind = "secondaryReadonly" +) + +// PossibleKeyKindValues returns an array of possible values for the KeyKind const type. +func PossibleKeyKindValues() []KeyKind { + return []KeyKind{Primary, PrimaryReadonly, Secondary, SecondaryReadonly} +} + +// ManagedCassandraProvisioningState enumerates the values for managed cassandra provisioning state. +type ManagedCassandraProvisioningState string + +const ( + // Canceled ... + Canceled ManagedCassandraProvisioningState = "Canceled" + // Creating ... + Creating ManagedCassandraProvisioningState = "Creating" + // Deleting ... + Deleting ManagedCassandraProvisioningState = "Deleting" + // Failed ... + Failed ManagedCassandraProvisioningState = "Failed" + // Succeeded ... + Succeeded ManagedCassandraProvisioningState = "Succeeded" + // Updating ... + Updating ManagedCassandraProvisioningState = "Updating" +) + +// PossibleManagedCassandraProvisioningStateValues returns an array of possible values for the ManagedCassandraProvisioningState const type. +func PossibleManagedCassandraProvisioningStateValues() []ManagedCassandraProvisioningState { + return []ManagedCassandraProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} +} + +// NetworkACLBypass enumerates the values for network acl bypass. +type NetworkACLBypass string + +const ( + // NetworkACLBypassAzureServices ... + NetworkACLBypassAzureServices NetworkACLBypass = "AzureServices" + // NetworkACLBypassNone ... + NetworkACLBypassNone NetworkACLBypass = "None" +) + +// PossibleNetworkACLBypassValues returns an array of possible values for the NetworkACLBypass const type. +func PossibleNetworkACLBypassValues() []NetworkACLBypass { + return []NetworkACLBypass{NetworkACLBypassAzureServices, NetworkACLBypassNone} +} + +// NodeState enumerates the values for node state. +type NodeState string + +const ( + // Joining ... + Joining NodeState = "Joining" + // Leaving ... + Leaving NodeState = "Leaving" + // Moving ... + Moving NodeState = "Moving" + // Normal ... + Normal NodeState = "Normal" + // Stopped ... + Stopped NodeState = "Stopped" +) + +// PossibleNodeStateValues returns an array of possible values for the NodeState const type. +func PossibleNodeStateValues() []NodeState { + return []NodeState{Joining, Leaving, Moving, Normal, Stopped} +} + +// NodeStatus enumerates the values for node status. +type NodeStatus string + +const ( + // Down ... + Down NodeStatus = "Down" + // Up ... + Up NodeStatus = "Up" +) + +// PossibleNodeStatusValues returns an array of possible values for the NodeStatus const type. +func PossibleNodeStatusValues() []NodeStatus { + return []NodeStatus{Down, Up} +} + +// OperationType enumerates the values for operation type. +type OperationType string + +const ( + // Create ... + Create OperationType = "Create" + // Delete ... + Delete OperationType = "Delete" + // Replace ... + Replace OperationType = "Replace" + // SystemOperation ... + SystemOperation OperationType = "SystemOperation" +) + +// PossibleOperationTypeValues returns an array of possible values for the OperationType const type. +func PossibleOperationTypeValues() []OperationType { + return []OperationType{Create, Delete, Replace, SystemOperation} +} + +// PartitionKind enumerates the values for partition kind. +type PartitionKind string + +const ( + // PartitionKindHash ... + PartitionKindHash PartitionKind = "Hash" + // PartitionKindMultiHash ... + PartitionKindMultiHash PartitionKind = "MultiHash" + // PartitionKindRange ... + PartitionKindRange PartitionKind = "Range" +) + +// PossiblePartitionKindValues returns an array of possible values for the PartitionKind const type. +func PossiblePartitionKindValues() []PartitionKind { + return []PartitionKind{PartitionKindHash, PartitionKindMultiHash, PartitionKindRange} +} + +// PrimaryAggregationType enumerates the values for primary aggregation type. +type PrimaryAggregationType string + +const ( + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeLast ... + PrimaryAggregationTypeLast PrimaryAggregationType = "Last" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. +func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeLast, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // ResourceIdentityTypeNone ... + ResourceIdentityTypeNone ResourceIdentityType = "None" + // ResourceIdentityTypeSystemAssigned ... + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + // ResourceIdentityTypeSystemAssignedUserAssigned ... + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned,UserAssigned" + // ResourceIdentityTypeUserAssigned ... + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, ResourceIdentityTypeSystemAssignedUserAssigned, ResourceIdentityTypeUserAssigned} +} + +// RestoreMode enumerates the values for restore mode. +type RestoreMode string + +const ( + // PointInTime ... + PointInTime RestoreMode = "PointInTime" +) + +// PossibleRestoreModeValues returns an array of possible values for the RestoreMode const type. +func PossibleRestoreModeValues() []RestoreMode { + return []RestoreMode{PointInTime} +} + +// RoleDefinitionType enumerates the values for role definition type. +type RoleDefinitionType string + +const ( + // BuiltInRole ... + BuiltInRole RoleDefinitionType = "BuiltInRole" + // CustomRole ... + CustomRole RoleDefinitionType = "CustomRole" +) + +// PossibleRoleDefinitionTypeValues returns an array of possible values for the RoleDefinitionType const type. +func PossibleRoleDefinitionTypeValues() []RoleDefinitionType { + return []RoleDefinitionType{BuiltInRole, CustomRole} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // FourFullStopZero ... + FourFullStopZero ServerVersion = "4.0" + // ThreeFullStopSix ... + ThreeFullStopSix ServerVersion = "3.6" + // ThreeFullStopTwo ... + ThreeFullStopTwo ServerVersion = "3.2" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{FourFullStopZero, ThreeFullStopSix, ThreeFullStopTwo} +} + +// SpatialType enumerates the values for spatial type. +type SpatialType string + +const ( + // SpatialTypeLineString ... + SpatialTypeLineString SpatialType = "LineString" + // SpatialTypeMultiPolygon ... + SpatialTypeMultiPolygon SpatialType = "MultiPolygon" + // SpatialTypePoint ... + SpatialTypePoint SpatialType = "Point" + // SpatialTypePolygon ... + SpatialTypePolygon SpatialType = "Polygon" +) + +// PossibleSpatialTypeValues returns an array of possible values for the SpatialType const type. +func PossibleSpatialTypeValues() []SpatialType { + return []SpatialType{SpatialTypeLineString, SpatialTypeMultiPolygon, SpatialTypePoint, SpatialTypePolygon} +} + +// TriggerOperation enumerates the values for trigger operation. +type TriggerOperation string + +const ( + // TriggerOperationAll ... + TriggerOperationAll TriggerOperation = "All" + // TriggerOperationCreate ... + TriggerOperationCreate TriggerOperation = "Create" + // TriggerOperationDelete ... + TriggerOperationDelete TriggerOperation = "Delete" + // TriggerOperationReplace ... + TriggerOperationReplace TriggerOperation = "Replace" + // TriggerOperationUpdate ... + TriggerOperationUpdate TriggerOperation = "Update" +) + +// PossibleTriggerOperationValues returns an array of possible values for the TriggerOperation const type. +func PossibleTriggerOperationValues() []TriggerOperation { + return []TriggerOperation{TriggerOperationAll, TriggerOperationCreate, TriggerOperationDelete, TriggerOperationReplace, TriggerOperationUpdate} +} + +// TriggerType enumerates the values for trigger type. +type TriggerType string + +const ( + // Post ... + Post TriggerType = "Post" + // Pre ... + Pre TriggerType = "Pre" +) + +// PossibleTriggerTypeValues returns an array of possible values for the TriggerType const type. +func PossibleTriggerTypeValues() []TriggerType { + return []TriggerType{Post, Pre} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeBackupPolicy ... + TypeBackupPolicy Type = "BackupPolicy" + // TypeContinuous ... + TypeContinuous Type = "Continuous" + // TypePeriodic ... + TypePeriodic Type = "Periodic" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeBackupPolicy, TypeContinuous, TypePeriodic} +} + +// UnitType enumerates the values for unit type. +type UnitType string + +const ( + // Bytes ... + Bytes UnitType = "Bytes" + // BytesPerSecond ... + BytesPerSecond UnitType = "BytesPerSecond" + // Count ... + Count UnitType = "Count" + // CountPerSecond ... + CountPerSecond UnitType = "CountPerSecond" + // Milliseconds ... + Milliseconds UnitType = "Milliseconds" + // Percent ... + Percent UnitType = "Percent" + // Seconds ... + Seconds UnitType = "Seconds" +) + +// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. +func PossibleUnitTypeValues() []UnitType { + return []UnitType{Bytes, BytesPerSecond, Count, CountPerSecond, Milliseconds, Percent, Seconds} +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/gremlinresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/gremlinresources.go new file mode 100644 index 000000000000..54de1a6ef644 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/gremlinresources.go @@ -0,0 +1,1804 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GremlinResourcesClient is the client for the GremlinResources methods of the Documentdb service. +type GremlinResourcesClient struct { + BaseClient +} + +// NewGremlinResourcesClient creates an instance of the GremlinResourcesClient client. +func NewGremlinResourcesClient(subscriptionID string) GremlinResourcesClient { + return NewGremlinResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGremlinResourcesClientWithBaseURI creates an instance of the GremlinResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewGremlinResourcesClientWithBaseURI(baseURI string, subscriptionID string) GremlinResourcesClient { + return GremlinResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateGremlinDatabase create or update an Azure Cosmos DB Gremlin database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateGremlinDatabaseParameters - the parameters to provide for the current Gremlin database. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateGremlinDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", err.Error()) + } + + req, err := client.CreateUpdateGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateGremlinDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateGremlinDatabasePreparer prepares the CreateUpdateGremlinDatabase request. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateGremlinDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateGremlinDatabaseSender sends the CreateUpdateGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (gdgr GremlinDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + gdgr.Response.Response, err = future.GetResult(sender) + if gdgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", nil, "received nil response and error") + } + if err == nil && gdgr.Response.Response.StatusCode != http.StatusNoContent { + gdgr, err = client.CreateUpdateGremlinDatabaseResponder(gdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", gdgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateGremlinDatabaseResponder handles the response to the CreateUpdateGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateGremlinGraph create or update an Azure Cosmos DB Gremlin graph +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +// createUpdateGremlinGraphParameters - the parameters to provide for the current Gremlin graph. +func (client GremlinResourcesClient) CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinGraph") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateGremlinGraphParameters, + Constraints: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, + {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", err.Error()) + } + + req, err := client.CreateUpdateGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateGremlinGraphSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateGremlinGraphPreparer prepares the CreateUpdateGremlinGraph request. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithJSON(createUpdateGremlinGraphParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateGremlinGraphSender sends the CreateUpdateGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (gggr GremlinGraphGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + gggr.Response.Response, err = future.GetResult(sender) + if gggr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", nil, "received nil response and error") + } + if err == nil && gggr.Response.Response.StatusCode != http.StatusNoContent { + gggr, err = client.CreateUpdateGremlinGraphResponder(gggr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", gggr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateGremlinGraphResponder handles the response to the CreateUpdateGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteGremlinDatabase deletes an existing Azure Cosmos DB Gremlin database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesDeleteGremlinDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", err.Error()) + } + + req, err := client.DeleteGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteGremlinDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteGremlinDatabasePreparer prepares the DeleteGremlinDatabase request. +func (client GremlinResourcesClient) DeleteGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteGremlinDatabaseSender sends the DeleteGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) DeleteGremlinDatabaseSender(req *http.Request) (future GremlinResourcesDeleteGremlinDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinDatabaseFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteGremlinDatabaseResponder handles the response to the DeleteGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) DeleteGremlinDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteGremlinGraph deletes an existing Azure Cosmos DB Gremlin graph. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesDeleteGremlinGraphFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinGraph") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinGraph", err.Error()) + } + + req, err := client.DeleteGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure preparing request") + return + } + + result, err = client.DeleteGremlinGraphSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure sending request") + return + } + + return +} + +// DeleteGremlinGraphPreparer prepares the DeleteGremlinGraph request. +func (client GremlinResourcesClient) DeleteGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteGremlinGraphSender sends the DeleteGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) DeleteGremlinGraphSender(req *http.Request) (future GremlinResourcesDeleteGremlinGraphFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinGraphFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinGraphFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteGremlinGraphResponder handles the response to the DeleteGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) DeleteGremlinGraphResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetGremlinDatabase gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided +// name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabase", err.Error()) + } + + req, err := client.GetGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinDatabasePreparer prepares the GetGremlinDatabase request. +func (client GremlinResourcesClient) GetGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinDatabaseSender sends the GetGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinDatabaseResponder handles the response to the GetGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinDatabaseThroughput gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", err.Error()) + } + + req, err := client.GetGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinDatabaseThroughputPreparer prepares the GetGremlinDatabaseThroughput request. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinDatabaseThroughputSender sends the GetGremlinDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinDatabaseThroughputResponder handles the response to the GetGremlinDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinGraph gets the Gremlin graph under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinGraphGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraph") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraph", err.Error()) + } + + req, err := client.GetGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinGraphSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinGraphResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinGraphPreparer prepares the GetGremlinGraph request. +func (client GremlinResourcesClient) GetGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinGraphSender sends the GetGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinGraphSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinGraphResponder handles the response to the GetGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinGraphThroughput gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with +// the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraphThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", err.Error()) + } + + req, err := client.GetGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinGraphThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinGraphThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinGraphThroughputPreparer prepares the GetGremlinGraphThroughput request. +func (client GremlinResourcesClient) GetGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinGraphThroughputSender sends the GetGremlinGraphThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinGraphThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinGraphThroughputResponder handles the response to the GetGremlinGraphThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListGremlinDatabases lists the Gremlin databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client GremlinResourcesClient) ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result GremlinDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinDatabases", err.Error()) + } + + req, err := client.ListGremlinDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListGremlinDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListGremlinDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListGremlinDatabasesPreparer prepares the ListGremlinDatabases request. +func (client GremlinResourcesClient) ListGremlinDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListGremlinDatabasesSender sends the ListGremlinDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) ListGremlinDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListGremlinDatabasesResponder handles the response to the ListGremlinDatabases request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) ListGremlinDatabasesResponder(resp *http.Response) (result GremlinDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListGremlinGraphs lists the Gremlin graph under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinGraphListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinGraphs") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinGraphs", err.Error()) + } + + req, err := client.ListGremlinGraphsPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", nil, "Failure preparing request") + return + } + + resp, err := client.ListGremlinGraphsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure sending request") + return + } + + result, err = client.ListGremlinGraphsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure responding to request") + return + } + + return +} + +// ListGremlinGraphsPreparer prepares the ListGremlinGraphs request. +func (client GremlinResourcesClient) ListGremlinGraphsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListGremlinGraphsSender sends the ListGremlinGraphs request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) ListGremlinGraphsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListGremlinGraphsResponder handles the response to the ListGremlinGraphs request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) ListGremlinGraphsResponder(resp *http.Response) (result GremlinGraphListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinDatabaseToAutoscale migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateGremlinDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinDatabaseToAutoscalePreparer prepares the MigrateGremlinDatabaseToAutoscale request. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinDatabaseToAutoscaleSender sends the MigrateGremlinDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateGremlinDatabaseToAutoscaleResponder handles the response to the MigrateGremlinDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinDatabaseToManualThroughput migrate an Azure Cosmos DB Gremlin database from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateGremlinDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinDatabaseToManualThroughputPreparer prepares the MigrateGremlinDatabaseToManualThroughput request. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinDatabaseToManualThroughputSender sends the MigrateGremlinDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateGremlinDatabaseToManualThroughputResponder handles the response to the MigrateGremlinDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinGraphToAutoscale migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", err.Error()) + } + + req, err := client.MigrateGremlinGraphToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinGraphToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinGraphToAutoscalePreparer prepares the MigrateGremlinGraphToAutoscale request. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinGraphToAutoscaleSender sends the MigrateGremlinGraphToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinGraphToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateGremlinGraphToAutoscaleResponder handles the response to the MigrateGremlinGraphToAutoscale request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinGraphToManualThroughput migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", err.Error()) + } + + req, err := client.MigrateGremlinGraphToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinGraphToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinGraphToManualThroughputPreparer prepares the MigrateGremlinGraphToManualThroughput request. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinGraphToManualThroughputSender sends the MigrateGremlinGraphToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinGraphToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateGremlinGraphToManualThroughputResponder handles the response to the MigrateGremlinGraphToManualThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateGremlinDatabaseThroughput update RUs per second of an Azure Cosmos DB Gremlin database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin +// database. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateGremlinDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateGremlinDatabaseThroughputPreparer prepares the UpdateGremlinDatabaseThroughput request. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateGremlinDatabaseThroughputSender sends the UpdateGremlinDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateGremlinDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateGremlinDatabaseThroughputResponder handles the response to the UpdateGremlinDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateGremlinGraphThroughput update RUs per second of an Azure Cosmos DB Gremlin graph +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin graph. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinGraphThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", err.Error()) + } + + req, err := client.UpdateGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateGremlinGraphThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateGremlinGraphThroughputPreparer prepares the UpdateGremlinGraphThroughput request. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateGremlinGraphThroughputSender sends the UpdateGremlinGraphThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateGremlinGraphThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateGremlinGraphThroughputResponder handles the response to the UpdateGremlinGraphThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/models.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/models.go new file mode 100644 index 000000000000..d969c760f157 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/models.go @@ -0,0 +1,9355 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb" + +// APIProperties ... +type APIProperties struct { + // ServerVersion - Describes the ServerVersion of an a MongoDB account. Possible values include: 'ThreeFullStopTwo', 'ThreeFullStopSix', 'FourFullStopZero' + ServerVersion ServerVersion `json:"serverVersion,omitempty"` +} + +// ARMProxyResource the resource model definition for a ARM proxy resource. It will have everything other +// than required location and tags +type ARMProxyResource struct { + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// ARMResourceProperties the core properties of ARM resources. +type ARMResourceProperties struct { + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ARMResourceProperties. +func (arp ARMResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arp.Location != nil { + objectMap["location"] = arp.Location + } + if arp.Tags != nil { + objectMap["tags"] = arp.Tags + } + if arp.Identity != nil { + objectMap["identity"] = arp.Identity + } + return json.Marshal(objectMap) +} + +// AutoscaleSettings ... +type AutoscaleSettings struct { + // MaxThroughput - Represents maximum throughput, the resource can scale up to. + MaxThroughput *int32 `json:"maxThroughput,omitempty"` +} + +// AutoscaleSettingsResource cosmos DB provisioned throughput settings object +type AutoscaleSettingsResource struct { + // MaxThroughput - Represents maximum throughput container can scale up to. + MaxThroughput *int32 `json:"maxThroughput,omitempty"` + // AutoUpgradePolicy - Cosmos DB resource auto-upgrade policy + AutoUpgradePolicy *AutoUpgradePolicyResource `json:"autoUpgradePolicy,omitempty"` + // TargetMaxThroughput - READ-ONLY; Represents target maximum throughput container can scale up to once offer is no longer in pending state. + TargetMaxThroughput *int32 `json:"targetMaxThroughput,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingsResource. +func (asr AutoscaleSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asr.MaxThroughput != nil { + objectMap["maxThroughput"] = asr.MaxThroughput + } + if asr.AutoUpgradePolicy != nil { + objectMap["autoUpgradePolicy"] = asr.AutoUpgradePolicy + } + return json.Marshal(objectMap) +} + +// AutoUpgradePolicyResource cosmos DB resource auto-upgrade policy +type AutoUpgradePolicyResource struct { + // ThroughputPolicy - Represents throughput policy which service must adhere to for auto-upgrade + ThroughputPolicy *ThroughputPolicyResource `json:"throughputPolicy,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// BasicBackupPolicy the object representing the policy for taking backups on an account. +type BasicBackupPolicy interface { + AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) + AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) + AsBackupPolicy() (*BackupPolicy, bool) +} + +// BackupPolicy the object representing the policy for taking backups on an account. +type BackupPolicy struct { + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +func unmarshalBasicBackupPolicy(body []byte) (BasicBackupPolicy, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["type"] { + case string(TypePeriodic): + var pmbp PeriodicModeBackupPolicy + err := json.Unmarshal(body, &pmbp) + return pmbp, err + case string(TypeContinuous): + var cmbp ContinuousModeBackupPolicy + err := json.Unmarshal(body, &cmbp) + return cmbp, err + default: + var bp BackupPolicy + err := json.Unmarshal(body, &bp) + return bp, err + } +} +func unmarshalBasicBackupPolicyArray(body []byte) ([]BasicBackupPolicy, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + bpArray := make([]BasicBackupPolicy, len(rawMessages)) + + for index, rawMessage := range rawMessages { + bp, err := unmarshalBasicBackupPolicy(*rawMessage) + if err != nil { + return nil, err + } + bpArray[index] = bp + } + return bpArray, nil +} + +// MarshalJSON is the custom marshaler for BackupPolicy. +func (bp BackupPolicy) MarshalJSON() ([]byte, error) { + bp.Type = TypeBackupPolicy + objectMap := make(map[string]interface{}) + if bp.Type != "" { + objectMap["type"] = bp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return nil, false +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return nil, false +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return &bp, true +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &bp, true +} + +// BackupResource a restorable backup of a Cassandra cluster. +type BackupResource struct { + autorest.Response `json:"-"` + Properties *BackupResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupResource. +func (br BackupResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if br.Properties != nil { + objectMap["properties"] = br.Properties + } + return json.Marshal(objectMap) +} + +// BackupResourceProperties ... +type BackupResourceProperties struct { + // Timestamp - The time this backup was taken, formatted like 2021-01-21T17:35:21 + Timestamp *date.Time `json:"timestamp,omitempty"` +} + +// Capability cosmos DB capability object +type Capability struct { + // Name - Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". + Name *string `json:"name,omitempty"` +} + +// CassandraClustersCreateUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraClustersCreateUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraClustersClient) (ClusterResource, error) +} + +// CassandraClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CassandraClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraClustersClient) (autorest.Response, error) +} + +// CassandraClustersFetchNodeStatusFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraClustersFetchNodeStatusFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraClustersClient) (ClusterNodeStatus, error) +} + +// CassandraClustersRequestRepairFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraClustersRequestRepairFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraClustersClient) (autorest.Response, error) +} + +// CassandraClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CassandraClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraClustersClient) (ClusterResource, error) +} + +// CassandraDataCentersCreateUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraDataCentersCreateUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraDataCentersClient) (DataCenterResource, error) +} + +// CassandraDataCentersDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraDataCentersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraDataCentersClient) (autorest.Response, error) +} + +// CassandraDataCentersUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CassandraDataCentersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraDataCentersClient) (DataCenterResource, error) +} + +// CassandraKeyspaceCreateUpdateParameters parameters to create and update Cosmos DB Cassandra keyspace. +type CassandraKeyspaceCreateUpdateParameters struct { + // CassandraKeyspaceCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra keyspace. + *CassandraKeyspaceCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceCreateUpdateParameters. +func (ckcup CassandraKeyspaceCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckcup.CassandraKeyspaceCreateUpdateProperties != nil { + objectMap["properties"] = ckcup.CassandraKeyspaceCreateUpdateProperties + } + if ckcup.Location != nil { + objectMap["location"] = ckcup.Location + } + if ckcup.Tags != nil { + objectMap["tags"] = ckcup.Tags + } + if ckcup.Identity != nil { + objectMap["identity"] = ckcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceCreateUpdateParameters struct. +func (ckcup *CassandraKeyspaceCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cassandraKeyspaceCreateUpdateProperties CassandraKeyspaceCreateUpdateProperties + err = json.Unmarshal(*v, &cassandraKeyspaceCreateUpdateProperties) + if err != nil { + return err + } + ckcup.CassandraKeyspaceCreateUpdateProperties = &cassandraKeyspaceCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ckcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ckcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ckcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ckcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ckcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ckcup.Identity = &identity + } + } + } + + return nil +} + +// CassandraKeyspaceCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra +// keyspace. +type CassandraKeyspaceCreateUpdateProperties struct { + // Resource - The standard JSON format of a Cassandra keyspace + Resource *CassandraKeyspaceResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// CassandraKeyspaceGetProperties the properties of an Azure Cosmos DB Cassandra keyspace +type CassandraKeyspaceGetProperties struct { + Resource *CassandraKeyspaceGetPropertiesResource `json:"resource,omitempty"` + Options *CassandraKeyspaceGetPropertiesOptions `json:"options,omitempty"` +} + +// CassandraKeyspaceGetPropertiesOptions ... +type CassandraKeyspaceGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// CassandraKeyspaceGetPropertiesResource ... +type CassandraKeyspaceGetPropertiesResource struct { + // ID - Name of the Cosmos DB Cassandra keyspace + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceGetPropertiesResource. +func (ckgp CassandraKeyspaceGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckgp.ID != nil { + objectMap["id"] = ckgp.ID + } + return json.Marshal(objectMap) +} + +// CassandraKeyspaceGetResults an Azure Cosmos DB Cassandra keyspace. +type CassandraKeyspaceGetResults struct { + autorest.Response `json:"-"` + // CassandraKeyspaceGetProperties - The properties of an Azure Cosmos DB Cassandra keyspace + *CassandraKeyspaceGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceGetResults. +func (ckgr CassandraKeyspaceGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckgr.CassandraKeyspaceGetProperties != nil { + objectMap["properties"] = ckgr.CassandraKeyspaceGetProperties + } + if ckgr.Location != nil { + objectMap["location"] = ckgr.Location + } + if ckgr.Tags != nil { + objectMap["tags"] = ckgr.Tags + } + if ckgr.Identity != nil { + objectMap["identity"] = ckgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceGetResults struct. +func (ckgr *CassandraKeyspaceGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cassandraKeyspaceGetProperties CassandraKeyspaceGetProperties + err = json.Unmarshal(*v, &cassandraKeyspaceGetProperties) + if err != nil { + return err + } + ckgr.CassandraKeyspaceGetProperties = &cassandraKeyspaceGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ckgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ckgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ckgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ckgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ckgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ckgr.Identity = &identity + } + } + } + + return nil +} + +// CassandraKeyspaceListResult the List operation response, that contains the Cassandra keyspaces and their +// properties. +type CassandraKeyspaceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Cassandra keyspaces and their properties. + Value *[]CassandraKeyspaceGetResults `json:"value,omitempty"` +} + +// CassandraKeyspaceResource cosmos DB Cassandra keyspace resource object +type CassandraKeyspaceResource struct { + // ID - Name of the Cosmos DB Cassandra keyspace + ID *string `json:"id,omitempty"` +} + +// CassandraPartitionKey cosmos DB Cassandra table partition key +type CassandraPartitionKey struct { + // Name - Name of the Cosmos DB Cassandra table partition key + Name *string `json:"name,omitempty"` +} + +// CassandraResourcesCreateUpdateCassandraKeyspaceFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesCreateUpdateCassandraKeyspaceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (CassandraKeyspaceGetResults, error) +} + +// CassandraResourcesCreateUpdateCassandraTableFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesCreateUpdateCassandraTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (CassandraTableGetResults, error) +} + +// CassandraResourcesDeleteCassandraKeyspaceFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type CassandraResourcesDeleteCassandraKeyspaceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (autorest.Response, error) +} + +// CassandraResourcesDeleteCassandraTableFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type CassandraResourcesDeleteCassandraTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (autorest.Response, error) +} + +// CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraResourcesMigrateCassandraTableToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesMigrateCassandraTableToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraResourcesMigrateCassandraTableToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type CassandraResourcesMigrateCassandraTableToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraResourcesUpdateCassandraKeyspaceThroughputFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesUpdateCassandraKeyspaceThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraResourcesUpdateCassandraTableThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesUpdateCassandraTableThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// CassandraSchema cosmos DB Cassandra table schema +type CassandraSchema struct { + // Columns - List of Cassandra table columns. + Columns *[]Column `json:"columns,omitempty"` + // PartitionKeys - List of partition key. + PartitionKeys *[]CassandraPartitionKey `json:"partitionKeys,omitempty"` + // ClusterKeys - List of cluster key. + ClusterKeys *[]ClusterKey `json:"clusterKeys,omitempty"` +} + +// CassandraTableCreateUpdateParameters parameters to create and update Cosmos DB Cassandra table. +type CassandraTableCreateUpdateParameters struct { + // CassandraTableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra table. + *CassandraTableCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraTableCreateUpdateParameters. +func (ctcup CassandraTableCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcup.CassandraTableCreateUpdateProperties != nil { + objectMap["properties"] = ctcup.CassandraTableCreateUpdateProperties + } + if ctcup.Location != nil { + objectMap["location"] = ctcup.Location + } + if ctcup.Tags != nil { + objectMap["tags"] = ctcup.Tags + } + if ctcup.Identity != nil { + objectMap["identity"] = ctcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraTableCreateUpdateParameters struct. +func (ctcup *CassandraTableCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cassandraTableCreateUpdateProperties CassandraTableCreateUpdateProperties + err = json.Unmarshal(*v, &cassandraTableCreateUpdateProperties) + if err != nil { + return err + } + ctcup.CassandraTableCreateUpdateProperties = &cassandraTableCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ctcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ctcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ctcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ctcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ctcup.Identity = &identity + } + } + } + + return nil +} + +// CassandraTableCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra table. +type CassandraTableCreateUpdateProperties struct { + // Resource - The standard JSON format of a Cassandra table + Resource *CassandraTableResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// CassandraTableGetProperties the properties of an Azure Cosmos DB Cassandra table +type CassandraTableGetProperties struct { + Resource *CassandraTableGetPropertiesResource `json:"resource,omitempty"` + Options *CassandraTableGetPropertiesOptions `json:"options,omitempty"` +} + +// CassandraTableGetPropertiesOptions ... +type CassandraTableGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// CassandraTableGetPropertiesResource ... +type CassandraTableGetPropertiesResource struct { + // ID - Name of the Cosmos DB Cassandra table + ID *string `json:"id,omitempty"` + // DefaultTTL - Time to live of the Cosmos DB Cassandra table + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // Schema - Schema of the Cosmos DB Cassandra table + Schema *CassandraSchema `json:"schema,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraTableGetPropertiesResource. +func (ctgp CassandraTableGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctgp.ID != nil { + objectMap["id"] = ctgp.ID + } + if ctgp.DefaultTTL != nil { + objectMap["defaultTtl"] = ctgp.DefaultTTL + } + if ctgp.Schema != nil { + objectMap["schema"] = ctgp.Schema + } + if ctgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = ctgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// CassandraTableGetResults an Azure Cosmos DB Cassandra table. +type CassandraTableGetResults struct { + autorest.Response `json:"-"` + // CassandraTableGetProperties - The properties of an Azure Cosmos DB Cassandra table + *CassandraTableGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraTableGetResults. +func (ctgr CassandraTableGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctgr.CassandraTableGetProperties != nil { + objectMap["properties"] = ctgr.CassandraTableGetProperties + } + if ctgr.Location != nil { + objectMap["location"] = ctgr.Location + } + if ctgr.Tags != nil { + objectMap["tags"] = ctgr.Tags + } + if ctgr.Identity != nil { + objectMap["identity"] = ctgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraTableGetResults struct. +func (ctgr *CassandraTableGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cassandraTableGetProperties CassandraTableGetProperties + err = json.Unmarshal(*v, &cassandraTableGetProperties) + if err != nil { + return err + } + ctgr.CassandraTableGetProperties = &cassandraTableGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ctgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ctgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ctgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ctgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ctgr.Identity = &identity + } + } + } + + return nil +} + +// CassandraTableListResult the List operation response, that contains the Cassandra tables and their +// properties. +type CassandraTableListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Cassandra tables and their properties. + Value *[]CassandraTableGetResults `json:"value,omitempty"` +} + +// CassandraTableResource cosmos DB Cassandra table resource object +type CassandraTableResource struct { + // ID - Name of the Cosmos DB Cassandra table + ID *string `json:"id,omitempty"` + // DefaultTTL - Time to live of the Cosmos DB Cassandra table + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // Schema - Schema of the Cosmos DB Cassandra table + Schema *CassandraSchema `json:"schema,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` +} + +// Certificate ... +type Certificate struct { + // Pem - PEM formatted public key. + Pem *string `json:"pem,omitempty"` +} + +// CloudError an error response from the service. +type CloudError struct { + Error *ErrorResponse `json:"error,omitempty"` +} + +// ClusterKey cosmos DB Cassandra table cluster key +type ClusterKey struct { + // Name - Name of the Cosmos DB Cassandra table cluster key + Name *string `json:"name,omitempty"` + // OrderBy - Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc" + OrderBy *string `json:"orderBy,omitempty"` +} + +// ClusterNodeStatus the status of all nodes in the cluster (as returned by 'nodetool status'). +type ClusterNodeStatus struct { + autorest.Response `json:"-"` + // Nodes - Information about nodes in the cluster (corresponds to what is returned from nodetool info). + Nodes *[]ClusterNodeStatusNodesItem `json:"nodes,omitempty"` +} + +// ClusterNodeStatusNodesItem ... +type ClusterNodeStatusNodesItem struct { + // Datacenter - The Cassandra data center this node resides in. + Datacenter *string `json:"datacenter,omitempty"` + // Status - Indicates whether the node is functioning or not. Possible values include: 'Up', 'Down' + Status NodeStatus `json:"status,omitempty"` + // State - The state of the node in relation to the cluster. Possible values include: 'Normal', 'Leaving', 'Joining', 'Moving', 'Stopped' + State NodeState `json:"state,omitempty"` + // Address - The node's URL. + Address *string `json:"address,omitempty"` + // Load - The amount of file system data in the data directory (e.g., 47.66 KB), excluding all content in the snapshots subdirectories. Because all SSTable data files are included, any data that is not cleaned up (such as TTL-expired cell or tombstoned data) is counted. + Load *string `json:"load,omitempty"` + // Tokens - List of tokens. + Tokens *[]string `json:"tokens,omitempty"` + // Owns - The percentage of the data owned by the node per datacenter times the replication factor (e.g., 33.3, or null if the data is not available). For example, a node can own 33% of the ring, but shows 100% if the replication factor is 3. For non-system keyspaces, the endpoint percentage ownership information is shown. + Owns *float64 `json:"owns,omitempty"` + // HostID - The network ID of the node. + HostID *string `json:"hostId,omitempty"` + // Rack - The rack this node is part of. + Rack *string `json:"rack,omitempty"` +} + +// ClusterResource representation of a managed Cassandra cluster. +type ClusterResource struct { + autorest.Response `json:"-"` + // Properties - Properties of a managed Cassandra cluster. + Properties *ClusterResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterResource. +func (cr ClusterResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Properties != nil { + objectMap["properties"] = cr.Properties + } + if cr.Location != nil { + objectMap["location"] = cr.Location + } + if cr.Tags != nil { + objectMap["tags"] = cr.Tags + } + if cr.Identity != nil { + objectMap["identity"] = cr.Identity + } + return json.Marshal(objectMap) +} + +// ClusterResourceProperties properties of a managed Cassandra cluster. +type ClusterResourceProperties struct { + // ProvisioningState - Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' + ProvisioningState ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` + // RestoreFromBackupID - To create an empty cluster, omit this field or set it to null. To restore a backup into a new cluster, set this field to the resource id of the backup. + RestoreFromBackupID *string `json:"restoreFromBackupId,omitempty"` + // DelegatedManagementSubnetID - Resource id of a subnet that this cluster's management service should have its network interface attached to. The subnet must be routable to all subnets that will be delegated to data centers. The resource id must be of the form '/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/' + DelegatedManagementSubnetID *string `json:"delegatedManagementSubnetId,omitempty"` + // CassandraVersion - Which version of Cassandra should this cluster converge to running (e.g., 3.11). When updated, the cluster may take some time to migrate to the new version. + CassandraVersion *string `json:"cassandraVersion,omitempty"` + // ClusterNameOverride - If you need to set the clusterName property in cassandra.yaml to something besides the resource name of the cluster, set the value to use on this property. + ClusterNameOverride *string `json:"clusterNameOverride,omitempty"` + // AuthenticationMethod - Which authentication method Cassandra should use to authenticate clients. 'None' turns off authentication, so should not be used except in emergencies. 'Cassandra' is the default password based authentication. The default is 'Cassandra'. Possible values include: 'AuthenticationMethodNone', 'AuthenticationMethodCassandra' + AuthenticationMethod AuthenticationMethod `json:"authenticationMethod,omitempty"` + // InitialCassandraAdminPassword - Initial password for clients connecting as admin to the cluster. Should be changed after cluster creation. Returns null on GET. This field only applies when the authenticationMethod field is 'Cassandra'. + InitialCassandraAdminPassword *string `json:"initialCassandraAdminPassword,omitempty"` + // HoursBetweenBackups - Number of hours to wait between taking a backup of the cluster. To disable backups, set this property to 0. + HoursBetweenBackups *int32 `json:"hoursBetweenBackups,omitempty"` + // PrometheusEndpoint - Hostname or IP address where the Prometheus endpoint containing data about the managed Cassandra nodes can be reached. + PrometheusEndpoint *string `json:"prometheusEndpoint,omitempty"` + // RepairEnabled - Should automatic repairs run on this cluster? If omitted, this is true, and should stay true unless you are running a hybrid cluster where you are already doing your own repairs. + RepairEnabled *bool `json:"repairEnabled,omitempty"` + // ClientCertificates - List of TLS certificates used to authorize clients connecting to the cluster. All connections are TLS encrypted whether clientCertificates is set or not, but if clientCertificates is set, the managed Cassandra cluster will reject all connections not bearing a TLS client certificate that can be validated from one or more of the public certificates in this property. + ClientCertificates *[]Certificate `json:"clientCertificates,omitempty"` + // ExternalGossipCertificates - List of TLS certificates used to authorize gossip from unmanaged data centers. The TLS certificates of all nodes in unmanaged data centers must be verifiable using one of the certificates provided in this property. + ExternalGossipCertificates *[]Certificate `json:"externalGossipCertificates,omitempty"` + // GossipCertificates - READ-ONLY; List of TLS certificates that unmanaged nodes must trust for gossip with managed nodes. All managed nodes will present TLS client certificates that are verifiable using one of the certificates provided in this property. + GossipCertificates *[]Certificate `json:"gossipCertificates,omitempty"` + // ExternalSeedNodes - List of IP addresses of seed nodes in unmanaged data centers. These will be added to the seed node lists of all managed nodes. + ExternalSeedNodes *[]SeedNode `json:"externalSeedNodes,omitempty"` + // SeedNodes - READ-ONLY; List of IP addresses of seed nodes in the managed data centers. These should be added to the seed node lists of all unmanaged nodes. + SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterResourceProperties. +func (cr ClusterResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.ProvisioningState != "" { + objectMap["provisioningState"] = cr.ProvisioningState + } + if cr.RestoreFromBackupID != nil { + objectMap["restoreFromBackupId"] = cr.RestoreFromBackupID + } + if cr.DelegatedManagementSubnetID != nil { + objectMap["delegatedManagementSubnetId"] = cr.DelegatedManagementSubnetID + } + if cr.CassandraVersion != nil { + objectMap["cassandraVersion"] = cr.CassandraVersion + } + if cr.ClusterNameOverride != nil { + objectMap["clusterNameOverride"] = cr.ClusterNameOverride + } + if cr.AuthenticationMethod != "" { + objectMap["authenticationMethod"] = cr.AuthenticationMethod + } + if cr.InitialCassandraAdminPassword != nil { + objectMap["initialCassandraAdminPassword"] = cr.InitialCassandraAdminPassword + } + if cr.HoursBetweenBackups != nil { + objectMap["hoursBetweenBackups"] = cr.HoursBetweenBackups + } + if cr.PrometheusEndpoint != nil { + objectMap["prometheusEndpoint"] = cr.PrometheusEndpoint + } + if cr.RepairEnabled != nil { + objectMap["repairEnabled"] = cr.RepairEnabled + } + if cr.ClientCertificates != nil { + objectMap["clientCertificates"] = cr.ClientCertificates + } + if cr.ExternalGossipCertificates != nil { + objectMap["externalGossipCertificates"] = cr.ExternalGossipCertificates + } + if cr.ExternalSeedNodes != nil { + objectMap["externalSeedNodes"] = cr.ExternalSeedNodes + } + return json.Marshal(objectMap) +} + +// Column cosmos DB Cassandra table column +type Column struct { + // Name - Name of the Cosmos DB Cassandra table column + Name *string `json:"name,omitempty"` + // Type - Type of the Cosmos DB Cassandra table column + Type *string `json:"type,omitempty"` +} + +// CompositePath ... +type CompositePath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Order - Sort order for composite paths. Possible values include: 'Ascending', 'Descending' + Order CompositePathSortOrder `json:"order,omitempty"` +} + +// ConflictResolutionPolicy the conflict resolution policy for the container. +type ConflictResolutionPolicy struct { + // Mode - Indicates the conflict resolution mode. Possible values include: 'LastWriterWins', 'Custom' + Mode ConflictResolutionMode `json:"mode,omitempty"` + // ConflictResolutionPath - The conflict resolution path in the case of LastWriterWins mode. + ConflictResolutionPath *string `json:"conflictResolutionPath,omitempty"` + // ConflictResolutionProcedure - The procedure to resolve conflicts in the case of custom mode. + ConflictResolutionProcedure *string `json:"conflictResolutionProcedure,omitempty"` +} + +// ConsistencyPolicy the consistency policy for the Cosmos DB database account. +type ConsistencyPolicy struct { + // DefaultConsistencyLevel - The default consistency level and configuration settings of the Cosmos DB account. Possible values include: 'Eventual', 'Session', 'BoundedStaleness', 'Strong', 'ConsistentPrefix' + DefaultConsistencyLevel DefaultConsistencyLevel `json:"defaultConsistencyLevel,omitempty"` + // MaxStalenessPrefix - When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + MaxStalenessPrefix *int64 `json:"maxStalenessPrefix,omitempty"` + // MaxIntervalInSeconds - When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + MaxIntervalInSeconds *int32 `json:"maxIntervalInSeconds,omitempty"` +} + +// ContainerPartitionKey the configuration of the partition key to be used for partitioning data into +// multiple partitions +type ContainerPartitionKey struct { + // Paths - List of paths using which data within the container can be partitioned + Paths *[]string `json:"paths,omitempty"` + // Kind - Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (upto three maximum) are supported for container create. Possible values include: 'PartitionKindHash', 'PartitionKindRange', 'PartitionKindMultiHash' + Kind PartitionKind `json:"kind,omitempty"` + // Version - Indicates the version of the partition key definition + Version *int32 `json:"version,omitempty"` + // SystemKey - READ-ONLY; Indicates if the container is using a system generated partition key + SystemKey *bool `json:"systemKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContainerPartitionKey. +func (cpk ContainerPartitionKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpk.Paths != nil { + objectMap["paths"] = cpk.Paths + } + if cpk.Kind != "" { + objectMap["kind"] = cpk.Kind + } + if cpk.Version != nil { + objectMap["version"] = cpk.Version + } + return json.Marshal(objectMap) +} + +// ContinuousModeBackupPolicy the object representing continuous mode backup policy. +type ContinuousModeBackupPolicy struct { + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) MarshalJSON() ([]byte, error) { + cmbp.Type = TypeContinuous + objectMap := make(map[string]interface{}) + if cmbp.Type != "" { + objectMap["type"] = cmbp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return nil, false +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return &cmbp, true +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return nil, false +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &cmbp, true +} + +// CorsPolicy the CORS policy for the Cosmos DB database account. +type CorsPolicy struct { + // AllowedOrigins - The origin domains that are permitted to make a request against the service via CORS. + AllowedOrigins *string `json:"allowedOrigins,omitempty"` + // AllowedMethods - The methods (HTTP request verbs) that the origin domain may use for a CORS request. + AllowedMethods *string `json:"allowedMethods,omitempty"` + // AllowedHeaders - The request headers that the origin domain may specify on the CORS request. + AllowedHeaders *string `json:"allowedHeaders,omitempty"` + // ExposedHeaders - The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. + ExposedHeaders *string `json:"exposedHeaders,omitempty"` + // MaxAgeInSeconds - The maximum amount time that a browser should cache the preflight OPTIONS request. + MaxAgeInSeconds *int64 `json:"maxAgeInSeconds,omitempty"` +} + +// CreateUpdateOptions createUpdateOptions are a list of key-value pairs that describe the resource. +// Supported keys are "If-Match", "If-None-Match", "Session-Token" and "Throughput" +type CreateUpdateOptions struct { + // Throughput - Request Units per second. For example, "throughput": 10000. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// DatabaseAccountConnectionString connection string for the Cosmos DB account +type DatabaseAccountConnectionString struct { + // ConnectionString - READ-ONLY; Value of the connection string + ConnectionString *string `json:"connectionString,omitempty"` + // Description - READ-ONLY; Description of the connection string + Description *string `json:"description,omitempty"` +} + +// DatabaseAccountCreateUpdateParameters parameters to create and update Cosmos DB database accounts. +type DatabaseAccountCreateUpdateParameters struct { + // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' + Kind DatabaseAccountKind `json:"kind,omitempty"` + Properties BasicDatabaseAccountCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountCreateUpdateParameters. +func (dacup DatabaseAccountCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dacup.Kind != "" { + objectMap["kind"] = dacup.Kind + } + objectMap["properties"] = dacup.Properties + if dacup.Location != nil { + objectMap["location"] = dacup.Location + } + if dacup.Tags != nil { + objectMap["tags"] = dacup.Tags + } + if dacup.Identity != nil { + objectMap["identity"] = dacup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateParameters struct. +func (dacup *DatabaseAccountCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind DatabaseAccountKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dacup.Kind = kind + } + case "properties": + if v != nil { + properties, err := unmarshalBasicDatabaseAccountCreateUpdateProperties(*v) + if err != nil { + return err + } + dacup.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dacup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dacup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dacup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dacup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dacup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + dacup.Identity = &identity + } + } + } + + return nil +} + +// BasicDatabaseAccountCreateUpdateProperties properties to create and update Azure Cosmos DB database accounts. +type BasicDatabaseAccountCreateUpdateProperties interface { + AsDefaultRequestDatabaseAccountCreateUpdateProperties() (*DefaultRequestDatabaseAccountCreateUpdateProperties, bool) + AsRestoreReqeustDatabaseAccountCreateUpdateProperties() (*RestoreReqeustDatabaseAccountCreateUpdateProperties, bool) + AsDatabaseAccountCreateUpdateProperties() (*DatabaseAccountCreateUpdateProperties, bool) +} + +// DatabaseAccountCreateUpdateProperties properties to create and update Azure Cosmos DB database accounts. +type DatabaseAccountCreateUpdateProperties struct { + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // DatabaseAccountOfferType - The offer type for the database + DatabaseAccountOfferType *string `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'Small' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // CreateMode - Possible values include: 'CreateModeDatabaseAccountCreateUpdateProperties', 'CreateModeDefault', 'CreateModeRestore' + CreateMode CreateModeBasicDatabaseAccountCreateUpdateProperties `json:"createMode,omitempty"` +} + +func unmarshalBasicDatabaseAccountCreateUpdateProperties(body []byte) (BasicDatabaseAccountCreateUpdateProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["createMode"] { + case string(CreateModeDefault): + var drdacup DefaultRequestDatabaseAccountCreateUpdateProperties + err := json.Unmarshal(body, &drdacup) + return drdacup, err + case string(CreateModeRestore): + var rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties + err := json.Unmarshal(body, &rrdacup) + return rrdacup, err + default: + var dacup DatabaseAccountCreateUpdateProperties + err := json.Unmarshal(body, &dacup) + return dacup, err + } +} +func unmarshalBasicDatabaseAccountCreateUpdatePropertiesArray(body []byte) ([]BasicDatabaseAccountCreateUpdateProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + dacupArray := make([]BasicDatabaseAccountCreateUpdateProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + dacup, err := unmarshalBasicDatabaseAccountCreateUpdateProperties(*rawMessage) + if err != nil { + return nil, err + } + dacupArray[index] = dacup + } + return dacupArray, nil +} + +// MarshalJSON is the custom marshaler for DatabaseAccountCreateUpdateProperties. +func (dacup DatabaseAccountCreateUpdateProperties) MarshalJSON() ([]byte, error) { + dacup.CreateMode = CreateModeDatabaseAccountCreateUpdateProperties + objectMap := make(map[string]interface{}) + if dacup.ConsistencyPolicy != nil { + objectMap["consistencyPolicy"] = dacup.ConsistencyPolicy + } + if dacup.Locations != nil { + objectMap["locations"] = dacup.Locations + } + if dacup.DatabaseAccountOfferType != nil { + objectMap["databaseAccountOfferType"] = dacup.DatabaseAccountOfferType + } + if dacup.IPRules != nil { + objectMap["ipRules"] = dacup.IPRules + } + if dacup.IsVirtualNetworkFilterEnabled != nil { + objectMap["isVirtualNetworkFilterEnabled"] = dacup.IsVirtualNetworkFilterEnabled + } + if dacup.EnableAutomaticFailover != nil { + objectMap["enableAutomaticFailover"] = dacup.EnableAutomaticFailover + } + if dacup.Capabilities != nil { + objectMap["capabilities"] = dacup.Capabilities + } + if dacup.VirtualNetworkRules != nil { + objectMap["virtualNetworkRules"] = dacup.VirtualNetworkRules + } + if dacup.EnableMultipleWriteLocations != nil { + objectMap["enableMultipleWriteLocations"] = dacup.EnableMultipleWriteLocations + } + if dacup.EnableCassandraConnector != nil { + objectMap["enableCassandraConnector"] = dacup.EnableCassandraConnector + } + if dacup.ConnectorOffer != "" { + objectMap["connectorOffer"] = dacup.ConnectorOffer + } + if dacup.DisableKeyBasedMetadataWriteAccess != nil { + objectMap["disableKeyBasedMetadataWriteAccess"] = dacup.DisableKeyBasedMetadataWriteAccess + } + if dacup.KeyVaultKeyURI != nil { + objectMap["keyVaultKeyUri"] = dacup.KeyVaultKeyURI + } + if dacup.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = dacup.PublicNetworkAccess + } + if dacup.EnableFreeTier != nil { + objectMap["enableFreeTier"] = dacup.EnableFreeTier + } + if dacup.APIProperties != nil { + objectMap["apiProperties"] = dacup.APIProperties + } + if dacup.EnableAnalyticalStorage != nil { + objectMap["enableAnalyticalStorage"] = dacup.EnableAnalyticalStorage + } + objectMap["backupPolicy"] = dacup.BackupPolicy + if dacup.Cors != nil { + objectMap["cors"] = dacup.Cors + } + if dacup.NetworkACLBypass != "" { + objectMap["networkAclBypass"] = dacup.NetworkACLBypass + } + if dacup.NetworkACLBypassResourceIds != nil { + objectMap["networkAclBypassResourceIds"] = dacup.NetworkACLBypassResourceIds + } + if dacup.CreateMode != "" { + objectMap["createMode"] = dacup.CreateMode + } + return json.Marshal(objectMap) +} + +// AsDefaultRequestDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DatabaseAccountCreateUpdateProperties. +func (dacup DatabaseAccountCreateUpdateProperties) AsDefaultRequestDatabaseAccountCreateUpdateProperties() (*DefaultRequestDatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsRestoreReqeustDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DatabaseAccountCreateUpdateProperties. +func (dacup DatabaseAccountCreateUpdateProperties) AsRestoreReqeustDatabaseAccountCreateUpdateProperties() (*RestoreReqeustDatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DatabaseAccountCreateUpdateProperties. +func (dacup DatabaseAccountCreateUpdateProperties) AsDatabaseAccountCreateUpdateProperties() (*DatabaseAccountCreateUpdateProperties, bool) { + return &dacup, true +} + +// AsBasicDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DatabaseAccountCreateUpdateProperties. +func (dacup DatabaseAccountCreateUpdateProperties) AsBasicDatabaseAccountCreateUpdateProperties() (BasicDatabaseAccountCreateUpdateProperties, bool) { + return &dacup, true +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateProperties struct. +func (dacup *DatabaseAccountCreateUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + dacup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + dacup.Locations = &locations + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType string + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + dacup.DatabaseAccountOfferType = &databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + dacup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + dacup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + dacup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + dacup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + dacup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + dacup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + dacup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + dacup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + dacup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + dacup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + dacup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + dacup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + dacup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + dacup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + dacup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + dacup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + dacup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + dacup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "createMode": + if v != nil { + var createMode CreateModeBasicDatabaseAccountCreateUpdateProperties + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + dacup.CreateMode = createMode + } + } + } + + return nil +} + +// DatabaseAccountGetProperties properties for the database account. +type DatabaseAccountGetProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + // DocumentEndpoint - READ-ONLY; The connection endpoint for the Cosmos DB database account. + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + // DatabaseAccountOfferType - READ-ONLY; The offer type for the Cosmos DB database account. Default value: Standard. Possible values include: 'Standard' + DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // ConsistencyPolicy - The consistency policy for the Cosmos DB database account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // WriteLocations - READ-ONLY; An array that contains the write location for the Cosmos DB account. + WriteLocations *[]Location `json:"writeLocations,omitempty"` + // ReadLocations - READ-ONLY; An array that contains of the read locations enabled for the Cosmos DB account. + ReadLocations *[]Location `json:"readLocations,omitempty"` + // Locations - READ-ONLY; An array that contains all of the locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // FailoverPolicies - READ-ONLY; An array that contains the regions ordered by their failover priorities. + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of Private Endpoint Connections configured for the Cosmos DB account. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'Small' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // InstanceID - READ-ONLY; A unique identifier assigned to the database account + InstanceID *string `json:"instanceId,omitempty"` + // CreateMode - Enum to indicate the mode of account creation. Possible values include: 'Default', 'Restore' + CreateMode CreateMode `json:"createMode,omitempty"` + // RestoreParameters - Parameters to indicate the information about the restore. + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountGetProperties. +func (dagp DatabaseAccountGetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dagp.ProvisioningState != nil { + objectMap["provisioningState"] = dagp.ProvisioningState + } + if dagp.IPRules != nil { + objectMap["ipRules"] = dagp.IPRules + } + if dagp.IsVirtualNetworkFilterEnabled != nil { + objectMap["isVirtualNetworkFilterEnabled"] = dagp.IsVirtualNetworkFilterEnabled + } + if dagp.EnableAutomaticFailover != nil { + objectMap["enableAutomaticFailover"] = dagp.EnableAutomaticFailover + } + if dagp.ConsistencyPolicy != nil { + objectMap["consistencyPolicy"] = dagp.ConsistencyPolicy + } + if dagp.Capabilities != nil { + objectMap["capabilities"] = dagp.Capabilities + } + if dagp.VirtualNetworkRules != nil { + objectMap["virtualNetworkRules"] = dagp.VirtualNetworkRules + } + if dagp.EnableMultipleWriteLocations != nil { + objectMap["enableMultipleWriteLocations"] = dagp.EnableMultipleWriteLocations + } + if dagp.EnableCassandraConnector != nil { + objectMap["enableCassandraConnector"] = dagp.EnableCassandraConnector + } + if dagp.ConnectorOffer != "" { + objectMap["connectorOffer"] = dagp.ConnectorOffer + } + if dagp.DisableKeyBasedMetadataWriteAccess != nil { + objectMap["disableKeyBasedMetadataWriteAccess"] = dagp.DisableKeyBasedMetadataWriteAccess + } + if dagp.KeyVaultKeyURI != nil { + objectMap["keyVaultKeyUri"] = dagp.KeyVaultKeyURI + } + if dagp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = dagp.PublicNetworkAccess + } + if dagp.EnableFreeTier != nil { + objectMap["enableFreeTier"] = dagp.EnableFreeTier + } + if dagp.APIProperties != nil { + objectMap["apiProperties"] = dagp.APIProperties + } + if dagp.EnableAnalyticalStorage != nil { + objectMap["enableAnalyticalStorage"] = dagp.EnableAnalyticalStorage + } + if dagp.CreateMode != "" { + objectMap["createMode"] = dagp.CreateMode + } + if dagp.RestoreParameters != nil { + objectMap["restoreParameters"] = dagp.RestoreParameters + } + objectMap["backupPolicy"] = dagp.BackupPolicy + if dagp.Cors != nil { + objectMap["cors"] = dagp.Cors + } + if dagp.NetworkACLBypass != "" { + objectMap["networkAclBypass"] = dagp.NetworkACLBypass + } + if dagp.NetworkACLBypassResourceIds != nil { + objectMap["networkAclBypassResourceIds"] = dagp.NetworkACLBypassResourceIds + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetProperties struct. +func (dagp *DatabaseAccountGetProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + dagp.ProvisioningState = &provisioningState + } + case "documentEndpoint": + if v != nil { + var documentEndpoint string + err = json.Unmarshal(*v, &documentEndpoint) + if err != nil { + return err + } + dagp.DocumentEndpoint = &documentEndpoint + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType DatabaseAccountOfferType + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + dagp.DatabaseAccountOfferType = databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + dagp.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + dagp.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + dagp.EnableAutomaticFailover = &enableAutomaticFailover + } + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + dagp.ConsistencyPolicy = &consistencyPolicy + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + dagp.Capabilities = &capabilities + } + case "writeLocations": + if v != nil { + var writeLocations []Location + err = json.Unmarshal(*v, &writeLocations) + if err != nil { + return err + } + dagp.WriteLocations = &writeLocations + } + case "readLocations": + if v != nil { + var readLocations []Location + err = json.Unmarshal(*v, &readLocations) + if err != nil { + return err + } + dagp.ReadLocations = &readLocations + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + dagp.Locations = &locations + } + case "failoverPolicies": + if v != nil { + var failoverPolicies []FailoverPolicy + err = json.Unmarshal(*v, &failoverPolicies) + if err != nil { + return err + } + dagp.FailoverPolicies = &failoverPolicies + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + dagp.VirtualNetworkRules = &virtualNetworkRules + } + case "privateEndpointConnections": + if v != nil { + var privateEndpointConnections []PrivateEndpointConnection + err = json.Unmarshal(*v, &privateEndpointConnections) + if err != nil { + return err + } + dagp.PrivateEndpointConnections = &privateEndpointConnections + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + dagp.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + dagp.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + dagp.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + dagp.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + dagp.KeyVaultKeyURI = &keyVaultKeyURI + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + dagp.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + dagp.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + dagp.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + dagp.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "instanceId": + if v != nil { + var instanceID string + err = json.Unmarshal(*v, &instanceID) + if err != nil { + return err + } + dagp.InstanceID = &instanceID + } + case "createMode": + if v != nil { + var createMode CreateMode + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + dagp.CreateMode = createMode + } + case "restoreParameters": + if v != nil { + var restoreParameters RestoreParameters + err = json.Unmarshal(*v, &restoreParameters) + if err != nil { + return err + } + dagp.RestoreParameters = &restoreParameters + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + dagp.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + dagp.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + dagp.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + dagp.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + } + } + + return nil +} + +// DatabaseAccountGetResults an Azure Cosmos DB database account. +type DatabaseAccountGetResults struct { + autorest.Response `json:"-"` + // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' + Kind DatabaseAccountKind `json:"kind,omitempty"` + *DatabaseAccountGetProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountGetResults. +func (dagr DatabaseAccountGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dagr.Kind != "" { + objectMap["kind"] = dagr.Kind + } + if dagr.DatabaseAccountGetProperties != nil { + objectMap["properties"] = dagr.DatabaseAccountGetProperties + } + if dagr.Location != nil { + objectMap["location"] = dagr.Location + } + if dagr.Tags != nil { + objectMap["tags"] = dagr.Tags + } + if dagr.Identity != nil { + objectMap["identity"] = dagr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetResults struct. +func (dagr *DatabaseAccountGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind DatabaseAccountKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dagr.Kind = kind + } + case "properties": + if v != nil { + var databaseAccountGetProperties DatabaseAccountGetProperties + err = json.Unmarshal(*v, &databaseAccountGetProperties) + if err != nil { + return err + } + dagr.DatabaseAccountGetProperties = &databaseAccountGetProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dagr.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dagr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dagr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dagr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dagr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dagr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + dagr.Identity = &identity + } + } + } + + return nil +} + +// DatabaseAccountListConnectionStringsResult the connection strings for the given database account. +type DatabaseAccountListConnectionStringsResult struct { + autorest.Response `json:"-"` + // ConnectionStrings - An array that contains the connection strings for the Cosmos DB account. + ConnectionStrings *[]DatabaseAccountConnectionString `json:"connectionStrings,omitempty"` +} + +// DatabaseAccountListKeysResult the access keys for the given database account. +type DatabaseAccountListKeysResult struct { + autorest.Response `json:"-"` + // PrimaryMasterKey - READ-ONLY; Base 64 encoded value of the primary read-write key. + PrimaryMasterKey *string `json:"primaryMasterKey,omitempty"` + // SecondaryMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-write key. + SecondaryMasterKey *string `json:"secondaryMasterKey,omitempty"` + // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} + +// DatabaseAccountListReadOnlyKeysResult the read-only access keys for the given database account. +type DatabaseAccountListReadOnlyKeysResult struct { + autorest.Response `json:"-"` + // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} + +// DatabaseAccountRegenerateKeyParameters parameters to regenerate the keys within the database account. +type DatabaseAccountRegenerateKeyParameters struct { + // KeyKind - The access key to regenerate. Possible values include: 'Primary', 'Secondary', 'PrimaryReadonly', 'SecondaryReadonly' + KeyKind KeyKind `json:"keyKind,omitempty"` +} + +// DatabaseAccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) +} + +// DatabaseAccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseAccountsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// DatabaseAccountsFailoverPriorityChangeFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type DatabaseAccountsFailoverPriorityChangeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// DatabaseAccountsListResult the List operation response, that contains the database accounts and their +// properties. +type DatabaseAccountsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of database account and their properties. + Value *[]DatabaseAccountGetResults `json:"value,omitempty"` +} + +// DatabaseAccountsOfflineRegionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsOfflineRegionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// DatabaseAccountsOnlineRegionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsOnlineRegionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// DatabaseAccountsRegenerateKeyFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsRegenerateKeyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// DatabaseAccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseAccountsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) +} + +// DatabaseAccountUpdateParameters parameters for patching Azure Cosmos DB database account properties. +type DatabaseAccountUpdateParameters struct { + Tags map[string]*string `json:"tags"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + *DatabaseAccountUpdateProperties `json:"properties,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountUpdateParameters. +func (daup DatabaseAccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if daup.Tags != nil { + objectMap["tags"] = daup.Tags + } + if daup.Location != nil { + objectMap["location"] = daup.Location + } + if daup.DatabaseAccountUpdateProperties != nil { + objectMap["properties"] = daup.DatabaseAccountUpdateProperties + } + if daup.Identity != nil { + objectMap["identity"] = daup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateParameters struct. +func (daup *DatabaseAccountUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + daup.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + daup.Location = &location + } + case "properties": + if v != nil { + var databaseAccountUpdateProperties DatabaseAccountUpdateProperties + err = json.Unmarshal(*v, &databaseAccountUpdateProperties) + if err != nil { + return err + } + daup.DatabaseAccountUpdateProperties = &databaseAccountUpdateProperties + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + daup.Identity = &identity + } + } + } + + return nil +} + +// DatabaseAccountUpdateProperties properties to update Azure Cosmos DB database accounts. +type DatabaseAccountUpdateProperties struct { + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'Small' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateProperties struct. +func (daup *DatabaseAccountUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + daup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + daup.Locations = &locations + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + daup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + daup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + daup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + daup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + daup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + daup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + daup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + daup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + daup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + daup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + daup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + daup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + daup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + daup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + daup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + daup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + daup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + daup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + } + } + + return nil +} + +// DatabaseRestoreResource specific Databases to restore. +type DatabaseRestoreResource struct { + // DatabaseName - The name of the database available for restore. + DatabaseName *string `json:"databaseName,omitempty"` + // CollectionNames - The names of the collections available for restore. + CollectionNames *[]string `json:"collectionNames,omitempty"` +} + +// DataCenterResource a managed Cassandra data center. +type DataCenterResource struct { + autorest.Response `json:"-"` + // Properties - Properties of a managed Cassandra data center. + Properties *DataCenterResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCenterResource. +func (dcr DataCenterResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcr.Properties != nil { + objectMap["properties"] = dcr.Properties + } + return json.Marshal(objectMap) +} + +// DataCenterResourceProperties properties of a managed Cassandra data center. +type DataCenterResourceProperties struct { + // ProvisioningState - Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' + ProvisioningState ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` + // DataCenterLocation - The region this data center should be created in. + DataCenterLocation *string `json:"dataCenterLocation,omitempty"` + // DelegatedSubnetID - Resource id of a subnet the nodes in this data center should have their network interfaces connected to. The subnet must be in the same region specified in 'dataCenterLocation' and must be able to route to the subnet specified in the cluster's 'delegatedManagementSubnetId' property. This resource id will be of the form '/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/'. + DelegatedSubnetID *string `json:"delegatedSubnetId,omitempty"` + // NodeCount - The number of nodes the data center should have. This is the desired number. After it is set, it may take some time for the data center to be scaled to match. To monitor the number of nodes and their status, use the fetchNodeStatus method on the cluster. + NodeCount *int32 `json:"nodeCount,omitempty"` + // SeedNodes - READ-ONLY; IP addresses for seed nodes in this data center. This is for reference. Generally you will want to use the seedNodes property on the cluster, which aggregates the seed nodes from all data centers in the cluster. + SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` + // Base64EncodedCassandraYamlFragment - A fragment of a cassandra.yaml configuration file to be included in the cassandra.yaml for all nodes in this data center. The fragment should be Base64 encoded, and only a subset of keys are allowed. + Base64EncodedCassandraYamlFragment *string `json:"base64EncodedCassandraYamlFragment,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCenterResourceProperties. +func (dcr DataCenterResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcr.ProvisioningState != "" { + objectMap["provisioningState"] = dcr.ProvisioningState + } + if dcr.DataCenterLocation != nil { + objectMap["dataCenterLocation"] = dcr.DataCenterLocation + } + if dcr.DelegatedSubnetID != nil { + objectMap["delegatedSubnetId"] = dcr.DelegatedSubnetID + } + if dcr.NodeCount != nil { + objectMap["nodeCount"] = dcr.NodeCount + } + if dcr.Base64EncodedCassandraYamlFragment != nil { + objectMap["base64EncodedCassandraYamlFragment"] = dcr.Base64EncodedCassandraYamlFragment + } + return json.Marshal(objectMap) +} + +// DefaultRequestDatabaseAccountCreateUpdateProperties properties for non-restore Azure Cosmos DB database +// account requests. +type DefaultRequestDatabaseAccountCreateUpdateProperties struct { + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // DatabaseAccountOfferType - The offer type for the database + DatabaseAccountOfferType *string `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'Small' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // CreateMode - Possible values include: 'CreateModeDatabaseAccountCreateUpdateProperties', 'CreateModeDefault', 'CreateModeRestore' + CreateMode CreateModeBasicDatabaseAccountCreateUpdateProperties `json:"createMode,omitempty"` +} + +// MarshalJSON is the custom marshaler for DefaultRequestDatabaseAccountCreateUpdateProperties. +func (drdacup DefaultRequestDatabaseAccountCreateUpdateProperties) MarshalJSON() ([]byte, error) { + drdacup.CreateMode = CreateModeDefault + objectMap := make(map[string]interface{}) + if drdacup.ConsistencyPolicy != nil { + objectMap["consistencyPolicy"] = drdacup.ConsistencyPolicy + } + if drdacup.Locations != nil { + objectMap["locations"] = drdacup.Locations + } + if drdacup.DatabaseAccountOfferType != nil { + objectMap["databaseAccountOfferType"] = drdacup.DatabaseAccountOfferType + } + if drdacup.IPRules != nil { + objectMap["ipRules"] = drdacup.IPRules + } + if drdacup.IsVirtualNetworkFilterEnabled != nil { + objectMap["isVirtualNetworkFilterEnabled"] = drdacup.IsVirtualNetworkFilterEnabled + } + if drdacup.EnableAutomaticFailover != nil { + objectMap["enableAutomaticFailover"] = drdacup.EnableAutomaticFailover + } + if drdacup.Capabilities != nil { + objectMap["capabilities"] = drdacup.Capabilities + } + if drdacup.VirtualNetworkRules != nil { + objectMap["virtualNetworkRules"] = drdacup.VirtualNetworkRules + } + if drdacup.EnableMultipleWriteLocations != nil { + objectMap["enableMultipleWriteLocations"] = drdacup.EnableMultipleWriteLocations + } + if drdacup.EnableCassandraConnector != nil { + objectMap["enableCassandraConnector"] = drdacup.EnableCassandraConnector + } + if drdacup.ConnectorOffer != "" { + objectMap["connectorOffer"] = drdacup.ConnectorOffer + } + if drdacup.DisableKeyBasedMetadataWriteAccess != nil { + objectMap["disableKeyBasedMetadataWriteAccess"] = drdacup.DisableKeyBasedMetadataWriteAccess + } + if drdacup.KeyVaultKeyURI != nil { + objectMap["keyVaultKeyUri"] = drdacup.KeyVaultKeyURI + } + if drdacup.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = drdacup.PublicNetworkAccess + } + if drdacup.EnableFreeTier != nil { + objectMap["enableFreeTier"] = drdacup.EnableFreeTier + } + if drdacup.APIProperties != nil { + objectMap["apiProperties"] = drdacup.APIProperties + } + if drdacup.EnableAnalyticalStorage != nil { + objectMap["enableAnalyticalStorage"] = drdacup.EnableAnalyticalStorage + } + objectMap["backupPolicy"] = drdacup.BackupPolicy + if drdacup.Cors != nil { + objectMap["cors"] = drdacup.Cors + } + if drdacup.NetworkACLBypass != "" { + objectMap["networkAclBypass"] = drdacup.NetworkACLBypass + } + if drdacup.NetworkACLBypassResourceIds != nil { + objectMap["networkAclBypassResourceIds"] = drdacup.NetworkACLBypassResourceIds + } + if drdacup.CreateMode != "" { + objectMap["createMode"] = drdacup.CreateMode + } + return json.Marshal(objectMap) +} + +// AsDefaultRequestDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DefaultRequestDatabaseAccountCreateUpdateProperties. +func (drdacup DefaultRequestDatabaseAccountCreateUpdateProperties) AsDefaultRequestDatabaseAccountCreateUpdateProperties() (*DefaultRequestDatabaseAccountCreateUpdateProperties, bool) { + return &drdacup, true +} + +// AsRestoreReqeustDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DefaultRequestDatabaseAccountCreateUpdateProperties. +func (drdacup DefaultRequestDatabaseAccountCreateUpdateProperties) AsRestoreReqeustDatabaseAccountCreateUpdateProperties() (*RestoreReqeustDatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DefaultRequestDatabaseAccountCreateUpdateProperties. +func (drdacup DefaultRequestDatabaseAccountCreateUpdateProperties) AsDatabaseAccountCreateUpdateProperties() (*DatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsBasicDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for DefaultRequestDatabaseAccountCreateUpdateProperties. +func (drdacup DefaultRequestDatabaseAccountCreateUpdateProperties) AsBasicDatabaseAccountCreateUpdateProperties() (BasicDatabaseAccountCreateUpdateProperties, bool) { + return &drdacup, true +} + +// UnmarshalJSON is the custom unmarshaler for DefaultRequestDatabaseAccountCreateUpdateProperties struct. +func (drdacup *DefaultRequestDatabaseAccountCreateUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + drdacup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + drdacup.Locations = &locations + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType string + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + drdacup.DatabaseAccountOfferType = &databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + drdacup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + drdacup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + drdacup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + drdacup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + drdacup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + drdacup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + drdacup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + drdacup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + drdacup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + drdacup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + drdacup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + drdacup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + drdacup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + drdacup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + drdacup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + drdacup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + drdacup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + drdacup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "createMode": + if v != nil { + var createMode CreateModeBasicDatabaseAccountCreateUpdateProperties + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + drdacup.CreateMode = createMode + } + } + } + + return nil +} + +// ErrorResponse error Response. +type ErrorResponse struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ExcludedPath ... +type ExcludedPath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` +} + +// ExtendedResourceProperties the system generated resource properties associated with SQL databases, SQL +// containers, Gremlin databases and Gremlin graphs. +type ExtendedResourceProperties struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// FailoverPolicies the list of new failover policies for the failover priority change. +type FailoverPolicies struct { + // FailoverPolicies - List of failover policies. + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` +} + +// FailoverPolicy the failover policy for a given region of a database account. +type FailoverPolicy struct { + // ID - READ-ONLY; The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. + ID *string `json:"id,omitempty"` + // LocationName - The name of the region in which the database account exists. + LocationName *string `json:"locationName,omitempty"` + // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. + FailoverPriority *int32 `json:"failoverPriority,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverPolicy. +func (fp FailoverPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fp.LocationName != nil { + objectMap["locationName"] = fp.LocationName + } + if fp.FailoverPriority != nil { + objectMap["failoverPriority"] = fp.FailoverPriority + } + return json.Marshal(objectMap) +} + +// GremlinDatabaseCreateUpdateParameters parameters to create and update Cosmos DB Gremlin database. +type GremlinDatabaseCreateUpdateParameters struct { + // GremlinDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin database. + *GremlinDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseCreateUpdateParameters. +func (gdcup GremlinDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdcup.GremlinDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = gdcup.GremlinDatabaseCreateUpdateProperties + } + if gdcup.Location != nil { + objectMap["location"] = gdcup.Location + } + if gdcup.Tags != nil { + objectMap["tags"] = gdcup.Tags + } + if gdcup.Identity != nil { + objectMap["identity"] = gdcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseCreateUpdateParameters struct. +func (gdcup *GremlinDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gremlinDatabaseCreateUpdateProperties GremlinDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &gremlinDatabaseCreateUpdateProperties) + if err != nil { + return err + } + gdcup.GremlinDatabaseCreateUpdateProperties = &gremlinDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gdcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gdcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + gdcup.Identity = &identity + } + } + } + + return nil +} + +// GremlinDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin database. +type GremlinDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a Gremlin database + Resource *GremlinDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// GremlinDatabaseGetProperties the properties of an Azure Cosmos DB SQL database +type GremlinDatabaseGetProperties struct { + Resource *GremlinDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *GremlinDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// GremlinDatabaseGetPropertiesOptions ... +type GremlinDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// GremlinDatabaseGetPropertiesResource ... +type GremlinDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB Gremlin database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseGetPropertiesResource. +func (gdgp GremlinDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdgp.ID != nil { + objectMap["id"] = gdgp.ID + } + return json.Marshal(objectMap) +} + +// GremlinDatabaseGetResults an Azure Cosmos DB Gremlin database. +type GremlinDatabaseGetResults struct { + autorest.Response `json:"-"` + // GremlinDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database + *GremlinDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseGetResults. +func (gdgr GremlinDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdgr.GremlinDatabaseGetProperties != nil { + objectMap["properties"] = gdgr.GremlinDatabaseGetProperties + } + if gdgr.Location != nil { + objectMap["location"] = gdgr.Location + } + if gdgr.Tags != nil { + objectMap["tags"] = gdgr.Tags + } + if gdgr.Identity != nil { + objectMap["identity"] = gdgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseGetResults struct. +func (gdgr *GremlinDatabaseGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gremlinDatabaseGetProperties GremlinDatabaseGetProperties + err = json.Unmarshal(*v, &gremlinDatabaseGetProperties) + if err != nil { + return err + } + gdgr.GremlinDatabaseGetProperties = &gremlinDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gdgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gdgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + gdgr.Identity = &identity + } + } + } + + return nil +} + +// GremlinDatabaseListResult the List operation response, that contains the Gremlin databases and their +// properties. +type GremlinDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Gremlin databases and their properties. + Value *[]GremlinDatabaseGetResults `json:"value,omitempty"` +} + +// GremlinDatabaseResource cosmos DB Gremlin database resource object +type GremlinDatabaseResource struct { + // ID - Name of the Cosmos DB Gremlin database + ID *string `json:"id,omitempty"` +} + +// GremlinGraphCreateUpdateParameters parameters to create and update Cosmos DB Gremlin graph. +type GremlinGraphCreateUpdateParameters struct { + // GremlinGraphCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin graph. + *GremlinGraphCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphCreateUpdateParameters. +func (ggcup GremlinGraphCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ggcup.GremlinGraphCreateUpdateProperties != nil { + objectMap["properties"] = ggcup.GremlinGraphCreateUpdateProperties + } + if ggcup.Location != nil { + objectMap["location"] = ggcup.Location + } + if ggcup.Tags != nil { + objectMap["tags"] = ggcup.Tags + } + if ggcup.Identity != nil { + objectMap["identity"] = ggcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinGraphCreateUpdateParameters struct. +func (ggcup *GremlinGraphCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gremlinGraphCreateUpdateProperties GremlinGraphCreateUpdateProperties + err = json.Unmarshal(*v, &gremlinGraphCreateUpdateProperties) + if err != nil { + return err + } + ggcup.GremlinGraphCreateUpdateProperties = &gremlinGraphCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ggcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ggcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ggcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ggcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ggcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ggcup.Identity = &identity + } + } + } + + return nil +} + +// GremlinGraphCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin graph. +type GremlinGraphCreateUpdateProperties struct { + // Resource - The standard JSON format of a Gremlin graph + Resource *GremlinGraphResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// GremlinGraphGetProperties the properties of an Azure Cosmos DB Gremlin graph +type GremlinGraphGetProperties struct { + Resource *GremlinGraphGetPropertiesResource `json:"resource,omitempty"` + Options *GremlinGraphGetPropertiesOptions `json:"options,omitempty"` +} + +// GremlinGraphGetPropertiesOptions ... +type GremlinGraphGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// GremlinGraphGetPropertiesResource ... +type GremlinGraphGetPropertiesResource struct { + // ID - Name of the Cosmos DB Gremlin graph + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the graph. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphGetPropertiesResource. +func (gggp GremlinGraphGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gggp.ID != nil { + objectMap["id"] = gggp.ID + } + if gggp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = gggp.IndexingPolicy + } + if gggp.PartitionKey != nil { + objectMap["partitionKey"] = gggp.PartitionKey + } + if gggp.DefaultTTL != nil { + objectMap["defaultTtl"] = gggp.DefaultTTL + } + if gggp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = gggp.UniqueKeyPolicy + } + if gggp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = gggp.ConflictResolutionPolicy + } + return json.Marshal(objectMap) +} + +// GremlinGraphGetResults an Azure Cosmos DB Gremlin graph. +type GremlinGraphGetResults struct { + autorest.Response `json:"-"` + // GremlinGraphGetProperties - The properties of an Azure Cosmos DB Gremlin graph + *GremlinGraphGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphGetResults. +func (gggr GremlinGraphGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gggr.GremlinGraphGetProperties != nil { + objectMap["properties"] = gggr.GremlinGraphGetProperties + } + if gggr.Location != nil { + objectMap["location"] = gggr.Location + } + if gggr.Tags != nil { + objectMap["tags"] = gggr.Tags + } + if gggr.Identity != nil { + objectMap["identity"] = gggr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinGraphGetResults struct. +func (gggr *GremlinGraphGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gremlinGraphGetProperties GremlinGraphGetProperties + err = json.Unmarshal(*v, &gremlinGraphGetProperties) + if err != nil { + return err + } + gggr.GremlinGraphGetProperties = &gremlinGraphGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gggr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gggr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gggr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gggr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gggr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + gggr.Identity = &identity + } + } + } + + return nil +} + +// GremlinGraphListResult the List operation response, that contains the graphs and their properties. +type GremlinGraphListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of graphs and their properties. + Value *[]GremlinGraphGetResults `json:"value,omitempty"` +} + +// GremlinGraphResource cosmos DB Gremlin graph resource object +type GremlinGraphResource struct { + // ID - Name of the Cosmos DB Gremlin graph + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the graph. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` +} + +// GremlinResourcesCreateUpdateGremlinDatabaseFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesCreateUpdateGremlinDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (GremlinDatabaseGetResults, error) +} + +// GremlinResourcesCreateUpdateGremlinGraphFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type GremlinResourcesCreateUpdateGremlinGraphFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (GremlinGraphGetResults, error) +} + +// GremlinResourcesDeleteGremlinDatabaseFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type GremlinResourcesDeleteGremlinDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (autorest.Response, error) +} + +// GremlinResourcesDeleteGremlinGraphFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type GremlinResourcesDeleteGremlinGraphFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (autorest.Response, error) +} + +// GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// GremlinResourcesMigrateGremlinGraphToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesMigrateGremlinGraphToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// GremlinResourcesMigrateGremlinGraphToManualThroughputFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type GremlinResourcesMigrateGremlinGraphToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// GremlinResourcesUpdateGremlinDatabaseThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesUpdateGremlinDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// GremlinResourcesUpdateGremlinGraphThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesUpdateGremlinGraphThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// IncludedPath the paths that are included in indexing +type IncludedPath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Indexes - List of indexes for this path + Indexes *[]Indexes `json:"indexes,omitempty"` +} + +// Indexes the indexes for the path. +type Indexes struct { + // DataType - The datatype for which the indexing behavior is applied to. Possible values include: 'String', 'Number', 'Point', 'Polygon', 'LineString', 'MultiPolygon' + DataType DataType `json:"dataType,omitempty"` + // Precision - The precision of the index. -1 is maximum precision. + Precision *int32 `json:"precision,omitempty"` + // Kind - Indicates the type of index. Possible values include: 'Hash', 'Range', 'Spatial' + Kind IndexKind `json:"kind,omitempty"` +} + +// IndexingPolicy cosmos DB indexing policy +type IndexingPolicy struct { + // Automatic - Indicates if the indexing policy is automatic + Automatic *bool `json:"automatic,omitempty"` + // IndexingMode - Indicates the indexing mode. Possible values include: 'Consistent', 'Lazy', 'None' + IndexingMode IndexingMode `json:"indexingMode,omitempty"` + // IncludedPaths - List of paths to include in the indexing + IncludedPaths *[]IncludedPath `json:"includedPaths,omitempty"` + // ExcludedPaths - List of paths to exclude from indexing + ExcludedPaths *[]ExcludedPath `json:"excludedPaths,omitempty"` + // CompositeIndexes - List of composite path list + CompositeIndexes *[][]CompositePath `json:"compositeIndexes,omitempty"` + // SpatialIndexes - List of spatial specifics + SpatialIndexes *[]SpatialSpec `json:"spatialIndexes,omitempty"` +} + +// IPAddressOrRange ipAddressOrRange object +type IPAddressOrRange struct { + // IPAddressOrRange - A single IPv4 address or a single IPv4 address range in CIDR format. Provided IPs must be well-formatted and cannot be contained in one of the following ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. + IPAddressOrRange *string `json:"ipAddressOrRange,omitempty"` +} + +// ListBackups list of restorable backups for a Cassandra cluster. +type ListBackups struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Container for array of backups. + Value *[]BackupResource `json:"value,omitempty"` +} + +// ListClusters list of managed Cassandra clusters. +type ListClusters struct { + autorest.Response `json:"-"` + // Value - Container for the array of clusters. + Value *[]ClusterResource `json:"value,omitempty"` +} + +// ListDataCenters list of managed Cassandra data centers and their properties. +type ListDataCenters struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Container for array of data centers. + Value *[]DataCenterResource `json:"value,omitempty"` +} + +// Location a region in which the Azure Cosmos DB database account is deployed. +type Location struct { + // ID - READ-ONLY; The unique identifier of the region within the database account. Example: <accountName>-<locationName>. + ID *string `json:"id,omitempty"` + // LocationName - The name of the region. + LocationName *string `json:"locationName,omitempty"` + // DocumentEndpoint - READ-ONLY; The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/ + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. + FailoverPriority *int32 `json:"failoverPriority,omitempty"` + // IsZoneRedundant - Flag to indicate whether or not this region is an AvailabilityZone region + IsZoneRedundant *bool `json:"isZoneRedundant,omitempty"` +} + +// MarshalJSON is the custom marshaler for Location. +func (l Location) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if l.LocationName != nil { + objectMap["locationName"] = l.LocationName + } + if l.ProvisioningState != nil { + objectMap["provisioningState"] = l.ProvisioningState + } + if l.FailoverPriority != nil { + objectMap["failoverPriority"] = l.FailoverPriority + } + if l.IsZoneRedundant != nil { + objectMap["isZoneRedundant"] = l.IsZoneRedundant + } + return json.Marshal(objectMap) +} + +// ManagedServiceIdentity identity for the resource. +type ManagedServiceIdentity struct { + // PrincipalID - READ-ONLY; The principal id of the system assigned identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty"` + // Type - The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. Possible values include: 'ResourceIdentityTypeSystemAssigned', 'ResourceIdentityTypeUserAssigned', 'ResourceIdentityTypeSystemAssignedUserAssigned', 'ResourceIdentityTypeNone' + Type ResourceIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*ManagedServiceIdentityUserAssignedIdentitiesValue `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ManagedServiceIdentity. +func (msi ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msi.Type != "" { + objectMap["type"] = msi.Type + } + if msi.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = msi.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ManagedServiceIdentityUserAssignedIdentitiesValue ... +type ManagedServiceIdentityUserAssignedIdentitiesValue struct { + // PrincipalID - READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` +} + +// Metric metric data +type Metric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for Metric. +func (mVar Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.Unit != "" { + objectMap["unit"] = mVar.Unit + } + return json.Marshal(objectMap) +} + +// MetricAvailability the availability of the metric. +type MetricAvailability struct { + // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Retention - READ-ONLY; The retention for the metric values. + Retention *string `json:"retention,omitempty"` +} + +// MetricDefinition the definition of a metric. +type MetricDefinition struct { + // MetricAvailabilities - READ-ONLY; The list of metric availabilities for the account. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` + // PrimaryAggregationType - READ-ONLY; The primary aggregation type of the metric. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeTotal', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeLast' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // ResourceURI - READ-ONLY; The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinition. +func (md MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if md.Unit != "" { + objectMap["unit"] = md.Unit + } + return json.Marshal(objectMap) +} + +// MetricDefinitionsListResult the response to a list metric definitions request. +type MetricDefinitionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of metric definitions for the account. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricListResult the response to a list metrics request. +type MetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of metrics for the account. + Value *[]Metric `json:"value,omitempty"` +} + +// MetricName a metric name. +type MetricName struct { + // Value - READ-ONLY; The name of the metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; The friendly name of the metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MetricValue represents metrics values. +type MetricValue struct { + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"_count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MongoDBCollectionCreateUpdateParameters parameters to create and update Cosmos DB MongoDB collection. +type MongoDBCollectionCreateUpdateParameters struct { + // MongoDBCollectionCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB collection. + *MongoDBCollectionCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionCreateUpdateParameters. +func (mdccup MongoDBCollectionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdccup.MongoDBCollectionCreateUpdateProperties != nil { + objectMap["properties"] = mdccup.MongoDBCollectionCreateUpdateProperties + } + if mdccup.Location != nil { + objectMap["location"] = mdccup.Location + } + if mdccup.Tags != nil { + objectMap["tags"] = mdccup.Tags + } + if mdccup.Identity != nil { + objectMap["identity"] = mdccup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionCreateUpdateParameters struct. +func (mdccup *MongoDBCollectionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var mongoDBCollectionCreateUpdateProperties MongoDBCollectionCreateUpdateProperties + err = json.Unmarshal(*v, &mongoDBCollectionCreateUpdateProperties) + if err != nil { + return err + } + mdccup.MongoDBCollectionCreateUpdateProperties = &mongoDBCollectionCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdccup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdccup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdccup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mdccup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdccup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mdccup.Identity = &identity + } + } + } + + return nil +} + +// MongoDBCollectionCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB +// collection. +type MongoDBCollectionCreateUpdateProperties struct { + // Resource - The standard JSON format of a MongoDB collection + Resource *MongoDBCollectionResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// MongoDBCollectionGetProperties the properties of an Azure Cosmos DB MongoDB collection +type MongoDBCollectionGetProperties struct { + Resource *MongoDBCollectionGetPropertiesResource `json:"resource,omitempty"` + Options *MongoDBCollectionGetPropertiesOptions `json:"options,omitempty"` +} + +// MongoDBCollectionGetPropertiesOptions ... +type MongoDBCollectionGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// MongoDBCollectionGetPropertiesResource ... +type MongoDBCollectionGetPropertiesResource struct { + // ID - Name of the Cosmos DB MongoDB collection + ID *string `json:"id,omitempty"` + // ShardKey - A key-value pair of shard keys to be applied for the request. + ShardKey map[string]*string `json:"shardKey"` + // Indexes - List of index keys + Indexes *[]MongoIndex `json:"indexes,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionGetPropertiesResource. +func (mdcgp MongoDBCollectionGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcgp.ID != nil { + objectMap["id"] = mdcgp.ID + } + if mdcgp.ShardKey != nil { + objectMap["shardKey"] = mdcgp.ShardKey + } + if mdcgp.Indexes != nil { + objectMap["indexes"] = mdcgp.Indexes + } + if mdcgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = mdcgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// MongoDBCollectionGetResults an Azure Cosmos DB MongoDB collection. +type MongoDBCollectionGetResults struct { + autorest.Response `json:"-"` + // MongoDBCollectionGetProperties - The properties of an Azure Cosmos DB MongoDB collection + *MongoDBCollectionGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionGetResults. +func (mdcgr MongoDBCollectionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcgr.MongoDBCollectionGetProperties != nil { + objectMap["properties"] = mdcgr.MongoDBCollectionGetProperties + } + if mdcgr.Location != nil { + objectMap["location"] = mdcgr.Location + } + if mdcgr.Tags != nil { + objectMap["tags"] = mdcgr.Tags + } + if mdcgr.Identity != nil { + objectMap["identity"] = mdcgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionGetResults struct. +func (mdcgr *MongoDBCollectionGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var mongoDBCollectionGetProperties MongoDBCollectionGetProperties + err = json.Unmarshal(*v, &mongoDBCollectionGetProperties) + if err != nil { + return err + } + mdcgr.MongoDBCollectionGetProperties = &mongoDBCollectionGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdcgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdcgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdcgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mdcgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdcgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mdcgr.Identity = &identity + } + } + } + + return nil +} + +// MongoDBCollectionListResult the List operation response, that contains the MongoDB collections and their +// properties. +type MongoDBCollectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB collections and their properties. + Value *[]MongoDBCollectionGetResults `json:"value,omitempty"` +} + +// MongoDBCollectionResource cosmos DB MongoDB collection resource object +type MongoDBCollectionResource struct { + // ID - Name of the Cosmos DB MongoDB collection + ID *string `json:"id,omitempty"` + // ShardKey - A key-value pair of shard keys to be applied for the request. + ShardKey map[string]*string `json:"shardKey"` + // Indexes - List of index keys + Indexes *[]MongoIndex `json:"indexes,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionResource. +func (mdcr MongoDBCollectionResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcr.ID != nil { + objectMap["id"] = mdcr.ID + } + if mdcr.ShardKey != nil { + objectMap["shardKey"] = mdcr.ShardKey + } + if mdcr.Indexes != nil { + objectMap["indexes"] = mdcr.Indexes + } + if mdcr.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = mdcr.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// MongoDBDatabaseCreateUpdateParameters parameters to create and update Cosmos DB MongoDB database. +type MongoDBDatabaseCreateUpdateParameters struct { + // MongoDBDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB database. + *MongoDBDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseCreateUpdateParameters. +func (mddcup MongoDBDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddcup.MongoDBDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = mddcup.MongoDBDatabaseCreateUpdateProperties + } + if mddcup.Location != nil { + objectMap["location"] = mddcup.Location + } + if mddcup.Tags != nil { + objectMap["tags"] = mddcup.Tags + } + if mddcup.Identity != nil { + objectMap["identity"] = mddcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseCreateUpdateParameters struct. +func (mddcup *MongoDBDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var mongoDBDatabaseCreateUpdateProperties MongoDBDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &mongoDBDatabaseCreateUpdateProperties) + if err != nil { + return err + } + mddcup.MongoDBDatabaseCreateUpdateProperties = &mongoDBDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mddcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mddcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mddcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mddcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mddcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mddcup.Identity = &identity + } + } + } + + return nil +} + +// MongoDBDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB database. +type MongoDBDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a MongoDB database + Resource *MongoDBDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// MongoDBDatabaseGetProperties the properties of an Azure Cosmos DB MongoDB database +type MongoDBDatabaseGetProperties struct { + Resource *MongoDBDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *MongoDBDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// MongoDBDatabaseGetPropertiesOptions ... +type MongoDBDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// MongoDBDatabaseGetPropertiesResource ... +type MongoDBDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB MongoDB database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseGetPropertiesResource. +func (mddgp MongoDBDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddgp.ID != nil { + objectMap["id"] = mddgp.ID + } + return json.Marshal(objectMap) +} + +// MongoDBDatabaseGetResults an Azure Cosmos DB MongoDB database. +type MongoDBDatabaseGetResults struct { + autorest.Response `json:"-"` + // MongoDBDatabaseGetProperties - The properties of an Azure Cosmos DB MongoDB database + *MongoDBDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseGetResults. +func (mddgr MongoDBDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddgr.MongoDBDatabaseGetProperties != nil { + objectMap["properties"] = mddgr.MongoDBDatabaseGetProperties + } + if mddgr.Location != nil { + objectMap["location"] = mddgr.Location + } + if mddgr.Tags != nil { + objectMap["tags"] = mddgr.Tags + } + if mddgr.Identity != nil { + objectMap["identity"] = mddgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseGetResults struct. +func (mddgr *MongoDBDatabaseGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var mongoDBDatabaseGetProperties MongoDBDatabaseGetProperties + err = json.Unmarshal(*v, &mongoDBDatabaseGetProperties) + if err != nil { + return err + } + mddgr.MongoDBDatabaseGetProperties = &mongoDBDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mddgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mddgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mddgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mddgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mddgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mddgr.Identity = &identity + } + } + } + + return nil +} + +// MongoDBDatabaseListResult the List operation response, that contains the MongoDB databases and their +// properties. +type MongoDBDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB databases and their properties. + Value *[]MongoDBDatabaseGetResults `json:"value,omitempty"` +} + +// MongoDBDatabaseResource cosmos DB MongoDB database resource object +type MongoDBDatabaseResource struct { + // ID - Name of the Cosmos DB MongoDB database + ID *string `json:"id,omitempty"` +} + +// MongoDBResourcesCreateUpdateMongoDBCollectionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesCreateUpdateMongoDBCollectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (MongoDBCollectionGetResults, error) +} + +// MongoDBResourcesCreateUpdateMongoDBDatabaseFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesCreateUpdateMongoDBDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (MongoDBDatabaseGetResults, error) +} + +// MongoDBResourcesDeleteMongoDBCollectionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type MongoDBResourcesDeleteMongoDBCollectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (autorest.Response, error) +} + +// MongoDBResourcesDeleteMongoDBDatabaseFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type MongoDBResourcesDeleteMongoDBDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (autorest.Response, error) +} + +// MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoDBResourcesUpdateMongoDBCollectionThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesUpdateMongoDBCollectionThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// MongoIndex cosmos DB MongoDB collection index key +type MongoIndex struct { + // Key - Cosmos DB MongoDB collection index keys + Key *MongoIndexKeys `json:"key,omitempty"` + // Options - Cosmos DB MongoDB collection index key options + Options *MongoIndexOptions `json:"options,omitempty"` +} + +// MongoIndexKeys cosmos DB MongoDB collection resource object +type MongoIndexKeys struct { + // Keys - List of keys for each MongoDB collection in the Azure Cosmos DB service + Keys *[]string `json:"keys,omitempty"` +} + +// MongoIndexOptions cosmos DB MongoDB collection index options +type MongoIndexOptions struct { + // ExpireAfterSeconds - Expire after seconds + ExpireAfterSeconds *int32 `json:"expireAfterSeconds,omitempty"` + // Unique - Is unique or not + Unique *bool `json:"unique,omitempty"` +} + +// NotebookWorkspace a notebook workspace resource +type NotebookWorkspace struct { + autorest.Response `json:"-"` + // NotebookWorkspaceProperties - Resource properties. + *NotebookWorkspaceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspace. +func (nw NotebookWorkspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nw.NotebookWorkspaceProperties != nil { + objectMap["properties"] = nw.NotebookWorkspaceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NotebookWorkspace struct. +func (nw *NotebookWorkspace) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var notebookWorkspaceProperties NotebookWorkspaceProperties + err = json.Unmarshal(*v, ¬ebookWorkspaceProperties) + if err != nil { + return err + } + nw.NotebookWorkspaceProperties = ¬ebookWorkspaceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nw.Type = &typeVar + } + } + } + + return nil +} + +// NotebookWorkspaceConnectionInfoResult the connection info for the given notebook workspace +type NotebookWorkspaceConnectionInfoResult struct { + autorest.Response `json:"-"` + // AuthToken - READ-ONLY; Specifies auth token used for connecting to Notebook server (uses token-based auth). + AuthToken *string `json:"authToken,omitempty"` + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` +} + +// NotebookWorkspaceCreateUpdateParameters parameters to create a notebook workspace resource +type NotebookWorkspaceCreateUpdateParameters struct { + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// NotebookWorkspaceListResult a list of notebook workspace resources +type NotebookWorkspaceListResult struct { + autorest.Response `json:"-"` + // Value - Array of notebook workspace resources + Value *[]NotebookWorkspace `json:"value,omitempty"` +} + +// NotebookWorkspaceProperties properties of a notebook workspace resource. +type NotebookWorkspaceProperties struct { + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` + // Status - READ-ONLY; Status of the notebook workspace. Possible values are: Creating, Online, Deleting, Failed, Updating. + Status *string `json:"status,omitempty"` +} + +// NotebookWorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (NotebookWorkspace, error) +} + +// NotebookWorkspacesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// NotebookWorkspacesRegenerateAuthTokenFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type NotebookWorkspacesRegenerateAuthTokenFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// NotebookWorkspacesStartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type NotebookWorkspacesStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// Operation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.ResourceProvider + Provider *string `json:"Provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"Resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"Operation,omitempty"` + // Description - Description of operation + Description *string `json:"Description,omitempty"` +} + +// OperationListResult result of the request to list Resource Provider operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Resource Provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OptionsResource cosmos DB options resource object +type OptionsResource struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// PartitionMetric the metric values for a single partition. +type PartitionMetric struct { + // PartitionID - READ-ONLY; The partition id (GUID identifier) of the metric values. + PartitionID *string `json:"partitionId,omitempty"` + // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the metric values. + PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionMetric. +func (pm PartitionMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pm.Unit != "" { + objectMap["unit"] = pm.Unit + } + return json.Marshal(objectMap) +} + +// PartitionMetricListResult the response to a list partition metrics request. +type PartitionMetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of partition-level metrics for the account. + Value *[]PartitionMetric `json:"value,omitempty"` +} + +// PartitionUsage the partition level usage data for a usage request. +type PartitionUsage struct { + // PartitionID - READ-ONLY; The partition id (GUID identifier) of the usages. + PartitionID *string `json:"partitionId,omitempty"` + // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the usages. + PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + // Limit - READ-ONLY; Maximum value for this metric + Limit *int64 `json:"limit,omitempty"` + // CurrentValue - READ-ONLY; Current value for this metric + CurrentValue *int64 `json:"currentValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionUsage. +func (pu PartitionUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pu.Unit != "" { + objectMap["unit"] = pu.Unit + } + return json.Marshal(objectMap) +} + +// PartitionUsagesResult the response to a list partition level usage request. +type PartitionUsagesResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of partition-level usages for the database. A usage is a point in time metric + Value *[]PartitionUsage `json:"value,omitempty"` +} + +// PercentileMetric percentile Metric data +type PercentileMetric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The percentile metric values for the specified time window and timestep. + MetricValues *[]PercentileMetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for PercentileMetric. +func (pm PercentileMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pm.Unit != "" { + objectMap["unit"] = pm.Unit + } + return json.Marshal(objectMap) +} + +// PercentileMetricListResult the response to a list percentile metrics request. +type PercentileMetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of percentile metrics for the account. + Value *[]PercentileMetric `json:"value,omitempty"` +} + +// PercentileMetricValue represents percentile metrics values. +type PercentileMetricValue struct { + // P10 - READ-ONLY; The 10th percentile value for the metric. + P10 *float64 `json:"P10,omitempty"` + // P25 - READ-ONLY; The 25th percentile value for the metric. + P25 *float64 `json:"P25,omitempty"` + // P50 - READ-ONLY; The 50th percentile value for the metric. + P50 *float64 `json:"P50,omitempty"` + // P75 - READ-ONLY; The 75th percentile value for the metric. + P75 *float64 `json:"P75,omitempty"` + // P90 - READ-ONLY; The 90th percentile value for the metric. + P90 *float64 `json:"P90,omitempty"` + // P95 - READ-ONLY; The 95th percentile value for the metric. + P95 *float64 `json:"P95,omitempty"` + // P99 - READ-ONLY; The 99th percentile value for the metric. + P99 *float64 `json:"P99,omitempty"` + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"_count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// PeriodicModeBackupPolicy the object representing periodic mode backup policy. +type PeriodicModeBackupPolicy struct { + // PeriodicModeProperties - Configuration values for periodic mode backup + PeriodicModeProperties *PeriodicModeProperties `json:"periodicModeProperties,omitempty"` + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) MarshalJSON() ([]byte, error) { + pmbp.Type = TypePeriodic + objectMap := make(map[string]interface{}) + if pmbp.PeriodicModeProperties != nil { + objectMap["periodicModeProperties"] = pmbp.PeriodicModeProperties + } + if pmbp.Type != "" { + objectMap["type"] = pmbp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return &pmbp, true +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return nil, false +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return nil, false +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &pmbp, true +} + +// PeriodicModeProperties configuration values for periodic mode backup +type PeriodicModeProperties struct { + // BackupIntervalInMinutes - An integer representing the interval in minutes between two backups + BackupIntervalInMinutes *int32 `json:"backupIntervalInMinutes,omitempty"` + // BackupRetentionIntervalInHours - An integer representing the time (in hours) that each backup is retained + BackupRetentionIntervalInHours *int32 `json:"backupRetentionIntervalInHours,omitempty"` + // BackupStorageRedundancy - Enum to indicate type of backup residency. Possible values include: 'Geo', 'Local', 'Zone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` +} + +// Permission the set of data plane operations permitted through this Role Definition. +type Permission struct { + // DataActions - An array of data actions that are allowed. + DataActions *[]string `json:"dataActions,omitempty"` + // NotDataActions - An array of data actions that are denied. + NotDataActions *[]string `json:"notDataActions,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // GroupID - Group id of the private endpoint. + GroupID *string `json:"groupId,omitempty"` + // ProvisioningState - Provisioning state of the private endpoint. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// PrivateEndpointProperty private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - Array of private link resources + Value *[]PrivateLinkResource `json:"value,omitempty"` +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The private link resource required zone names. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// PrivateLinkServiceConnectionStateProperty connection State of the Private Endpoint Connection. +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect) + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != nil { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// RegionForOnlineOffline cosmos DB region to online or offline. +type RegionForOnlineOffline struct { + // Region - Cosmos DB region, with spaces between words and each word capitalized. + Region *string `json:"region,omitempty"` +} + +// RepairPostBody specification of the keyspaces and tables to run repair on. +type RepairPostBody struct { + // Keyspace - The name of the keyspace that repair should be run on. + Keyspace *string `json:"keyspace,omitempty"` + // Tables - List of tables in the keyspace to repair. If omitted, repair all tables in the keyspace. + Tables *[]string `json:"tables,omitempty"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// RestorableDatabaseAccountGetResult a Azure Cosmos DB restorable database account. +type RestorableDatabaseAccountGetResult struct { + autorest.Response `json:"-"` + // RestorableDatabaseAccountProperties - The properties of a restorable database account. + *RestorableDatabaseAccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDatabaseAccountGetResult. +func (rdagr RestorableDatabaseAccountGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdagr.RestorableDatabaseAccountProperties != nil { + objectMap["properties"] = rdagr.RestorableDatabaseAccountProperties + } + if rdagr.Location != nil { + objectMap["location"] = rdagr.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDatabaseAccountGetResult struct. +func (rdagr *RestorableDatabaseAccountGetResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableDatabaseAccountProperties RestorableDatabaseAccountProperties + err = json.Unmarshal(*v, &restorableDatabaseAccountProperties) + if err != nil { + return err + } + rdagr.RestorableDatabaseAccountProperties = &restorableDatabaseAccountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdagr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdagr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdagr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdagr.Location = &location + } + } + } + + return nil +} + +// RestorableDatabaseAccountProperties the properties of a restorable database account. +type RestorableDatabaseAccountProperties struct { + // AccountName - The name of the global database account + AccountName *string `json:"accountName,omitempty"` + // CreationTime - The creation time of the restorable database account (ISO-8601 format). + CreationTime *date.Time `json:"creationTime,omitempty"` + // DeletionTime - The time at which the restorable database account has been deleted (ISO-8601 format). + DeletionTime *date.Time `json:"deletionTime,omitempty"` + // APIType - READ-ONLY; The API type of the restorable database account. Possible values include: 'MongoDB', 'Gremlin', 'Cassandra', 'Table', 'SQL', 'GremlinV2' + APIType APIType `json:"apiType,omitempty"` + // RestorableLocations - READ-ONLY; List of regions where the of the database account can be restored from. + RestorableLocations *[]RestorableLocationResource `json:"restorableLocations,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDatabaseAccountProperties. +func (rdap RestorableDatabaseAccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdap.AccountName != nil { + objectMap["accountName"] = rdap.AccountName + } + if rdap.CreationTime != nil { + objectMap["creationTime"] = rdap.CreationTime + } + if rdap.DeletionTime != nil { + objectMap["deletionTime"] = rdap.DeletionTime + } + return json.Marshal(objectMap) +} + +// RestorableDatabaseAccountsListResult the List operation response, that contains the restorable database +// accounts and their properties. +type RestorableDatabaseAccountsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable database accounts and their properties. + Value *[]RestorableDatabaseAccountGetResult `json:"value,omitempty"` +} + +// RestorableLocationResource properties of the regional restorable account. +type RestorableLocationResource struct { + // LocationName - READ-ONLY; The location of the regional restorable account. + LocationName *string `json:"locationName,omitempty"` + // RegionalDatabaseAccountInstanceID - READ-ONLY; The instance id of the regional restorable account. + RegionalDatabaseAccountInstanceID *string `json:"regionalDatabaseAccountInstanceId,omitempty"` + // CreationTime - READ-ONLY; The creation time of the regional restorable database account (ISO-8601 format). + CreationTime *date.Time `json:"creationTime,omitempty"` + // DeletionTime - READ-ONLY; The time at which the regional restorable database account has been deleted (ISO-8601 format). + DeletionTime *date.Time `json:"deletionTime,omitempty"` +} + +// RestorableMongodbCollectionGetResult an Azure Cosmos DB MongoDB collection event +type RestorableMongodbCollectionGetResult struct { + // RestorableMongodbCollectionProperties - The properties of a MongoDB collection event. + *RestorableMongodbCollectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbCollectionGetResult. +func (rmcgr RestorableMongodbCollectionGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmcgr.RestorableMongodbCollectionProperties != nil { + objectMap["properties"] = rmcgr.RestorableMongodbCollectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableMongodbCollectionGetResult struct. +func (rmcgr *RestorableMongodbCollectionGetResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableMongodbCollectionProperties RestorableMongodbCollectionProperties + err = json.Unmarshal(*v, &restorableMongodbCollectionProperties) + if err != nil { + return err + } + rmcgr.RestorableMongodbCollectionProperties = &restorableMongodbCollectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmcgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmcgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmcgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableMongodbCollectionProperties the properties of an Azure Cosmos DB MongoDB collection event +type RestorableMongodbCollectionProperties struct { + // Resource - The resource of an Azure Cosmos DB MongoDB collection event + Resource *RestorableMongodbCollectionPropertiesResource `json:"resource,omitempty"` +} + +// RestorableMongodbCollectionPropertiesResource the resource of an Azure Cosmos DB MongoDB collection +// event +type RestorableMongodbCollectionPropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this collection event. Possible values include: 'Create', 'Replace', 'Delete', 'SystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this collection event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this MongoDB collection. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB collection. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` +} + +// RestorableMongodbCollectionsListResult the List operation response, that contains the MongoDB collection +// events and their properties. +type RestorableMongodbCollectionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB collection events and their properties. + Value *[]RestorableMongodbCollectionGetResult `json:"value,omitempty"` +} + +// RestorableMongodbDatabaseGetResult an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabaseGetResult struct { + // RestorableMongodbDatabaseProperties - The properties of a MongoDB database event. + *RestorableMongodbDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbDatabaseGetResult. +func (rmdgr RestorableMongodbDatabaseGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmdgr.RestorableMongodbDatabaseProperties != nil { + objectMap["properties"] = rmdgr.RestorableMongodbDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableMongodbDatabaseGetResult struct. +func (rmdgr *RestorableMongodbDatabaseGetResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableMongodbDatabaseProperties RestorableMongodbDatabaseProperties + err = json.Unmarshal(*v, &restorableMongodbDatabaseProperties) + if err != nil { + return err + } + rmdgr.RestorableMongodbDatabaseProperties = &restorableMongodbDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmdgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableMongodbDatabaseProperties the properties of an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabaseProperties struct { + // Resource - The resource of an Azure Cosmos DB MongoDB database event + Resource *RestorableMongodbDatabasePropertiesResource `json:"resource,omitempty"` +} + +// RestorableMongodbDatabasePropertiesResource the resource of an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabasePropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'Create', 'Replace', 'Delete', 'SystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this database event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this MongoDB database. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB database. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` +} + +// RestorableMongodbDatabasesListResult the List operation response, that contains the MongoDB database +// events and their properties. +type RestorableMongodbDatabasesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB database events and their properties. + Value *[]RestorableMongodbDatabaseGetResult `json:"value,omitempty"` +} + +// RestorableMongodbResourcesListResult the List operation response, that contains the restorable MongoDB +// resources. +type RestorableMongodbResourcesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable MongoDB resources, including the database and collection names. + Value *[]DatabaseRestoreResource `json:"value,omitempty"` +} + +// RestorableSQLContainerGetResult an Azure Cosmos DB SQL container event +type RestorableSQLContainerGetResult struct { + // RestorableSQLContainerProperties - The properties of a SQL container event. + *RestorableSQLContainerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerGetResult. +func (rscgr RestorableSQLContainerGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscgr.RestorableSQLContainerProperties != nil { + objectMap["properties"] = rscgr.RestorableSQLContainerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableSQLContainerGetResult struct. +func (rscgr *RestorableSQLContainerGetResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableSQLContainerProperties RestorableSQLContainerProperties + err = json.Unmarshal(*v, &restorableSQLContainerProperties) + if err != nil { + return err + } + rscgr.RestorableSQLContainerProperties = &restorableSQLContainerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rscgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rscgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rscgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableSQLContainerProperties the properties of an Azure Cosmos DB SQL container event +type RestorableSQLContainerProperties struct { + // Resource - The resource of an Azure Cosmos DB SQL container event + Resource *RestorableSQLContainerPropertiesResource `json:"resource,omitempty"` +} + +// RestorableSQLContainerPropertiesResource the resource of an Azure Cosmos DB SQL container event +type RestorableSQLContainerPropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this container event. Possible values include: 'Create', 'Replace', 'Delete', 'SystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The when this container event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this SQL container. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this SQL container. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` + // Container - Cosmos DB SQL container resource object + Container *RestorableSQLContainerPropertiesResourceContainer `json:"container,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResource. +func (rscp RestorableSQLContainerPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscp.Container != nil { + objectMap["container"] = rscp.Container + } + return json.Marshal(objectMap) +} + +// RestorableSQLContainerPropertiesResourceContainer cosmos DB SQL container resource object +type RestorableSQLContainerPropertiesResourceContainer struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Self - READ-ONLY; A system generated property that specifies the addressable path of the container resource. + Self *string `json:"_self,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResourceContainer. +func (rscp RestorableSQLContainerPropertiesResourceContainer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscp.ID != nil { + objectMap["id"] = rscp.ID + } + if rscp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = rscp.IndexingPolicy + } + if rscp.PartitionKey != nil { + objectMap["partitionKey"] = rscp.PartitionKey + } + if rscp.DefaultTTL != nil { + objectMap["defaultTtl"] = rscp.DefaultTTL + } + if rscp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = rscp.UniqueKeyPolicy + } + if rscp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = rscp.ConflictResolutionPolicy + } + if rscp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = rscp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// RestorableSQLContainersListResult the List operation response, that contains the SQL container events +// and their properties. +type RestorableSQLContainersListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL container events and their properties. + Value *[]RestorableSQLContainerGetResult `json:"value,omitempty"` +} + +// RestorableSQLDatabaseGetResult an Azure Cosmos DB SQL database event +type RestorableSQLDatabaseGetResult struct { + // RestorableSQLDatabaseProperties - The properties of a SQL database event. + *RestorableSQLDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabaseGetResult. +func (rsdgr RestorableSQLDatabaseGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdgr.RestorableSQLDatabaseProperties != nil { + objectMap["properties"] = rsdgr.RestorableSQLDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableSQLDatabaseGetResult struct. +func (rsdgr *RestorableSQLDatabaseGetResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableSQLDatabaseProperties RestorableSQLDatabaseProperties + err = json.Unmarshal(*v, &restorableSQLDatabaseProperties) + if err != nil { + return err + } + rsdgr.RestorableSQLDatabaseProperties = &restorableSQLDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rsdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rsdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rsdgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableSQLDatabaseProperties the properties of an Azure Cosmos DB SQL database event +type RestorableSQLDatabaseProperties struct { + // Resource - The resource of an Azure Cosmos DB SQL database event + Resource *RestorableSQLDatabasePropertiesResource `json:"resource,omitempty"` +} + +// RestorableSQLDatabasePropertiesResource the resource of an Azure Cosmos DB SQL database event +type RestorableSQLDatabasePropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'Create', 'Replace', 'Delete', 'SystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this database event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of the SQL database. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of the SQL database. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` + // Database - Cosmos DB SQL database resource object + Database *RestorableSQLDatabasePropertiesResourceDatabase `json:"database,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResource. +func (rsdp RestorableSQLDatabasePropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdp.Database != nil { + objectMap["database"] = rsdp.Database + } + return json.Marshal(objectMap) +} + +// RestorableSQLDatabasePropertiesResourceDatabase cosmos DB SQL database resource object +type RestorableSQLDatabasePropertiesResourceDatabase struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Colls - READ-ONLY; A system generated property that specified the addressable path of the collections resource. + Colls *string `json:"_colls,omitempty"` + // Users - READ-ONLY; A system generated property that specifies the addressable path of the users resource. + Users *string `json:"_users,omitempty"` + // Self - READ-ONLY; A system generated property that specifies the addressable path of the database resource. + Self *string `json:"_self,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResourceDatabase. +func (rsdp RestorableSQLDatabasePropertiesResourceDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdp.ID != nil { + objectMap["id"] = rsdp.ID + } + return json.Marshal(objectMap) +} + +// RestorableSQLDatabasesListResult the List operation response, that contains the SQL database events and +// their properties. +type RestorableSQLDatabasesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL database events and their properties. + Value *[]RestorableSQLDatabaseGetResult `json:"value,omitempty"` +} + +// RestorableSQLResourcesListResult the List operation response, that contains the restorable SQL +// resources. +type RestorableSQLResourcesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable SQL resources, including the database and collection names. + Value *[]DatabaseRestoreResource `json:"value,omitempty"` +} + +// RestoreParameters parameters to indicate the information about the restore. +type RestoreParameters struct { + // RestoreMode - Describes the mode of the restore. Possible values include: 'PointInTime' + RestoreMode RestoreMode `json:"restoreMode,omitempty"` + // RestoreSource - The id of the restorable database account from which the restore has to be initiated. For example: /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName} + RestoreSource *string `json:"restoreSource,omitempty"` + // RestoreTimestampInUtc - Time to which the account has to be restored (ISO-8601 format). + RestoreTimestampInUtc *date.Time `json:"restoreTimestampInUtc,omitempty"` + // DatabasesToRestore - List of specific databases available for restore. + DatabasesToRestore *[]DatabaseRestoreResource `json:"databasesToRestore,omitempty"` +} + +// RestoreReqeustDatabaseAccountCreateUpdateProperties properties to restore Azure Cosmos DB database +// account. +type RestoreReqeustDatabaseAccountCreateUpdateProperties struct { + // RestoreParameters - Parameters to indicate the information about the restore. + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // DatabaseAccountOfferType - The offer type for the database + DatabaseAccountOfferType *string `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'Small' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // CreateMode - Possible values include: 'CreateModeDatabaseAccountCreateUpdateProperties', 'CreateModeDefault', 'CreateModeRestore' + CreateMode CreateModeBasicDatabaseAccountCreateUpdateProperties `json:"createMode,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestoreReqeustDatabaseAccountCreateUpdateProperties. +func (rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties) MarshalJSON() ([]byte, error) { + rrdacup.CreateMode = CreateModeRestore + objectMap := make(map[string]interface{}) + if rrdacup.RestoreParameters != nil { + objectMap["restoreParameters"] = rrdacup.RestoreParameters + } + if rrdacup.ConsistencyPolicy != nil { + objectMap["consistencyPolicy"] = rrdacup.ConsistencyPolicy + } + if rrdacup.Locations != nil { + objectMap["locations"] = rrdacup.Locations + } + if rrdacup.DatabaseAccountOfferType != nil { + objectMap["databaseAccountOfferType"] = rrdacup.DatabaseAccountOfferType + } + if rrdacup.IPRules != nil { + objectMap["ipRules"] = rrdacup.IPRules + } + if rrdacup.IsVirtualNetworkFilterEnabled != nil { + objectMap["isVirtualNetworkFilterEnabled"] = rrdacup.IsVirtualNetworkFilterEnabled + } + if rrdacup.EnableAutomaticFailover != nil { + objectMap["enableAutomaticFailover"] = rrdacup.EnableAutomaticFailover + } + if rrdacup.Capabilities != nil { + objectMap["capabilities"] = rrdacup.Capabilities + } + if rrdacup.VirtualNetworkRules != nil { + objectMap["virtualNetworkRules"] = rrdacup.VirtualNetworkRules + } + if rrdacup.EnableMultipleWriteLocations != nil { + objectMap["enableMultipleWriteLocations"] = rrdacup.EnableMultipleWriteLocations + } + if rrdacup.EnableCassandraConnector != nil { + objectMap["enableCassandraConnector"] = rrdacup.EnableCassandraConnector + } + if rrdacup.ConnectorOffer != "" { + objectMap["connectorOffer"] = rrdacup.ConnectorOffer + } + if rrdacup.DisableKeyBasedMetadataWriteAccess != nil { + objectMap["disableKeyBasedMetadataWriteAccess"] = rrdacup.DisableKeyBasedMetadataWriteAccess + } + if rrdacup.KeyVaultKeyURI != nil { + objectMap["keyVaultKeyUri"] = rrdacup.KeyVaultKeyURI + } + if rrdacup.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = rrdacup.PublicNetworkAccess + } + if rrdacup.EnableFreeTier != nil { + objectMap["enableFreeTier"] = rrdacup.EnableFreeTier + } + if rrdacup.APIProperties != nil { + objectMap["apiProperties"] = rrdacup.APIProperties + } + if rrdacup.EnableAnalyticalStorage != nil { + objectMap["enableAnalyticalStorage"] = rrdacup.EnableAnalyticalStorage + } + objectMap["backupPolicy"] = rrdacup.BackupPolicy + if rrdacup.Cors != nil { + objectMap["cors"] = rrdacup.Cors + } + if rrdacup.NetworkACLBypass != "" { + objectMap["networkAclBypass"] = rrdacup.NetworkACLBypass + } + if rrdacup.NetworkACLBypassResourceIds != nil { + objectMap["networkAclBypassResourceIds"] = rrdacup.NetworkACLBypassResourceIds + } + if rrdacup.CreateMode != "" { + objectMap["createMode"] = rrdacup.CreateMode + } + return json.Marshal(objectMap) +} + +// AsDefaultRequestDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for RestoreReqeustDatabaseAccountCreateUpdateProperties. +func (rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties) AsDefaultRequestDatabaseAccountCreateUpdateProperties() (*DefaultRequestDatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsRestoreReqeustDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for RestoreReqeustDatabaseAccountCreateUpdateProperties. +func (rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties) AsRestoreReqeustDatabaseAccountCreateUpdateProperties() (*RestoreReqeustDatabaseAccountCreateUpdateProperties, bool) { + return &rrdacup, true +} + +// AsDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for RestoreReqeustDatabaseAccountCreateUpdateProperties. +func (rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties) AsDatabaseAccountCreateUpdateProperties() (*DatabaseAccountCreateUpdateProperties, bool) { + return nil, false +} + +// AsBasicDatabaseAccountCreateUpdateProperties is the BasicDatabaseAccountCreateUpdateProperties implementation for RestoreReqeustDatabaseAccountCreateUpdateProperties. +func (rrdacup RestoreReqeustDatabaseAccountCreateUpdateProperties) AsBasicDatabaseAccountCreateUpdateProperties() (BasicDatabaseAccountCreateUpdateProperties, bool) { + return &rrdacup, true +} + +// UnmarshalJSON is the custom unmarshaler for RestoreReqeustDatabaseAccountCreateUpdateProperties struct. +func (rrdacup *RestoreReqeustDatabaseAccountCreateUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "restoreParameters": + if v != nil { + var restoreParameters RestoreParameters + err = json.Unmarshal(*v, &restoreParameters) + if err != nil { + return err + } + rrdacup.RestoreParameters = &restoreParameters + } + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + rrdacup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + rrdacup.Locations = &locations + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType string + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + rrdacup.DatabaseAccountOfferType = &databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + rrdacup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + rrdacup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + rrdacup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + rrdacup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + rrdacup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + rrdacup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + rrdacup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + rrdacup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + rrdacup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + rrdacup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + rrdacup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + rrdacup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + rrdacup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + rrdacup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + rrdacup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + rrdacup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + rrdacup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + rrdacup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "createMode": + if v != nil { + var createMode CreateModeBasicDatabaseAccountCreateUpdateProperties + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + rrdacup.CreateMode = createMode + } + } + } + + return nil +} + +// SeedNode ... +type SeedNode struct { + // IPAddress - IP address of this seed node. + IPAddress *string `json:"ipAddress,omitempty"` +} + +// SpatialSpec ... +type SpatialSpec struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Types - List of path's spatial type + Types *[]SpatialType `json:"types,omitempty"` +} + +// SQLContainerCreateUpdateParameters parameters to create and update Cosmos DB container. +type SQLContainerCreateUpdateParameters struct { + // SQLContainerCreateUpdateProperties - Properties to create and update Azure Cosmos DB container. + *SQLContainerCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLContainerCreateUpdateParameters. +func (sccup SQLContainerCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sccup.SQLContainerCreateUpdateProperties != nil { + objectMap["properties"] = sccup.SQLContainerCreateUpdateProperties + } + if sccup.Location != nil { + objectMap["location"] = sccup.Location + } + if sccup.Tags != nil { + objectMap["tags"] = sccup.Tags + } + if sccup.Identity != nil { + objectMap["identity"] = sccup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLContainerCreateUpdateParameters struct. +func (sccup *SQLContainerCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLContainerCreateUpdateProperties SQLContainerCreateUpdateProperties + err = json.Unmarshal(*v, &SQLContainerCreateUpdateProperties) + if err != nil { + return err + } + sccup.SQLContainerCreateUpdateProperties = &SQLContainerCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sccup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sccup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sccup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sccup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sccup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sccup.Identity = &identity + } + } + } + + return nil +} + +// SQLContainerCreateUpdateProperties properties to create and update Azure Cosmos DB container. +type SQLContainerCreateUpdateProperties struct { + // Resource - The standard JSON format of a container + Resource *SQLContainerResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLContainerGetProperties the properties of an Azure Cosmos DB container +type SQLContainerGetProperties struct { + Resource *SQLContainerGetPropertiesResource `json:"resource,omitempty"` + Options *SQLContainerGetPropertiesOptions `json:"options,omitempty"` +} + +// SQLContainerGetPropertiesOptions ... +type SQLContainerGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// SQLContainerGetPropertiesResource ... +type SQLContainerGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLContainerGetPropertiesResource. +func (scgp SQLContainerGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scgp.ID != nil { + objectMap["id"] = scgp.ID + } + if scgp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = scgp.IndexingPolicy + } + if scgp.PartitionKey != nil { + objectMap["partitionKey"] = scgp.PartitionKey + } + if scgp.DefaultTTL != nil { + objectMap["defaultTtl"] = scgp.DefaultTTL + } + if scgp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = scgp.UniqueKeyPolicy + } + if scgp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = scgp.ConflictResolutionPolicy + } + if scgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = scgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// SQLContainerGetResults an Azure Cosmos DB container. +type SQLContainerGetResults struct { + autorest.Response `json:"-"` + // SQLContainerGetProperties - The properties of an Azure Cosmos DB container + *SQLContainerGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLContainerGetResults. +func (scgr SQLContainerGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scgr.SQLContainerGetProperties != nil { + objectMap["properties"] = scgr.SQLContainerGetProperties + } + if scgr.Location != nil { + objectMap["location"] = scgr.Location + } + if scgr.Tags != nil { + objectMap["tags"] = scgr.Tags + } + if scgr.Identity != nil { + objectMap["identity"] = scgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLContainerGetResults struct. +func (scgr *SQLContainerGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLContainerGetProperties SQLContainerGetProperties + err = json.Unmarshal(*v, &SQLContainerGetProperties) + if err != nil { + return err + } + scgr.SQLContainerGetProperties = &SQLContainerGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + scgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + scgr.Identity = &identity + } + } + } + + return nil +} + +// SQLContainerListResult the List operation response, that contains the containers and their properties. +type SQLContainerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of containers and their properties. + Value *[]SQLContainerGetResults `json:"value,omitempty"` +} + +// SQLContainerResource cosmos DB SQL container resource object +type SQLContainerResource struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` +} + +// SQLDatabaseCreateUpdateParameters parameters to create and update Cosmos DB SQL database. +type SQLDatabaseCreateUpdateParameters struct { + // SQLDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB SQL database. + *SQLDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseCreateUpdateParameters. +func (sdcup SQLDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdcup.SQLDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = sdcup.SQLDatabaseCreateUpdateProperties + } + if sdcup.Location != nil { + objectMap["location"] = sdcup.Location + } + if sdcup.Tags != nil { + objectMap["tags"] = sdcup.Tags + } + if sdcup.Identity != nil { + objectMap["identity"] = sdcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLDatabaseCreateUpdateParameters struct. +func (sdcup *SQLDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLDatabaseCreateUpdateProperties SQLDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &SQLDatabaseCreateUpdateProperties) + if err != nil { + return err + } + sdcup.SQLDatabaseCreateUpdateProperties = &SQLDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sdcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sdcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sdcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sdcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sdcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sdcup.Identity = &identity + } + } + } + + return nil +} + +// SQLDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB SQL database. +type SQLDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a SQL database + Resource *SQLDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLDatabaseGetProperties the properties of an Azure Cosmos DB SQL database +type SQLDatabaseGetProperties struct { + Resource *SQLDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *SQLDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// SQLDatabaseGetPropertiesOptions ... +type SQLDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// SQLDatabaseGetPropertiesResource ... +type SQLDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Colls - A system generated property that specified the addressable path of the collections resource. + Colls *string `json:"_colls,omitempty"` + // Users - A system generated property that specifies the addressable path of the users resource. + Users *string `json:"_users,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseGetPropertiesResource. +func (sdgp SQLDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdgp.ID != nil { + objectMap["id"] = sdgp.ID + } + if sdgp.Colls != nil { + objectMap["_colls"] = sdgp.Colls + } + if sdgp.Users != nil { + objectMap["_users"] = sdgp.Users + } + return json.Marshal(objectMap) +} + +// SQLDatabaseGetResults an Azure Cosmos DB SQL database. +type SQLDatabaseGetResults struct { + autorest.Response `json:"-"` + // SQLDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database + *SQLDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseGetResults. +func (sdgr SQLDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdgr.SQLDatabaseGetProperties != nil { + objectMap["properties"] = sdgr.SQLDatabaseGetProperties + } + if sdgr.Location != nil { + objectMap["location"] = sdgr.Location + } + if sdgr.Tags != nil { + objectMap["tags"] = sdgr.Tags + } + if sdgr.Identity != nil { + objectMap["identity"] = sdgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLDatabaseGetResults struct. +func (sdgr *SQLDatabaseGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLDatabaseGetProperties SQLDatabaseGetProperties + err = json.Unmarshal(*v, &SQLDatabaseGetProperties) + if err != nil { + return err + } + sdgr.SQLDatabaseGetProperties = &SQLDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sdgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sdgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sdgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sdgr.Identity = &identity + } + } + } + + return nil +} + +// SQLDatabaseListResult the List operation response, that contains the SQL databases and their properties. +type SQLDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL databases and their properties. + Value *[]SQLDatabaseGetResults `json:"value,omitempty"` +} + +// SQLDatabaseResource cosmos DB SQL database resource object +type SQLDatabaseResource struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` +} + +// SQLResourcesCreateUpdateSQLContainerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLContainerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLContainerGetResults, error) +} + +// SQLResourcesCreateUpdateSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLDatabaseGetResults, error) +} + +// SQLResourcesCreateUpdateSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesCreateUpdateSQLRoleAssignmentFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLRoleAssignmentGetResults, error) +} + +// SQLResourcesCreateUpdateSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesCreateUpdateSQLRoleDefinitionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLRoleDefinitionGetResults, error) +} + +// SQLResourcesCreateUpdateSQLStoredProcedureFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesCreateUpdateSQLStoredProcedureFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLStoredProcedureGetResults, error) +} + +// SQLResourcesCreateUpdateSQLTriggerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLTriggerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLTriggerGetResults, error) +} + +// SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLUserDefinedFunctionGetResults, error) +} + +// SQLResourcesDeleteSQLContainerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLContainerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLRoleAssignmentFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLRoleDefinitionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLStoredProcedureFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLStoredProcedureFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLTriggerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLTriggerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesDeleteSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesDeleteSQLUserDefinedFunctionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// SQLResourcesMigrateSQLContainerToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLContainerToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLResourcesMigrateSQLContainerToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLContainerToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLResourcesMigrateSQLDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesMigrateSQLDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLResourcesMigrateSQLDatabaseToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLResourcesUpdateSQLContainerThroughputFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesUpdateSQLContainerThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLResourcesUpdateSQLDatabaseThroughputFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesUpdateSQLDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// SQLRoleAssignmentCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role +// Assignment. +type SQLRoleAssignmentCreateUpdateParameters struct { + // SQLRoleAssignmentResource - Properties to create and update an Azure Cosmos DB SQL Role Assignment. + *SQLRoleAssignmentResource `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleAssignmentCreateUpdateParameters. +func (sracup SQLRoleAssignmentCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sracup.SQLRoleAssignmentResource != nil { + objectMap["properties"] = sracup.SQLRoleAssignmentResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentCreateUpdateParameters struct. +func (sracup *SQLRoleAssignmentCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLRoleAssignmentResource SQLRoleAssignmentResource + err = json.Unmarshal(*v, &SQLRoleAssignmentResource) + if err != nil { + return err + } + sracup.SQLRoleAssignmentResource = &SQLRoleAssignmentResource + } + } + } + + return nil +} + +// SQLRoleAssignmentGetResults an Azure Cosmos DB Role Assignment +type SQLRoleAssignmentGetResults struct { + autorest.Response `json:"-"` + // SQLRoleAssignmentResource - Properties related to the Role Assignment. + *SQLRoleAssignmentResource `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleAssignmentGetResults. +func (sragr SQLRoleAssignmentGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sragr.SQLRoleAssignmentResource != nil { + objectMap["properties"] = sragr.SQLRoleAssignmentResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentGetResults struct. +func (sragr *SQLRoleAssignmentGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLRoleAssignmentResource SQLRoleAssignmentResource + err = json.Unmarshal(*v, &SQLRoleAssignmentResource) + if err != nil { + return err + } + sragr.SQLRoleAssignmentResource = &SQLRoleAssignmentResource + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sragr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sragr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sragr.Type = &typeVar + } + } + } + + return nil +} + +// SQLRoleAssignmentListResult the relevant Role Assignments. +type SQLRoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Role Assignments and their properties + Value *[]SQLRoleAssignmentGetResults `json:"value,omitempty"` +} + +// SQLRoleAssignmentResource azure Cosmos DB SQL Role Assignment resource object. +type SQLRoleAssignmentResource struct { + // RoleDefinitionID - The unique identifier for the associated Role Definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Scope - The data plane resource path for which access is being granted through this Role Assignment. + Scope *string `json:"scope,omitempty"` + // PrincipalID - The unique identifier for the associated AAD principal in the AAD graph to which access is being granted through this Role Assignment. Tenant ID for the principal is inferred using the tenant associated with the subscription. + PrincipalID *string `json:"principalId,omitempty"` +} + +// SQLRoleDefinitionCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role +// Definition. +type SQLRoleDefinitionCreateUpdateParameters struct { + // SQLRoleDefinitionResource - Properties to create and update an Azure Cosmos DB SQL Role Definition. + *SQLRoleDefinitionResource `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleDefinitionCreateUpdateParameters. +func (srdcup SQLRoleDefinitionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srdcup.SQLRoleDefinitionResource != nil { + objectMap["properties"] = srdcup.SQLRoleDefinitionResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionCreateUpdateParameters struct. +func (srdcup *SQLRoleDefinitionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLRoleDefinitionResource SQLRoleDefinitionResource + err = json.Unmarshal(*v, &SQLRoleDefinitionResource) + if err != nil { + return err + } + srdcup.SQLRoleDefinitionResource = &SQLRoleDefinitionResource + } + } + } + + return nil +} + +// SQLRoleDefinitionGetResults an Azure Cosmos DB SQL Role Definition. +type SQLRoleDefinitionGetResults struct { + autorest.Response `json:"-"` + // SQLRoleDefinitionResource - Properties related to the Role Definition. + *SQLRoleDefinitionResource `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleDefinitionGetResults. +func (srdgr SQLRoleDefinitionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srdgr.SQLRoleDefinitionResource != nil { + objectMap["properties"] = srdgr.SQLRoleDefinitionResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionGetResults struct. +func (srdgr *SQLRoleDefinitionGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLRoleDefinitionResource SQLRoleDefinitionResource + err = json.Unmarshal(*v, &SQLRoleDefinitionResource) + if err != nil { + return err + } + srdgr.SQLRoleDefinitionResource = &SQLRoleDefinitionResource + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + srdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + srdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + srdgr.Type = &typeVar + } + } + } + + return nil +} + +// SQLRoleDefinitionListResult the relevant Role Definitions. +type SQLRoleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Role Definitions and their properties. + Value *[]SQLRoleDefinitionGetResults `json:"value,omitempty"` +} + +// SQLRoleDefinitionResource azure Cosmos DB SQL Role Definition resource object. +type SQLRoleDefinitionResource struct { + // RoleName - A user-friendly name for the Role Definition. Must be unique for the database account. + RoleName *string `json:"roleName,omitempty"` + // Type - Indicates whether the Role Definition was built-in or user created. Possible values include: 'BuiltInRole', 'CustomRole' + Type RoleDefinitionType `json:"type,omitempty"` + // AssignableScopes - A set of fully qualified Scopes at or below which Role Assignments may be created using this Role Definition. This will allow application of this Role Definition on the entire database account or any underlying Database / Collection. Must have at least one element. Scopes higher than Database account are not enforceable as assignable Scopes. Note that resources referenced in assignable Scopes need not exist. + AssignableScopes *[]string `json:"assignableScopes,omitempty"` + // Permissions - The set of operations allowed through this Role Definition. + Permissions *[]Permission `json:"permissions,omitempty"` +} + +// SQLStoredProcedureCreateUpdateParameters parameters to create and update Cosmos DB storedProcedure. +type SQLStoredProcedureCreateUpdateParameters struct { + // SQLStoredProcedureCreateUpdateProperties - Properties to create and update Azure Cosmos DB storedProcedure. + *SQLStoredProcedureCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureCreateUpdateParameters. +func (sspcup SQLStoredProcedureCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspcup.SQLStoredProcedureCreateUpdateProperties != nil { + objectMap["properties"] = sspcup.SQLStoredProcedureCreateUpdateProperties + } + if sspcup.Location != nil { + objectMap["location"] = sspcup.Location + } + if sspcup.Tags != nil { + objectMap["tags"] = sspcup.Tags + } + if sspcup.Identity != nil { + objectMap["identity"] = sspcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureCreateUpdateParameters struct. +func (sspcup *SQLStoredProcedureCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLStoredProcedureCreateUpdateProperties SQLStoredProcedureCreateUpdateProperties + err = json.Unmarshal(*v, &SQLStoredProcedureCreateUpdateProperties) + if err != nil { + return err + } + sspcup.SQLStoredProcedureCreateUpdateProperties = &SQLStoredProcedureCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sspcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sspcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sspcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sspcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sspcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sspcup.Identity = &identity + } + } + } + + return nil +} + +// SQLStoredProcedureCreateUpdateProperties properties to create and update Azure Cosmos DB +// storedProcedure. +type SQLStoredProcedureCreateUpdateProperties struct { + // Resource - The standard JSON format of a storedProcedure + Resource *SQLStoredProcedureResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLStoredProcedureGetProperties the properties of an Azure Cosmos DB StoredProcedure +type SQLStoredProcedureGetProperties struct { + Resource *SQLStoredProcedureGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLStoredProcedureGetPropertiesResource ... +type SQLStoredProcedureGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL storedProcedure + ID *string `json:"id,omitempty"` + // Body - Body of the Stored Procedure + Body *string `json:"body,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureGetPropertiesResource. +func (sspgp SQLStoredProcedureGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspgp.ID != nil { + objectMap["id"] = sspgp.ID + } + if sspgp.Body != nil { + objectMap["body"] = sspgp.Body + } + return json.Marshal(objectMap) +} + +// SQLStoredProcedureGetResults an Azure Cosmos DB storedProcedure. +type SQLStoredProcedureGetResults struct { + autorest.Response `json:"-"` + // SQLStoredProcedureGetProperties - The properties of an Azure Cosmos DB storedProcedure + *SQLStoredProcedureGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureGetResults. +func (sspgr SQLStoredProcedureGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspgr.SQLStoredProcedureGetProperties != nil { + objectMap["properties"] = sspgr.SQLStoredProcedureGetProperties + } + if sspgr.Location != nil { + objectMap["location"] = sspgr.Location + } + if sspgr.Tags != nil { + objectMap["tags"] = sspgr.Tags + } + if sspgr.Identity != nil { + objectMap["identity"] = sspgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureGetResults struct. +func (sspgr *SQLStoredProcedureGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLStoredProcedureGetProperties SQLStoredProcedureGetProperties + err = json.Unmarshal(*v, &SQLStoredProcedureGetProperties) + if err != nil { + return err + } + sspgr.SQLStoredProcedureGetProperties = &SQLStoredProcedureGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sspgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sspgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sspgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sspgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sspgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sspgr.Identity = &identity + } + } + } + + return nil +} + +// SQLStoredProcedureListResult the List operation response, that contains the storedProcedures and their +// properties. +type SQLStoredProcedureListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of storedProcedures and their properties. + Value *[]SQLStoredProcedureGetResults `json:"value,omitempty"` +} + +// SQLStoredProcedureResource cosmos DB SQL storedProcedure resource object +type SQLStoredProcedureResource struct { + // ID - Name of the Cosmos DB SQL storedProcedure + ID *string `json:"id,omitempty"` + // Body - Body of the Stored Procedure + Body *string `json:"body,omitempty"` +} + +// SQLTriggerCreateUpdateParameters parameters to create and update Cosmos DB trigger. +type SQLTriggerCreateUpdateParameters struct { + // SQLTriggerCreateUpdateProperties - Properties to create and update Azure Cosmos DB trigger. + *SQLTriggerCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerCreateUpdateParameters. +func (stcup SQLTriggerCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stcup.SQLTriggerCreateUpdateProperties != nil { + objectMap["properties"] = stcup.SQLTriggerCreateUpdateProperties + } + if stcup.Location != nil { + objectMap["location"] = stcup.Location + } + if stcup.Tags != nil { + objectMap["tags"] = stcup.Tags + } + if stcup.Identity != nil { + objectMap["identity"] = stcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLTriggerCreateUpdateParameters struct. +func (stcup *SQLTriggerCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLTriggerCreateUpdateProperties SQLTriggerCreateUpdateProperties + err = json.Unmarshal(*v, &SQLTriggerCreateUpdateProperties) + if err != nil { + return err + } + stcup.SQLTriggerCreateUpdateProperties = &SQLTriggerCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + stcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + stcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + stcup.Identity = &identity + } + } + } + + return nil +} + +// SQLTriggerCreateUpdateProperties properties to create and update Azure Cosmos DB trigger. +type SQLTriggerCreateUpdateProperties struct { + // Resource - The standard JSON format of a trigger + Resource *SQLTriggerResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLTriggerGetProperties the properties of an Azure Cosmos DB trigger +type SQLTriggerGetProperties struct { + Resource *SQLTriggerGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLTriggerGetPropertiesResource ... +type SQLTriggerGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL trigger + ID *string `json:"id,omitempty"` + // Body - Body of the Trigger + Body *string `json:"body,omitempty"` + // TriggerType - Type of the Trigger. Possible values include: 'Pre', 'Post' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' + TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerGetPropertiesResource. +func (stgp SQLTriggerGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stgp.ID != nil { + objectMap["id"] = stgp.ID + } + if stgp.Body != nil { + objectMap["body"] = stgp.Body + } + if stgp.TriggerType != "" { + objectMap["triggerType"] = stgp.TriggerType + } + if stgp.TriggerOperation != "" { + objectMap["triggerOperation"] = stgp.TriggerOperation + } + return json.Marshal(objectMap) +} + +// SQLTriggerGetResults an Azure Cosmos DB trigger. +type SQLTriggerGetResults struct { + autorest.Response `json:"-"` + // SQLTriggerGetProperties - The properties of an Azure Cosmos DB trigger + *SQLTriggerGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerGetResults. +func (stgr SQLTriggerGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stgr.SQLTriggerGetProperties != nil { + objectMap["properties"] = stgr.SQLTriggerGetProperties + } + if stgr.Location != nil { + objectMap["location"] = stgr.Location + } + if stgr.Tags != nil { + objectMap["tags"] = stgr.Tags + } + if stgr.Identity != nil { + objectMap["identity"] = stgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLTriggerGetResults struct. +func (stgr *SQLTriggerGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLTriggerGetProperties SQLTriggerGetProperties + err = json.Unmarshal(*v, &SQLTriggerGetProperties) + if err != nil { + return err + } + stgr.SQLTriggerGetProperties = &SQLTriggerGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + stgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + stgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + stgr.Identity = &identity + } + } + } + + return nil +} + +// SQLTriggerListResult the List operation response, that contains the triggers and their properties. +type SQLTriggerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of triggers and their properties. + Value *[]SQLTriggerGetResults `json:"value,omitempty"` +} + +// SQLTriggerResource cosmos DB SQL trigger resource object +type SQLTriggerResource struct { + // ID - Name of the Cosmos DB SQL trigger + ID *string `json:"id,omitempty"` + // Body - Body of the Trigger + Body *string `json:"body,omitempty"` + // TriggerType - Type of the Trigger. Possible values include: 'Pre', 'Post' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' + TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` +} + +// SQLUserDefinedFunctionCreateUpdateParameters parameters to create and update Cosmos DB +// userDefinedFunction. +type SQLUserDefinedFunctionCreateUpdateParameters struct { + // SQLUserDefinedFunctionCreateUpdateProperties - Properties to create and update Azure Cosmos DB userDefinedFunction. + *SQLUserDefinedFunctionCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionCreateUpdateParameters. +func (sudfcup SQLUserDefinedFunctionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfcup.SQLUserDefinedFunctionCreateUpdateProperties != nil { + objectMap["properties"] = sudfcup.SQLUserDefinedFunctionCreateUpdateProperties + } + if sudfcup.Location != nil { + objectMap["location"] = sudfcup.Location + } + if sudfcup.Tags != nil { + objectMap["tags"] = sudfcup.Tags + } + if sudfcup.Identity != nil { + objectMap["identity"] = sudfcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionCreateUpdateParameters struct. +func (sudfcup *SQLUserDefinedFunctionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLUserDefinedFunctionCreateUpdateProperties SQLUserDefinedFunctionCreateUpdateProperties + err = json.Unmarshal(*v, &SQLUserDefinedFunctionCreateUpdateProperties) + if err != nil { + return err + } + sudfcup.SQLUserDefinedFunctionCreateUpdateProperties = &SQLUserDefinedFunctionCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sudfcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sudfcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sudfcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sudfcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sudfcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sudfcup.Identity = &identity + } + } + } + + return nil +} + +// SQLUserDefinedFunctionCreateUpdateProperties properties to create and update Azure Cosmos DB +// userDefinedFunction. +type SQLUserDefinedFunctionCreateUpdateProperties struct { + // Resource - The standard JSON format of a userDefinedFunction + Resource *SQLUserDefinedFunctionResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLUserDefinedFunctionGetProperties the properties of an Azure Cosmos DB userDefinedFunction +type SQLUserDefinedFunctionGetProperties struct { + Resource *SQLUserDefinedFunctionGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLUserDefinedFunctionGetPropertiesResource ... +type SQLUserDefinedFunctionGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL userDefinedFunction + ID *string `json:"id,omitempty"` + // Body - Body of the User Defined Function + Body *string `json:"body,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetPropertiesResource. +func (sudfgp SQLUserDefinedFunctionGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfgp.ID != nil { + objectMap["id"] = sudfgp.ID + } + if sudfgp.Body != nil { + objectMap["body"] = sudfgp.Body + } + return json.Marshal(objectMap) +} + +// SQLUserDefinedFunctionGetResults an Azure Cosmos DB userDefinedFunction. +type SQLUserDefinedFunctionGetResults struct { + autorest.Response `json:"-"` + // SQLUserDefinedFunctionGetProperties - The properties of an Azure Cosmos DB userDefinedFunction + *SQLUserDefinedFunctionGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetResults. +func (sudfgr SQLUserDefinedFunctionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfgr.SQLUserDefinedFunctionGetProperties != nil { + objectMap["properties"] = sudfgr.SQLUserDefinedFunctionGetProperties + } + if sudfgr.Location != nil { + objectMap["location"] = sudfgr.Location + } + if sudfgr.Tags != nil { + objectMap["tags"] = sudfgr.Tags + } + if sudfgr.Identity != nil { + objectMap["identity"] = sudfgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionGetResults struct. +func (sudfgr *SQLUserDefinedFunctionGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var SQLUserDefinedFunctionGetProperties SQLUserDefinedFunctionGetProperties + err = json.Unmarshal(*v, &SQLUserDefinedFunctionGetProperties) + if err != nil { + return err + } + sudfgr.SQLUserDefinedFunctionGetProperties = &SQLUserDefinedFunctionGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sudfgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sudfgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sudfgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sudfgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sudfgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sudfgr.Identity = &identity + } + } + } + + return nil +} + +// SQLUserDefinedFunctionListResult the List operation response, that contains the userDefinedFunctions and +// their properties. +type SQLUserDefinedFunctionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of userDefinedFunctions and their properties. + Value *[]SQLUserDefinedFunctionGetResults `json:"value,omitempty"` +} + +// SQLUserDefinedFunctionResource cosmos DB SQL userDefinedFunction resource object +type SQLUserDefinedFunctionResource struct { + // ID - Name of the Cosmos DB SQL userDefinedFunction + ID *string `json:"id,omitempty"` + // Body - Body of the User Defined Function + Body *string `json:"body,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TableCreateUpdateParameters parameters to create and update Cosmos DB Table. +type TableCreateUpdateParameters struct { + // TableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Table. + *TableCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for TableCreateUpdateParameters. +func (tcup TableCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tcup.TableCreateUpdateProperties != nil { + objectMap["properties"] = tcup.TableCreateUpdateProperties + } + if tcup.Location != nil { + objectMap["location"] = tcup.Location + } + if tcup.Tags != nil { + objectMap["tags"] = tcup.Tags + } + if tcup.Identity != nil { + objectMap["identity"] = tcup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TableCreateUpdateParameters struct. +func (tcup *TableCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tableCreateUpdateProperties TableCreateUpdateProperties + err = json.Unmarshal(*v, &tableCreateUpdateProperties) + if err != nil { + return err + } + tcup.TableCreateUpdateProperties = &tableCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tcup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + tcup.Identity = &identity + } + } + } + + return nil +} + +// TableCreateUpdateProperties properties to create and update Azure Cosmos DB Table. +type TableCreateUpdateProperties struct { + // Resource - The standard JSON format of a Table + Resource *TableResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// TableGetProperties the properties of an Azure Cosmos Table +type TableGetProperties struct { + Resource *TableGetPropertiesResource `json:"resource,omitempty"` + Options *TableGetPropertiesOptions `json:"options,omitempty"` +} + +// TableGetPropertiesOptions ... +type TableGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// TableGetPropertiesResource ... +type TableGetPropertiesResource struct { + // ID - Name of the Cosmos DB table + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for TableGetPropertiesResource. +func (tgp TableGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tgp.ID != nil { + objectMap["id"] = tgp.ID + } + return json.Marshal(objectMap) +} + +// TableGetResults an Azure Cosmos DB Table. +type TableGetResults struct { + autorest.Response `json:"-"` + // TableGetProperties - The properties of an Azure Cosmos DB Table + *TableGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for TableGetResults. +func (tgr TableGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tgr.TableGetProperties != nil { + objectMap["properties"] = tgr.TableGetProperties + } + if tgr.Location != nil { + objectMap["location"] = tgr.Location + } + if tgr.Tags != nil { + objectMap["tags"] = tgr.Tags + } + if tgr.Identity != nil { + objectMap["identity"] = tgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TableGetResults struct. +func (tgr *TableGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tableGetProperties TableGetProperties + err = json.Unmarshal(*v, &tableGetProperties) + if err != nil { + return err + } + tgr.TableGetProperties = &tableGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + tgr.Identity = &identity + } + } + } + + return nil +} + +// TableListResult the List operation response, that contains the Table and their properties. +type TableListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Table and their properties. + Value *[]TableGetResults `json:"value,omitempty"` +} + +// TableResource cosmos DB table resource object +type TableResource struct { + // ID - Name of the Cosmos DB table + ID *string `json:"id,omitempty"` +} + +// TableResourcesCreateUpdateTableFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesCreateUpdateTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (TableGetResults, error) +} + +// TableResourcesDeleteTableFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesDeleteTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (autorest.Response, error) +} + +// TableResourcesMigrateTableToAutoscaleFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type TableResourcesMigrateTableToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// TableResourcesMigrateTableToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type TableResourcesMigrateTableToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// TableResourcesUpdateTableThroughputFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesUpdateTableThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// ThroughputPolicyResource cosmos DB resource throughput policy +type ThroughputPolicyResource struct { + // IsEnabled - Determines whether the ThroughputPolicy is active or not + IsEnabled *bool `json:"isEnabled,omitempty"` + // IncrementPercent - Represents the percentage by which throughput can increase every time throughput policy kicks in. + IncrementPercent *int32 `json:"incrementPercent,omitempty"` +} + +// ThroughputSettingsGetProperties the properties of an Azure Cosmos DB resource throughput +type ThroughputSettingsGetProperties struct { + Resource *ThroughputSettingsGetPropertiesResource `json:"resource,omitempty"` +} + +// ThroughputSettingsGetPropertiesResource ... +type ThroughputSettingsGetPropertiesResource struct { + // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. + AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + // MinimumThroughput - READ-ONLY; The minimum throughput of the resource + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + // OfferReplacePending - READ-ONLY; The throughput replace is pending + OfferReplacePending *string `json:"offerReplacePending,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsGetPropertiesResource. +func (tsgp ThroughputSettingsGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsgp.Throughput != nil { + objectMap["throughput"] = tsgp.Throughput + } + if tsgp.AutoscaleSettings != nil { + objectMap["autoscaleSettings"] = tsgp.AutoscaleSettings + } + return json.Marshal(objectMap) +} + +// ThroughputSettingsGetResults an Azure Cosmos DB resource throughput. +type ThroughputSettingsGetResults struct { + autorest.Response `json:"-"` + // ThroughputSettingsGetProperties - The properties of an Azure Cosmos DB resource throughput + *ThroughputSettingsGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsGetResults. +func (tsgr ThroughputSettingsGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsgr.ThroughputSettingsGetProperties != nil { + objectMap["properties"] = tsgr.ThroughputSettingsGetProperties + } + if tsgr.Location != nil { + objectMap["location"] = tsgr.Location + } + if tsgr.Tags != nil { + objectMap["tags"] = tsgr.Tags + } + if tsgr.Identity != nil { + objectMap["identity"] = tsgr.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsGetResults struct. +func (tsgr *ThroughputSettingsGetResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var throughputSettingsGetProperties ThroughputSettingsGetProperties + err = json.Unmarshal(*v, &throughputSettingsGetProperties) + if err != nil { + return err + } + tsgr.ThroughputSettingsGetProperties = &throughputSettingsGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tsgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tsgr.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + tsgr.Identity = &identity + } + } + } + + return nil +} + +// ThroughputSettingsResource cosmos DB resource throughput object. Either throughput is required or +// autoscaleSettings is required, but not both. +type ThroughputSettingsResource struct { + // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. + AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + // MinimumThroughput - READ-ONLY; The minimum throughput of the resource + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + // OfferReplacePending - READ-ONLY; The throughput replace is pending + OfferReplacePending *string `json:"offerReplacePending,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsResource. +func (tsr ThroughputSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsr.Throughput != nil { + objectMap["throughput"] = tsr.Throughput + } + if tsr.AutoscaleSettings != nil { + objectMap["autoscaleSettings"] = tsr.AutoscaleSettings + } + return json.Marshal(objectMap) +} + +// ThroughputSettingsUpdateParameters parameters to update Cosmos DB resource throughput. +type ThroughputSettingsUpdateParameters struct { + // ThroughputSettingsUpdateProperties - Properties to update Azure Cosmos DB resource throughput. + *ThroughputSettingsUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsUpdateParameters. +func (tsup ThroughputSettingsUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsup.ThroughputSettingsUpdateProperties != nil { + objectMap["properties"] = tsup.ThroughputSettingsUpdateProperties + } + if tsup.Location != nil { + objectMap["location"] = tsup.Location + } + if tsup.Tags != nil { + objectMap["tags"] = tsup.Tags + } + if tsup.Identity != nil { + objectMap["identity"] = tsup.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsUpdateParameters struct. +func (tsup *ThroughputSettingsUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var throughputSettingsUpdateProperties ThroughputSettingsUpdateProperties + err = json.Unmarshal(*v, &throughputSettingsUpdateProperties) + if err != nil { + return err + } + tsup.ThroughputSettingsUpdateProperties = &throughputSettingsUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tsup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tsup.Tags = tags + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + tsup.Identity = &identity + } + } + } + + return nil +} + +// ThroughputSettingsUpdateProperties properties to update Azure Cosmos DB resource throughput. +type ThroughputSettingsUpdateProperties struct { + // Resource - The standard JSON format of a resource throughput + Resource *ThroughputSettingsResource `json:"resource,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UniqueKey the unique key on that enforces uniqueness constraint on documents in the collection in the +// Azure Cosmos DB service. +type UniqueKey struct { + // Paths - List of paths must be unique for each document in the Azure Cosmos DB service + Paths *[]string `json:"paths,omitempty"` +} + +// UniqueKeyPolicy the unique key policy configuration for specifying uniqueness constraints on documents +// in the collection in the Azure Cosmos DB service. +type UniqueKeyPolicy struct { + // UniqueKeys - List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. + UniqueKeys *[]UniqueKey `json:"uniqueKeys,omitempty"` +} + +// Usage the usage data for a usage request. +type Usage struct { + // Unit - The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + // Limit - READ-ONLY; Maximum value for this metric + Limit *int64 `json:"limit,omitempty"` + // CurrentValue - READ-ONLY; Current value for this metric + CurrentValue *int64 `json:"currentValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if u.Unit != "" { + objectMap["unit"] = u.Unit + } + return json.Marshal(objectMap) +} + +// UsagesResult the response to a list usage request. +type UsagesResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of usages for the database. A usage is a point in time metric + Value *[]Usage `json:"value,omitempty"` +} + +// VirtualNetworkRule virtual Network ACL Rule object +type VirtualNetworkRule struct { + // ID - Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. + ID *string `json:"id,omitempty"` + // IgnoreMissingVNetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. + IgnoreMissingVNetServiceEndpoint *bool `json:"ignoreMissingVNetServiceEndpoint,omitempty"` +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/mongodbresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/mongodbresources.go new file mode 100644 index 000000000000..728801c5f02a --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/mongodbresources.go @@ -0,0 +1,1800 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MongoDBResourcesClient is the client for the MongoDBResources methods of the Documentdb service. +type MongoDBResourcesClient struct { + BaseClient +} + +// NewMongoDBResourcesClient creates an instance of the MongoDBResourcesClient client. +func NewMongoDBResourcesClient(subscriptionID string) MongoDBResourcesClient { + return NewMongoDBResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMongoDBResourcesClientWithBaseURI creates an instance of the MongoDBResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMongoDBResourcesClientWithBaseURI(baseURI string, subscriptionID string) MongoDBResourcesClient { + return MongoDBResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateMongoDBCollection create or update an Azure Cosmos DB MongoDB Collection +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +// createUpdateMongoDBCollectionParameters - the parameters to provide for the current MongoDB Collection. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBCollection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateMongoDBCollectionParameters, + Constraints: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", err.Error()) + } + + req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateMongoDBCollectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateMongoDBCollectionPreparer prepares the CreateUpdateMongoDBCollection request. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithJSON(createUpdateMongoDBCollectionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateMongoDBCollectionSender sends the CreateUpdateMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (mdcgr MongoDBCollectionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + mdcgr.Response.Response, err = future.GetResult(sender) + if mdcgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", nil, "received nil response and error") + } + if err == nil && mdcgr.Response.Response.StatusCode != http.StatusNoContent { + mdcgr, err = client.CreateUpdateMongoDBCollectionResponder(mdcgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", mdcgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateMongoDBCollectionResponder handles the response to the CreateUpdateMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateMongoDBDatabase create or updates Azure Cosmos DB MongoDB database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateMongoDBDatabaseParameters - the parameters to provide for the current MongoDB database. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateMongoDBDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", err.Error()) + } + + req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateMongoDBDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateMongoDBDatabasePreparer prepares the CreateUpdateMongoDBDatabase request. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateMongoDBDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateMongoDBDatabaseSender sends the CreateUpdateMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (mddgr MongoDBDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + mddgr.Response.Response, err = future.GetResult(sender) + if mddgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", nil, "received nil response and error") + } + if err == nil && mddgr.Response.Response.StatusCode != http.StatusNoContent { + mddgr, err = client.CreateUpdateMongoDBDatabaseResponder(mddgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", mddgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateMongoDBDatabaseResponder handles the response to the CreateUpdateMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteMongoDBCollection deletes an existing Azure Cosmos DB MongoDB Collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBCollection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", err.Error()) + } + + req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure preparing request") + return + } + + result, err = client.DeleteMongoDBCollectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure sending request") + return + } + + return +} + +// DeleteMongoDBCollectionPreparer prepares the DeleteMongoDBCollection request. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteMongoDBCollectionSender sends the DeleteMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteMongoDBCollectionResponder handles the response to the DeleteMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteMongoDBDatabase deletes an existing Azure Cosmos DB MongoDB database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", err.Error()) + } + + req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteMongoDBDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteMongoDBDatabasePreparer prepares the DeleteMongoDBDatabase request. +func (client MongoDBResourcesClient) DeleteMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteMongoDBDatabaseSender sends the DeleteMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) DeleteMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteMongoDBDatabaseResponder handles the response to the DeleteMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) DeleteMongoDBDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetMongoDBCollection gets the MongoDB collection under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollectionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollection", err.Error()) + } + + req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBCollectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBCollectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBCollectionPreparer prepares the GetMongoDBCollection request. +func (client MongoDBResourcesClient) GetMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBCollectionSender sends the GetMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBCollectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBCollectionResponder handles the response to the GetMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBCollectionThroughput gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollectionThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", err.Error()) + } + + req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBCollectionThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBCollectionThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBCollectionThroughputPreparer prepares the GetMongoDBCollectionThroughput request. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBCollectionThroughputSender sends the GetMongoDBCollectionThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBCollectionThroughputResponder handles the response to the GetMongoDBCollectionThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBDatabase gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided +// name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", err.Error()) + } + + req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBDatabasePreparer prepares the GetMongoDBDatabase request. +func (client MongoDBResourcesClient) GetMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBDatabaseSender sends the GetMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBDatabaseResponder handles the response to the GetMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBDatabaseThroughput gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", err.Error()) + } + + req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBDatabaseThroughputPreparer prepares the GetMongoDBDatabaseThroughput request. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBDatabaseThroughputSender sends the GetMongoDBDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBDatabaseThroughputResponder handles the response to the GetMongoDBDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMongoDBCollections lists the MongoDB collection under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBCollections") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBCollections", err.Error()) + } + + req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", nil, "Failure preparing request") + return + } + + resp, err := client.ListMongoDBCollectionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure sending request") + return + } + + result, err = client.ListMongoDBCollectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure responding to request") + return + } + + return +} + +// ListMongoDBCollectionsPreparer prepares the ListMongoDBCollections request. +func (client MongoDBResourcesClient) ListMongoDBCollectionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMongoDBCollectionsSender sends the ListMongoDBCollections request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) ListMongoDBCollectionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMongoDBCollectionsResponder handles the response to the ListMongoDBCollections request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) ListMongoDBCollectionsResponder(resp *http.Response) (result MongoDBCollectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMongoDBDatabases lists the MongoDB databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client MongoDBResourcesClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", err.Error()) + } + + req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListMongoDBDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListMongoDBDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListMongoDBDatabasesPreparer prepares the ListMongoDBDatabases request. +func (client MongoDBResourcesClient) ListMongoDBDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMongoDBDatabasesSender sends the ListMongoDBDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) ListMongoDBDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMongoDBDatabasesResponder handles the response to the ListMongoDBDatabases request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) ListMongoDBDatabasesResponder(resp *http.Response) (result MongoDBDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBCollectionToAutoscale migrate an Azure Cosmos DB MongoDB collection from manual throughput to +// autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", err.Error()) + } + + req, err := client.MigrateMongoDBCollectionToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBCollectionToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBCollectionToAutoscalePreparer prepares the MigrateMongoDBCollectionToAutoscale request. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBCollectionToAutoscaleSender sends the MigrateMongoDBCollectionToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBCollectionToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateMongoDBCollectionToAutoscaleResponder handles the response to the MigrateMongoDBCollectionToAutoscale request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBCollectionToManualThroughput migrate an Azure Cosmos DB MongoDB collection from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", err.Error()) + } + + req, err := client.MigrateMongoDBCollectionToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBCollectionToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBCollectionToManualThroughputPreparer prepares the MigrateMongoDBCollectionToManualThroughput request. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBCollectionToManualThroughputSender sends the MigrateMongoDBCollectionToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBCollectionToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateMongoDBCollectionToManualThroughputResponder handles the response to the MigrateMongoDBCollectionToManualThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBDatabaseToAutoscale migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateMongoDBDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBDatabaseToAutoscalePreparer prepares the MigrateMongoDBDatabaseToAutoscale request. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBDatabaseToAutoscaleSender sends the MigrateMongoDBDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateMongoDBDatabaseToAutoscaleResponder handles the response to the MigrateMongoDBDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBDatabaseToManualThroughput migrate an Azure Cosmos DB MongoDB database from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateMongoDBDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBDatabaseToManualThroughputPreparer prepares the MigrateMongoDBDatabaseToManualThroughput request. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBDatabaseToManualThroughputSender sends the MigrateMongoDBDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateMongoDBDatabaseToManualThroughputResponder handles the response to the MigrateMongoDBDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMongoDBCollectionThroughput update the RUs per second of an Azure Cosmos DB MongoDB collection +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB +// collection. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBCollectionThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", err.Error()) + } + + req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateMongoDBCollectionThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateMongoDBCollectionThroughputPreparer prepares the UpdateMongoDBCollectionThroughput request. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMongoDBCollectionThroughputSender sends the UpdateMongoDBCollectionThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateMongoDBCollectionThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateMongoDBCollectionThroughputResponder handles the response to the UpdateMongoDBCollectionThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMongoDBDatabaseThroughput update RUs per second of the an Azure Cosmos DB MongoDB database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB +// database. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateMongoDBDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateMongoDBDatabaseThroughputPreparer prepares the UpdateMongoDBDatabaseThroughput request. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMongoDBDatabaseThroughputSender sends the UpdateMongoDBDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateMongoDBDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateMongoDBDatabaseThroughputResponder handles the response to the UpdateMongoDBDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/notebookworkspaces.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/notebookworkspaces.go new file mode 100644 index 000000000000..cbe42dd5354d --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/notebookworkspaces.go @@ -0,0 +1,750 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotebookWorkspacesClient is the client for the NotebookWorkspaces methods of the Documentdb service. +type NotebookWorkspacesClient struct { + BaseClient +} + +// NewNotebookWorkspacesClient creates an instance of the NotebookWorkspacesClient client. +func NewNotebookWorkspacesClient(subscriptionID string) NotebookWorkspacesClient { + return NewNotebookWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotebookWorkspacesClientWithBaseURI creates an instance of the NotebookWorkspacesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewNotebookWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) NotebookWorkspacesClient { + return NotebookWorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// notebookCreateUpdateParameters - the notebook workspace to create for the current database account. +func (client NotebookWorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (result NotebookWorkspacesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, notebookCreateUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotebookWorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithJSON(notebookCreateUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) CreateOrUpdateSender(req *http.Request) (future NotebookWorkspacesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client NotebookWorkspacesClient) (nw NotebookWorkspace, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + nw.Response.Response, err = future.GetResult(sender) + if nw.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && nw.Response.Response.StatusCode != http.StatusNoContent { + nw, err = client.CreateOrUpdateResponder(nw.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", nw.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotebookWorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) DeleteSender(req *http.Request) (future NotebookWorkspacesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotebookWorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) GetResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount gets the notebook workspace resources of an existing Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client NotebookWorkspacesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListByDatabaseAccountResponder(resp *http.Response) (result NotebookWorkspaceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListConnectionInfo retrieves the connection info for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceConnectionInfoResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListConnectionInfo") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListConnectionInfo", err.Error()) + } + + req, err := client.ListConnectionInfoPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure responding to request") + return + } + + return +} + +// ListConnectionInfoPreparer prepares the ListConnectionInfo request. +func (client NotebookWorkspacesClient) ListConnectionInfoPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionInfoSender sends the ListConnectionInfo request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListConnectionInfoSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionInfoResponder handles the response to the ListConnectionInfo request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListConnectionInfoResponder(resp *http.Response) (result NotebookWorkspaceConnectionInfoResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateAuthToken regenerates the auth token for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.RegenerateAuthToken") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", err.Error()) + } + + req, err := client.RegenerateAuthTokenPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateAuthTokenSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure sending request") + return + } + + return +} + +// RegenerateAuthTokenPreparer prepares the RegenerateAuthToken request. +func (client NotebookWorkspacesClient) RegenerateAuthTokenPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateAuthTokenSender sends the RegenerateAuthToken request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) RegenerateAuthTokenSender(req *http.Request) (future NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesRegenerateAuthTokenFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesRegenerateAuthTokenFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// RegenerateAuthTokenResponder handles the response to the RegenerateAuthToken request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) RegenerateAuthTokenResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Start(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Start") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client NotebookWorkspacesClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) StartSender(req *http.Request) (future NotebookWorkspacesStartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesStartFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/operations.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/operations.go new file mode 100644 index 000000000000..229d507235eb --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/operations.go @@ -0,0 +1,151 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Documentdb service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Cosmos DB Resource Provider operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DocumentDB/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeid.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeid.go new file mode 100644 index 000000000000..d8acc08e779c --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeid.go @@ -0,0 +1,144 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PartitionKeyRangeIDClient is the client for the PartitionKeyRangeID methods of the Documentdb service. +type PartitionKeyRangeIDClient struct { + BaseClient +} + +// NewPartitionKeyRangeIDClient creates an instance of the PartitionKeyRangeIDClient client. +func NewPartitionKeyRangeIDClient(subscriptionID string) PartitionKeyRangeIDClient { + return NewPartitionKeyRangeIDClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPartitionKeyRangeIDClientWithBaseURI creates an instance of the PartitionKeyRangeIDClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPartitionKeyRangeIDClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDClient { + return PartitionKeyRangeIDClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// partitionKeyRangeID - partition Key Range Id for which to get data. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PartitionKeyRangeIDClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PartitionKeyRangeIDClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, partitionKeyRangeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PartitionKeyRangeIDClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client PartitionKeyRangeIDClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PartitionKeyRangeIDClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeidregion.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeidregion.go new file mode 100644 index 000000000000..cf3021bdf45d --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/partitionkeyrangeidregion.go @@ -0,0 +1,146 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PartitionKeyRangeIDRegionClient is the client for the PartitionKeyRangeIDRegion methods of the Documentdb service. +type PartitionKeyRangeIDRegionClient struct { + BaseClient +} + +// NewPartitionKeyRangeIDRegionClient creates an instance of the PartitionKeyRangeIDRegionClient client. +func NewPartitionKeyRangeIDRegionClient(subscriptionID string) PartitionKeyRangeIDRegionClient { + return NewPartitionKeyRangeIDRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPartitionKeyRangeIDRegionClientWithBaseURI creates an instance of the PartitionKeyRangeIDRegionClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPartitionKeyRangeIDRegionClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDRegionClient { + return PartitionKeyRangeIDRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id and region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// partitionKeyRangeID - partition Key Range Id for which to get data. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PartitionKeyRangeIDRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, partitionKeyRangeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PartitionKeyRangeIDRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client PartitionKeyRangeIDRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PartitionKeyRangeIDRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentile.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentile.go new file mode 100644 index 000000000000..9eebdeea304b --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentile.go @@ -0,0 +1,138 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileClient is the client for the Percentile methods of the Documentdb service. +type PercentileClient struct { + BaseClient +} + +// NewPercentileClient creates an instance of the PercentileClient client. +func NewPercentileClient(subscriptionID string) PercentileClient { + return NewPercentileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileClientWithBaseURI creates an instance of the PercentileClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPercentileClientWithBaseURI(baseURI string, subscriptionID string) PercentileClient { + return PercentileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account. This url is only +// for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client PercentileClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentilesourcetarget.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentilesourcetarget.go new file mode 100644 index 000000000000..426d6a809c91 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentilesourcetarget.go @@ -0,0 +1,145 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileSourceTargetClient is the client for the PercentileSourceTarget methods of the Documentdb service. +type PercentileSourceTargetClient struct { + BaseClient +} + +// NewPercentileSourceTargetClient creates an instance of the PercentileSourceTargetClient client. +func NewPercentileSourceTargetClient(subscriptionID string) PercentileSourceTargetClient { + return NewPercentileSourceTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileSourceTargetClientWithBaseURI creates an instance of the PercentileSourceTargetClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewPercentileSourceTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileSourceTargetClient { + return PercentileSourceTargetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given account, source and target region. +// This url is only for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// sourceRegion - source region from which data is written. Cosmos DB region, with spaces between words and +// each word capitalized. +// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each +// word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileSourceTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileSourceTargetClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileSourceTargetClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, sourceRegion, targetRegion, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileSourceTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceRegion": autorest.Encode("path", sourceRegion), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetRegion": autorest.Encode("path", targetRegion), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client PercentileSourceTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileSourceTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentiletarget.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentiletarget.go new file mode 100644 index 000000000000..6604f497b6bd --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/percentiletarget.go @@ -0,0 +1,142 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileTargetClient is the client for the PercentileTarget methods of the Documentdb service. +type PercentileTargetClient struct { + BaseClient +} + +// NewPercentileTargetClient creates an instance of the PercentileTargetClient client. +func NewPercentileTargetClient(subscriptionID string) PercentileTargetClient { + return NewPercentileTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileTargetClientWithBaseURI creates an instance of the PercentileTargetClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPercentileTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileTargetClient { + return PercentileTargetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given account target region. This url is +// only for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each +// word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileTargetClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileTargetClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, targetRegion, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetRegion": autorest.Encode("path", targetRegion), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client PercentileTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privateendpointconnections.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privateendpointconnections.go new file mode 100644 index 000000000000..f3972324bbef --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privateendpointconnections.go @@ -0,0 +1,451 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the client for the PrivateEndpointConnections methods of the Documentdb service. +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + pec.Response.Response, err = future.GetResult(sender) + if pec.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount list all private endpoint connections on a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateEndpointConnectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privatelinkresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privatelinkresources.go new file mode 100644 index 000000000000..47d634029d7b --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/privatelinkresources.go @@ -0,0 +1,226 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the client for the PrivateLinkResources methods of the Documentdb service. +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the private link resources that need to be created for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount gets the private link resources that need to be created for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorabledatabaseaccounts.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorabledatabaseaccounts.go new file mode 100644 index 000000000000..a87e60a6f8f7 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorabledatabaseaccounts.go @@ -0,0 +1,286 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableDatabaseAccountsClient is the client for the RestorableDatabaseAccounts methods of the Documentdb service. +type RestorableDatabaseAccountsClient struct { + BaseClient +} + +// NewRestorableDatabaseAccountsClient creates an instance of the RestorableDatabaseAccountsClient client. +func NewRestorableDatabaseAccountsClient(subscriptionID string) RestorableDatabaseAccountsClient { + return NewRestorableDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDatabaseAccountsClientWithBaseURI creates an instance of the RestorableDatabaseAccountsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) RestorableDatabaseAccountsClient { + return RestorableDatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByLocation retrieves the properties of an existing Azure Cosmos DB restorable database account. This call +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableDatabaseAccountsClient) GetByLocation(ctx context.Context, location string, instanceID string) (result RestorableDatabaseAccountGetResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.GetByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "GetByLocation", err.Error()) + } + + req, err := client.GetByLocationPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.GetByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure sending request") + return + } + + result, err = client.GetByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure responding to request") + return + } + + return +} + +// GetByLocationPreparer prepares the GetByLocation request. +func (client RestorableDatabaseAccountsClient) GetByLocationPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByLocationSender sends the GetByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDatabaseAccountsClient) GetByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByLocationResponder handles the response to the GetByLocation request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) GetByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountGetResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the restorable Azure Cosmos DB database accounts available under the subscription. This call requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. +func (client RestorableDatabaseAccountsClient) List(ctx context.Context) (result RestorableDatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableDatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) ListResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a +// region. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +func (client RestorableDatabaseAccountsClient) ListByLocation(ctx context.Context, location string) (result RestorableDatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "ListByLocation", err.Error()) + } + + req, err := client.ListByLocationPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client RestorableDatabaseAccountsClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDatabaseAccountsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) ListByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbcollections.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbcollections.go new file mode 100644 index 000000000000..5cea06281fc8 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbcollections.go @@ -0,0 +1,133 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbCollectionsClient is the client for the RestorableMongodbCollections methods of the Documentdb +// service. +type RestorableMongodbCollectionsClient struct { + BaseClient +} + +// NewRestorableMongodbCollectionsClient creates an instance of the RestorableMongodbCollectionsClient client. +func NewRestorableMongodbCollectionsClient(subscriptionID string) RestorableMongodbCollectionsClient { + return NewRestorableMongodbCollectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbCollectionsClientWithBaseURI creates an instance of the RestorableMongodbCollectionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRestorableMongodbCollectionsClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbCollectionsClient { + return RestorableMongodbCollectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific +// database. This helps in scenario where container was accidentally deleted. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restorableMongodbDatabaseRid - the resource ID of the MongoDB database. +func (client RestorableMongodbCollectionsClient) List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result RestorableMongodbCollectionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbCollectionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbCollectionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restorableMongodbDatabaseRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbCollectionsClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restorableMongodbDatabaseRid) > 0 { + queryParameters["restorableMongodbDatabaseRid"] = autorest.Encode("query", restorableMongodbDatabaseRid) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableMongodbCollectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbCollectionsClient) ListResponder(resp *http.Response) (result RestorableMongodbCollectionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbdatabases.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbdatabases.go new file mode 100644 index 000000000000..62234763bcee --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbdatabases.go @@ -0,0 +1,128 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbDatabasesClient is the client for the RestorableMongodbDatabases methods of the Documentdb service. +type RestorableMongodbDatabasesClient struct { + BaseClient +} + +// NewRestorableMongodbDatabasesClient creates an instance of the RestorableMongodbDatabasesClient client. +func NewRestorableMongodbDatabasesClient(subscriptionID string) RestorableMongodbDatabasesClient { + return NewRestorableMongodbDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbDatabasesClientWithBaseURI creates an instance of the RestorableMongodbDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableMongodbDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbDatabasesClient { + return RestorableMongodbDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB databases under the restorable +// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableMongodbDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableMongodbDatabasesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbDatabasesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbDatabasesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableMongodbDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbDatabasesClient) ListResponder(resp *http.Response) (result RestorableMongodbDatabasesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbresources.go new file mode 100644 index 000000000000..0ca4cd337c8a --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablemongodbresources.go @@ -0,0 +1,136 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbResourcesClient is the client for the RestorableMongodbResources methods of the Documentdb service. +type RestorableMongodbResourcesClient struct { + BaseClient +} + +// NewRestorableMongodbResourcesClient creates an instance of the RestorableMongodbResourcesClient client. +func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient { + return NewRestorableMongodbResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbResourcesClientWithBaseURI creates an instance of the RestorableMongodbResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient { + return RestorableMongodbResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List return a list of database and collection combo that exist on the account at the given timestamp and location. +// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restoreLocation - the location where the restorable resources are located. +// restoreTimestampInUtc - the timestamp when the restorable resources existed. +func (client RestorableMongodbResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableMongodbResourcesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbResourcesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restoreLocation) > 0 { + queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) + } + if len(restoreTimestampInUtc) > 0 { + queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableMongodbResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbResourcesClient) ListResponder(resp *http.Response) (result RestorableMongodbResourcesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlcontainers.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlcontainers.go new file mode 100644 index 000000000000..420fb47cbe24 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlcontainers.go @@ -0,0 +1,132 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLContainersClient is the client for the RestorableSQLContainers methods of the Documentdb service. +type RestorableSQLContainersClient struct { + BaseClient +} + +// NewRestorableSQLContainersClient creates an instance of the RestorableSQLContainersClient client. +func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient { + return NewRestorableSQLContainersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLContainersClientWithBaseURI creates an instance of the RestorableSQLContainersClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient { + return RestorableSQLContainersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB SQL containers under a specific database. +// This helps in scenario where container was accidentally deleted. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restorableSQLDatabaseRid - the resource ID of the SQL database. +func (client RestorableSQLContainersClient) List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string) (result RestorableSQLContainersListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLContainersClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLContainersClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restorableSQLDatabaseRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLContainersClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restorableSQLDatabaseRid) > 0 { + queryParameters["restorableSqlDatabaseRid"] = autorest.Encode("query", restorableSQLDatabaseRid) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableSQLContainersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLContainersClient) ListResponder(resp *http.Response) (result RestorableSQLContainersListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqldatabases.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqldatabases.go new file mode 100644 index 000000000000..7d1da4469361 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqldatabases.go @@ -0,0 +1,128 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLDatabasesClient is the client for the RestorableSQLDatabases methods of the Documentdb service. +type RestorableSQLDatabasesClient struct { + BaseClient +} + +// NewRestorableSQLDatabasesClient creates an instance of the RestorableSQLDatabasesClient client. +func NewRestorableSQLDatabasesClient(subscriptionID string) RestorableSQLDatabasesClient { + return NewRestorableSQLDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLDatabasesClientWithBaseURI creates an instance of the RestorableSQLDatabasesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLDatabasesClient { + return RestorableSQLDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB SQL databases under the restorable +// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableSQLDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableSQLDatabasesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLDatabasesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLDatabasesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableSQLDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLDatabasesClient) ListResponder(resp *http.Response) (result RestorableSQLDatabasesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlresources.go new file mode 100644 index 000000000000..1f49a783e9ae --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/restorablesqlresources.go @@ -0,0 +1,136 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLResourcesClient is the client for the RestorableSQLResources methods of the Documentdb service. +type RestorableSQLResourcesClient struct { + BaseClient +} + +// NewRestorableSQLResourcesClient creates an instance of the RestorableSQLResourcesClient client. +func NewRestorableSQLResourcesClient(subscriptionID string) RestorableSQLResourcesClient { + return NewRestorableSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLResourcesClientWithBaseURI creates an instance of the RestorableSQLResourcesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLResourcesClient { + return RestorableSQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List return a list of database and container combo that exist on the account at the given timestamp and location. +// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restoreLocation - the location where the restorable resources are located. +// restoreTimestampInUtc - the timestamp when the restorable resources existed. +func (client RestorableSQLResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableSQLResourcesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLResourcesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restoreLocation) > 0 { + queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) + } + if len(restoreTimestampInUtc) > 0 { + queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableSQLResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLResourcesClient) ListResponder(resp *http.Response) (result RestorableSQLResourcesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/sqlresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/sqlresources.go new file mode 100644 index 000000000000..e0ccab3bb586 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/sqlresources.go @@ -0,0 +1,3904 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SQLResourcesClient is the client for the SQLResources methods of the Documentdb service. +type SQLResourcesClient struct { + BaseClient +} + +// NewSQLResourcesClient creates an instance of the SQLResourcesClient client. +func NewSQLResourcesClient(subscriptionID string) SQLResourcesClient { + return NewSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSQLResourcesClientWithBaseURI creates an instance of the SQLResourcesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) SQLResourcesClient { + return SQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateSQLContainer create or update an Azure Cosmos DB SQL container +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// createUpdateSQLContainerParameters - the parameters to provide for the current SQL container. +func (client SQLResourcesClient) CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLContainerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLContainer") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLContainerParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, + {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", err.Error()) + } + + req, err := client.CreateUpdateSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, createUpdateSQLContainerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLContainerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLContainerPreparer prepares the CreateUpdateSQLContainer request. +func (client SQLResourcesClient) CreateUpdateSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithJSON(createUpdateSQLContainerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLContainerSender sends the CreateUpdateSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLContainerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLContainerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (scgr SQLContainerGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLContainerFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + scgr.Response.Response, err = future.GetResult(sender) + if scgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", nil, "received nil response and error") + } + if err == nil && scgr.Response.Response.StatusCode != http.StatusNoContent { + scgr, err = client.CreateUpdateSQLContainerResponder(scgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", scgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLContainerResponder handles the response to the CreateUpdateSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLDatabase create or update an Azure Cosmos DB SQL database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateSQLDatabaseParameters - the parameters to provide for the current SQL database. +func (client SQLResourcesClient) CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", err.Error()) + } + + req, err := client.CreateUpdateSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateSQLDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLDatabasePreparer prepares the CreateUpdateSQLDatabase request. +func (client SQLResourcesClient) CreateUpdateSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateSQLDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLDatabaseSender sends the CreateUpdateSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLDatabaseSender(req *http.Request) (future SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (sdgr SQLDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + sdgr.Response.Response, err = future.GetResult(sender) + if sdgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", nil, "received nil response and error") + } + if err == nil && sdgr.Response.Response.StatusCode != http.StatusNoContent { + sdgr, err = client.CreateUpdateSQLDatabaseResponder(sdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", sdgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLDatabaseResponder handles the response to the CreateUpdateSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLRoleAssignment creates or updates an Azure Cosmos DB SQL Role Assignment. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateSQLRoleAssignmentParameters - the properties required to create or update a Role Assignment. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleAssignment") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", err.Error()) + } + + req, err := client.CreateUpdateSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName, createUpdateSQLRoleAssignmentParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLRoleAssignmentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLRoleAssignmentPreparer prepares the CreateUpdateSQLRoleAssignment request. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithJSON(createUpdateSQLRoleAssignmentParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLRoleAssignmentSender sends the CreateUpdateSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (sragr SQLRoleAssignmentGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + sragr.Response.Response, err = future.GetResult(sender) + if sragr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", nil, "received nil response and error") + } + if err == nil && sragr.Response.Response.StatusCode != http.StatusNoContent { + sragr, err = client.CreateUpdateSQLRoleAssignmentResponder(sragr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", sragr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLRoleAssignmentResponder handles the response to the CreateUpdateSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLRoleDefinition creates or updates an Azure Cosmos DB SQL Role Definition. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateSQLRoleDefinitionParameters - the properties required to create or update a Role Definition. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleDefinition") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", err.Error()) + } + + req, err := client.CreateUpdateSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName, createUpdateSQLRoleDefinitionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLRoleDefinitionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLRoleDefinitionPreparer prepares the CreateUpdateSQLRoleDefinition request. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithJSON(createUpdateSQLRoleDefinitionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLRoleDefinitionSender sends the CreateUpdateSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (srdgr SQLRoleDefinitionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + srdgr.Response.Response, err = future.GetResult(sender) + if srdgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", nil, "received nil response and error") + } + if err == nil && srdgr.Response.Response.StatusCode != http.StatusNoContent { + srdgr, err = client.CreateUpdateSQLRoleDefinitionResponder(srdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", srdgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLRoleDefinitionResponder handles the response to the CreateUpdateSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLStoredProcedure create or update an Azure Cosmos DB SQL storedProcedure +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +// createUpdateSQLStoredProcedureParameters - the parameters to provide for the current SQL storedProcedure. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLStoredProcedure") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLStoredProcedureParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", err.Error()) + } + + req, err := client.CreateUpdateSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSQLStoredProcedureParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLStoredProcedureSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLStoredProcedurePreparer prepares the CreateUpdateSQLStoredProcedure request. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithJSON(createUpdateSQLStoredProcedureParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLStoredProcedureSender sends the CreateUpdateSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureSender(req *http.Request) (future SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (sspgr SQLStoredProcedureGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + sspgr.Response.Response, err = future.GetResult(sender) + if sspgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", nil, "received nil response and error") + } + if err == nil && sspgr.Response.Response.StatusCode != http.StatusNoContent { + sspgr, err = client.CreateUpdateSQLStoredProcedureResponder(sspgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", sspgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLStoredProcedureResponder handles the response to the CreateUpdateSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLTrigger create or update an Azure Cosmos DB SQL trigger +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +// createUpdateSQLTriggerParameters - the parameters to provide for the current SQL trigger. +func (client SQLResourcesClient) CreateUpdateSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLTriggerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLTrigger") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLTriggerParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", err.Error()) + } + + req, err := client.CreateUpdateSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSQLTriggerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLTriggerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLTriggerPreparer prepares the CreateUpdateSQLTrigger request. +func (client SQLResourcesClient) CreateUpdateSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithJSON(createUpdateSQLTriggerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLTriggerSender sends the CreateUpdateSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLTriggerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLTriggerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (stgr SQLTriggerGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLTriggerFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + stgr.Response.Response, err = future.GetResult(sender) + if stgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", nil, "received nil response and error") + } + if err == nil && stgr.Response.Response.StatusCode != http.StatusNoContent { + stgr, err = client.CreateUpdateSQLTriggerResponder(stgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", stgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLTriggerResponder handles the response to the CreateUpdateSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLUserDefinedFunction create or update an Azure Cosmos DB SQL userDefinedFunction +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +// createUpdateSQLUserDefinedFunctionParameters - the parameters to provide for the current SQL +// userDefinedFunction. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLUserDefinedFunctionParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", err.Error()) + } + + req, err := client.CreateUpdateSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSQLUserDefinedFunctionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLUserDefinedFunctionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLUserDefinedFunctionPreparer prepares the CreateUpdateSQLUserDefinedFunction request. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithJSON(createUpdateSQLUserDefinedFunctionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLUserDefinedFunctionSender sends the CreateUpdateSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (sudfgr SQLUserDefinedFunctionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + sudfgr.Response.Response, err = future.GetResult(sender) + if sudfgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", nil, "received nil response and error") + } + if err == nil && sudfgr.Response.Response.StatusCode != http.StatusNoContent { + sudfgr, err = client.CreateUpdateSQLUserDefinedFunctionResponder(sudfgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", sudfgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateSQLUserDefinedFunctionResponder handles the response to the CreateUpdateSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteSQLContainer deletes an existing Azure Cosmos DB SQL container. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesDeleteSQLContainerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLContainer") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLContainer", err.Error()) + } + + req, err := client.DeleteSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLContainerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLContainerPreparer prepares the DeleteSQLContainer request. +func (client SQLResourcesClient) DeleteSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLContainerSender sends the DeleteSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLContainerSender(req *http.Request) (future SQLResourcesDeleteSQLContainerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLContainerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLContainerFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLContainerResponder handles the response to the DeleteSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLContainerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLDatabase deletes an existing Azure Cosmos DB SQL database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesDeleteSQLDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLDatabase", err.Error()) + } + + req, err := client.DeleteSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLDatabasePreparer prepares the DeleteSQLDatabase request. +func (client SQLResourcesClient) DeleteSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLDatabaseSender sends the DeleteSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLDatabaseSender(req *http.Request) (future SQLResourcesDeleteSQLDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLDatabaseFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLDatabaseResponder handles the response to the DeleteSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLRoleAssignment deletes an existing Azure Cosmos DB SQL Role Assignment. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) DeleteSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleAssignment") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", err.Error()) + } + + req, err := client.DeleteSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLRoleAssignmentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLRoleAssignmentPreparer prepares the DeleteSQLRoleAssignment request. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLRoleAssignmentSender sends the DeleteSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLRoleAssignmentResponder handles the response to the DeleteSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLRoleDefinition deletes an existing Azure Cosmos DB SQL Role Definition. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) DeleteSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleDefinition") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", err.Error()) + } + + req, err := client.DeleteSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLRoleDefinitionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLRoleDefinitionPreparer prepares the DeleteSQLRoleDefinition request. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLRoleDefinitionSender sends the DeleteSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLRoleDefinitionResponder handles the response to the DeleteSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLStoredProcedure deletes an existing Azure Cosmos DB SQL storedProcedure. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +func (client SQLResourcesClient) DeleteSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLResourcesDeleteSQLStoredProcedureFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLStoredProcedure") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", err.Error()) + } + + req, err := client.DeleteSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLStoredProcedureSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLStoredProcedurePreparer prepares the DeleteSQLStoredProcedure request. +func (client SQLResourcesClient) DeleteSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLStoredProcedureSender sends the DeleteSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLStoredProcedureSender(req *http.Request) (future SQLResourcesDeleteSQLStoredProcedureFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLStoredProcedureFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLStoredProcedureResponder handles the response to the DeleteSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLStoredProcedureResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLTrigger deletes an existing Azure Cosmos DB SQL trigger. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +func (client SQLResourcesClient) DeleteSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLResourcesDeleteSQLTriggerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLTrigger") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLTrigger", err.Error()) + } + + req, err := client.DeleteSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLTriggerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLTriggerPreparer prepares the DeleteSQLTrigger request. +func (client SQLResourcesClient) DeleteSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLTriggerSender sends the DeleteSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLTriggerSender(req *http.Request) (future SQLResourcesDeleteSQLTriggerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLTriggerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLTriggerFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLTriggerResponder handles the response to the DeleteSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLTriggerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLUserDefinedFunction deletes an existing Azure Cosmos DB SQL userDefinedFunction. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", err.Error()) + } + + req, err := client.DeleteSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLUserDefinedFunctionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLUserDefinedFunctionPreparer prepares the DeleteSQLUserDefinedFunction request. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLUserDefinedFunctionSender sends the DeleteSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteSQLUserDefinedFunctionResponder handles the response to the DeleteSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetSQLContainer gets the SQL container under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLContainerGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainer", err.Error()) + } + + req, err := client.GetSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLContainerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure sending request") + return + } + + result, err = client.GetSQLContainerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLContainerPreparer prepares the GetSQLContainer request. +func (client SQLResourcesClient) GetSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLContainerSender sends the GetSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLContainerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLContainerResponder handles the response to the GetSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLContainerThroughput gets the RUs per second of the SQL container under an existing Azure Cosmos DB database +// account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainerThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainerThroughput", err.Error()) + } + + req, err := client.GetSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLContainerThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetSQLContainerThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLContainerThroughputPreparer prepares the GetSQLContainerThroughput request. +func (client SQLResourcesClient) GetSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLContainerThroughputSender sends the GetSQLContainerThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLContainerThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLContainerThroughputResponder handles the response to the GetSQLContainerThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLDatabase gets the SQL database under an existing Azure Cosmos DB database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabase", err.Error()) + } + + req, err := client.GetSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetSQLDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLDatabasePreparer prepares the GetSQLDatabase request. +func (client SQLResourcesClient) GetSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLDatabaseSender sends the GetSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLDatabaseResponder handles the response to the GetSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLDatabaseThroughput gets the RUs per second of the SQL database under an existing Azure Cosmos DB database +// account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", err.Error()) + } + + req, err := client.GetSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetSQLDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLDatabaseThroughputPreparer prepares the GetSQLDatabaseThroughput request. +func (client SQLResourcesClient) GetSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLDatabaseThroughputSender sends the GetSQLDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLDatabaseThroughputResponder handles the response to the GetSQLDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLRoleAssignment retrieves the properties of an existing Azure Cosmos DB SQL Role Assignment with the given Id. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) GetSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLRoleAssignmentGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleAssignment", err.Error()) + } + + req, err := client.GetSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLRoleAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure sending request") + return + } + + result, err = client.GetSQLRoleAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLRoleAssignmentPreparer prepares the GetSQLRoleAssignment request. +func (client SQLResourcesClient) GetSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLRoleAssignmentSender sends the GetSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLRoleAssignmentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLRoleAssignmentResponder handles the response to the GetSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLRoleDefinition retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) GetSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLRoleDefinitionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleDefinition", err.Error()) + } + + req, err := client.GetSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLRoleDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure sending request") + return + } + + result, err = client.GetSQLRoleDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLRoleDefinitionPreparer prepares the GetSQLRoleDefinition request. +func (client SQLResourcesClient) GetSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLRoleDefinitionSender sends the GetSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLRoleDefinitionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLRoleDefinitionResponder handles the response to the GetSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLStoredProcedure gets the SQL storedProcedure under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +func (client SQLResourcesClient) GetSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLStoredProcedureGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLStoredProcedure") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLStoredProcedure", err.Error()) + } + + req, err := client.GetSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLStoredProcedureSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure sending request") + return + } + + result, err = client.GetSQLStoredProcedureResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLStoredProcedurePreparer prepares the GetSQLStoredProcedure request. +func (client SQLResourcesClient) GetSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLStoredProcedureSender sends the GetSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLStoredProcedureSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLStoredProcedureResponder handles the response to the GetSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLTrigger gets the SQL trigger under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +func (client SQLResourcesClient) GetSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLTriggerGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLTrigger") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLTrigger", err.Error()) + } + + req, err := client.GetSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLTriggerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure sending request") + return + } + + result, err = client.GetSQLTriggerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLTriggerPreparer prepares the GetSQLTrigger request. +func (client SQLResourcesClient) GetSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLTriggerSender sends the GetSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLTriggerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLTriggerResponder handles the response to the GetSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLUserDefinedFunction gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +func (client SQLResourcesClient) GetSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLUserDefinedFunctionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", err.Error()) + } + + req, err := client.GetSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLUserDefinedFunctionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure sending request") + return + } + + result, err = client.GetSQLUserDefinedFunctionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLUserDefinedFunctionPreparer prepares the GetSQLUserDefinedFunction request. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLUserDefinedFunctionSender sends the GetSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLUserDefinedFunctionResponder handles the response to the GetSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLContainers lists the SQL container under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLContainerListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLContainers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLContainers", err.Error()) + } + + req, err := client.ListSQLContainersPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure sending request") + return + } + + result, err = client.ListSQLContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLContainersPreparer prepares the ListSQLContainers request. +func (client SQLResourcesClient) ListSQLContainersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLContainersSender sends the ListSQLContainers request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLContainersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLContainersResponder handles the response to the ListSQLContainers request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLContainersResponder(resp *http.Response) (result SQLContainerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLDatabases lists the SQL databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result SQLDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLDatabases", err.Error()) + } + + req, err := client.ListSQLDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListSQLDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLDatabasesPreparer prepares the ListSQLDatabases request. +func (client SQLResourcesClient) ListSQLDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLDatabasesSender sends the ListSQLDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLDatabasesResponder handles the response to the ListSQLDatabases request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLDatabasesResponder(resp *http.Response) (result SQLDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLRoleAssignments retrieves the list of all Azure Cosmos DB SQL Role Assignments. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLRoleAssignments(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleAssignments") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleAssignments", err.Error()) + } + + req, err := client.ListSQLRoleAssignmentsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLRoleAssignmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure sending request") + return + } + + result, err = client.ListSQLRoleAssignmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLRoleAssignmentsPreparer prepares the ListSQLRoleAssignments request. +func (client SQLResourcesClient) ListSQLRoleAssignmentsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLRoleAssignmentsSender sends the ListSQLRoleAssignments request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLRoleAssignmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLRoleAssignmentsResponder handles the response to the ListSQLRoleAssignments request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLRoleAssignmentsResponder(resp *http.Response) (result SQLRoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLRoleDefinitions retrieves the list of all Azure Cosmos DB SQL Role Definitions. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLRoleDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", err.Error()) + } + + req, err := client.ListSQLRoleDefinitionsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLRoleDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListSQLRoleDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLRoleDefinitionsPreparer prepares the ListSQLRoleDefinitions request. +func (client SQLResourcesClient) ListSQLRoleDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLRoleDefinitionsSender sends the ListSQLRoleDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLRoleDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLRoleDefinitionsResponder handles the response to the ListSQLRoleDefinitions request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLRoleDefinitionsResponder(resp *http.Response) (result SQLRoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLStoredProcedures lists the SQL storedProcedure under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLStoredProcedures(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLStoredProcedureListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLStoredProcedures") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLStoredProcedures", err.Error()) + } + + req, err := client.ListSQLStoredProceduresPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLStoredProceduresSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure sending request") + return + } + + result, err = client.ListSQLStoredProceduresResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLStoredProceduresPreparer prepares the ListSQLStoredProcedures request. +func (client SQLResourcesClient) ListSQLStoredProceduresPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLStoredProceduresSender sends the ListSQLStoredProcedures request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLStoredProceduresSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLStoredProceduresResponder handles the response to the ListSQLStoredProcedures request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLStoredProceduresResponder(resp *http.Response) (result SQLStoredProcedureListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLTriggers lists the SQL trigger under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLTriggers(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLTriggerListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLTriggers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLTriggers", err.Error()) + } + + req, err := client.ListSQLTriggersPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLTriggersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure sending request") + return + } + + result, err = client.ListSQLTriggersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLTriggersPreparer prepares the ListSQLTriggers request. +func (client SQLResourcesClient) ListSQLTriggersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLTriggersSender sends the ListSQLTriggers request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLTriggersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLTriggersResponder handles the response to the ListSQLTriggers request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLTriggersResponder(resp *http.Response) (result SQLTriggerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLUserDefinedFunctions lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLUserDefinedFunctions(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLUserDefinedFunctionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLUserDefinedFunctions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", err.Error()) + } + + req, err := client.ListSQLUserDefinedFunctionsPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLUserDefinedFunctionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure sending request") + return + } + + result, err = client.ListSQLUserDefinedFunctionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLUserDefinedFunctionsPreparer prepares the ListSQLUserDefinedFunctions request. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLUserDefinedFunctionsSender sends the ListSQLUserDefinedFunctions request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLUserDefinedFunctionsResponder handles the response to the ListSQLUserDefinedFunctions request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsResponder(resp *http.Response) (result SQLUserDefinedFunctionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLContainerToAutoscale migrate an Azure Cosmos DB SQL container from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", err.Error()) + } + + req, err := client.MigrateSQLContainerToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLContainerToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLContainerToAutoscalePreparer prepares the MigrateSQLContainerToAutoscale request. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLContainerToAutoscaleSender sends the MigrateSQLContainerToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLContainerToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateSQLContainerToAutoscaleResponder handles the response to the MigrateSQLContainerToAutoscale request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLContainerToManualThroughput migrate an Azure Cosmos DB SQL container from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", err.Error()) + } + + req, err := client.MigrateSQLContainerToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLContainerToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLContainerToManualThroughputPreparer prepares the MigrateSQLContainerToManualThroughput request. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLContainerToManualThroughputSender sends the MigrateSQLContainerToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLContainerToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateSQLContainerToManualThroughputResponder handles the response to the MigrateSQLContainerToManualThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLDatabaseToAutoscale migrate an Azure Cosmos DB SQL database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateSQLDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLDatabaseToAutoscalePreparer prepares the MigrateSQLDatabaseToAutoscale request. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLDatabaseToAutoscaleSender sends the MigrateSQLDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateSQLDatabaseToAutoscaleResponder handles the response to the MigrateSQLDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLDatabaseToManualThroughput migrate an Azure Cosmos DB SQL database from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateSQLDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLDatabaseToManualThroughputPreparer prepares the MigrateSQLDatabaseToManualThroughput request. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLDatabaseToManualThroughputSender sends the MigrateSQLDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateSQLDatabaseToManualThroughputResponder handles the response to the MigrateSQLDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSQLContainerThroughput update RUs per second of an Azure Cosmos DB SQL container +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL container. +func (client SQLResourcesClient) UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLContainerThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLContainerThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", err.Error()) + } + + req, err := client.UpdateSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSQLContainerThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateSQLContainerThroughputPreparer prepares the UpdateSQLContainerThroughput request. +func (client SQLResourcesClient) UpdateSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSQLContainerThroughputSender sends the UpdateSQLContainerThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) UpdateSQLContainerThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLContainerThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLContainerThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateSQLContainerThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateSQLContainerThroughputResponder handles the response to the UpdateSQLContainerThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) UpdateSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSQLDatabaseThroughput update RUs per second of an Azure Cosmos DB SQL database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL database. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSQLDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateSQLDatabaseThroughputPreparer prepares the UpdateSQLDatabaseThroughput request. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSQLDatabaseThroughputSender sends the UpdateSQLDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateSQLDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateSQLDatabaseThroughputResponder handles the response to the UpdateSQLDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/tableresources.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/tableresources.go new file mode 100644 index 000000000000..89c3f8b1d1fc --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/tableresources.go @@ -0,0 +1,910 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TableResourcesClient is the client for the TableResources methods of the Documentdb service. +type TableResourcesClient struct { + BaseClient +} + +// NewTableResourcesClient creates an instance of the TableResourcesClient client. +func NewTableResourcesClient(subscriptionID string) TableResourcesClient { + return NewTableResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTableResourcesClientWithBaseURI creates an instance of the TableResourcesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) TableResourcesClient { + return TableResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateTable create or update an Azure Cosmos DB Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +// createUpdateTableParameters - the parameters to provide for the current Table. +func (client TableResourcesClient) CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (result TableResourcesCreateUpdateTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.CreateUpdateTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateTableParameters, + Constraints: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "CreateUpdateTable", err.Error()) + } + + req, err := client.CreateUpdateTablePreparer(ctx, resourceGroupName, accountName, tableName, createUpdateTableParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateTablePreparer prepares the CreateUpdateTable request. +func (client TableResourcesClient) CreateUpdateTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithJSON(createUpdateTableParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateTableSender sends the CreateUpdateTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) CreateUpdateTableSender(req *http.Request) (future TableResourcesCreateUpdateTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client TableResourcesClient) (tgr TableGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesCreateUpdateTableFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tgr.Response.Response, err = future.GetResult(sender) + if tgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", nil, "received nil response and error") + } + if err == nil && tgr.Response.Response.StatusCode != http.StatusNoContent { + tgr, err = client.CreateUpdateTableResponder(tgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", tgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateUpdateTableResponder handles the response to the CreateUpdateTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) CreateUpdateTableResponder(resp *http.Response) (result TableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteTable deletes an existing Azure Cosmos DB Table. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesDeleteTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.DeleteTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "DeleteTable", err.Error()) + } + + req, err := client.DeleteTablePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure preparing request") + return + } + + result, err = client.DeleteTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure sending request") + return + } + + return +} + +// DeleteTablePreparer prepares the DeleteTable request. +func (client TableResourcesClient) DeleteTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteTableSender sends the DeleteTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) DeleteTableSender(req *http.Request) (future TableResourcesDeleteTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client TableResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesDeleteTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesDeleteTableFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteTableResponder handles the response to the DeleteTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) DeleteTableResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetTable gets the Tables under an existing Azure Cosmos DB database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTable") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "GetTable", err.Error()) + } + + req, err := client.GetTablePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", nil, "Failure preparing request") + return + } + + resp, err := client.GetTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure sending request") + return + } + + result, err = client.GetTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure responding to request") + return + } + + return +} + +// GetTablePreparer prepares the GetTable request. +func (client TableResourcesClient) GetTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTableSender sends the GetTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) GetTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetTableResponder handles the response to the GetTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) GetTableResponder(resp *http.Response) (result TableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTableThroughput gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the +// provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTableThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "GetTableThroughput", err.Error()) + } + + req, err := client.GetTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetTableThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetTableThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetTableThroughputPreparer prepares the GetTableThroughput request. +func (client TableResourcesClient) GetTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTableThroughputSender sends the GetTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) GetTableThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetTableThroughputResponder handles the response to the GetTableThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) GetTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListTables lists the Tables under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client TableResourcesClient) ListTables(ctx context.Context, resourceGroupName string, accountName string) (result TableListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.ListTables") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "ListTables", err.Error()) + } + + req, err := client.ListTablesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", nil, "Failure preparing request") + return + } + + resp, err := client.ListTablesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure sending request") + return + } + + result, err = client.ListTablesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure responding to request") + return + } + + return +} + +// ListTablesPreparer prepares the ListTables request. +func (client TableResourcesClient) ListTablesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListTablesSender sends the ListTables request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) ListTablesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListTablesResponder handles the response to the ListTables request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) ListTablesResponder(resp *http.Response) (result TableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateTableToAutoscale migrate an Azure Cosmos DB Table from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) MigrateTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToAutoscale", err.Error()) + } + + req, err := client.MigrateTableToAutoscalePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateTableToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateTableToAutoscalePreparer prepares the MigrateTableToAutoscale request. +func (client TableResourcesClient) MigrateTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateTableToAutoscaleSender sends the MigrateTableToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) MigrateTableToAutoscaleSender(req *http.Request) (future TableResourcesMigrateTableToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateTableToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateTableToAutoscaleResponder handles the response to the MigrateTableToAutoscale request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) MigrateTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateTableToManualThroughput migrate an Azure Cosmos DB Table from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) MigrateTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToManualThroughput", err.Error()) + } + + req, err := client.MigrateTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateTableToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateTableToManualThroughputPreparer prepares the MigrateTableToManualThroughput request. +func (client TableResourcesClient) MigrateTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateTableToManualThroughputSender sends the MigrateTableToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) MigrateTableToManualThroughputSender(req *http.Request) (future TableResourcesMigrateTableToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateTableToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// MigrateTableToManualThroughputResponder handles the response to the MigrateTableToManualThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) MigrateTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateTableThroughput update RUs per second of an Azure Cosmos DB Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current Table. +func (client TableResourcesClient) UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result TableResourcesUpdateTableThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.UpdateTableThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "UpdateTableThroughput", err.Error()) + } + + req, err := client.UpdateTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateTableThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateTableThroughputPreparer prepares the UpdateTableThroughput request. +func (client TableResourcesClient) UpdateTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTableThroughputSender sends the UpdateTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) UpdateTableThroughputSender(req *http.Request) (future TableResourcesUpdateTableThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesUpdateTableThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + tsgr.Response.Response, err = future.GetResult(sender) + if tsgr.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", nil, "received nil response and error") + } + if err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateTableThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateTableThroughputResponder handles the response to the UpdateTableThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) UpdateTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/version.go b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/version.go new file mode 100644 index 000000000000..f57c9ac0bba3 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2021-03-01-preview/documentdb/version.go @@ -0,0 +1,30 @@ +package documentdb + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " documentdb/2021-03-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}