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) 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},
58 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
59 return result, validation.NewError("mysqlflexibleservers.ConfigurationsClient", "Get", err.Error())
60 }
61
62 req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Get", nil, "Failure preparing request")
65 return
66 }
67
68 resp, err := client.GetSender(req)
69 if err != nil {
70 result.Response = autorest.Response{Response: resp}
71 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure sending request")
72 return
73 }
74
75 result, err = client.GetResponder(resp)
76 if err != nil {
77 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure responding to request")
78 return
79 }
80
81 return
82 }
83
84
85 func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) {
86 pathParameters := map[string]interface{}{
87 "configurationName": autorest.Encode("path", configurationName),
88 "resourceGroupName": autorest.Encode("path", resourceGroupName),
89 "serverName": autorest.Encode("path", serverName),
90 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
91 }
92
93 const APIVersion = "2020-07-01-preview"
94 queryParameters := map[string]interface{}{
95 "api-version": APIVersion,
96 }
97
98 preparer := autorest.CreatePreparer(
99 autorest.AsGet(),
100 autorest.WithBaseURL(client.BaseURI),
101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForMySql/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters),
102 autorest.WithQueryParameters(queryParameters))
103 return preparer.Prepare((&http.Request{}).WithContext(ctx))
104 }
105
106
107
108 func (client ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
109 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
110 }
111
112
113
114 func (client ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) {
115 err = autorest.Respond(
116 resp,
117 azure.WithErrorUnlessStatusCode(http.StatusOK),
118 autorest.ByUnmarshallingJSON(&result),
119 autorest.ByClosing())
120 result.Response = autorest.Response{Response: resp}
121 return
122 }
123
124
125
126
127
128 func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultPage, err error) {
129 if tracing.IsEnabled() {
130 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer")
131 defer func() {
132 sc := -1
133 if result.clr.Response.Response != nil {
134 sc = result.clr.Response.Response.StatusCode
135 }
136 tracing.EndSpan(ctx, sc, err)
137 }()
138 }
139 if err := validation.Validate([]validation.Validation{
140 {TargetValue: client.SubscriptionID,
141 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
142 {TargetValue: resourceGroupName,
143 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
144 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
145 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
146 return result, validation.NewError("mysqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error())
147 }
148
149 result.fn = client.listByServerNextResults
150 req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName)
151 if err != nil {
152 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "ListByServer", nil, "Failure preparing request")
153 return
154 }
155
156 resp, err := client.ListByServerSender(req)
157 if err != nil {
158 result.clr.Response = autorest.Response{Response: resp}
159 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure sending request")
160 return
161 }
162
163 result.clr, err = client.ListByServerResponder(resp)
164 if err != nil {
165 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure responding to request")
166 return
167 }
168 if result.clr.hasNextLink() && result.clr.IsEmpty() {
169 err = result.NextWithContext(ctx)
170 return
171 }
172
173 return
174 }
175
176
177 func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
178 pathParameters := map[string]interface{}{
179 "resourceGroupName": autorest.Encode("path", resourceGroupName),
180 "serverName": autorest.Encode("path", serverName),
181 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
182 }
183
184 const APIVersion = "2020-07-01-preview"
185 queryParameters := map[string]interface{}{
186 "api-version": APIVersion,
187 }
188
189 preparer := autorest.CreatePreparer(
190 autorest.AsGet(),
191 autorest.WithBaseURL(client.BaseURI),
192 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForMySql/flexibleServers/{serverName}/configurations", pathParameters),
193 autorest.WithQueryParameters(queryParameters))
194 return preparer.Prepare((&http.Request{}).WithContext(ctx))
195 }
196
197
198
199 func (client ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) {
200 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
201 }
202
203
204
205 func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) {
206 err = autorest.Respond(
207 resp,
208 azure.WithErrorUnlessStatusCode(http.StatusOK),
209 autorest.ByUnmarshallingJSON(&result),
210 autorest.ByClosing())
211 result.Response = autorest.Response{Response: resp}
212 return
213 }
214
215
216 func (client ConfigurationsClient) listByServerNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) {
217 req, err := lastResults.configurationListResultPreparer(ctx)
218 if err != nil {
219 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "listByServerNextResults", nil, "Failure preparing next results request")
220 }
221 if req == nil {
222 return
223 }
224 resp, err := client.ListByServerSender(req)
225 if err != nil {
226 result.Response = autorest.Response{Response: resp}
227 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure sending next results request")
228 }
229 result, err = client.ListByServerResponder(resp)
230 if err != nil {
231 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure responding to next results request")
232 }
233 return
234 }
235
236
237 func (client ConfigurationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultIterator, err error) {
238 if tracing.IsEnabled() {
239 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer")
240 defer func() {
241 sc := -1
242 if result.Response().Response.Response != nil {
243 sc = result.page.Response().Response.Response.StatusCode
244 }
245 tracing.EndSpan(ctx, sc, err)
246 }()
247 }
248 result.page, err = client.ListByServer(ctx, resourceGroupName, serverName)
249 return
250 }
251
252
253
254
255
256
257
258 func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsUpdateFuture, err error) {
259 if tracing.IsEnabled() {
260 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Update")
261 defer func() {
262 sc := -1
263 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
264 sc = result.FutureAPI.Response().StatusCode
265 }
266 tracing.EndSpan(ctx, sc, err)
267 }()
268 }
269 if err := validation.Validate([]validation.Validation{
270 {TargetValue: client.SubscriptionID,
271 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
272 {TargetValue: resourceGroupName,
273 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
274 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
275 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
276 return result, validation.NewError("mysqlflexibleservers.ConfigurationsClient", "Update", err.Error())
277 }
278
279 req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters)
280 if err != nil {
281 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure preparing request")
282 return
283 }
284
285 result, err = client.UpdateSender(req)
286 if err != nil {
287 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ConfigurationsClient", "Update", result.Response(), "Failure sending request")
288 return
289 }
290
291 return
292 }
293
294
295 func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) {
296 pathParameters := map[string]interface{}{
297 "configurationName": autorest.Encode("path", configurationName),
298 "resourceGroupName": autorest.Encode("path", resourceGroupName),
299 "serverName": autorest.Encode("path", serverName),
300 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
301 }
302
303 const APIVersion = "2020-07-01-preview"
304 queryParameters := map[string]interface{}{
305 "api-version": APIVersion,
306 }
307
308 preparer := autorest.CreatePreparer(
309 autorest.AsContentType("application/json; charset=utf-8"),
310 autorest.AsPatch(),
311 autorest.WithBaseURL(client.BaseURI),
312 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForMySql/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters),
313 autorest.WithJSON(parameters),
314 autorest.WithQueryParameters(queryParameters))
315 return preparer.Prepare((&http.Request{}).WithContext(ctx))
316 }
317
318
319
320 func (client ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, err error) {
321 var resp *http.Response
322 future.FutureAPI = &azure.Future{}
323 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
324 if err != nil {
325 return
326 }
327 var azf azure.Future
328 azf, err = azure.NewFutureFromResponse(resp)
329 future.FutureAPI = &azf
330 future.Result = future.result
331 return
332 }
333
334
335
336 func (client ConfigurationsClient) UpdateResponder(resp *http.Response) (result Configuration, err error) {
337 err = autorest.Respond(
338 resp,
339 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
340 autorest.ByUnmarshallingJSON(&result),
341 autorest.ByClosing())
342 result.Response = autorest.Response{Response: resp}
343 return
344 }
345
View as plain text