Skip to content

Commit c63d5e6

Browse files
AutorestCIlmazuel
authored andcommitted
[AutoPR] iothub/resource-manager (Azure#5219)
* Move iothub to SDK folder * [AutoPR iothub/resource-manager] IotHub new Py path (Azure#5249) * Generated from 488135776101e538bd7904352ad3db000586b621 IotHub new Py path * Generated from a80a0d64a5a445fa98a51f157ea87a3435498e63 Update readme.python.md * Update HISTORY.rst * Update dev_requirements.txt
1 parent a5ae496 commit c63d5e6

File tree

150 files changed

+60
-33
lines changed

Some content is hidden

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

150 files changed

+60
-33
lines changed

azure-mgmt-iothub/dev_requirements.txt

-1
This file was deleted.

azure-mgmt-iothub/HISTORY.rst renamed to sdk/iothub/azure-mgmt-iothub/HISTORY.rst

+7

azure-mgmt-iothub/azure/mgmt/iothub/operations/iot_hub_operations.py renamed to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/iot_hub_operations.py

+51-31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import uuid
1313
from msrest.pipeline import ClientRawResponse
14+
from msrest.polling import LROPoller, NoPolling
15+
from msrestazure.polling.arm_polling import ARMPolling
1416

1517
from .. import models
1618

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

3739
self.config = config
3840

39-
def manual_failover(
40-
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, **operation_config):
41-
"""Manual Failover Fail over.
42-
43-
Perform manual fail over of given hub.
4441

45-
:param iot_hub_name: IotHub to fail over
46-
:type iot_hub_name: str
47-
:param resource_group_name: resource group which Iot Hub belongs to
48-
:type resource_group_name: str
49-
:param failover_region: Region the hub will be failed over to
50-
:type failover_region: str
51-
:param dict custom_headers: headers that will be added to the request
52-
:param bool raw: returns the direct response alongside the
53-
deserialized response
54-
:param operation_config: :ref:`Operation configuration
55-
overrides<msrest:optionsforoperations>`.
56-
:return: IotHubDescription or ClientRawResponse if raw=true
57-
:rtype: ~azure.mgmt.iothub.models.IotHubDescription or
58-
~msrest.pipeline.ClientRawResponse
59-
:raises:
60-
:class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>`
61-
"""
42+
def _manual_failover_initial(
43+
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, **operation_config):
6244
failover_input = models.FailoverInput(failover_region=failover_region)
6345

6446
# Construct URL
@@ -76,7 +58,6 @@ def manual_failover(
7658

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

95-
if response.status_code not in [200]:
76+
if response.status_code not in [200, 202]:
9677
raise models.ErrorDetailsException(self._deserialize, response)
9778

98-
deserialized = None
99-
100-
if response.status_code == 200:
101-
deserialized = self._deserialize('IotHubDescription', response)
102-
10379
if raw:
104-
client_raw_response = ClientRawResponse(deserialized, response)
80+
client_raw_response = ClientRawResponse(None, response)
10581
return client_raw_response
10682

107-
return deserialized
83+
def manual_failover(
84+
self, iot_hub_name, resource_group_name, failover_region, custom_headers=None, raw=False, polling=True, **operation_config):
85+
"""Manual Failover Fail over.
86+
87+
Perform manual fail over of given hub.
88+
89+
:param iot_hub_name: IotHub to fail over
90+
:type iot_hub_name: str
91+
:param resource_group_name: resource group which Iot Hub belongs to
92+
:type resource_group_name: str
93+
:param failover_region: Region the hub will be failed over to
94+
:type failover_region: str
95+
:param dict custom_headers: headers that will be added to the request
96+
:param bool raw: The poller return type is ClientRawResponse, the
97+
direct response alongside the deserialized response
98+
:param polling: True for ARMPolling, False for no polling, or a
99+
polling object for personal polling strategy
100+
:return: An instance of LROPoller that returns None or
101+
ClientRawResponse<None> if raw==True
102+
:rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
103+
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
104+
:raises:
105+
:class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>`
106+
"""
107+
raw_result = self._manual_failover_initial(
108+
iot_hub_name=iot_hub_name,
109+
resource_group_name=resource_group_name,
110+
failover_region=failover_region,
111+
custom_headers=custom_headers,
112+
raw=True,
113+
**operation_config
114+
)
115+
116+
def get_long_running_output(response):
117+
if raw:
118+
client_raw_response = ClientRawResponse(None, response)
119+
return client_raw_response
120+
121+
lro_delay = operation_config.get(
122+
'long_running_operation_timeout',
123+
self.config.long_running_operation_timeout)
124+
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
125+
elif polling is False: polling_method = NoPolling()
126+
else: polling_method = polling
127+
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
108128
manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'}

azure-mgmt-iothub/azure/mgmt/iothub/version.py renamed to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
VERSION = "0.8.1"
12+
VERSION = "0.8.2"
1313

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-e ../../../azure-sdk-tools
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)