Skip to content

Commit 3312a25

Browse files
mwesigwagumaNoriZC
andauthored
Updating Service Fabric commands to use updated APIs (#23406)
* updating commands to use listNext functions * MaxUnusedVersionsToKeep from long back to int * updating changelog command * Update ChangeLog.md --------- Co-authored-by: NoriZC <[email protected]>
1 parent e867fd0 commit 3312a25

38 files changed

+1573
-432
lines changed

src/ServiceFabric/ServiceFabric.Management.sdk/Generated/ApplicationTypeVersionsOperations.cs

Lines changed: 180 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ internal ApplicationTypeVersionsOperations (ServiceFabricManagementClient client
358358
/// <return>
359359
/// A response object containing the response body and response headers.
360360
/// </return>
361-
public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<ApplicationTypeVersionResourceList>> ListWithHttpMessagesAsync(string resourceGroupName, string clusterName, string applicationTypeName, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
361+
public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>>> ListWithHttpMessagesAsync(string resourceGroupName, string clusterName, string applicationTypeName, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
362362
{
363363

364364

@@ -506,7 +506,7 @@ internal ApplicationTypeVersionsOperations (ServiceFabricManagementClient client
506506
throw ex;
507507
}
508508
// Create Result
509-
var _result = new Microsoft.Rest.Azure.AzureOperationResponse<ApplicationTypeVersionResourceList>();
509+
var _result = new Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>>();
510510
_result.Request = _httpRequest;
511511
_result.Response = _httpResponse;
512512

@@ -520,7 +520,7 @@ internal ApplicationTypeVersionsOperations (ServiceFabricManagementClient client
520520
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
521521
try
522522
{
523-
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<ApplicationTypeVersionResourceList>(_responseContent, this.Client.DeserializationSettings);
523+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ApplicationTypeVersionResource>>(_responseContent, this.Client.DeserializationSettings);
524524
}
525525
catch (Newtonsoft.Json.JsonException ex)
526526
{
@@ -992,6 +992,183 @@ internal ApplicationTypeVersionsOperations (ServiceFabricManagementClient client
992992

993993

994994

995+
}
996+
/// <summary>
997+
/// Gets all application type version resources created or in the process of being created in the Service Fabric application type name resource.
998+
/// </summary>
999+
/// <param name='nextPageLink'>
1000+
/// The NextLink from the previous successful call to List operation.
1001+
/// </param>
1002+
/// <param name='customHeaders'>
1003+
/// Headers that will be added to request.
1004+
/// </param>
1005+
/// <param name='cancellationToken'>
1006+
/// The cancellation token.
1007+
/// </param>
1008+
/// <exception cref="Microsoft.Rest.Azure.CloudException">
1009+
/// Thrown when the operation returned an invalid status code
1010+
/// </exception>
1011+
/// <exception cref="Microsoft.Rest.SerializationException">
1012+
/// Thrown when unable to deserialize the response
1013+
/// </exception>
1014+
/// <exception cref="Microsoft.Rest.ValidationException">
1015+
/// Thrown when a required parameter is null
1016+
/// </exception>
1017+
/// <exception cref="System.ArgumentNullException">
1018+
/// Thrown when a required parameter is null
1019+
/// </exception>
1020+
/// <return>
1021+
/// A response object containing the response body and response headers.
1022+
/// </return>
1023+
public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>>> ListNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
1024+
{
1025+
1026+
if (nextPageLink == null)
1027+
{
1028+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink");
1029+
}
1030+
// Tracing
1031+
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
1032+
string _invocationId = null;
1033+
if (_shouldTrace)
1034+
{
1035+
_invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
1036+
System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
1037+
tracingParameters.Add("nextPageLink", nextPageLink);
1038+
1039+
1040+
tracingParameters.Add("cancellationToken", cancellationToken);
1041+
Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
1042+
}
1043+
// Construct URL
1044+
string _url = "{nextLink}";
1045+
_url = _url.Replace("{nextLink}", nextPageLink);
1046+
1047+
System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
1048+
if (_queryParameters.Count > 0)
1049+
{
1050+
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
1051+
}
1052+
// Create HTTP transport objects
1053+
var _httpRequest = new System.Net.Http.HttpRequestMessage();
1054+
System.Net.Http.HttpResponseMessage _httpResponse = null;
1055+
_httpRequest.Method = new System.Net.Http.HttpMethod("GET");
1056+
_httpRequest.RequestUri = new System.Uri(_url);
1057+
// Set Headers
1058+
if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
1059+
{
1060+
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
1061+
}
1062+
if (this.Client.AcceptLanguage != null)
1063+
{
1064+
if (_httpRequest.Headers.Contains("accept-language"))
1065+
{
1066+
_httpRequest.Headers.Remove("accept-language");
1067+
}
1068+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
1069+
}
1070+
1071+
if (customHeaders != null)
1072+
{
1073+
foreach(var _header in customHeaders)
1074+
{
1075+
if (_httpRequest.Headers.Contains(_header.Key))
1076+
{
1077+
_httpRequest.Headers.Remove(_header.Key);
1078+
}
1079+
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
1080+
}
1081+
}
1082+
// Serialize Request
1083+
string _requestContent = null;
1084+
// Set Credentials
1085+
if (this.Client.Credentials != null)
1086+
{
1087+
cancellationToken.ThrowIfCancellationRequested();
1088+
await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
1089+
}
1090+
// Send Request
1091+
if (_shouldTrace)
1092+
{
1093+
Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
1094+
}
1095+
cancellationToken.ThrowIfCancellationRequested();
1096+
_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
1097+
if (_shouldTrace)
1098+
{
1099+
Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
1100+
}
1101+
1102+
System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
1103+
cancellationToken.ThrowIfCancellationRequested();
1104+
string _responseContent = null;
1105+
1106+
if ((int)_statusCode != 200)
1107+
{
1108+
var ex = new ErrorModelException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
1109+
try
1110+
{
1111+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
1112+
ErrorModel _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorModel>(_responseContent, this.Client.DeserializationSettings);
1113+
if (_errorBody != null)
1114+
{
1115+
ex.Body = _errorBody;
1116+
}
1117+
}
1118+
catch (Newtonsoft.Json.JsonException)
1119+
{
1120+
// Ignore the exception
1121+
}
1122+
ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
1123+
ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
1124+
if (_shouldTrace)
1125+
{
1126+
Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
1127+
}
1128+
_httpRequest.Dispose();
1129+
if (_httpResponse != null)
1130+
{
1131+
_httpResponse.Dispose();
1132+
}
1133+
throw ex;
1134+
}
1135+
// Create Result
1136+
var _result = new Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>>();
1137+
_result.Request = _httpRequest;
1138+
_result.Response = _httpResponse;
1139+
1140+
if (_httpResponse.Headers.Contains("x-ms-request-id"))
1141+
{
1142+
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
1143+
}
1144+
// Deserialize Response
1145+
if ((int)_statusCode == 200)
1146+
{
1147+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
1148+
try
1149+
{
1150+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ApplicationTypeVersionResource>>(_responseContent, this.Client.DeserializationSettings);
1151+
}
1152+
catch (Newtonsoft.Json.JsonException ex)
1153+
{
1154+
_httpRequest.Dispose();
1155+
if (_httpResponse != null)
1156+
{
1157+
_httpResponse.Dispose();
1158+
}
1159+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
1160+
}
1161+
}
1162+
if (_shouldTrace)
1163+
{
1164+
Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
1165+
}
1166+
return _result;
1167+
1168+
1169+
1170+
1171+
9951172
}
9961173
}
9971174
}

src/ServiceFabric/ServiceFabric.Management.sdk/Generated/ApplicationTypeVersionsOperationsExtensions.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public static void Delete(this IApplicationTypeVersionsOperations operations, st
177177
/// <param name='applicationTypeName'>
178178
/// The name of the application type name resource.
179179
/// </param>
180-
public static ApplicationTypeVersionResourceList List(this IApplicationTypeVersionsOperations operations, string resourceGroupName, string clusterName, string applicationTypeName)
180+
public static Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource> List(this IApplicationTypeVersionsOperations operations, string resourceGroupName, string clusterName, string applicationTypeName)
181181
{
182182
return ((IApplicationTypeVersionsOperations)operations).ListAsync(resourceGroupName, clusterName, applicationTypeName).GetAwaiter().GetResult();
183183
}
@@ -200,7 +200,7 @@ public static ApplicationTypeVersionResourceList List(this IApplicationTypeVersi
200200
/// <param name='cancellationToken'>
201201
/// The cancellation token.
202202
/// </param>
203-
public static async System.Threading.Tasks.Task<ApplicationTypeVersionResourceList> ListAsync(this IApplicationTypeVersionsOperations operations, string resourceGroupName, string clusterName, string applicationTypeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
203+
public static async System.Threading.Tasks.Task<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>> ListAsync(this IApplicationTypeVersionsOperations operations, string resourceGroupName, string clusterName, string applicationTypeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
204204
{
205205
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, clusterName, applicationTypeName, null, cancellationToken).ConfigureAwait(false))
206206
{
@@ -306,5 +306,38 @@ public static void BeginDelete(this IApplicationTypeVersionsOperations operation
306306
{
307307
(await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, applicationTypeName, version, null, cancellationToken).ConfigureAwait(false)).Dispose();
308308
}
309+
/// <summary>
310+
/// Gets all application type version resources created or in the process of being created in the Service Fabric application type name resource.
311+
/// </summary>
312+
/// <param name='operations'>
313+
/// The operations group for this extension method.
314+
/// </param>
315+
/// <param name='nextPageLink'>
316+
/// The NextLink from the previous successful call to List operation.
317+
/// </param>
318+
public static Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource> ListNext(this IApplicationTypeVersionsOperations operations, string nextPageLink)
319+
{
320+
return ((IApplicationTypeVersionsOperations)operations).ListNextAsync(nextPageLink).GetAwaiter().GetResult();
321+
}
322+
323+
/// <summary>
324+
/// Gets all application type version resources created or in the process of being created in the Service Fabric application type name resource.
325+
/// </summary>
326+
/// <param name='operations'>
327+
/// The operations group for this extension method.
328+
/// </param>
329+
/// <param name='nextPageLink'>
330+
/// The NextLink from the previous successful call to List operation.
331+
/// </param>
332+
/// <param name='cancellationToken'>
333+
/// The cancellation token.
334+
/// </param>
335+
public static async System.Threading.Tasks.Task<Microsoft.Rest.Azure.IPage<ApplicationTypeVersionResource>> ListNextAsync(this IApplicationTypeVersionsOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
336+
{
337+
using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
338+
{
339+
return _result.Body;
340+
}
341+
}
309342
}
310343
}

0 commit comments

Comments
 (0)