Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Batch] Fix issue in latest REST API #11604

Merged
merged 3 commits into from
May 26, 2020
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/sdk/eventhub/ @annatisch @yunhaoling @YijunXieMS
/sdk/storage/ @amishra-dev @zezha-msft @annatisch @rakshith91 @xiafu-msft
/sdk/applicationinsights/ @alexeldeib
/sdk/batch/ @bgklein @matthchr @xingwu1
/sdk/batch/ @bgklein @xingwu1
/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/ @areddish
/sdk/keyvault/ @schaabs @chlowell @iscai-msft
/sdk/loganalytics/ @alexeldeib
Expand Down
4 changes: 4 additions & 0 deletions sdk/batch/azure-mgmt-batch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 8.0.1 (2020-05-26)
### Bugfixes
- Fix issues in PrivateEndpointConnection get and update methods due to mistakes in the Swagger specification causing validation to fail.

## 8.0.0 (2020-04-10)
### REST API version
- This version targets REST API version 2020-03-01.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling

from .. import models

Expand Down Expand Up @@ -145,7 +147,7 @@ def get(
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3, pattern=r'^[a-zA-Z0-9]+$'),
'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str', max_length=64, min_length=1, pattern=r'^[a-zA-Z0-9_-]+$')
'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str', max_length=101, min_length=1, pattern=r'^[a-zA-Z0-9_-]+\.?[a-fA-F0-9-]*$')
}
url = self._client.format_url(url, **path_format_arguments)

Expand Down Expand Up @@ -183,39 +185,9 @@ def get(
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'}

def update(
self, resource_group_name, account_name, private_endpoint_connection_name, if_match=None, private_endpoint=None, private_link_service_connection_state=None, custom_headers=None, raw=False, **operation_config):
"""Updates the properties of an existing private endpoint connection.

:param resource_group_name: The name of the resource group that
contains the Batch account.
:type resource_group_name: str
:param account_name: The name of the Batch account.
:type account_name: str
:param private_endpoint_connection_name: The private endpoint
connection name. This must be unique within the account.
:type private_endpoint_connection_name: str
:param if_match: The state (ETag) version of the private endpoint
connection to update. This value can be omitted or set to "*" to apply
the operation unconditionally.
:type if_match: str
:param private_endpoint: The ARM resource identifier of the private
endpoint.
:type private_endpoint: ~azure.mgmt.batch.models.PrivateEndpoint
:param private_link_service_connection_state: The private link service
connection state of the private endpoint connection.
:type private_link_service_connection_state:
~azure.mgmt.batch.models.PrivateLinkServiceConnectionState
: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: PrivateEndpointConnection or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.batch.models.PrivateEndpointConnection or
~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
def _update_initial(
self, resource_group_name, account_name, private_endpoint_connection_name, if_match=None, private_endpoint=None, private_link_service_connection_state=None, custom_headers=None, raw=False, **operation_config):
parameters = models.PrivateEndpointConnection(private_endpoint=private_endpoint, private_link_service_connection_state=private_link_service_connection_state)

# Construct URL
Expand All @@ -224,7 +196,7 @@ def update(
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3, pattern=r'^[a-zA-Z0-9]+$'),
'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str', max_length=64, min_length=1, pattern=r'^[a-zA-Z0-9_-]+$')
'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str', max_length=101, min_length=1, pattern=r'^[a-zA-Z0-9_-]+\.?[a-fA-F0-9-]*$')
}
url = self._client.format_url(url, **path_format_arguments)

Expand Down Expand Up @@ -252,17 +224,19 @@ def update(
request = self._client.patch(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, 204]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

header_dict = {}
deserialized = None
header_dict = {}

if response.status_code == 200:
deserialized = self._deserialize('PrivateEndpointConnection', response)
header_dict = {
'ETag': 'str',
'Location': 'str',
'Retry-After': 'int',
}

if raw:
Expand All @@ -271,4 +245,75 @@ def update(
return client_raw_response

return deserialized

def update(
self, resource_group_name, account_name, private_endpoint_connection_name, if_match=None, private_endpoint=None, private_link_service_connection_state=None, custom_headers=None, raw=False, polling=True, **operation_config):
"""Updates the properties of an existing private endpoint connection.

:param resource_group_name: The name of the resource group that
contains the Batch account.
:type resource_group_name: str
:param account_name: The name of the Batch account.
:type account_name: str
:param private_endpoint_connection_name: The private endpoint
connection name. This must be unique within the account.
:type private_endpoint_connection_name: str
:param if_match: The state (ETag) version of the private endpoint
connection to update. This value can be omitted or set to "*" to apply
the operation unconditionally.
:type if_match: str
:param private_endpoint: The ARM resource identifier of the private
endpoint.
:type private_endpoint: ~azure.mgmt.batch.models.PrivateEndpoint
:param private_link_service_connection_state: The private link service
connection state of the private endpoint connection.
:type private_link_service_connection_state:
~azure.mgmt.batch.models.PrivateLinkServiceConnectionState
: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
PrivateEndpointConnection or
ClientRawResponse<PrivateEndpointConnection> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.batch.models.PrivateEndpointConnection]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.batch.models.PrivateEndpointConnection]]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
raw_result = self._update_initial(
resource_group_name=resource_group_name,
account_name=account_name,
private_endpoint_connection_name=private_endpoint_connection_name,
if_match=if_match,
private_endpoint=private_endpoint,
private_link_service_connection_state=private_link_service_connection_state,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
header_dict = {
'Location': 'str',
'Retry-After': 'int',
}
deserialized = self._deserialize('PrivateEndpointConnection', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
client_raw_response.add_headers(header_dict)
return client_raw_response

return deserialized

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)
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get(
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3, pattern=r'^[a-zA-Z0-9]+$'),
'privateLinkResourceName': self._serialize.url("private_link_resource_name", private_link_resource_name, 'str', max_length=64, min_length=1, pattern=r'^[a-zA-Z0-9_-]+$')
'privateLinkResourceName': self._serialize.url("private_link_resource_name", private_link_resource_name, 'str', max_length=101, min_length=1, pattern=r'^[a-zA-Z0-9_-]+\.?[a-fA-F0-9-]*$')
}
url = self._client.format_url(url, **path_format_arguments)

