...

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

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

     1  package documentdb
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // RestorableSQLContainersClient is the client for the RestorableSQLContainers methods of the Documentdb service.
    19  type RestorableSQLContainersClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewRestorableSQLContainersClient creates an instance of the RestorableSQLContainersClient client.
    24  func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient {
    25  	return NewRestorableSQLContainersClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewRestorableSQLContainersClientWithBaseURI creates an instance of the RestorableSQLContainersClient client using a
    29  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    30  // Azure stack).
    31  func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient {
    32  	return RestorableSQLContainersClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // List show the event feed of all mutations done on all the Azure Cosmos DB SQL containers under a specific database.
    36  // This helps in scenario where container was accidentally deleted.  This API requires
    37  // 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission
    38  // Parameters:
    39  // location - cosmos DB region, with spaces between words and each word capitalized.
    40  // instanceID - the instanceId GUID of a restorable database account.
    41  // restorableSQLDatabaseRid - the resource ID of the SQL database.
    42  // startTime - restorable Sql containers event feed start time.
    43  // endTime - restorable Sql containers event feed end time.
    44  func (client RestorableSQLContainersClient) List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (result RestorableSQLContainersListResult, err error) {
    45  	if tracing.IsEnabled() {
    46  		ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLContainersClient.List")
    47  		defer func() {
    48  			sc := -1
    49  			if result.Response.Response != nil {
    50  				sc = result.Response.Response.StatusCode
    51  			}
    52  			tracing.EndSpan(ctx, sc, err)
    53  		}()
    54  	}
    55  	if err := validation.Validate([]validation.Validation{
    56  		{TargetValue: client.SubscriptionID,
    57  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    58  		return result, validation.NewError("documentdb.RestorableSQLContainersClient", "List", err.Error())
    59  	}
    60  
    61  	req, err := client.ListPreparer(ctx, location, instanceID, restorableSQLDatabaseRid, startTime, endTime)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", nil, "Failure preparing request")
    64  		return
    65  	}
    66  
    67  	resp, err := client.ListSender(req)
    68  	if err != nil {
    69  		result.Response = autorest.Response{Response: resp}
    70  		err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure sending request")
    71  		return
    72  	}
    73  
    74  	result, err = client.ListResponder(resp)
    75  	if err != nil {
    76  		err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure responding to request")
    77  		return
    78  	}
    79  
    80  	return
    81  }
    82  
    83  // ListPreparer prepares the List request.
    84  func (client RestorableSQLContainersClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (*http.Request, error) {
    85  	pathParameters := map[string]interface{}{
    86  		"instanceId":     autorest.Encode("path", instanceID),
    87  		"location":       autorest.Encode("path", location),
    88  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
    89  	}
    90  
    91  	const APIVersion = "2021-11-15-preview"
    92  	queryParameters := map[string]interface{}{
    93  		"api-version": APIVersion,
    94  	}
    95  	if len(restorableSQLDatabaseRid) > 0 {
    96  		queryParameters["restorableSqlDatabaseRid"] = autorest.Encode("query", restorableSQLDatabaseRid)
    97  	}
    98  	if len(startTime) > 0 {
    99  		queryParameters["startTime"] = autorest.Encode("query", startTime)
   100  	}
   101  	if len(endTime) > 0 {
   102  		queryParameters["endTime"] = autorest.Encode("query", endTime)
   103  	}
   104  
   105  	preparer := autorest.CreatePreparer(
   106  		autorest.AsGet(),
   107  		autorest.WithBaseURL(client.BaseURI),
   108  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers", pathParameters),
   109  		autorest.WithQueryParameters(queryParameters))
   110  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   111  }
   112  
   113  // ListSender sends the List request. The method will close the
   114  // http.Response Body if it receives an error.
   115  func (client RestorableSQLContainersClient) ListSender(req *http.Request) (*http.Response, error) {
   116  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   117  }
   118  
   119  // ListResponder handles the response to the List request. The method always
   120  // closes the http.Response Body.
   121  func (client RestorableSQLContainersClient) ListResponder(resp *http.Response) (result RestorableSQLContainersListResult, err error) {
   122  	err = autorest.Respond(
   123  		resp,
   124  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   125  		autorest.ByUnmarshallingJSON(&result),
   126  		autorest.ByClosing())
   127  	result.Response = autorest.Response{Response: resp}
   128  	return
   129  }
   130  

View as plain text