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 func (client RestorableMongodbCollectionsClient) List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result RestorableMongodbCollectionsListResult, err error) {
44 if tracing.IsEnabled() {
45 ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbCollectionsClient.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.RestorableMongodbCollectionsClient", "List", err.Error())
58 }
59
60 req, err := client.ListPreparer(ctx, location, instanceID, restorableMongodbDatabaseRid)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "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.RestorableMongodbCollectionsClient", "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.RestorableMongodbCollectionsClient", "List", resp, "Failure responding to request")
76 return
77 }
78
79 return
80 }
81
82
83 func (client RestorableMongodbCollectionsClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid 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-08-15"
91 queryParameters := map[string]interface{}{
92 "api-version": APIVersion,
93 }
94 if len(restorableMongodbDatabaseRid) > 0 {
95 queryParameters["restorableMongodbDatabaseRid"] = autorest.Encode("query", restorableMongodbDatabaseRid)
96 }
97
98 preparer := autorest.CreatePreparer(
99 autorest.AsGet(),
100 autorest.WithBaseURL(client.BaseURI),
101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections", pathParameters),
102 autorest.WithQueryParameters(queryParameters))
103 return preparer.Prepare((&http.Request{}).WithContext(ctx))
104 }
105
106
107
108 func (client RestorableMongodbCollectionsClient) ListSender(req *http.Request) (*http.Response, error) {
109 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
110 }
111
112
113
114 func (client RestorableMongodbCollectionsClient) ListResponder(resp *http.Response) (result RestorableMongodbCollectionsListResult, err error) {
115 err = autorest.Respond(
116 resp,
117 azure.WithErrorUnlessStatusCode(http.StatusOK),
118 autorest.ByUnmarshallingJSON(&result),
119 autorest.ByClosing())
120 result.Response = autorest.Response{Response: resp}
121 return
122 }
123
View as plain text