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 MongoDBResourcesClient struct {
20 BaseClient
21 }
22
23
24 func NewMongoDBResourcesClient(subscriptionID string) MongoDBResourcesClient {
25 return NewMongoDBResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewMongoDBResourcesClientWithBaseURI(baseURI string, subscriptionID string) MongoDBResourcesClient {
32 return MongoDBResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42 func (client MongoDBResourcesClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBCollection")
45 defer func() {
46 sc := -1
47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48 sc = result.FutureAPI.Response().StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: client.SubscriptionID,
55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
56 {TargetValue: resourceGroupName,
57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
59 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
60 {TargetValue: accountName,
61 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
62 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
63 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
64 {TargetValue: createUpdateMongoDBCollectionParameters,
65 Constraints: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties", Name: validation.Null, Rule: true,
66 Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true,
67 Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}},
68 {Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil},
69 }}}}}); err != nil {
70 return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", err.Error())
71 }
72
73 req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters)
74 if err != nil {
75 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request")
76 return
77 }
78
79 result, err = client.CreateUpdateMongoDBCollectionSender(req)
80 if err != nil {
81 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", result.Response(), "Failure sending request")
82 return
83 }
84
85 return
86 }
87
88
89 func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (*http.Request, error) {
90 pathParameters := map[string]interface{}{
91 "accountName": autorest.Encode("path", accountName),
92 "collectionName": autorest.Encode("path", collectionName),
93 "databaseName": autorest.Encode("path", databaseName),
94 "resourceGroupName": autorest.Encode("path", resourceGroupName),
95 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
96 }
97
98 const APIVersion = "2019-08-01"
99 queryParameters := map[string]interface{}{
100 "api-version": APIVersion,
101 }
102
103 preparer := autorest.CreatePreparer(
104 autorest.AsContentType("application/json; charset=utf-8"),
105 autorest.AsPut(),
106 autorest.WithBaseURL(client.BaseURI),
107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
108 autorest.WithJSON(createUpdateMongoDBCollectionParameters),
109 autorest.WithQueryParameters(queryParameters))
110 return preparer.Prepare((&http.Request{}).WithContext(ctx))
111 }
112
113
114
115 func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) {
116 var resp *http.Response
117 future.FutureAPI = &azure.Future{}
118 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
119 if err != nil {
120 return
121 }
122 var azf azure.Future
123 azf, err = azure.NewFutureFromResponse(resp)
124 future.FutureAPI = &azf
125 future.Result = future.result
126 return
127 }
128
129
130
131 func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) {
132 err = autorest.Respond(
133 resp,
134 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
135 autorest.ByUnmarshallingJSON(&result),
136 autorest.ByClosing())
137 result.Response = autorest.Response{Response: resp}
138 return
139 }
140
141
142
143
144
145
146
147 func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) {
148 if tracing.IsEnabled() {
149 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBDatabase")
150 defer func() {
151 sc := -1
152 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
153 sc = result.FutureAPI.Response().StatusCode
154 }
155 tracing.EndSpan(ctx, sc, err)
156 }()
157 }
158 if err := validation.Validate([]validation.Validation{
159 {TargetValue: client.SubscriptionID,
160 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
161 {TargetValue: resourceGroupName,
162 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
163 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
164 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
165 {TargetValue: accountName,
166 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
167 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
168 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
169 {TargetValue: createUpdateMongoDBDatabaseParameters,
170 Constraints: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true,
171 Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true,
172 Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}},
173 {Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil},
174 }}}}}); err != nil {
175 return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", err.Error())
176 }
177
178 req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters)
179 if err != nil {
180 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request")
181 return
182 }
183
184 result, err = client.CreateUpdateMongoDBDatabaseSender(req)
185 if err != nil {
186 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", result.Response(), "Failure sending request")
187 return
188 }
189
190 return
191 }
192
193
194 func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (*http.Request, error) {
195 pathParameters := map[string]interface{}{
196 "accountName": autorest.Encode("path", accountName),
197 "databaseName": autorest.Encode("path", databaseName),
198 "resourceGroupName": autorest.Encode("path", resourceGroupName),
199 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
200 }
201
202 const APIVersion = "2019-08-01"
203 queryParameters := map[string]interface{}{
204 "api-version": APIVersion,
205 }
206
207 preparer := autorest.CreatePreparer(
208 autorest.AsContentType("application/json; charset=utf-8"),
209 autorest.AsPut(),
210 autorest.WithBaseURL(client.BaseURI),
211 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
212 autorest.WithJSON(createUpdateMongoDBDatabaseParameters),
213 autorest.WithQueryParameters(queryParameters))
214 return preparer.Prepare((&http.Request{}).WithContext(ctx))
215 }
216
217
218
219 func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) {
220 var resp *http.Response
221 future.FutureAPI = &azure.Future{}
222 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
223 if err != nil {
224 return
225 }
226 var azf azure.Future
227 azf, err = azure.NewFutureFromResponse(resp)
228 future.FutureAPI = &azf
229 future.Result = future.result
230 return
231 }
232
233
234
235 func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) {
236 err = autorest.Respond(
237 resp,
238 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
239 autorest.ByUnmarshallingJSON(&result),
240 autorest.ByClosing())
241 result.Response = autorest.Response{Response: resp}
242 return
243 }
244
245
246
247
248
249
250
251 func (client MongoDBResourcesClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesDeleteMongoDBCollectionFuture, err error) {
252 if tracing.IsEnabled() {
253 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBCollection")
254 defer func() {
255 sc := -1
256 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
257 sc = result.FutureAPI.Response().StatusCode
258 }
259 tracing.EndSpan(ctx, sc, err)
260 }()
261 }
262 if err := validation.Validate([]validation.Validation{
263 {TargetValue: client.SubscriptionID,
264 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
265 {TargetValue: resourceGroupName,
266 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
267 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
268 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
269 {TargetValue: accountName,
270 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
271 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
272 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
273 return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", err.Error())
274 }
275
276 req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
277 if err != nil {
278 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure preparing request")
279 return
280 }
281
282 result, err = client.DeleteMongoDBCollectionSender(req)
283 if err != nil {
284 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", result.Response(), "Failure sending request")
285 return
286 }
287
288 return
289 }
290
291
292 func (client MongoDBResourcesClient) DeleteMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
293 pathParameters := map[string]interface{}{
294 "accountName": autorest.Encode("path", accountName),
295 "collectionName": autorest.Encode("path", collectionName),
296 "databaseName": autorest.Encode("path", databaseName),
297 "resourceGroupName": autorest.Encode("path", resourceGroupName),
298 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
299 }
300
301 const APIVersion = "2019-08-01"
302 queryParameters := map[string]interface{}{
303 "api-version": APIVersion,
304 }
305
306 preparer := autorest.CreatePreparer(
307 autorest.AsDelete(),
308 autorest.WithBaseURL(client.BaseURI),
309 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
310 autorest.WithQueryParameters(queryParameters))
311 return preparer.Prepare((&http.Request{}).WithContext(ctx))
312 }
313
314
315
316 func (client MongoDBResourcesClient) DeleteMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBCollectionFuture, err error) {
317 var resp *http.Response
318 future.FutureAPI = &azure.Future{}
319 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
320 if err != nil {
321 return
322 }
323 var azf azure.Future
324 azf, err = azure.NewFutureFromResponse(resp)
325 future.FutureAPI = &azf
326 future.Result = future.result
327 return
328 }
329
330
331
332 func (client MongoDBResourcesClient) DeleteMongoDBCollectionResponder(resp *http.Response) (result autorest.Response, err error) {
333 err = autorest.Respond(
334 resp,
335 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
336 autorest.ByClosing())
337 result.Response = resp
338 return
339 }
340
341
342
343
344
345
346 func (client MongoDBResourcesClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) {
347 if tracing.IsEnabled() {
348 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBDatabase")
349 defer func() {
350 sc := -1
351 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
352 sc = result.FutureAPI.Response().StatusCode
353 }
354 tracing.EndSpan(ctx, sc, err)
355 }()
356 }
357 if err := validation.Validate([]validation.Validation{
358 {TargetValue: client.SubscriptionID,
359 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
360 {TargetValue: resourceGroupName,
361 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
362 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
363 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
364 {TargetValue: accountName,
365 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
366 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
367 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
368 return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", err.Error())
369 }
370
371 req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName)
372 if err != nil {
373 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure preparing request")
374 return
375 }
376
377 result, err = client.DeleteMongoDBDatabaseSender(req)
378 if err != nil {
379 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", result.Response(), "Failure sending request")
380 return
381 }
382
383 return
384 }
385
386
387 func (client MongoDBResourcesClient) DeleteMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
388 pathParameters := map[string]interface{}{
389 "accountName": autorest.Encode("path", accountName),
390 "databaseName": autorest.Encode("path", databaseName),
391 "resourceGroupName": autorest.Encode("path", resourceGroupName),
392 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
393 }
394
395 const APIVersion = "2019-08-01"
396 queryParameters := map[string]interface{}{
397 "api-version": APIVersion,
398 }
399
400 preparer := autorest.CreatePreparer(
401 autorest.AsDelete(),
402 autorest.WithBaseURL(client.BaseURI),
403 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
404 autorest.WithQueryParameters(queryParameters))
405 return preparer.Prepare((&http.Request{}).WithContext(ctx))
406 }
407
408
409
410 func (client MongoDBResourcesClient) DeleteMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) {
411 var resp *http.Response
412 future.FutureAPI = &azure.Future{}
413 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
414 if err != nil {
415 return
416 }
417 var azf azure.Future
418 azf, err = azure.NewFutureFromResponse(resp)
419 future.FutureAPI = &azf
420 future.Result = future.result
421 return
422 }
423
424
425
426 func (client MongoDBResourcesClient) DeleteMongoDBDatabaseResponder(resp *http.Response) (result autorest.Response, err error) {
427 err = autorest.Respond(
428 resp,
429 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
430 autorest.ByClosing())
431 result.Response = resp
432 return
433 }
434
435
436
437
438
439
440
441 func (client MongoDBResourcesClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollectionGetResults, err error) {
442 if tracing.IsEnabled() {
443 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollection")
444 defer func() {
445 sc := -1
446 if result.Response.Response != nil {
447 sc = result.Response.Response.StatusCode
448 }
449 tracing.EndSpan(ctx, sc, err)
450 }()
451 }
452 if err := validation.Validate([]validation.Validation{
453 {TargetValue: client.SubscriptionID,
454 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
455 {TargetValue: resourceGroupName,
456 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
457 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
458 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
459 {TargetValue: accountName,
460 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
461 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
462 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
463 return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollection", err.Error())
464 }
465
466 req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
467 if err != nil {
468 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", nil, "Failure preparing request")
469 return
470 }
471
472 resp, err := client.GetMongoDBCollectionSender(req)
473 if err != nil {
474 result.Response = autorest.Response{Response: resp}
475 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure sending request")
476 return
477 }
478
479 result, err = client.GetMongoDBCollectionResponder(resp)
480 if err != nil {
481 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure responding to request")
482 return
483 }
484
485 return
486 }
487
488
489 func (client MongoDBResourcesClient) GetMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
490 pathParameters := map[string]interface{}{
491 "accountName": autorest.Encode("path", accountName),
492 "collectionName": autorest.Encode("path", collectionName),
493 "databaseName": autorest.Encode("path", databaseName),
494 "resourceGroupName": autorest.Encode("path", resourceGroupName),
495 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
496 }
497
498 const APIVersion = "2019-08-01"
499 queryParameters := map[string]interface{}{
500 "api-version": APIVersion,
501 }
502
503 preparer := autorest.CreatePreparer(
504 autorest.AsGet(),
505 autorest.WithBaseURL(client.BaseURI),
506 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters),
507 autorest.WithQueryParameters(queryParameters))
508 return preparer.Prepare((&http.Request{}).WithContext(ctx))
509 }
510
511
512
513 func (client MongoDBResourcesClient) GetMongoDBCollectionSender(req *http.Request) (*http.Response, error) {
514 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
515 }
516
517
518
519 func (client MongoDBResourcesClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) {
520 err = autorest.Respond(
521 resp,
522 azure.WithErrorUnlessStatusCode(http.StatusOK),
523 autorest.ByUnmarshallingJSON(&result),
524 autorest.ByClosing())
525 result.Response = autorest.Response{Response: resp}
526 return
527 }
528
529
530
531
532
533
534
535
536 func (client MongoDBResourcesClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result ThroughputSettingsGetResults, err error) {
537 if tracing.IsEnabled() {
538 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollectionThroughput")
539 defer func() {
540 sc := -1
541 if result.Response.Response != nil {
542 sc = result.Response.Response.StatusCode
543 }
544 tracing.EndSpan(ctx, sc, err)
545 }()
546 }
547 if err := validation.Validate([]validation.Validation{
548 {TargetValue: client.SubscriptionID,
549 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
550 {TargetValue: resourceGroupName,
551 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
552 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
553 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
554 {TargetValue: accountName,
555 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
556 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
557 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
558 return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", err.Error())
559 }
560
561 req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName)
562 if err != nil {
563 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", nil, "Failure preparing request")
564 return
565 }
566
567 resp, err := client.GetMongoDBCollectionThroughputSender(req)
568 if err != nil {
569 result.Response = autorest.Response{Response: resp}
570 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request")
571 return
572 }
573
574 result, err = client.GetMongoDBCollectionThroughputResponder(resp)
575 if err != nil {
576 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request")
577 return
578 }
579
580 return
581 }
582
583
584 func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) {
585 pathParameters := map[string]interface{}{
586 "accountName": autorest.Encode("path", accountName),
587 "collectionName": autorest.Encode("path", collectionName),
588 "databaseName": autorest.Encode("path", databaseName),
589 "resourceGroupName": autorest.Encode("path", resourceGroupName),
590 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
591 }
592
593 const APIVersion = "2019-08-01"
594 queryParameters := map[string]interface{}{
595 "api-version": APIVersion,
596 }
597
598 preparer := autorest.CreatePreparer(
599 autorest.AsGet(),
600 autorest.WithBaseURL(client.BaseURI),
601 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters),
602 autorest.WithQueryParameters(queryParameters))
603 return preparer.Prepare((&http.Request{}).WithContext(ctx))
604 }
605
606
607
608 func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputSender(req *http.Request) (*http.Response, error) {
609 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
610 }
611
612
613
614 func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
615 err = autorest.Respond(
616 resp,
617 azure.WithErrorUnlessStatusCode(http.StatusOK),
618 autorest.ByUnmarshallingJSON(&result),
619 autorest.ByClosing())
620 result.Response = autorest.Response{Response: resp}
621 return
622 }
623
624
625
626
627
628
629
630 func (client MongoDBResourcesClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabaseGetResults, err error) {
631 if tracing.IsEnabled() {
632 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabase")
633 defer func() {
634 sc := -1
635 if result.Response.Response != nil {
636 sc = result.Response.Response.StatusCode
637 }
638 tracing.EndSpan(ctx, sc, err)
639 }()
640 }
641 if err := validation.Validate([]validation.Validation{
642 {TargetValue: client.SubscriptionID,
643 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
644 {TargetValue: resourceGroupName,
645 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
646 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
647 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
648 {TargetValue: accountName,
649 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
650 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
651 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
652 return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", err.Error())
653 }
654
655 req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName)
656 if err != nil {
657 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", nil, "Failure preparing request")
658 return
659 }
660
661 resp, err := client.GetMongoDBDatabaseSender(req)
662 if err != nil {
663 result.Response = autorest.Response{Response: resp}
664 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure sending request")
665 return
666 }
667
668 result, err = client.GetMongoDBDatabaseResponder(resp)
669 if err != nil {
670 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure responding to request")
671 return
672 }
673
674 return
675 }
676
677
678 func (client MongoDBResourcesClient) GetMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
679 pathParameters := map[string]interface{}{
680 "accountName": autorest.Encode("path", accountName),
681 "databaseName": autorest.Encode("path", databaseName),
682 "resourceGroupName": autorest.Encode("path", resourceGroupName),
683 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
684 }
685
686 const APIVersion = "2019-08-01"
687 queryParameters := map[string]interface{}{
688 "api-version": APIVersion,
689 }
690
691 preparer := autorest.CreatePreparer(
692 autorest.AsGet(),
693 autorest.WithBaseURL(client.BaseURI),
694 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters),
695 autorest.WithQueryParameters(queryParameters))
696 return preparer.Prepare((&http.Request{}).WithContext(ctx))
697 }
698
699
700
701 func (client MongoDBResourcesClient) GetMongoDBDatabaseSender(req *http.Request) (*http.Response, error) {
702 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
703 }
704
705
706
707 func (client MongoDBResourcesClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) {
708 err = autorest.Respond(
709 resp,
710 azure.WithErrorUnlessStatusCode(http.StatusOK),
711 autorest.ByUnmarshallingJSON(&result),
712 autorest.ByClosing())
713 result.Response = autorest.Response{Response: resp}
714 return
715 }
716
717
718
719
720
721
722
723 func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) {
724 if tracing.IsEnabled() {
725 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabaseThroughput")
726 defer func() {
727 sc := -1
728 if result.Response.Response != nil {
729 sc = result.Response.Response.StatusCode
730 }
731 tracing.EndSpan(ctx, sc, err)
732 }()
733 }
734 if err := validation.Validate([]validation.Validation{
735 {TargetValue: client.SubscriptionID,
736 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
737 {TargetValue: resourceGroupName,
738 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
739 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
740 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
741 {TargetValue: accountName,
742 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
743 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
744 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
745 return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", err.Error())
746 }
747
748 req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName)
749 if err != nil {
750 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", nil, "Failure preparing request")
751 return
752 }
753
754 resp, err := client.GetMongoDBDatabaseThroughputSender(req)
755 if err != nil {
756 result.Response = autorest.Response{Response: resp}
757 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request")
758 return
759 }
760
761 result, err = client.GetMongoDBDatabaseThroughputResponder(resp)
762 if err != nil {
763 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request")
764 return
765 }
766
767 return
768 }
769
770
771 func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
772 pathParameters := map[string]interface{}{
773 "accountName": autorest.Encode("path", accountName),
774 "databaseName": autorest.Encode("path", databaseName),
775 "resourceGroupName": autorest.Encode("path", resourceGroupName),
776 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
777 }
778
779 const APIVersion = "2019-08-01"
780 queryParameters := map[string]interface{}{
781 "api-version": APIVersion,
782 }
783
784 preparer := autorest.CreatePreparer(
785 autorest.AsGet(),
786 autorest.WithBaseURL(client.BaseURI),
787 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters),
788 autorest.WithQueryParameters(queryParameters))
789 return preparer.Prepare((&http.Request{}).WithContext(ctx))
790 }
791
792
793
794 func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputSender(req *http.Request) (*http.Response, error) {
795 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
796 }
797
798
799
800 func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
801 err = autorest.Respond(
802 resp,
803 azure.WithErrorUnlessStatusCode(http.StatusOK),
804 autorest.ByUnmarshallingJSON(&result),
805 autorest.ByClosing())
806 result.Response = autorest.Response{Response: resp}
807 return
808 }
809
810
811
812
813
814
815 func (client MongoDBResourcesClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) {
816 if tracing.IsEnabled() {
817 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBCollections")
818 defer func() {
819 sc := -1
820 if result.Response.Response != nil {
821 sc = result.Response.Response.StatusCode
822 }
823 tracing.EndSpan(ctx, sc, err)
824 }()
825 }
826 if err := validation.Validate([]validation.Validation{
827 {TargetValue: client.SubscriptionID,
828 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
829 {TargetValue: resourceGroupName,
830 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
831 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
832 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
833 {TargetValue: accountName,
834 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
835 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
836 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
837 return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBCollections", err.Error())
838 }
839
840 req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName)
841 if err != nil {
842 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", nil, "Failure preparing request")
843 return
844 }
845
846 resp, err := client.ListMongoDBCollectionsSender(req)
847 if err != nil {
848 result.Response = autorest.Response{Response: resp}
849 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure sending request")
850 return
851 }
852
853 result, err = client.ListMongoDBCollectionsResponder(resp)
854 if err != nil {
855 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure responding to request")
856 return
857 }
858
859 return
860 }
861
862
863 func (client MongoDBResourcesClient) ListMongoDBCollectionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) {
864 pathParameters := map[string]interface{}{
865 "accountName": autorest.Encode("path", accountName),
866 "databaseName": autorest.Encode("path", databaseName),
867 "resourceGroupName": autorest.Encode("path", resourceGroupName),
868 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
869 }
870
871 const APIVersion = "2019-08-01"
872 queryParameters := map[string]interface{}{
873 "api-version": APIVersion,
874 }
875
876 preparer := autorest.CreatePreparer(
877 autorest.AsGet(),
878 autorest.WithBaseURL(client.BaseURI),
879 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", pathParameters),
880 autorest.WithQueryParameters(queryParameters))
881 return preparer.Prepare((&http.Request{}).WithContext(ctx))
882 }
883
884
885
886 func (client MongoDBResourcesClient) ListMongoDBCollectionsSender(req *http.Request) (*http.Response, error) {
887 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
888 }
889
890
891
892 func (client MongoDBResourcesClient) ListMongoDBCollectionsResponder(resp *http.Response) (result MongoDBCollectionListResult, err error) {
893 err = autorest.Respond(
894 resp,
895 azure.WithErrorUnlessStatusCode(http.StatusOK),
896 autorest.ByUnmarshallingJSON(&result),
897 autorest.ByClosing())
898 result.Response = autorest.Response{Response: resp}
899 return
900 }
901
902
903
904
905
906 func (client MongoDBResourcesClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) {
907 if tracing.IsEnabled() {
908 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBDatabases")
909 defer func() {
910 sc := -1
911 if result.Response.Response != nil {
912 sc = result.Response.Response.StatusCode
913 }
914 tracing.EndSpan(ctx, sc, err)
915 }()
916 }
917 if err := validation.Validate([]validation.Validation{
918 {TargetValue: client.SubscriptionID,
919 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
920 {TargetValue: resourceGroupName,
921 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
922 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
923 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
924 {TargetValue: accountName,
925 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
926 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
927 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
928 return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", err.Error())
929 }
930
931 req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName)
932 if err != nil {
933 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", nil, "Failure preparing request")
934 return
935 }
936
937 resp, err := client.ListMongoDBDatabasesSender(req)
938 if err != nil {
939 result.Response = autorest.Response{Response: resp}
940 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure sending request")
941 return
942 }
943
944 result, err = client.ListMongoDBDatabasesResponder(resp)
945 if err != nil {
946 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure responding to request")
947 return
948 }
949
950 return
951 }
952
953
954 func (client MongoDBResourcesClient) ListMongoDBDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
955 pathParameters := map[string]interface{}{
956 "accountName": autorest.Encode("path", accountName),
957 "resourceGroupName": autorest.Encode("path", resourceGroupName),
958 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
959 }
960
961 const APIVersion = "2019-08-01"
962 queryParameters := map[string]interface{}{
963 "api-version": APIVersion,
964 }
965
966 preparer := autorest.CreatePreparer(
967 autorest.AsGet(),
968 autorest.WithBaseURL(client.BaseURI),
969 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", pathParameters),
970 autorest.WithQueryParameters(queryParameters))
971 return preparer.Prepare((&http.Request{}).WithContext(ctx))
972 }
973
974
975
976 func (client MongoDBResourcesClient) ListMongoDBDatabasesSender(req *http.Request) (*http.Response, error) {
977 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
978 }
979
980
981
982 func (client MongoDBResourcesClient) ListMongoDBDatabasesResponder(resp *http.Response) (result MongoDBDatabaseListResult, err error) {
983 err = autorest.Respond(
984 resp,
985 azure.WithErrorUnlessStatusCode(http.StatusOK),
986 autorest.ByUnmarshallingJSON(&result),
987 autorest.ByClosing())
988 result.Response = autorest.Response{Response: resp}
989 return
990 }
991
992
993
994
995
996
997
998
999
1000 func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) {
1001 if tracing.IsEnabled() {
1002 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBCollectionThroughput")
1003 defer func() {
1004 sc := -1
1005 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1006 sc = result.FutureAPI.Response().StatusCode
1007 }
1008 tracing.EndSpan(ctx, sc, err)
1009 }()
1010 }
1011 if err := validation.Validate([]validation.Validation{
1012 {TargetValue: client.SubscriptionID,
1013 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1014 {TargetValue: resourceGroupName,
1015 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1016 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1017 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
1018 {TargetValue: accountName,
1019 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1020 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
1021 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
1022 {TargetValue: updateThroughputParameters,
1023 Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true,
1024 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true,
1025 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}},
1026 }}}}}); err != nil {
1027 return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", err.Error())
1028 }
1029
1030 req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters)
1031 if err != nil {
1032 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request")
1033 return
1034 }
1035
1036 result, err = client.UpdateMongoDBCollectionThroughputSender(req)
1037 if err != nil {
1038 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", result.Response(), "Failure sending request")
1039 return
1040 }
1041
1042 return
1043 }
1044
1045
1046 func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) {
1047 pathParameters := map[string]interface{}{
1048 "accountName": autorest.Encode("path", accountName),
1049 "collectionName": autorest.Encode("path", collectionName),
1050 "databaseName": autorest.Encode("path", databaseName),
1051 "resourceGroupName": autorest.Encode("path", resourceGroupName),
1052 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
1053 }
1054
1055 const APIVersion = "2019-08-01"
1056 queryParameters := map[string]interface{}{
1057 "api-version": APIVersion,
1058 }
1059
1060 preparer := autorest.CreatePreparer(
1061 autorest.AsContentType("application/json; charset=utf-8"),
1062 autorest.AsPut(),
1063 autorest.WithBaseURL(client.BaseURI),
1064 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters),
1065 autorest.WithJSON(updateThroughputParameters),
1066 autorest.WithQueryParameters(queryParameters))
1067 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1068 }
1069
1070
1071
1072 func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) {
1073 var resp *http.Response
1074 future.FutureAPI = &azure.Future{}
1075 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1076 if err != nil {
1077 return
1078 }
1079 var azf azure.Future
1080 azf, err = azure.NewFutureFromResponse(resp)
1081 future.FutureAPI = &azf
1082 future.Result = future.result
1083 return
1084 }
1085
1086
1087
1088 func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
1089 err = autorest.Respond(
1090 resp,
1091 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1092 autorest.ByUnmarshallingJSON(&result),
1093 autorest.ByClosing())
1094 result.Response = autorest.Response{Response: resp}
1095 return
1096 }
1097
1098
1099
1100
1101
1102
1103
1104
1105 func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) {
1106 if tracing.IsEnabled() {
1107 ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBDatabaseThroughput")
1108 defer func() {
1109 sc := -1
1110 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1111 sc = result.FutureAPI.Response().StatusCode
1112 }
1113 tracing.EndSpan(ctx, sc, err)
1114 }()
1115 }
1116 if err := validation.Validate([]validation.Validation{
1117 {TargetValue: client.SubscriptionID,
1118 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1119 {TargetValue: resourceGroupName,
1120 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1121 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1122 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
1123 {TargetValue: accountName,
1124 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1125 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
1126 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}},
1127 {TargetValue: updateThroughputParameters,
1128 Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true,
1129 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true,
1130 Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}},
1131 }}}}}); err != nil {
1132 return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", err.Error())
1133 }
1134
1135 req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters)
1136 if err != nil {
1137 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request")
1138 return
1139 }
1140
1141 result, err = client.UpdateMongoDBDatabaseThroughputSender(req)
1142 if err != nil {
1143 err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", result.Response(), "Failure sending request")
1144 return
1145 }
1146
1147 return
1148 }
1149
1150
1151 func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) {
1152 pathParameters := map[string]interface{}{
1153 "accountName": autorest.Encode("path", accountName),
1154 "databaseName": autorest.Encode("path", databaseName),
1155 "resourceGroupName": autorest.Encode("path", resourceGroupName),
1156 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
1157 }
1158
1159 const APIVersion = "2019-08-01"
1160 queryParameters := map[string]interface{}{
1161 "api-version": APIVersion,
1162 }
1163
1164 preparer := autorest.CreatePreparer(
1165 autorest.AsContentType("application/json; charset=utf-8"),
1166 autorest.AsPut(),
1167 autorest.WithBaseURL(client.BaseURI),
1168 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters),
1169 autorest.WithJSON(updateThroughputParameters),
1170 autorest.WithQueryParameters(queryParameters))
1171 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1172 }
1173
1174
1175
1176 func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) {
1177 var resp *http.Response
1178 future.FutureAPI = &azure.Future{}
1179 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1180 if err != nil {
1181 return
1182 }
1183 var azf azure.Future
1184 azf, err = azure.NewFutureFromResponse(resp)
1185 future.FutureAPI = &azf
1186 future.Result = future.result
1187 return
1188 }
1189
1190
1191
1192 func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) {
1193 err = autorest.Respond(
1194 resp,
1195 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1196 autorest.ByUnmarshallingJSON(&result),
1197 autorest.ByClosing())
1198 result.Response = autorest.Response{Response: resp}
1199 return
1200 }
1201
View as plain text