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