Skip to content

Commit

Permalink
CodeGen from PR 15001 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
[python]track2 config (Azure#15001)

* track2 config

* directive for required type in readme.python.md

* Update readme.md

* Update readme.python.md

* Update readme.python.md
  • Loading branch information
SDKAuto committed Jun 28, 2021
1 parent f897769 commit be7b60b
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 81 deletions.
1 change: 1 addition & 0 deletions sdk/support/azure-mgmt-support/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include _meta.json
recursive-include tests *.py *.yaml
include *.md
include azure/__init__.py
Expand Down
11 changes: 11 additions & 0 deletions sdk/support/azure-mgmt-support/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"autorest": "3.4.2",
"use": [
"@autorest/python@5.8.1",
"@autorest/modelerfour@4.19.2"
],
"commit": "c803720c6bcfcb0fcf4c97f3463ec33a18f9e55c",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest_command": "autorest specification/support/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.2",
"readme": "specification/support/resource-manager/readme.md"
}
62 changes: 52 additions & 10 deletions sdk/support/azure-mgmt-support/azure/mgmt/support/_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"custom_base_url": null,
"azure_arm": true,
"has_lro_operations": true,
"client_side_validation": false
"client_side_validation": false,
"sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftSupportConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}",
"async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftSupportConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}"
},
"global_parameters": {
"sync": {
Expand All @@ -28,38 +30,78 @@
},
"async": {
"credential": {
"signature": "credential, # type: \"AsyncTokenCredential\"",
"signature": "credential: \"AsyncTokenCredential\",",
"description": "Credential needed for the client to connect to Azure.",
"docstring_type": "~azure.core.credentials_async.AsyncTokenCredential",
"required": true
},
"subscription_id": {
"signature": "subscription_id, # type: str",
"signature": "subscription_id: str,",
"description": "Azure subscription Id.",
"docstring_type": "str",
"required": true
}
},
"constant": {
},
"call": "credential, subscription_id"
"call": "credential, subscription_id",
"service_client_specific": {
"sync": {
"api_version": {
"signature": "api_version=None, # type: Optional[str]",
"description": "API version to use if no profile is provided, or if missing in profile.",
"docstring_type": "str",
"required": false
},
"base_url": {
"signature": "base_url=None, # type: Optional[str]",
"description": "Service URL",
"docstring_type": "str",
"required": false
},
"profile": {
"signature": "profile=KnownProfiles.default, # type: KnownProfiles",
"description": "A profile definition, from KnownProfiles to dict.",
"docstring_type": "azure.profiles.KnownProfiles",
"required": false
}
},
"async": {
"api_version": {
"signature": "api_version: Optional[str] = None,",
"description": "API version to use if no profile is provided, or if missing in profile.",
"docstring_type": "str",
"required": false
},
"base_url": {
"signature": "base_url: Optional[str] = None,",
"description": "Service URL",
"docstring_type": "str",
"required": false
},
"profile": {
"signature": "profile: KnownProfiles = KnownProfiles.default,",
"description": "A profile definition, from KnownProfiles to dict.",
"docstring_type": "azure.profiles.KnownProfiles",
"required": false
}
}
}
},
"config": {
"credential": true,
"credential_scopes": ["https://management.azure.com/.default"],
"credential_default_policy_type": "BearerTokenCredentialPolicy",
"credential_default_policy_type_has_async_version": true,
"credential_key_header_name": null
"credential_key_header_name": null,
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
},
"operation_groups": {
"operations": "Operations",
"services": "ServicesOperations",
"problem_classifications": "ProblemClassificationsOperations",
"support_tickets": "SupportTicketsOperations",
"communications": "CommunicationsOperations"
},
"operation_mixins": {
},
"sync_imports": "None",
"async_imports": "None"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, Optional

from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpRequest, HttpResponse

