Skip to content

Commit 9101b13

Browse files
carjackson-msftkushalwarke1minhokang242
authored
[CosmosDB] Add support for new rp api version 2024-02-15-preview (#24261)
* update and regen for 02-15-2024-preview version * code changes * test recording * re-record tests * regen sdk * rerecord tests * test recording * Update ChangeLog.md * Add DisableTtl * Update md file * Introduce custom model class DisableTtl to accomodate enumness * Update readme * Update test json file to expect string instead of bool * Update readme to have boolean to string * Revert back to boolean parameter * Remove bak file * Update restore test * Update restore test * Undo recording file change * Add missing copy in the constructor * Fix spaceing * rerecord test --------- Co-authored-by: Kushal Warke <[email protected]> Co-authored-by: Min Ho Kang <[email protected]>
1 parent a7354be commit 9101b13

File tree

125 files changed

+62624
-50584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+62624
-50584
lines changed

src/CosmosDB/CosmosDB.Sdk/Generated/CassandraClustersOperations.cs

Lines changed: 510 additions & 0 deletions
Large diffs are not rendered by default.

src/CosmosDB/CosmosDB.Sdk/Generated/CassandraClustersOperationsExtensions.cs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,90 @@ public static CommandOutput InvokeCommand(this ICassandraClustersOperations oper
267267
}
268268
}
269269
/// <summary>
270+
/// List all commands currently running on ring info
271+
/// </summary>
272+
/// <param name='operations'>
273+
/// The operations group for this extension method.
274+
/// </param>
275+
/// <param name='resourceGroupName'>
276+
/// The name of the resource group. The name is case insensitive.
277+
/// </param>
278+
/// <param name='clusterName'>
279+
/// Managed Cassandra cluster name.
280+
/// </param>
281+
public static System.Collections.Generic.IEnumerable<CommandPublicResource> ListCommand(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName)
282+
{
283+
return ((ICassandraClustersOperations)operations).ListCommandAsync(resourceGroupName, clusterName).GetAwaiter().GetResult();
284+
}
285+
286+
/// <summary>
287+
/// List all commands currently running on ring info
288+
/// </summary>
289+
/// <param name='operations'>
290+
/// The operations group for this extension method.
291+
/// </param>
292+
/// <param name='resourceGroupName'>
293+
/// The name of the resource group. The name is case insensitive.
294+
/// </param>
295+
/// <param name='clusterName'>
296+
/// Managed Cassandra cluster name.
297+
/// </param>
298+
/// <param name='cancellationToken'>
299+
/// The cancellation token.
300+
/// </param>
301+
public static async System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<CommandPublicResource>> ListCommandAsync(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
302+
{
303+
using (var _result = await operations.ListCommandWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false))
304+
{
305+
return _result.Body;
306+
}
307+
}
308+
/// <summary>
309+
/// Get details about a specified command that was run asynchronously.
310+
/// </summary>
311+
/// <param name='operations'>
312+
/// The operations group for this extension method.
313+
/// </param>
314+
/// <param name='resourceGroupName'>
315+
/// The name of the resource group. The name is case insensitive.
316+
/// </param>
317+
/// <param name='clusterName'>
318+
/// Managed Cassandra cluster name.
319+
/// </param>
320+
/// <param name='commandId'>
321+
/// Managed Cassandra cluster command id.
322+
/// </param>
323+
public static ListCommands GetCommandAsync(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName, string commandId)
324+
{
325+
return ((ICassandraClustersOperations)operations).GetCommandAsyncAsync(resourceGroupName, clusterName, commandId).GetAwaiter().GetResult();
326+
}
327+
328+
/// <summary>
329+
/// Get details about a specified command that was run asynchronously.
330+
/// </summary>
331+
/// <param name='operations'>
332+
/// The operations group for this extension method.
333+
/// </param>
334+
/// <param name='resourceGroupName'>
335+
/// The name of the resource group. The name is case insensitive.
336+
/// </param>
337+
/// <param name='clusterName'>
338+
/// Managed Cassandra cluster name.
339+
/// </param>
340+
/// <param name='commandId'>
341+
/// Managed Cassandra cluster command id.
342+
/// </param>
343+
/// <param name='cancellationToken'>
344+
/// The cancellation token.
345+
/// </param>
346+
public static async System.Threading.Tasks.Task<ListCommands> GetCommandAsyncAsync(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName, string commandId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
347+
{
348+
using (var _result = await operations.GetCommandAsyncWithHttpMessagesAsync(resourceGroupName, clusterName, commandId, null, cancellationToken).ConfigureAwait(false))
349+
{
350+
return _result.Body;
351+
}
352+
}
353+
/// <summary>
270354
/// List the backups of this cluster that are available to restore.
271355
/// </summary>
272356
/// <param name='operations'>

src/CosmosDB/CosmosDB.Sdk/Generated/CosmosDBManagementClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ private void Initialize()
491491
this.RestorableTableResources = new RestorableTableResourcesOperations(this);
492492
this.Service = new ServiceOperations(this);
493493
this.BaseUri = new System.Uri("https://management.azure.com");
494-
this.ApiVersion = "2023-09-15-preview";
494+
this.ApiVersion = "2024-02-15-preview";
495495
this.AcceptLanguage = "en-US";
496496
this.LongRunningOperationRetryTimeout = 30;
497497
this.GenerateClientRequestId = true;
@@ -527,6 +527,8 @@ private void Initialize()
527527
DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter<DataTransferDataSourceSink>("component"));
528528
SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter<ServiceResourceProperties>("serviceType"));
529529
DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter<ServiceResourceProperties>("serviceType"));
530+
SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter<BaseCosmosDataTransferDataSourceSink>("component"));
531+
DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter<BaseCosmosDataTransferDataSourceSink>("component"));
530532
CustomInitialize();
531533
DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.TransformationJsonConverter());
532534
DeserializationSettings.Converters.Add(new Microsoft.Rest.Azure.CloudErrorJsonConverter());

src/CosmosDB/CosmosDB.Sdk/Generated/DataTransferJobsOperations.cs

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,259 @@ internal DataTransferJobsOperations (CosmosDBManagementClient client)
13201320

13211321

13221322

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+
13231576
}
13241577
/// <summary>
13251578
/// Get a list of Data Transfer jobs.

0 commit comments

Comments
 (0)