@@ -1320,6 +1320,259 @@ internal DataTransferJobsOperations (CosmosDBManagementClient client)
1320
1320
1321
1321
1322
1322
1323
+ }
1324
+ /// <summary>
1325
+ /// Completes a Data Transfer Online Job.
1326
+ /// </summary>
1327
+ /// <param name='resourceGroupName'>
1328
+ /// The name of the resource group. The name is case insensitive.
1329
+ /// </param>
1330
+ /// <param name='accountName'>
1331
+ /// Cosmos DB database account name.
1332
+ /// </param>
1333
+ /// <param name='jobName'>
1334
+ /// Name of the Data Transfer Job
1335
+ /// </param>
1336
+ /// <param name='customHeaders'>
1337
+ /// Headers that will be added to request.
1338
+ /// </param>
1339
+ /// <param name='cancellationToken'>
1340
+ /// The cancellation token.
1341
+ /// </param>
1342
+ /// <exception cref="Microsoft.Rest.Azure.CloudException">
1343
+ /// Thrown when the operation returned an invalid status code
1344
+ /// </exception>
1345
+ /// <exception cref="Microsoft.Rest.SerializationException">
1346
+ /// Thrown when unable to deserialize the response
1347
+ /// </exception>
1348
+ /// <exception cref="Microsoft.Rest.ValidationException">
1349
+ /// Thrown when a required parameter is null
1350
+ /// </exception>
1351
+ /// <exception cref="System.ArgumentNullException">
1352
+ /// Thrown when a required parameter is null
1353
+ /// </exception>
1354
+ /// <return>
1355
+ /// A response object containing the response body and response headers.
1356
+ /// </return>
1357
+ public async System . Threading . Tasks . Task < Microsoft . Rest . Azure . AzureOperationResponse < DataTransferJobGetResults > > CompleteWithHttpMessagesAsync ( string resourceGroupName , string accountName , string jobName , System . Collections . Generic . Dictionary < string , System . Collections . Generic . List < string > > customHeaders = null , System . Threading . CancellationToken cancellationToken = default ( System . Threading . CancellationToken ) )
1358
+ {
1359
+
1360
+
1361
+
1362
+
1363
+ if ( this . Client . SubscriptionId == null )
1364
+ {
1365
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
1366
+ }
1367
+ if ( this . Client . SubscriptionId != null )
1368
+ {
1369
+ if ( this . Client . SubscriptionId . Length < 1 )
1370
+ {
1371
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MinLength , "Client.SubscriptionId" , 1 ) ;
1372
+ }
1373
+ }
1374
+ if ( resourceGroupName == null )
1375
+ {
1376
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "resourceGroupName" ) ;
1377
+ }
1378
+ if ( resourceGroupName != null )
1379
+ {
1380
+ if ( resourceGroupName . Length > 90 )
1381
+ {
1382
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MaxLength , "resourceGroupName" , 90 ) ;
1383
+ }
1384
+ if ( resourceGroupName . Length < 1 )
1385
+ {
1386
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MinLength , "resourceGroupName" , 1 ) ;
1387
+ }
1388
+ }
1389
+ if ( accountName == null )
1390
+ {
1391
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "accountName" ) ;
1392
+ }
1393
+ if ( accountName != null )
1394
+ {
1395
+ if ( accountName . Length > 50 )
1396
+ {
1397
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MaxLength , "accountName" , 50 ) ;
1398
+ }
1399
+ if ( accountName . Length < 3 )
1400
+ {
1401
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MinLength , "accountName" , 3 ) ;
1402
+ }
1403
+ if ( ! System . Text . RegularExpressions . Regex . IsMatch ( accountName , "^[a-z0-9]+(-[a-z0-9]+)*" ) )
1404
+ {
1405
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . Pattern , "accountName" , "^[a-z0-9]+(-[a-z0-9]+)*" ) ;
1406
+ }
1407
+ }
1408
+ if ( this . Client . ApiVersion == null )
1409
+ {
1410
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
1411
+ }
1412
+
1413
+ if ( jobName == null )
1414
+ {
1415
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "jobName" ) ;
1416
+ }
1417
+
1418
+ // Tracing
1419
+ bool _shouldTrace = Microsoft . Rest . ServiceClientTracing . IsEnabled ;
1420
+ string _invocationId = null ;
1421
+ if ( _shouldTrace )
1422
+ {
1423
+ _invocationId = Microsoft . Rest . ServiceClientTracing . NextInvocationId . ToString ( ) ;
1424
+ System . Collections . Generic . Dictionary < string , object > tracingParameters = new System . Collections . Generic . Dictionary < string , object > ( ) ;
1425
+ tracingParameters . Add ( "resourceGroupName" , resourceGroupName ) ;
1426
+ tracingParameters . Add ( "accountName" , accountName ) ;
1427
+ tracingParameters . Add ( "jobName" , jobName ) ;
1428
+
1429
+
1430
+ tracingParameters . Add ( "cancellationToken" , cancellationToken ) ;
1431
+ Microsoft . Rest . ServiceClientTracing . Enter ( _invocationId , this , "Complete" , tracingParameters ) ;
1432
+ }
1433
+ // Construct URL
1434
+
1435
+ var _baseUrl = this . Client . BaseUri . AbsoluteUri ;
1436
+ var _url = new System . Uri ( new System . Uri ( _baseUrl + ( _baseUrl . EndsWith ( "/" ) ? "" : "/" ) ) , "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/complete" ) . ToString ( ) ;
1437
+ _url = _url . Replace ( "{subscriptionId}" , System . Uri . EscapeDataString ( this . Client . SubscriptionId ) ) ;
1438
+ _url = _url . Replace ( "{resourceGroupName}" , System . Uri . EscapeDataString ( resourceGroupName ) ) ;
1439
+ _url = _url . Replace ( "{accountName}" , System . Uri . EscapeDataString ( accountName ) ) ;
1440
+ _url = _url . Replace ( "{jobName}" , System . Uri . EscapeDataString ( jobName ) ) ;
1441
+
1442
+ System . Collections . Generic . List < string > _queryParameters = new System . Collections . Generic . List < string > ( ) ;
1443
+ if ( this . Client . ApiVersion != null )
1444
+ {
1445
+ _queryParameters . Add ( string . Format ( "api-version={0}" , System . Uri . EscapeDataString ( this . Client . ApiVersion ) ) ) ;
1446
+ }
1447
+ if ( _queryParameters . Count > 0 )
1448
+ {
1449
+ _url += ( _url . Contains ( "?" ) ? "&" : "?" ) + string . Join ( "&" , _queryParameters ) ;
1450
+ }
1451
+ // Create HTTP transport objects
1452
+ var _httpRequest = new System . Net . Http . HttpRequestMessage ( ) ;
1453
+ System . Net . Http . HttpResponseMessage _httpResponse = null ;
1454
+ _httpRequest . Method = new System . Net . Http . HttpMethod ( "POST" ) ;
1455
+ _httpRequest . RequestUri = new System . Uri ( _url ) ;
1456
+ // Set Headers
1457
+ if ( this . Client . GenerateClientRequestId != null && this . Client . GenerateClientRequestId . Value )
1458
+ {
1459
+ _httpRequest . Headers . TryAddWithoutValidation ( "x-ms-client-request-id" , System . Guid . NewGuid ( ) . ToString ( ) ) ;
1460
+ }
1461
+ if ( this . Client . AcceptLanguage != null )
1462
+ {
1463
+ if ( _httpRequest . Headers . Contains ( "accept-language" ) )
1464
+ {
1465
+ _httpRequest . Headers . Remove ( "accept-language" ) ;
1466
+ }
1467
+ _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , this . Client . AcceptLanguage ) ;
1468
+ }
1469
+
1470
+ if ( customHeaders != null )
1471
+ {
1472
+ foreach ( var _header in customHeaders )
1473
+ {
1474
+ if ( _httpRequest . Headers . Contains ( _header . Key ) )
1475
+ {
1476
+ _httpRequest . Headers . Remove ( _header . Key ) ;
1477
+ }
1478
+ _httpRequest . Headers . TryAddWithoutValidation ( _header . Key , _header . Value ) ;
1479
+ }
1480
+ }
1481
+ // Serialize Request
1482
+ string _requestContent = null ;
1483
+ // Set Credentials
1484
+ if ( this . Client . Credentials != null )
1485
+ {
1486
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
1487
+ await this . Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
1488
+ }
1489
+ // Send Request
1490
+ if ( _shouldTrace )
1491
+ {
1492
+ Microsoft . Rest . ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
1493
+ }
1494
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
1495
+ _httpResponse = await this . Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
1496
+ if ( _shouldTrace )
1497
+ {
1498
+ Microsoft . Rest . ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
1499
+ }
1500
+
1501
+ System . Net . HttpStatusCode _statusCode = _httpResponse . StatusCode ;
1502
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
1503
+ string _responseContent = null ;
1504
+
1505
+ if ( ( int ) _statusCode != 200 )
1506
+ {
1507
+ var ex = new Microsoft . Rest . Azure . CloudException ( string . Format ( "Operation returned an invalid status code '{0}'" , _statusCode ) ) ;
1508
+ try
1509
+ {
1510
+ _responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
1511
+ CloudError _errorBody = Microsoft . Rest . Serialization . SafeJsonConvert . DeserializeObject < CloudError > ( _responseContent , this . Client . DeserializationSettings ) ;
1512
+ if ( _errorBody != null )
1513
+ {
1514
+ ex = new Microsoft . Rest . Azure . CloudException ( _errorBody . Message ) ;
1515
+ ex . Body = _errorBody ;
1516
+ }
1517
+ }
1518
+ catch ( Newtonsoft . Json . JsonException )
1519
+ {
1520
+ // Ignore the exception
1521
+ }
1522
+ ex . Request = new Microsoft . Rest . HttpRequestMessageWrapper ( _httpRequest , _requestContent ) ;
1523
+ ex . Response = new Microsoft . Rest . HttpResponseMessageWrapper ( _httpResponse , _responseContent ) ;
1524
+ if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
1525
+ {
1526
+ ex . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
1527
+ }
1528
+ if ( _shouldTrace )
1529
+ {
1530
+ Microsoft . Rest . ServiceClientTracing . Error ( _invocationId , ex ) ;
1531
+ }
1532
+ _httpRequest . Dispose ( ) ;
1533
+ if ( _httpResponse != null )
1534
+ {
1535
+ _httpResponse . Dispose ( ) ;
1536
+ }
1537
+ throw ex ;
1538
+ }
1539
+ // Create Result
1540
+ var _result = new Microsoft . Rest . Azure . AzureOperationResponse < DataTransferJobGetResults > ( ) ;
1541
+ _result . Request = _httpRequest ;
1542
+ _result . Response = _httpResponse ;
1543
+
1544
+ if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
1545
+ {
1546
+ _result . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
1547
+ }
1548
+ // Deserialize Response
1549
+ if ( ( int ) _statusCode == 200 )
1550
+ {
1551
+ _responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
1552
+ try
1553
+ {
1554
+ _result . Body = Microsoft . Rest . Serialization . SafeJsonConvert . DeserializeObject < DataTransferJobGetResults > ( _responseContent , this . Client . DeserializationSettings ) ;
1555
+ }
1556
+ catch ( Newtonsoft . Json . JsonException ex )
1557
+ {
1558
+ _httpRequest . Dispose ( ) ;
1559
+ if ( _httpResponse != null )
1560
+ {
1561
+ _httpResponse . Dispose ( ) ;
1562
+ }
1563
+ throw new Microsoft . Rest . SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
1564
+ }
1565
+ }
1566
+ if ( _shouldTrace )
1567
+ {
1568
+ Microsoft . Rest . ServiceClientTracing . Exit ( _invocationId , _result ) ;
1569
+ }
1570
+ return _result ;
1571
+
1572
+
1573
+
1574
+
1575
+
1323
1576
}
1324
1577
/// <summary>
1325
1578
/// Get a list of Data Transfer jobs.
0 commit comments