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

Commit

Permalink
include latest quota api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cataggar committed Apr 29, 2020
1 parent 3792f3a commit f4b8612
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 6 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ docker run --rm -it -v ${PWD}:/src -v ${PWD}/../azure-rest-api-specs:/azure-rest
```

``` sh
npm install -g autorest
npm install -g oav --unsafe-perm=true --allow-root
apt-get update
apt-get install libunwind-dev -y
rm -rf azext_vmware/vendored_sdks/
./autorest.sh
./install-autorest.sh
./run-autorest.sh
```
5 changes: 5 additions & 0 deletions azext_vmware/vendored_sdks/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# --------------------------------------------------------------------------

try:
from .quota_py3 import Quota
from .resource_py3 import Resource
from .tracked_resource_py3 import TrackedResource
from .api_error_base_py3 import ApiErrorBase
Expand All @@ -24,6 +25,7 @@
from .cluster_py3 import Cluster
from .admin_credentials_py3 import AdminCredentials
except (SyntaxError, ImportError):
from .quota import Quota
from .resource import Resource
from .tracked_resource import TrackedResource
from .api_error_base import ApiErrorBase
Expand All @@ -45,13 +47,15 @@
from .private_cloud_paged import PrivateCloudPaged
from .cluster_paged import ClusterPaged
from .virtustream_client_enums import (
QuotaEnabled,
SslEnum,
PrivateCloudProvisioningState,
InternetEnum,
ClusterProvisioningState,
)

__all__ = [
'Quota',
'Resource',
'TrackedResource',
'ApiErrorBase',
Expand All @@ -72,6 +76,7 @@
'OperationPaged',
'PrivateCloudPaged',
'ClusterPaged',
'QuotaEnabled',
'SslEnum',
'PrivateCloudProvisioningState',
'InternetEnum',
Expand Down
36 changes: 36 additions & 0 deletions azext_vmware/vendored_sdks/models/quota.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class Quota(Model):
"""Subscription quotas.
Variables are only populated by the server, and will be ignored when
sending a request.
:ivar hosts_remaining: Remaining hosts quota by sku type
:vartype hosts_remaining: dict[str, int]
:param quota_enabled: Host quota is active for current subscription.
Possible values include: 'Enabled', 'Disabled'
:type quota_enabled: str or ~vendored_sdks.models.QuotaEnabled
"""

_validation = {
'hosts_remaining': {'readonly': True},
}

_attribute_map = {
'hosts_remaining': {'key': 'hostsRemaining', 'type': '{int}'},
'quota_enabled': {'key': 'quotaEnabled', 'type': 'str'},
}

def __init__(self, **kwargs):
super(Quota, self).__init__(**kwargs)
self.hosts_remaining = None
self.quota_enabled = kwargs.get('quota_enabled', None)
36 changes: 36 additions & 0 deletions azext_vmware/vendored_sdks/models/quota_py3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class Quota(Model):
"""Subscription quotas.
Variables are only populated by the server, and will be ignored when
sending a request.
:ivar hosts_remaining: Remaining hosts quota by sku type
:vartype hosts_remaining: dict[str, int]
:param quota_enabled: Host quota is active for current subscription.
Possible values include: 'Enabled', 'Disabled'
:type quota_enabled: str or ~vendored_sdks.models.QuotaEnabled
"""

_validation = {
'hosts_remaining': {'readonly': True},
}

_attribute_map = {
'hosts_remaining': {'key': 'hostsRemaining', 'type': '{int}'},
'quota_enabled': {'key': 'quotaEnabled', 'type': 'str'},
}

def __init__(self, *, quota_enabled=None, **kwargs) -> None:
super(Quota, self).__init__(**kwargs)
self.hosts_remaining = None
self.quota_enabled = quota_enabled
6 changes: 6 additions & 0 deletions azext_vmware/vendored_sdks/models/virtustream_client_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from enum import Enum


class QuotaEnabled(str, Enum):

enabled = "Enabled"
disabled = "Disabled"


class SslEnum(str, Enum):

enabled = "Enabled"
Expand Down
62 changes: 62 additions & 0 deletions azext_vmware/vendored_sdks/virtustream_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from msrest.pipeline import ClientRawResponse
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling
import uuid
from .operations.operations import Operations
from .operations.private_clouds_operations import PrivateCloudsOperations
from .operations.clusters_operations import ClustersOperations
Expand Down Expand Up @@ -85,3 +89,61 @@ def __init__(
self._client, self.config, self._serialize, self._deserialize)
self.clusters = ClustersOperations(
self._client, self.config, self._serialize, self._deserialize)

def check_quota_availability(
self, location, custom_headers=None, raw=False, **operation_config):
"""Return quota for subscription by region.
:param location: Azure region
:type location: 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: Quota or ClientRawResponse if raw=true
:rtype: ~vendored_sdks.models.Quota or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ApiErrorException<vendored_sdks.models.ApiErrorException>`
"""
# Construct URL
url = self.check_quota_availability.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'location': self._serialize.url("location", location, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.post(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

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

deserialized = None

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

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

return deserialized
check_quota_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VMwareVirtustream/locations/{location}/checkQuotaAvailability'}
5 changes: 5 additions & 0 deletions install-autorest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e
npm install -g autorest
npm install -g oav --unsafe-perm=true --allow-root
apt-get update
apt-get install libunwind-dev -y
1 change: 1 addition & 0 deletions autorest.sh → run-autorest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ spec=/azure-rest-api-specs/specification/vmwarevirtustream/resource-manager/Micr
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=VirtustreamClient [email protected]/autorest.python@~3.0.56

0 comments on commit f4b8612

Please sign in to comment.