...
1 package postgresqlflexibleservers
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/tracing"
14 "net/http"
15 )
16
17
18
19
20 type OperationsClient struct {
21 BaseClient
22 }
23
24
25 func NewOperationsClient(subscriptionID string) OperationsClient {
26 return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
27 }
28
29
30
31 func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
32 return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36 func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) {
37 if tracing.IsEnabled() {
38 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
39 defer func() {
40 sc := -1
41 if result.Response.Response != nil {
42 sc = result.Response.Response.StatusCode
43 }
44 tracing.EndSpan(ctx, sc, err)
45 }()
46 }
47 req, err := client.ListPreparer(ctx)
48 if err != nil {
49 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", nil, "Failure preparing request")
50 return
51 }
52
53 resp, err := client.ListSender(req)
54 if err != nil {
55 result.Response = autorest.Response{Response: resp}
56 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure sending request")
57 return
58 }
59
60 result, err = client.ListResponder(resp)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure responding to request")
63 return
64 }
65
66 return
67 }
68
69
70 func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
71 const APIVersion = "2020-02-14-preview"
72 queryParameters := map[string]interface{}{
73 "api-version": APIVersion,
74 }
75
76 preparer := autorest.CreatePreparer(
77 autorest.AsGet(),
78 autorest.WithBaseURL(client.BaseURI),
79 autorest.WithPath("/providers/Microsoft.DBForPostgreSql/operations"),
80 autorest.WithQueryParameters(queryParameters))
81 return preparer.Prepare((&http.Request{}).WithContext(ctx))
82 }
83
84
85
86 func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
87 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
88 }
89
90
91
92 func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
93 err = autorest.Respond(
94 resp,
95 azure.WithErrorUnlessStatusCode(http.StatusOK),
96 autorest.ByUnmarshallingJSON(&result),
97 autorest.ByClosing())
98 result.Response = autorest.Response{Response: resp}
99 return
100 }
101
View as plain text