Expand Down
2 changes: 1 addition & 1 deletion sdk/batch/azure-mgmt-batch/azure/mgmt/batch/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "8.0.0"
VERSION = "8.0.1"

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interactions:
- application/json; charset=utf-8
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: PUT
Expand Down Expand Up @@ -57,7 +57,7 @@ interactions:
- keep-alive
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_batch_test_mgmt_batch_account3e1b0fe5/providers/Microsoft.Batch/batchAccounts/batch3e1b0fe5/operationResults/a4f17142-743a-4052-ba45-8b09bc57ba33?api-version=2020-03-01
response:
Expand Down Expand Up @@ -104,7 +104,7 @@ interactions:
- keep-alive
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: GET
Expand Down Expand Up @@ -153,7 +153,7 @@ interactions:
- keep-alive
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: GET
Expand Down Expand Up @@ -200,7 +200,7 @@ interactions:
- '0'
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: POST
Expand Down Expand Up @@ -251,7 +251,7 @@ interactions:
- application/json; charset=utf-8
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: POST
Expand Down Expand Up @@ -302,7 +302,7 @@ interactions:
- application/json; charset=utf-8
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: PATCH
Expand Down Expand Up @@ -355,7 +355,7 @@ interactions:
- '0'
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
accept-language:
- en-US
method: DELETE
Expand Down Expand Up @@ -398,7 +398,7 @@ interactions:
- keep-alive
User-Agent:
- python/3.7.3 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2
azure-mgmt-batch/8.0.0 Azure-SDK-For-Python
azure-mgmt-batch/8.0.1 Azure-SDK-For-Python
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Batch/locations/westcentralus/accountOperationResults/batch3e1b0fe5-1495797e-f9af-436d-ad44-ec39195f19a5?api-version=2020-03-01
response:
Expand Down