1 package artifacts
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 type SQLPoolsClient struct {
19 BaseClient
20 }
21
22
23 func NewSQLPoolsClient(endpoint string) SQLPoolsClient {
24 return SQLPoolsClient{New(endpoint)}
25 }
26
27
28
29
30 func (client SQLPoolsClient) Get(ctx context.Context, SQLPoolName string) (result SQLPool, err error) {
31 if tracing.IsEnabled() {
32 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolsClient.Get")
33 defer func() {
34 sc := -1
35 if result.Response.Response != nil {
36 sc = result.Response.Response.StatusCode
37 }
38 tracing.EndSpan(ctx, sc, err)
39 }()
40 }
41 req, err := client.GetPreparer(ctx, SQLPoolName)
42 if err != nil {
43 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "Get", nil, "Failure preparing request")
44 return
45 }
46
47 resp, err := client.GetSender(req)
48 if err != nil {
49 result.Response = autorest.Response{Response: resp}
50 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "Get", resp, "Failure sending request")
51 return
52 }
53
54 result, err = client.GetResponder(resp)
55 if err != nil {
56 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "Get", resp, "Failure responding to request")
57 return
58 }
59
60 return
61 }
62
63
64 func (client SQLPoolsClient) GetPreparer(ctx context.Context, SQLPoolName string) (*http.Request, error) {
65 urlParameters := map[string]interface{}{
66 "endpoint": client.Endpoint,
67 }
68
69 pathParameters := map[string]interface{}{
70 "sqlPoolName": autorest.Encode("path", SQLPoolName),
71 }
72
73 const APIVersion = "2019-06-01-preview"
74 queryParameters := map[string]interface{}{
75 "api-version": APIVersion,
76 }
77
78 preparer := autorest.CreatePreparer(
79 autorest.AsGet(),
80 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
81 autorest.WithPathParameters("/sqlPools/{sqlPoolName}", pathParameters),
82 autorest.WithQueryParameters(queryParameters))
83 return preparer.Prepare((&http.Request{}).WithContext(ctx))
84 }
85
86
87
88 func (client SQLPoolsClient) GetSender(req *http.Request) (*http.Response, error) {
89 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
90 }
91
92
93
94 func (client SQLPoolsClient) GetResponder(resp *http.Response) (result SQLPool, err error) {
95 err = autorest.Respond(
96 resp,
97 azure.WithErrorUnlessStatusCode(http.StatusOK),
98 autorest.ByUnmarshallingJSON(&result),
99 autorest.ByClosing())
100 result.Response = autorest.Response{Response: resp}
101 return
102 }
103
104
105 func (client SQLPoolsClient) List(ctx context.Context) (result SQLPoolInfoListResult, err error) {
106 if tracing.IsEnabled() {
107 ctx = tracing.StartSpan(ctx, fqdn+"/SQLPoolsClient.List")
108 defer func() {
109 sc := -1
110 if result.Response.Response != nil {
111 sc = result.Response.Response.StatusCode
112 }
113 tracing.EndSpan(ctx, sc, err)
114 }()
115 }
116 req, err := client.ListPreparer(ctx)
117 if err != nil {
118 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "List", nil, "Failure preparing request")
119 return
120 }
121
122 resp, err := client.ListSender(req)
123 if err != nil {
124 result.Response = autorest.Response{Response: resp}
125 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "List", resp, "Failure sending request")
126 return
127 }
128
129 result, err = client.ListResponder(resp)
130 if err != nil {
131 err = autorest.NewErrorWithError(err, "artifacts.SQLPoolsClient", "List", resp, "Failure responding to request")
132 return
133 }
134
135 return
136 }
137
138
139 func (client SQLPoolsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
140 urlParameters := map[string]interface{}{
141 "endpoint": client.Endpoint,
142 }
143
144 const APIVersion = "2019-06-01-preview"
145 queryParameters := map[string]interface{}{
146 "api-version": APIVersion,
147 }
148
149 preparer := autorest.CreatePreparer(
150 autorest.AsGet(),
151 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
152 autorest.WithPath("/sqlPools"),
153 autorest.WithQueryParameters(queryParameters))
154 return preparer.Prepare((&http.Request{}).WithContext(ctx))
155 }
156
157
158
159 func (client SQLPoolsClient) ListSender(req *http.Request) (*http.Response, error) {
160 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
161 }
162
163
164
165 func (client SQLPoolsClient) ListResponder(resp *http.Response) (result SQLPoolInfoListResult, err error) {
166 err = autorest.Respond(
167 resp,
168 azure.WithErrorUnlessStatusCode(http.StatusOK),
169 autorest.ByUnmarshallingJSON(&result),
170 autorest.ByClosing())
171 result.Response = autorest.Response{Response: resp}
172 return
173 }
174
View as plain text