Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
add workaround for autorest generation of empty objects
Browse files Browse the repository at this point in the history
  • Loading branch information
cataggar committed May 27, 2020
1 parent 09a18b4 commit 159f682
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 3,384 deletions.
3,519 changes: 146 additions & 3,373 deletions azext_vmware/tests/latest/recordings/test_vmware.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ExpressRouteAuthorization(Resource):
:ivar express_route_authorization_key: The key of the ExpressRoute Circuit
Authorization
:vartype express_route_authorization_key: str
:param empty: Ignore this property. It helps autorest code generation.
:type empty: str
"""

_validation = {
Expand All @@ -49,10 +51,12 @@ class ExpressRouteAuthorization(Resource):
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
'express_route_authorization_id': {'key': 'properties.expressRouteAuthorizationId', 'type': 'str'},
'express_route_authorization_key': {'key': 'properties.expressRouteAuthorizationKey', 'type': 'str'},
'empty': {'key': 'properties.empty', 'type': 'str'},
}

def __init__(self, **kwargs):
super(ExpressRouteAuthorization, self).__init__(**kwargs)
self.provisioning_state = None
self.express_route_authorization_id = None
self.express_route_authorization_key = None
self.empty = kwargs.get('empty', None)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ExpressRouteAuthorization(Resource):
:ivar express_route_authorization_key: The key of the ExpressRoute Circuit
Authorization
:vartype express_route_authorization_key: str
:param empty: Ignore this property. It helps autorest code generation.
:type empty: str
"""

_validation = {
Expand All @@ -49,10 +51,12 @@ class ExpressRouteAuthorization(Resource):
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
'express_route_authorization_id': {'key': 'properties.expressRouteAuthorizationId', 'type': 'str'},
'express_route_authorization_key': {'key': 'properties.expressRouteAuthorizationKey', 'type': 'str'},
'empty': {'key': 'properties.empty', 'type': 'str'},
}

def __init__(self, **kwargs) -> None:
def __init__(self, *, empty: str=None, **kwargs) -> None:
super(ExpressRouteAuthorization, self).__init__(**kwargs)
self.provisioning_state = None
self.express_route_authorization_id = None
self.express_route_authorization_key = None
self.empty = empty
4 changes: 4 additions & 0 deletions azext_vmware/vendored_sdks/models/hcx_enterprise_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class HcxEnterpriseSite(Resource):
:ivar status: The status of the HCX Enterprise Site. Possible values
include: 'Available', 'Consumed', 'Deactivated', 'Deleted'
:vartype status: str or ~vendored_sdks.models.HcxEnterpriseSiteStatus
:param empty: Ignore this property. It helps autorest code generation.
:type empty: str
"""

_validation = {
Expand All @@ -41,9 +43,11 @@ class HcxEnterpriseSite(Resource):
'type': {'key': 'type', 'type': 'str'},
'activation_key': {'key': 'properties.activationKey', 'type': 'str'},
'status': {'key': 'properties.status', 'type': 'str'},
'empty': {'key': 'properties.empty', 'type': 'str'},
}

def __init__(self, **kwargs):
super(HcxEnterpriseSite, self).__init__(**kwargs)
self.activation_key = None
self.status = None
self.empty = kwargs.get('empty', None)
6 changes: 5 additions & 1 deletion azext_vmware/vendored_sdks/models/hcx_enterprise_site_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class HcxEnterpriseSite(Resource):
:ivar status: The status of the HCX Enterprise Site. Possible values
include: 'Available', 'Consumed', 'Deactivated', 'Deleted'
:vartype status: str or ~vendored_sdks.models.HcxEnterpriseSiteStatus
:param empty: Ignore this property. It helps autorest code generation.
:type empty: str
"""

_validation = {
Expand All @@ -41,9 +43,11 @@ class HcxEnterpriseSite(Resource):
'type': {'key': 'type', 'type': 'str'},
'activation_key': {'key': 'properties.activationKey', 'type': 'str'},
'status': {'key': 'properties.status', 'type': 'str'},
'empty': {'key': 'properties.empty', 'type': 'str'},
}

def __init__(self, **kwargs) -> None:
def __init__(self, *, empty: str=None, **kwargs) -> None:
super(HcxEnterpriseSite, self).__init__(**kwargs)
self.activation_key = None
self.status = None
self.empty = empty
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ def get(


def _create_or_update_initial(
self, resource_group_name, private_cloud_name, authorization_name, custom_headers=None, raw=False, **operation_config):
authorization = None

self, resource_group_name, private_cloud_name, authorization_name, authorization, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.create_or_update.metadata['url']
path_format_arguments = {
Expand Down Expand Up @@ -224,7 +222,7 @@ def _create_or_update_initial(
return deserialized

def create_or_update(
self, resource_group_name, private_cloud_name, authorization_name, custom_headers=None, raw=False, polling=True, **operation_config):
self, resource_group_name, private_cloud_name, authorization_name, authorization, custom_headers=None, raw=False, polling=True, **operation_config):
"""Create or update an ExpressRoute Circuit Authorization in a private
cloud.
Expand All @@ -236,6 +234,8 @@ def create_or_update(
:param authorization_name: Name of the ExpressRoute Circuit
Authorization in the private cloud
:type authorization_name: str
:param authorization: An ExpressRoute Circuit Authorization
:type authorization: ~vendored_sdks.models.ExpressRouteAuthorization
: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
Expand All @@ -255,6 +255,7 @@ def create_or_update(
resource_group_name=resource_group_name,
private_cloud_name=private_cloud_name,
authorization_name=authorization_name,
authorization=authorization,
custom_headers=custom_headers,
raw=True,
**operation_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get(
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'}

def create_or_update(
self, resource_group_name, private_cloud_name, hcx_enterprise_site_name, custom_headers=None, raw=False, **operation_config):
self, resource_group_name, private_cloud_name, hcx_enterprise_site_name, hcx_enterprise_site, custom_headers=None, raw=False, **operation_config):
"""Create or update an HCX Enterprise Site in a private cloud.
:param resource_group_name: The name of the resource group. The name
Expand All @@ -180,6 +180,8 @@ def create_or_update(
:param hcx_enterprise_site_name: Name of the HCX Enterprise Site in
the private cloud
:type hcx_enterprise_site_name: str
:param hcx_enterprise_site: The HCX Enterprise Site
:type hcx_enterprise_site: ~vendored_sdks.models.HcxEnterpriseSite
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand All @@ -191,8 +193,6 @@ def create_or_update(
:raises:
:class:`ApiErrorException<vendored_sdks.models.ApiErrorException>`
"""
hcx_enterprise_site = None

# Construct URL
url = self.create_or_update.metadata['url']
path_format_arguments = {
Expand Down
2 changes: 1 addition & 1 deletion install-autorest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh -e
npm install -g autorest
npm install -g autorest@latest
npm install -g oav --unsafe-perm=true --allow-root
apt-get update
apt-get install libunwind-dev -y
2 changes: 1 addition & 1 deletion run-autorest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ autorest --input-file=$spec --azure-validator --openapi-type=arm
# oav validate-spec $spec -p
# oav validate-example $spec -p
rm -rf azext_vmware/vendored_sdks/
autorest --input-file=$spec --python --output-folder=azext_vmware --namespace=vendored_sdks --azure-arm=true --override-client-name=AVSClient --use=@microsoft.azure/autorest.python@~3.0.56
autorest --input-file=$spec --python --output-folder=azext_vmware --namespace=vendored_sdks --azure-arm=true --override-client-name=AVSClient --use=@microsoft.azure/autorest.python@3.0.62

0 comments on commit 159f682

Please sign in to comment.