1 package documentdb
2
3
4
5
6
7
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
19 type RestorableMongodbResourcesClient struct {
20 BaseClient
21 }
22
23
24 func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient {
25 return NewRestorableMongodbResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient {
32 return RestorableMongodbResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42
43 func (client RestorableMongodbResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableMongodbResourcesListResult, err error) {
44 if tracing.IsEnabled() {
45 ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbResourcesClient.List")
46 defer func() {
47 sc := -1
48 if result.Response.Response != nil {
49 sc = result.Response.Response.StatusCode
50 }
51 tracing.EndSpan(ctx, sc, err)
52 }()
53 }
54 if err := validation.Validate([]validation.Validation{
55 {TargetValue: client.SubscriptionID,
56 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
57 return result, validation.NewError("documentdb.RestorableMongodbResourcesClient", "List", err.Error())
58 }
59
60 req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", nil, "Failure preparing request")
63 return
64 }
65
66 resp, err := client.ListSender(req)
67 if err != nil {
68 result.Response = autorest.Response{Response: resp}
69 err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure sending request")
70 return
71 }
72
73 result, err = client.ListResponder(resp)
74 if err != nil {
75 err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure responding to request")
76 return
77 }
78
79 return
80 }
81
82
83 func (client RestorableMongodbResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) {
84 pathParameters := map[string]interface{}{
85 "instanceId": autorest.Encode("path", instanceID),
86 "location": autorest.Encode("path", location),
87 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
88 }
89
90 const APIVersion = "2022-05-15"
91 queryParameters := map[string]interface{}{
92 "api-version": APIVersion,
93 }
94 if len(restoreLocation) > 0 {
95 queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation)
96 }
97 if len(restoreTimestampInUtc) > 0 {
98 queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc)
99 }
100
101 preparer := autorest.CreatePreparer(
102 autorest.AsGet(),
103 autorest.WithBaseURL(client.BaseURI),
104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources", pathParameters),
105 autorest.WithQueryParameters(queryParameters))
106 return preparer.Prepare((&http.Request{}).WithContext(ctx))
107 }
108
109
110
111 func (client RestorableMongodbResourcesClient) ListSender(req *http.Request) (*http.Response, error) {
112 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
113 }
114
115
116
117 func (client RestorableMongodbResourcesClient) ListResponder(resp *http.Response) (result RestorableMongodbResourcesListResult, err error) {
118 err = autorest.Respond(
119 resp,
120 azure.WithErrorUnlessStatusCode(http.StatusOK),
121 autorest.ByUnmarshallingJSON(&result),
122 autorest.ByClosing())
123 result.Response = autorest.Response{Response: resp}
124 return
125 }
126
View as plain text