1 package documentdb
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 type CassandraClustersClient struct {
20 BaseClient
21 }
22
23
24 func NewCassandraClustersClient(subscriptionID string) CassandraClustersClient {
25 return NewCassandraClustersClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewCassandraClustersClientWithBaseURI(baseURI string, subscriptionID string) CassandraClustersClient {
32 return CassandraClustersClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client CassandraClustersClient) CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersCreateUpdateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.CreateUpdate")
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},
58 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
59 {TargetValue: clusterName,
60 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
61 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
62 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
63 return result, validation.NewError("documentdb.CassandraClustersClient", "CreateUpdate", err.Error())
64 }
65
66 req, err := client.CreateUpdatePreparer(ctx, resourceGroupName, clusterName, body)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", nil, "Failure preparing request")
69 return
70 }
71
72 result, err = client.CreateUpdateSender(req)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", result.Response(), "Failure sending request")
75 return
76 }
77
78 return
79 }
80
81
82 func (client CassandraClustersClient) CreateUpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) {
83 pathParameters := map[string]interface{}{
84 "clusterName": autorest.Encode("path", clusterName),
85 "resourceGroupName": autorest.Encode("path", resourceGroupName),
86 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
87 }
88
89 const APIVersion = "2021-04-01-preview"
90 queryParameters := map[string]interface{}{
91 "api-version": APIVersion,
92 }
93
94 preparer := autorest.CreatePreparer(
95 autorest.AsContentType("application/json; charset=utf-8"),
96 autorest.AsPut(),
97 autorest.WithBaseURL(client.BaseURI),
98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters),
99 autorest.WithJSON(body),
100 autorest.WithQueryParameters(queryParameters))
101 return preparer.Prepare((&http.Request{}).WithContext(ctx))
102 }
103
104
105
106 func (client CassandraClustersClient) CreateUpdateSender(req *http.Request) (future CassandraClustersCreateUpdateFuture, err error) {
107 var resp *http.Response
108 future.FutureAPI = &azure.Future{}
109 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
110 if err != nil {
111 return
112 }
113 var azf azure.Future
114 azf, err = azure.NewFutureFromResponse(resp)
115 future.FutureAPI = &azf
116 future.Result = future.result
117 return
118 }
119
120
121
122 func (client CassandraClustersClient) CreateUpdateResponder(resp *http.Response) (result ClusterResource, err error) {
123 err = autorest.Respond(
124 resp,
125 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
126 autorest.ByUnmarshallingJSON(&result),
127 autorest.ByClosing())
128 result.Response = autorest.Response{Response: resp}
129 return
130 }
131
132
133
134
135
136 func (client CassandraClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersDeleteFuture, err error) {
137 if tracing.IsEnabled() {
138 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Delete")
139 defer func() {
140 sc := -1
141 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
142 sc = result.FutureAPI.Response().StatusCode
143 }
144 tracing.EndSpan(ctx, sc, err)
145 }()
146 }
147 if err := validation.Validate([]validation.Validation{
148 {TargetValue: client.SubscriptionID,
149 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
150 {TargetValue: resourceGroupName,
151 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
152 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
153 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
154 {TargetValue: clusterName,
155 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
156 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
157 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
158 return result, validation.NewError("documentdb.CassandraClustersClient", "Delete", err.Error())
159 }
160
161 req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName)
162 if err != nil {
163 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", nil, "Failure preparing request")
164 return
165 }
166
167 result, err = client.DeleteSender(req)
168 if err != nil {
169 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", result.Response(), "Failure sending request")
170 return
171 }
172
173 return
174 }
175
176
177 func (client CassandraClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) {
178 pathParameters := map[string]interface{}{
179 "clusterName": autorest.Encode("path", clusterName),
180 "resourceGroupName": autorest.Encode("path", resourceGroupName),
181 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
182 }
183
184 const APIVersion = "2021-04-01-preview"
185 queryParameters := map[string]interface{}{
186 "api-version": APIVersion,
187 }
188
189 preparer := autorest.CreatePreparer(
190 autorest.AsDelete(),
191 autorest.WithBaseURL(client.BaseURI),
192 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters),
193 autorest.WithQueryParameters(queryParameters))
194 return preparer.Prepare((&http.Request{}).WithContext(ctx))
195 }
196
197
198
199 func (client CassandraClustersClient) DeleteSender(req *http.Request) (future CassandraClustersDeleteFuture, err error) {
200 var resp *http.Response
201 future.FutureAPI = &azure.Future{}
202 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
203 if err != nil {
204 return
205 }
206 var azf azure.Future
207 azf, err = azure.NewFutureFromResponse(resp)
208 future.FutureAPI = &azf
209 future.Result = future.result
210 return
211 }
212
213
214
215 func (client CassandraClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
216 err = autorest.Respond(
217 resp,
218 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
219 autorest.ByClosing())
220 result.Response = resp
221 return
222 }
223
224
225
226
227
228 func (client CassandraClustersClient) FetchNodeStatus(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersFetchNodeStatusFuture, err error) {
229 if tracing.IsEnabled() {
230 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.FetchNodeStatus")
231 defer func() {
232 sc := -1
233 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
234 sc = result.FutureAPI.Response().StatusCode
235 }
236 tracing.EndSpan(ctx, sc, err)
237 }()
238 }
239 if err := validation.Validate([]validation.Validation{
240 {TargetValue: client.SubscriptionID,
241 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
242 {TargetValue: resourceGroupName,
243 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
244 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
245 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
246 {TargetValue: clusterName,
247 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
248 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
249 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
250 return result, validation.NewError("documentdb.CassandraClustersClient", "FetchNodeStatus", err.Error())
251 }
252
253 req, err := client.FetchNodeStatusPreparer(ctx, resourceGroupName, clusterName)
254 if err != nil {
255 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "FetchNodeStatus", nil, "Failure preparing request")
256 return
257 }
258
259 result, err = client.FetchNodeStatusSender(req)
260 if err != nil {
261 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "FetchNodeStatus", result.Response(), "Failure sending request")
262 return
263 }
264
265 return
266 }
267
268
269 func (client CassandraClustersClient) FetchNodeStatusPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) {
270 pathParameters := map[string]interface{}{
271 "clusterName": autorest.Encode("path", clusterName),
272 "resourceGroupName": autorest.Encode("path", resourceGroupName),
273 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
274 }
275
276 const APIVersion = "2021-04-01-preview"
277 queryParameters := map[string]interface{}{
278 "api-version": APIVersion,
279 }
280
281 preparer := autorest.CreatePreparer(
282 autorest.AsPost(),
283 autorest.WithBaseURL(client.BaseURI),
284 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/fetchNodeStatus", pathParameters),
285 autorest.WithQueryParameters(queryParameters))
286 return preparer.Prepare((&http.Request{}).WithContext(ctx))
287 }
288
289
290
291 func (client CassandraClustersClient) FetchNodeStatusSender(req *http.Request) (future CassandraClustersFetchNodeStatusFuture, err error) {
292 var resp *http.Response
293 future.FutureAPI = &azure.Future{}
294 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
295 if err != nil {
296 return
297 }
298 var azf azure.Future
299 azf, err = azure.NewFutureFromResponse(resp)
300 future.FutureAPI = &azf
301 future.Result = future.result
302 return
303 }
304
305
306
307 func (client CassandraClustersClient) FetchNodeStatusResponder(resp *http.Response) (result ClusterNodeStatus, err error) {
308 err = autorest.Respond(
309 resp,
310 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
311 autorest.ByUnmarshallingJSON(&result),
312 autorest.ByClosing())
313 result.Response = autorest.Response{Response: resp}
314 return
315 }
316
317
318
319
320
321 func (client CassandraClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result ClusterResource, err error) {
322 if tracing.IsEnabled() {
323 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Get")
324 defer func() {
325 sc := -1
326 if result.Response.Response != nil {
327 sc = result.Response.Response.StatusCode
328 }
329 tracing.EndSpan(ctx, sc, err)
330 }()
331 }
332 if err := validation.Validate([]validation.Validation{
333 {TargetValue: client.SubscriptionID,
334 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
335 {TargetValue: resourceGroupName,
336 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
337 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
338 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
339 {TargetValue: clusterName,
340 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
341 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
342 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
343 return result, validation.NewError("documentdb.CassandraClustersClient", "Get", err.Error())
344 }
345
346 req, err := client.GetPreparer(ctx, resourceGroupName, clusterName)
347 if err != nil {
348 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", nil, "Failure preparing request")
349 return
350 }
351
352 resp, err := client.GetSender(req)
353 if err != nil {
354 result.Response = autorest.Response{Response: resp}
355 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure sending request")
356 return
357 }
358
359 result, err = client.GetResponder(resp)
360 if err != nil {
361 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure responding to request")
362 return
363 }
364
365 return
366 }
367
368
369 func (client CassandraClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) {
370 pathParameters := map[string]interface{}{
371 "clusterName": autorest.Encode("path", clusterName),
372 "resourceGroupName": autorest.Encode("path", resourceGroupName),
373 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
374 }
375
376 const APIVersion = "2021-04-01-preview"
377 queryParameters := map[string]interface{}{
378 "api-version": APIVersion,
379 }
380
381 preparer := autorest.CreatePreparer(
382 autorest.AsGet(),
383 autorest.WithBaseURL(client.BaseURI),
384 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters),
385 autorest.WithQueryParameters(queryParameters))
386 return preparer.Prepare((&http.Request{}).WithContext(ctx))
387 }
388
389
390
391 func (client CassandraClustersClient) GetSender(req *http.Request) (*http.Response, error) {
392 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
393 }
394
395
396
397 func (client CassandraClustersClient) GetResponder(resp *http.Response) (result ClusterResource, err error) {
398 err = autorest.Respond(
399 resp,
400 azure.WithErrorUnlessStatusCode(http.StatusOK),
401 autorest.ByUnmarshallingJSON(&result),
402 autorest.ByClosing())
403 result.Response = autorest.Response{Response: resp}
404 return
405 }
406
407
408
409
410
411
412 func (client CassandraClustersClient) GetBackup(ctx context.Context, resourceGroupName string, clusterName string, backupID string) (result BackupResource, err error) {
413 if tracing.IsEnabled() {
414 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.GetBackup")
415 defer func() {
416 sc := -1
417 if result.Response.Response != nil {
418 sc = result.Response.Response.StatusCode
419 }
420 tracing.EndSpan(ctx, sc, err)
421 }()
422 }
423 if err := validation.Validate([]validation.Validation{
424 {TargetValue: client.SubscriptionID,
425 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
426 {TargetValue: resourceGroupName,
427 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
428 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
429 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
430 {TargetValue: clusterName,
431 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
432 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
433 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}},
434 {TargetValue: backupID,
435 Constraints: []validation.Constraint{{Target: "backupID", Name: validation.MaxLength, Rule: 15, Chain: nil},
436 {Target: "backupID", Name: validation.MinLength, Rule: 1, Chain: nil},
437 {Target: "backupID", Name: validation.Pattern, Rule: `^[0-9]+$`, Chain: nil}}}}); err != nil {
438 return result, validation.NewError("documentdb.CassandraClustersClient", "GetBackup", err.Error())
439 }
440
441 req, err := client.GetBackupPreparer(ctx, resourceGroupName, clusterName, backupID)
442 if err != nil {
443 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", nil, "Failure preparing request")
444 return
445 }
446
447 resp, err := client.GetBackupSender(req)
448 if err != nil {
449 result.Response = autorest.Response{Response: resp}
450 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", resp, "Failure sending request")
451 return
452 }
453
454 result, err = client.GetBackupResponder(resp)
455 if err != nil {
456 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "GetBackup", resp, "Failure responding to request")
457 return
458 }
459
460 return
461 }
462
463
464 func (client CassandraClustersClient) GetBackupPreparer(ctx context.Context, resourceGroupName string, clusterName string, backupID string) (*http.Request, error) {
465 pathParameters := map[string]interface{}{
466 "backupId": autorest.Encode("path", backupID),
467 "clusterName": autorest.Encode("path", clusterName),
468 "resourceGroupName": autorest.Encode("path", resourceGroupName),
469 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
470 }
471
472 const APIVersion = "2021-04-01-preview"
473 queryParameters := map[string]interface{}{
474 "api-version": APIVersion,
475 }
476
477 preparer := autorest.CreatePreparer(
478 autorest.AsGet(),
479 autorest.WithBaseURL(client.BaseURI),
480 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}", pathParameters),
481 autorest.WithQueryParameters(queryParameters))
482 return preparer.Prepare((&http.Request{}).WithContext(ctx))
483 }
484
485
486
487 func (client CassandraClustersClient) GetBackupSender(req *http.Request) (*http.Response, error) {
488 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
489 }
490
491
492
493 func (client CassandraClustersClient) GetBackupResponder(resp *http.Response) (result BackupResource, err error) {
494 err = autorest.Respond(
495 resp,
496 azure.WithErrorUnlessStatusCode(http.StatusOK),
497 autorest.ByUnmarshallingJSON(&result),
498 autorest.ByClosing())
499 result.Response = autorest.Response{Response: resp}
500 return
501 }
502
503
504
505
506
507 func (client CassandraClustersClient) ListBackupsMethod(ctx context.Context, resourceGroupName string, clusterName string) (result ListBackups, err error) {
508 if tracing.IsEnabled() {
509 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListBackupsMethod")
510 defer func() {
511 sc := -1
512 if result.Response.Response != nil {
513 sc = result.Response.Response.StatusCode
514 }
515 tracing.EndSpan(ctx, sc, err)
516 }()
517 }
518 if err := validation.Validate([]validation.Validation{
519 {TargetValue: client.SubscriptionID,
520 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
521 {TargetValue: resourceGroupName,
522 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
523 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
524 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
525 {TargetValue: clusterName,
526 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
527 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
528 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
529 return result, validation.NewError("documentdb.CassandraClustersClient", "ListBackupsMethod", err.Error())
530 }
531
532 req, err := client.ListBackupsMethodPreparer(ctx, resourceGroupName, clusterName)
533 if err != nil {
534 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", nil, "Failure preparing request")
535 return
536 }
537
538 resp, err := client.ListBackupsMethodSender(req)
539 if err != nil {
540 result.Response = autorest.Response{Response: resp}
541 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", resp, "Failure sending request")
542 return
543 }
544
545 result, err = client.ListBackupsMethodResponder(resp)
546 if err != nil {
547 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBackupsMethod", resp, "Failure responding to request")
548 return
549 }
550
551 return
552 }
553
554
555 func (client CassandraClustersClient) ListBackupsMethodPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) {
556 pathParameters := map[string]interface{}{
557 "clusterName": autorest.Encode("path", clusterName),
558 "resourceGroupName": autorest.Encode("path", resourceGroupName),
559 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
560 }
561
562 const APIVersion = "2021-04-01-preview"
563 queryParameters := map[string]interface{}{
564 "api-version": APIVersion,
565 }
566
567 preparer := autorest.CreatePreparer(
568 autorest.AsGet(),
569 autorest.WithBaseURL(client.BaseURI),
570 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups", pathParameters),
571 autorest.WithQueryParameters(queryParameters))
572 return preparer.Prepare((&http.Request{}).WithContext(ctx))
573 }
574
575
576
577 func (client CassandraClustersClient) ListBackupsMethodSender(req *http.Request) (*http.Response, error) {
578 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
579 }
580
581
582
583 func (client CassandraClustersClient) ListBackupsMethodResponder(resp *http.Response) (result ListBackups, err error) {
584 err = autorest.Respond(
585 resp,
586 azure.WithErrorUnlessStatusCode(http.StatusOK),
587 autorest.ByUnmarshallingJSON(&result),
588 autorest.ByClosing())
589 result.Response = autorest.Response{Response: resp}
590 return
591 }
592
593
594
595
596 func (client CassandraClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListClusters, err error) {
597 if tracing.IsEnabled() {
598 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListByResourceGroup")
599 defer func() {
600 sc := -1
601 if result.Response.Response != nil {
602 sc = result.Response.Response.StatusCode
603 }
604 tracing.EndSpan(ctx, sc, err)
605 }()
606 }
607 if err := validation.Validate([]validation.Validation{
608 {TargetValue: client.SubscriptionID,
609 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
610 {TargetValue: resourceGroupName,
611 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
612 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
613 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
614 return result, validation.NewError("documentdb.CassandraClustersClient", "ListByResourceGroup", err.Error())
615 }
616
617 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
618 if err != nil {
619 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", nil, "Failure preparing request")
620 return
621 }
622
623 resp, err := client.ListByResourceGroupSender(req)
624 if err != nil {
625 result.Response = autorest.Response{Response: resp}
626 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure sending request")
627 return
628 }
629
630 result, err = client.ListByResourceGroupResponder(resp)
631 if err != nil {
632 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure responding to request")
633 return
634 }
635
636 return
637 }
638
639
640 func (client CassandraClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
641 pathParameters := map[string]interface{}{
642 "resourceGroupName": autorest.Encode("path", resourceGroupName),
643 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
644 }
645
646 const APIVersion = "2021-04-01-preview"
647 queryParameters := map[string]interface{}{
648 "api-version": APIVersion,
649 }
650
651 preparer := autorest.CreatePreparer(
652 autorest.AsGet(),
653 autorest.WithBaseURL(client.BaseURI),
654 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters),
655 autorest.WithQueryParameters(queryParameters))
656 return preparer.Prepare((&http.Request{}).WithContext(ctx))
657 }
658
659
660
661 func (client CassandraClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
662 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
663 }
664
665
666
667 func (client CassandraClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ListClusters, err error) {
668 err = autorest.Respond(
669 resp,
670 azure.WithErrorUnlessStatusCode(http.StatusOK),
671 autorest.ByUnmarshallingJSON(&result),
672 autorest.ByClosing())
673 result.Response = autorest.Response{Response: resp}
674 return
675 }
676
677
678 func (client CassandraClustersClient) ListBySubscription(ctx context.Context) (result ListClusters, err error) {
679 if tracing.IsEnabled() {
680 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListBySubscription")
681 defer func() {
682 sc := -1
683 if result.Response.Response != nil {
684 sc = result.Response.Response.StatusCode
685 }
686 tracing.EndSpan(ctx, sc, err)
687 }()
688 }
689 if err := validation.Validate([]validation.Validation{
690 {TargetValue: client.SubscriptionID,
691 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
692 return result, validation.NewError("documentdb.CassandraClustersClient", "ListBySubscription", err.Error())
693 }
694
695 req, err := client.ListBySubscriptionPreparer(ctx)
696 if err != nil {
697 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", nil, "Failure preparing request")
698 return
699 }
700
701 resp, err := client.ListBySubscriptionSender(req)
702 if err != nil {
703 result.Response = autorest.Response{Response: resp}
704 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure sending request")
705 return
706 }
707
708 result, err = client.ListBySubscriptionResponder(resp)
709 if err != nil {
710 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure responding to request")
711 return
712 }
713
714 return
715 }
716
717
718 func (client CassandraClustersClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
719 pathParameters := map[string]interface{}{
720 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
721 }
722
723 const APIVersion = "2021-04-01-preview"
724 queryParameters := map[string]interface{}{
725 "api-version": APIVersion,
726 }
727
728 preparer := autorest.CreatePreparer(
729 autorest.AsGet(),
730 autorest.WithBaseURL(client.BaseURI),
731 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters),
732 autorest.WithQueryParameters(queryParameters))
733 return preparer.Prepare((&http.Request{}).WithContext(ctx))
734 }
735
736
737
738 func (client CassandraClustersClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
739 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
740 }
741
742
743
744 func (client CassandraClustersClient) ListBySubscriptionResponder(resp *http.Response) (result ListClusters, err error) {
745 err = autorest.Respond(
746 resp,
747 azure.WithErrorUnlessStatusCode(http.StatusOK),
748 autorest.ByUnmarshallingJSON(&result),
749 autorest.ByClosing())
750 result.Response = autorest.Response{Response: resp}
751 return
752 }
753
754
755
756
757
758
759 func (client CassandraClustersClient) RequestRepair(ctx context.Context, resourceGroupName string, clusterName string, body RepairPostBody) (result CassandraClustersRequestRepairFuture, err error) {
760 if tracing.IsEnabled() {
761 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.RequestRepair")
762 defer func() {
763 sc := -1
764 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
765 sc = result.FutureAPI.Response().StatusCode
766 }
767 tracing.EndSpan(ctx, sc, err)
768 }()
769 }
770 if err := validation.Validate([]validation.Validation{
771 {TargetValue: client.SubscriptionID,
772 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
773 {TargetValue: resourceGroupName,
774 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
775 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
776 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
777 {TargetValue: clusterName,
778 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
779 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
780 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}},
781 {TargetValue: body,
782 Constraints: []validation.Constraint{{Target: "body.Keyspace", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
783 return result, validation.NewError("documentdb.CassandraClustersClient", "RequestRepair", err.Error())
784 }
785
786 req, err := client.RequestRepairPreparer(ctx, resourceGroupName, clusterName, body)
787 if err != nil {
788 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "RequestRepair", nil, "Failure preparing request")
789 return
790 }
791
792 result, err = client.RequestRepairSender(req)
793 if err != nil {
794 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "RequestRepair", result.Response(), "Failure sending request")
795 return
796 }
797
798 return
799 }
800
801
802 func (client CassandraClustersClient) RequestRepairPreparer(ctx context.Context, resourceGroupName string, clusterName string, body RepairPostBody) (*http.Request, error) {
803 pathParameters := map[string]interface{}{
804 "clusterName": autorest.Encode("path", clusterName),
805 "resourceGroupName": autorest.Encode("path", resourceGroupName),
806 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
807 }
808
809 const APIVersion = "2021-04-01-preview"
810 queryParameters := map[string]interface{}{
811 "api-version": APIVersion,
812 }
813
814 preparer := autorest.CreatePreparer(
815 autorest.AsContentType("application/json; charset=utf-8"),
816 autorest.AsPost(),
817 autorest.WithBaseURL(client.BaseURI),
818 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/repair", pathParameters),
819 autorest.WithJSON(body),
820 autorest.WithQueryParameters(queryParameters))
821 return preparer.Prepare((&http.Request{}).WithContext(ctx))
822 }
823
824
825
826 func (client CassandraClustersClient) RequestRepairSender(req *http.Request) (future CassandraClustersRequestRepairFuture, err error) {
827 var resp *http.Response
828 future.FutureAPI = &azure.Future{}
829 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
830 if err != nil {
831 return
832 }
833 var azf azure.Future
834 azf, err = azure.NewFutureFromResponse(resp)
835 future.FutureAPI = &azf
836 future.Result = future.result
837 return
838 }
839
840
841
842 func (client CassandraClustersClient) RequestRepairResponder(resp *http.Response) (result autorest.Response, err error) {
843 err = autorest.Respond(
844 resp,
845 azure.WithErrorUnlessStatusCode(http.StatusOK),
846 autorest.ByClosing())
847 result.Response = resp
848 return
849 }
850
851
852
853
854
855
856 func (client CassandraClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersUpdateFuture, err error) {
857 if tracing.IsEnabled() {
858 ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Update")
859 defer func() {
860 sc := -1
861 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
862 sc = result.FutureAPI.Response().StatusCode
863 }
864 tracing.EndSpan(ctx, sc, err)
865 }()
866 }
867 if err := validation.Validate([]validation.Validation{
868 {TargetValue: client.SubscriptionID,
869 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
870 {TargetValue: resourceGroupName,
871 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
872 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
873 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
874 {TargetValue: clusterName,
875 Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil},
876 {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil},
877 {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*`, Chain: nil}}}}); err != nil {
878 return result, validation.NewError("documentdb.CassandraClustersClient", "Update", err.Error())
879 }
880
881 req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, body)
882 if err != nil {
883 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", nil, "Failure preparing request")
884 return
885 }
886
887 result, err = client.UpdateSender(req)
888 if err != nil {
889 err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", result.Response(), "Failure sending request")
890 return
891 }
892
893 return
894 }
895
896
897 func (client CassandraClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) {
898 pathParameters := map[string]interface{}{
899 "clusterName": autorest.Encode("path", clusterName),
900 "resourceGroupName": autorest.Encode("path", resourceGroupName),
901 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
902 }
903
904 const APIVersion = "2021-04-01-preview"
905 queryParameters := map[string]interface{}{
906 "api-version": APIVersion,
907 }
908
909 preparer := autorest.CreatePreparer(
910 autorest.AsContentType("application/json; charset=utf-8"),
911 autorest.AsPatch(),
912 autorest.WithBaseURL(client.BaseURI),
913 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters),
914 autorest.WithJSON(body),
915 autorest.WithQueryParameters(queryParameters))
916 return preparer.Prepare((&http.Request{}).WithContext(ctx))
917 }
918
919
920
921 func (client CassandraClustersClient) UpdateSender(req *http.Request) (future CassandraClustersUpdateFuture, err error) {
922 var resp *http.Response
923 future.FutureAPI = &azure.Future{}
924 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
925 if err != nil {
926 return
927 }
928 var azf azure.Future
929 azf, err = azure.NewFutureFromResponse(resp)
930 future.FutureAPI = &azf
931 future.Result = future.result
932 return
933 }
934
935
936
937 func (client CassandraClustersClient) UpdateResponder(resp *http.Response) (result ClusterResource, err error) {
938 err = autorest.Respond(
939 resp,
940 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
941 autorest.ByUnmarshallingJSON(&result),
942 autorest.ByClosing())
943 result.Response = autorest.Response{Response: resp}
944 return
945 }
946
View as plain text