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