Skip to content

Commit

Permalink
.NET SDK Resource Provider:'IotHub' (Azure#6260)
Browse files Browse the repository at this point in the history
REST Spec PR 'Azure/azure-rest-api-specs#5940'
REST Spec PR Author 'reshantchandra'
REST Spec PR Last commit
  • Loading branch information
adxsdknet authored and mentat9 committed Jun 10, 2019
1 parent c0396b4 commit 58f72f5
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 35 deletions.
31 changes: 28 additions & 3 deletions src/SDKs/IotHub/Management.IotHub/Generated/IIotHubOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,37 @@ public partial interface IIotHubOperations
/// <exception cref="ErrorDetailsException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse> ManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Manual Failover Fail over
/// </summary>
/// <remarks>
/// Perform manual fail over of given hub
/// </remarks>
/// <param name='iotHubName'>
/// IotHub to fail over
/// </param>
/// <param name='failoverInput'>
/// Region to failover to. Must be a azure DR pair
/// </param>
/// <param name='resourceGroupName'>
/// resource group which Iot Hub belongs to
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="ErrorDetailsException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<IotHubDescription>> ManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<AzureOperationResponse> BeginManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
57 changes: 32 additions & 25 deletions src/SDKs/IotHub/Management.IotHub/Generated/IotHubOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ internal IotHubOperations(IotHubClient client)
/// </summary>
public IotHubClient Client { get; private set; }

/// <summary>
/// Manual Failover Fail over
/// </summary>
/// <remarks>
/// Perform manual fail over of given hub
/// </remarks>
/// <param name='iotHubName'>
/// IotHub to fail over
/// </param>
/// <param name='failoverInput'>
/// Region to failover to. Must be a azure DR pair
/// </param>
/// <param name='resourceGroupName'>
/// resource group which Iot Hub belongs to
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public async Task<AzureOperationResponse> ManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
// Send request
AzureOperationResponse _response = await BeginManualFailoverWithHttpMessagesAsync(iotHubName, failoverInput, resourceGroupName, customHeaders, cancellationToken).ConfigureAwait(false);
return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Manual Failover Fail over
/// </summary>
Expand All @@ -74,9 +102,6 @@ internal IotHubOperations(IotHubClient client)
/// <exception cref="ErrorDetailsException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Expand All @@ -86,7 +111,7 @@ internal IotHubOperations(IotHubClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IotHubDescription>> ManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse> BeginManualFailoverWithHttpMessagesAsync(string iotHubName, FailoverInput failoverInput, string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (iotHubName == null)
{
Expand Down Expand Up @@ -123,7 +148,7 @@ internal IotHubOperations(IotHubClient client)
tracingParameters.Add("failoverInput", failoverInput);
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "ManualFailover", tracingParameters);
ServiceClientTracing.Enter(_invocationId, this, "BeginManualFailover", tracingParameters);
}
// Construct URL
var _baseUrl = Client.BaseUri.AbsoluteUri;
Expand Down Expand Up @@ -200,7 +225,7 @@ internal IotHubOperations(IotHubClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200)
if ((int)_statusCode != 200 && (int)_statusCode != 202)
{
var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
Expand Down Expand Up @@ -230,31 +255,13 @@ internal IotHubOperations(IotHubClient client)
throw ex;
}
// Create Result
var _result = new AzureOperationResponse<IotHubDescription>();
var _result = new AzureOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
{
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
}
// Deserialize Response
if ((int)_statusCode == 200)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IotHubDescription>(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
_httpRequest.Dispose();
if (_httpResponse != null)
{
_httpResponse.Dispose();
}
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
}
}
if (_shouldTrace)
{
ServiceClientTracing.Exit(_invocationId, _result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static partial class IotHubOperationsExtensions
/// <param name='resourceGroupName'>
/// resource group which Iot Hub belongs to
/// </param>
public static IotHubDescription ManualFailover(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName)
public static void ManualFailover(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName)
{
return operations.ManualFailoverAsync(iotHubName, failoverInput, resourceGroupName).GetAwaiter().GetResult();
operations.ManualFailoverAsync(iotHubName, failoverInput, resourceGroupName).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -65,12 +65,58 @@ public static IotHubDescription ManualFailover(this IIotHubOperations operations
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IotHubDescription> ManualFailoverAsync(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
public static async Task ManualFailoverAsync(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ManualFailoverWithHttpMessagesAsync(iotHubName, failoverInput, resourceGroupName, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
(await operations.ManualFailoverWithHttpMessagesAsync(iotHubName, failoverInput, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose();
}

/// <summary>
/// Manual Failover Fail over
/// </summary>
/// <remarks>
/// Perform manual fail over of given hub
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='iotHubName'>
/// IotHub to fail over
/// </param>
/// <param name='failoverInput'>
/// Region to failover to. Must be a azure DR pair
/// </param>
/// <param name='resourceGroupName'>
/// resource group which Iot Hub belongs to
/// </param>
public static void BeginManualFailover(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName)
{
operations.BeginManualFailoverAsync(iotHubName, failoverInput, resourceGroupName).GetAwaiter().GetResult();
}

/// <summary>
/// Manual Failover Fail over
/// </summary>
/// <remarks>
/// Perform manual fail over of given hub
/// </remarks>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='iotHubName'>
/// IotHub to fail over
/// </param>
/// <param name='failoverInput'>
/// Region to failover to. Must be a azure DR pair
/// </param>
/// <param name='resourceGroupName'>
/// resource group which Iot Hub belongs to
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task BeginManualFailoverAsync(this IIotHubOperations operations, string iotHubName, FailoverInput failoverInput, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.BeginManualFailoverWithHttpMessagesAsync(iotHubName, failoverInput, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose();
}

}
Expand Down

0 comments on commit 58f72f5

Please sign in to comment.