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