...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/cosmos-db/mgmt/2021-11-15-preview/documentdb/restorablegremlingraphs.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  // RestorableGremlinGraphsClient is the client for the RestorableGremlinGraphs methods of the Documentdb service.
    19  type RestorableGremlinGraphsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewRestorableGremlinGraphsClient creates an instance of the RestorableGremlinGraphsClient client.
    24  func NewRestorableGremlinGraphsClient(subscriptionID string) RestorableGremlinGraphsClient {
    25  	return NewRestorableGremlinGraphsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewRestorableGremlinGraphsClientWithBaseURI creates an instance of the RestorableGremlinGraphsClient 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 NewRestorableGremlinGraphsClientWithBaseURI(baseURI string, subscriptionID string) RestorableGremlinGraphsClient {
    32  	return RestorableGremlinGraphsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // List show the event feed of all mutations done on all the Azure Cosmos DB Gremlin graphs 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  // restorableGremlinDatabaseRid - the resource ID of the Gremlin database.
    42  // startTime - restorable Gremlin graphs event feed start time.
    43  // endTime - restorable Gremlin graphs event feed end time.
    44  func (client RestorableGremlinGraphsClient) List(ctx context.Context, location string, instanceID string, restorableGremlinDatabaseRid string, startTime string, endTime string) (result RestorableGremlinGraphsListResult, err error) {
    45  	if tracing.IsEnabled() {
    46  		ctx = tracing.StartSpan(ctx, fqdn+"/RestorableGremlinGraphsClient.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.RestorableGremlinGraphsClient", "List", err.Error())
    59  	}
    60  
    61  	req, err := client.ListPreparer(ctx, location, instanceID, restorableGremlinDatabaseRid, startTime, endTime)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "documentdb.RestorableGremlinGraphsClient", "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.RestorableGremlinGraphsClient", "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.RestorableGremlinGraphsClient", "List", resp, "Failure responding to request")
    77  		return
    78  	}
    79  
    80  	return
    81  }
    82  
    83  // ListPreparer prepares the List request.
    84  func (client RestorableGremlinGraphsClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableGremlinDatabaseRid 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(restorableGremlinDatabaseRid) > 0 {
    96  		queryParameters["restorableGremlinDatabaseRid"] = autorest.Encode("query", restorableGremlinDatabaseRid)
    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}/restorableGraphs", 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 RestorableGremlinGraphsClient) 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 RestorableGremlinGraphsClient) ListResponder(resp *http.Response) (result RestorableGremlinGraphsListResult, 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