from ._configuration import MicrosoftSupportConfiguration
from .operations import Operations
Expand Down Expand Up @@ -76,6 +77,24 @@ def __init__(
self.communications = CommunicationsOperations(
self._client, self._config, self._serialize, self._deserialize)

def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
"""Runs the network request through the client's chained policies.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

def close(self):
# type: () -> None
self._client.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "6.0.0"
VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Deserializer, Serializer

Expand Down Expand Up @@ -73,6 +74,23 @@ def __init__(
self.communications = CommunicationsOperations(
self._client, self._config, self._serialize, self._deserialize)

async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
"""Runs the network request through the client's chained policies.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
"""
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

async def close(self) -> None:
await self._client.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def check_name_availability(
self,
support_ticket_name: str,
check_name_availability_input: "_models.CheckNameAvailabilityInput",
**kwargs
**kwargs: Any
) -> "_models.CheckNameAvailabilityOutput":
"""Check the availability of a resource name. This API should be used to check the uniqueness of
the name for adding a new communication to the support ticket.
Expand Down Expand Up @@ -96,7 +96,7 @@ async def check_name_availability(

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = self._deserialize('CheckNameAvailabilityOutput', pipeline_response)
Expand All @@ -112,7 +112,7 @@ def list(
support_ticket_name: str,
top: Optional[int] = None,
filter: Optional[str] = None,
**kwargs
**kwargs: Any
) -> AsyncIterable["_models.CommunicationsListResult"]:
"""Lists all communications (attachments not included) for a support ticket. :code:`<br/>`</br>
You can also filter support ticket communications by *CreatedDate* or *CommunicationType* using
Expand Down Expand Up @@ -186,7 +186,7 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

Expand All @@ -201,7 +201,7 @@ async def get(
self,
support_ticket_name: str,
communication_name: str,
**kwargs
**kwargs: Any
) -> "_models.CommunicationDetails":
"""Returns communication details for a support ticket.
Expand Down Expand Up @@ -245,7 +245,7 @@ async def get(

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = self._deserialize('CommunicationDetails', pipeline_response)
Expand All @@ -261,7 +261,7 @@ async def _create_initial(
support_ticket_name: str,
communication_name: str,
create_communication_parameters: "_models.CommunicationDetails",
**kwargs
**kwargs: Any
) -> Optional["_models.CommunicationDetails"]:
cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CommunicationDetails"]]
error_map = {
Expand Down Expand Up @@ -299,7 +299,7 @@ async def _create_initial(

if response.status_code not in [200, 202]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = None
Expand All @@ -317,7 +317,7 @@ async def begin_create(
support_ticket_name: str,
communication_name: str,
create_communication_parameters: "_models.CommunicationDetails",
**kwargs
**kwargs: Any
) -> AsyncLROPoller["_models.CommunicationDetails"]:
"""Adds a new customer communication to an Azure support ticket.
Expand All @@ -329,8 +329,8 @@ async def begin_create(
:type create_communication_parameters: ~azure.mgmt.support.models.CommunicationDetails
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: By default, your polling method will be AsyncARMPolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either CommunicationDetails or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:

def list(
self,
**kwargs
**kwargs: Any
) -> AsyncIterable["_models.OperationsListResult"]:
"""This lists all the available Microsoft Support REST API operations.
Expand Down Expand Up @@ -93,7 +93,7 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:
def list(
self,
service_name: str,
**kwargs
**kwargs: Any
) -> AsyncIterable["_models.ProblemClassificationsListResult"]:
"""Lists all the problem classifications (categories) available for a specific Azure service.
Always use the service and problem classifications obtained programmatically. This practice
Expand Down Expand Up @@ -103,7 +103,7 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

Expand All @@ -118,7 +118,7 @@ async def get(
self,
service_name: str,
problem_classification_name: str,
**kwargs
**kwargs: Any
) -> "_models.ProblemClassification":
"""Get problem classification details for a specific Azure service.
Expand Down Expand Up @@ -161,7 +161,7 @@ async def get(

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = self._deserialize('ProblemClassification', pipeline_response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:

def list(
self,
**kwargs
**kwargs: Any
) -> AsyncIterable["_models.ServicesListResult"]:
"""Lists all the Azure services available for support ticket creation. For **Technical** issues,
select the Service Id that maps to the Azure service/product as displayed in the **Services**
Expand Down Expand Up @@ -99,7 +99,7 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

Expand All @@ -113,7 +113,7 @@ async def get_next(next_link=None):
async def get(
self,
service_name: str,
**kwargs
**kwargs: Any
) -> "_models.Service":
"""Gets a specific Azure service for support ticket creation.
Expand Down Expand Up @@ -153,7 +153,7 @@ async def get(

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(_models.ExceptionResponse, response)
error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = self._deserialize('Service', pipeline_response)
Expand Down
Loading

0 comments on commit be7b60b

Please sign in to comment.