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/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19
20
21 type ConfigurationsClient struct {
22 BaseClient
23 }
24
25
26 func NewConfigurationsClient(subscriptionID string) ConfigurationsClient {
27 return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
28 }
29
30
31
32 func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient {
33 return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
34 }
35
36
37
38
39
40
41 func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result Configuration, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Get")
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}}},
55 {TargetValue: resourceGroupName,
56 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
57 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
58 return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error())
59 }
60
61 req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", nil, "Failure preparing request")
64 return
65 }
66
67 resp, err := client.GetSender(req)
68 if err != nil {
69 result.Response = autorest.Response{Response: resp}
70 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure sending request")
71 return
72 }
73
74 result, err = client.GetResponder(resp)
75 if err != nil {
76 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure responding to request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) {
85 pathParameters := map[string]interface{}{
86 "configurationName": autorest.Encode("path", configurationName),
87 "resourceGroupName": autorest.Encode("path", resourceGroupName),
88 "serverName": autorest.Encode("path", serverName),
89 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
90 }
91
92 const APIVersion = "2021-06-01"
93 queryParameters := map[string]interface{}{
94 "api-version": APIVersion,
95 }
96
97 preparer := autorest.CreatePreparer(
98 autorest.AsGet(),
99 autorest.WithBaseURL(client.BaseURI),
100 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters),
101 autorest.WithQueryParameters(queryParameters))
102 return preparer.Prepare((&http.Request{}).WithContext(ctx))
103 }
104
105
106
107 func (client ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
108 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
109 }
110
111
112
113 func (client ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) {
114 err = autorest.Respond(
115 resp,
116 azure.WithErrorUnlessStatusCode(http.StatusOK),
117 autorest.ByUnmarshallingJSON(&result),
118 autorest.ByClosing())
119 result.Response = autorest.Response{Response: resp}
120 return
121 }
122
123
124
125
126
127 func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultPage, err error) {
128 if tracing.IsEnabled() {
129 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer")
130 defer func() {
131 sc := -1
132 if result.clr.Response.Response != nil {
133 sc = result.clr.Response.Response.StatusCode
134 }
135 tracing.EndSpan(ctx, sc, err)
136 }()
137 }
138 if err := validation.Validate([]validation.Validation{
139 {TargetValue: client.SubscriptionID,
140 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
141 {TargetValue: resourceGroupName,
142 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
143 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
144 return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error())
145 }
146
147 result.fn = client.listByServerNextResults
148 req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName)
149 if err != nil {
150 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", nil, "Failure preparing request")
151 return
152 }
153
154 resp, err := client.ListByServerSender(req)
155 if err != nil {
156 result.clr.Response = autorest.Response{Response: resp}
157 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure sending request")
158 return
159 }
160
161 result.clr, err = client.ListByServerResponder(resp)
162 if err != nil {
163 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure responding to request")
164 return
165 }
166 if result.clr.hasNextLink() && result.clr.IsEmpty() {
167 err = result.NextWithContext(ctx)
168 return
169 }
170
171 return
172 }
173
174
175 func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
176 pathParameters := map[string]interface{}{
177 "resourceGroupName": autorest.Encode("path", resourceGroupName),
178 "serverName": autorest.Encode("path", serverName),
179 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
180 }
181
182 const APIVersion = "2021-06-01"
183 queryParameters := map[string]interface{}{
184 "api-version": APIVersion,
185 }
186
187 preparer := autorest.CreatePreparer(
188 autorest.AsGet(),
189 autorest.WithBaseURL(client.BaseURI),
190 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations", pathParameters),
191 autorest.WithQueryParameters(queryParameters))
192 return preparer.Prepare((&http.Request{}).WithContext(ctx))
193 }
194
195
196
197 func (client ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) {
198 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
199 }
200
201
202
203 func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) {
204 err = autorest.Respond(
205 resp,
206 azure.WithErrorUnlessStatusCode(http.StatusOK),
207 autorest.ByUnmarshallingJSON(&result),
208 autorest.ByClosing())
209 result.Response = autorest.Response{Response: resp}
210 return
211 }
212
213
214 func (client ConfigurationsClient) listByServerNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) {
215 req, err := lastResults.configurationListResultPreparer(ctx)
216 if err != nil {
217 return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", nil, "Failure preparing next results request")
218 }
219 if req == nil {
220 return
221 }
222 resp, err := client.ListByServerSender(req)
223 if err != nil {
224 result.Response = autorest.Response{Response: resp}
225 return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure sending next results request")
226 }
227 result, err = client.ListByServerResponder(resp)
228 if err != nil {
229 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure responding to next results request")
230 }
231 return
232 }
233
234
235 func (client ConfigurationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultIterator, err error) {
236 if tracing.IsEnabled() {
237 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer")
238 defer func() {
239 sc := -1
240 if result.Response().Response.Response != nil {
241 sc = result.page.Response().Response.Response.StatusCode
242 }
243 tracing.EndSpan(ctx, sc, err)
244 }()
245 }
246 result.page, err = client.ListByServer(ctx, resourceGroupName, serverName)
247 return
248 }
249
250
251
252
253
254
255
256 func (client ConfigurationsClient) Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsPutFuture, err error) {
257 if tracing.IsEnabled() {
258 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Put")
259 defer func() {
260 sc := -1
261 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
262 sc = result.FutureAPI.Response().StatusCode
263 }
264 tracing.EndSpan(ctx, sc, err)
265 }()
266 }
267 if err := validation.Validate([]validation.Validation{
268 {TargetValue: client.SubscriptionID,
269 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
270 {TargetValue: resourceGroupName,
271 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
272 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
273 return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Put", err.Error())
274 }
275
276 req, err := client.PutPreparer(ctx, resourceGroupName, serverName, configurationName, parameters)
277 if err != nil {
278 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure preparing request")
279 return
280 }
281
282 result, err = client.PutSender(req)
283 if err != nil {
284 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", result.Response(), "Failure sending request")
285 return
286 }
287
288 return
289 }
290
291
292 func (client ConfigurationsClient) PutPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) {
293 pathParameters := map[string]interface{}{
294 "configurationName": autorest.Encode("path", configurationName),
295 "resourceGroupName": autorest.Encode("path", resourceGroupName),
296 "serverName": autorest.Encode("path", serverName),
297 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
298 }
299
300 const APIVersion = "2021-06-01"
301 queryParameters := map[string]interface{}{
302 "api-version": APIVersion,
303 }
304
305 parameters.SystemData = nil
306 preparer := autorest.CreatePreparer(
307 autorest.AsContentType("application/json; charset=utf-8"),
308 autorest.AsPut(),
309 autorest.WithBaseURL(client.BaseURI),
310 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters),
311 autorest.WithJSON(parameters),
312 autorest.WithQueryParameters(queryParameters))
313 return preparer.Prepare((&http.Request{}).WithContext(ctx))
314 }
315
316
317
318 func (client ConfigurationsClient) PutSender(req *http.Request) (future ConfigurationsPutFuture, err error) {
319 var resp *http.Response
320 future.FutureAPI = &azure.Future{}
321 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
322 if err != nil {
323 return
324 }
325 var azf azure.Future
326 azf, err = azure.NewFutureFromResponse(resp)
327 future.FutureAPI = &azf
328 future.Result = future.result
329 return
330 }
331
332
333
334 func (client ConfigurationsClient) PutResponder(resp *http.Response) (result Configuration, err error) {
335 err = autorest.Respond(
336 resp,
337 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
338 autorest.ByUnmarshallingJSON(&result),
339 autorest.ByClosing())
340 result.Response = autorest.Response{Response: resp}
341 return
342 }
343
344
345
346
347
348
349
350 func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsUpdateFuture, err error) {
351 if tracing.IsEnabled() {
352 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Update")
353 defer func() {
354 sc := -1
355 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
356 sc = result.FutureAPI.Response().StatusCode
357 }
358 tracing.EndSpan(ctx, sc, err)
359 }()
360 }
361 if err := validation.Validate([]validation.Validation{
362 {TargetValue: client.SubscriptionID,
363 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
364 {TargetValue: resourceGroupName,
365 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
366 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
367 return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error())
368 }
369
370 req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters)
371 if err != nil {
372 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure preparing request")
373 return
374 }
375
376 result, err = client.UpdateSender(req)
377 if err != nil {
378 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", result.Response(), "Failure sending request")
379 return
380 }
381
382 return
383 }
384
385
386 func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) {
387 pathParameters := map[string]interface{}{
388 "configurationName": autorest.Encode("path", configurationName),
389 "resourceGroupName": autorest.Encode("path", resourceGroupName),
390 "serverName": autorest.Encode("path", serverName),
391 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
392 }
393
394 const APIVersion = "2021-06-01"
395 queryParameters := map[string]interface{}{
396 "api-version": APIVersion,
397 }
398
399 parameters.SystemData = nil
400 preparer := autorest.CreatePreparer(
401 autorest.AsContentType("application/json; charset=utf-8"),
402 autorest.AsPatch(),
403 autorest.WithBaseURL(client.BaseURI),
404 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters),
405 autorest.WithJSON(parameters),
406 autorest.WithQueryParameters(queryParameters))
407 return preparer.Prepare((&http.Request{}).WithContext(ctx))
408 }
409
410
411
412 func (client ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, err error) {
413 var resp *http.Response
414 future.FutureAPI = &azure.Future{}
415 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
416 if err != nil {
417 return
418 }
419 var azf azure.Future
420 azf, err = azure.NewFutureFromResponse(resp)
421 future.FutureAPI = &azf
422 future.Result = future.result
423 return
424 }
425
426
427
428 func (client ConfigurationsClient) UpdateResponder(resp *http.Response) (result Configuration, err error) {
429 err = autorest.Respond(
430 resp,
431 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
432 autorest.ByUnmarshallingJSON(&result),
433 autorest.ByClosing())
434 result.Response = autorest.Response{Response: resp}
435 return
436 }
437
View as plain text