Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling

from .. import models

Expand All @@ -36,29 +38,9 @@ def __init__(self, client, config, serializer, deserializer):

self.config = config

def manual_failover(
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, **operation_config):
"""Manual Failover Fail over.

Perform manual fail over of given hub.

:param iot_hub_name: IotHub to fail over
:type iot_hub_name: str
:param resource_group_name: resource group which Iot Hub belongs to
:type resource_group_name: str
:param failover_region: Region the hub will be failed over to
:type failover_region: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: IotHubDescription or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.iothub.models.IotHubDescription or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>`
"""
def _manual_failover_initial(
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, **operation_config):
failover_input = models.FailoverInput(failover_region=failover_region)

# Construct URL
Expand All @@ -76,7 +58,6 @@ def manual_failover(

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
Expand All @@ -92,17 +73,56 @@ def manual_failover(
request = self._client.post(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
if response.status_code not in [200, 202]:
raise models.ErrorDetailsException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('IotHubDescription', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
client_raw_response = ClientRawResponse(None, response)
return client_raw_response

return deserialized
def manual_failover(
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, polling=True, **operation_config):
"""Manual Failover Fail over.

Perform manual fail over of given hub.

:param iot_hub_name: IotHub to fail over
:type iot_hub_name: str
:param resource_group_name: resource group which Iot Hub belongs to
:type resource_group_name: str
:param failover_region: Region the hub will be failed over to
:type failover_region: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
:param polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:return: An instance of LROPoller that returns None or
ClientRawResponse<None> if raw==True
:rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
:raises:
:class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>`
"""
raw_result = self._manual_failover_initial(
iot_hub_name=iot_hub_name,
resource_group_name=resource_group_name,
failover_region=failover_region,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response

lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'}
2 changes: 1 addition & 1 deletion sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "0.8.1"
VERSION = "0.8.2"