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 RestorableSQLContainersClient struct {
20 BaseClient
21 }
22
23
24 func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient {
25 return NewRestorableSQLContainersClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient {
32 return RestorableSQLContainersClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42
43
44 func (client RestorableSQLContainersClient) List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (result RestorableSQLContainersListResult, err error) {
45 if tracing.IsEnabled() {
46 ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLContainersClient.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.RestorableSQLContainersClient", "List", err.Error())
59 }
60
61 req, err := client.ListPreparer(ctx, location, instanceID, restorableSQLDatabaseRid, startTime, endTime)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "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.RestorableSQLContainersClient", "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.RestorableSQLContainersClient", "List", resp, "Failure responding to request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client RestorableSQLContainersClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid 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(restorableSQLDatabaseRid) > 0 {
96 queryParameters["restorableSqlDatabaseRid"] = autorest.Encode("query", restorableSQLDatabaseRid)
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}/restorableSqlContainers", pathParameters),
109 autorest.WithQueryParameters(queryParameters))
110 return preparer.Prepare((&http.Request{}).WithContext(ctx))
111 }
112
113
114
115 func (client RestorableSQLContainersClient) ListSender(req *http.Request) (*http.Response, error) {
116 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
117 }
118
119
120
121 func (client RestorableSQLContainersClient) ListResponder(resp *http.Response) (result RestorableSQLContainersListResult, 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