Skip to content
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@autorest/autorest": "^3.0.0",
"@microsoft.azure/autorest.testserver": "^3.0.6"
"@microsoft.azure/autorest.testserver": "^3.0.9"
},
"files": [
"autorest/**/*.py",
Expand Down
22 changes: 21 additions & 1 deletion test/vanilla/AcceptanceTests/asynctests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from async_generator import yield_, async_generator

from xmlservice.aio import AutoRestSwaggerBATXMLService
from xmlservice.models import BlobType
from xmlservice.models import BlobType, ModelWithByteProperty, ModelWithUrlProperty

import pytest

Expand Down Expand Up @@ -195,3 +195,23 @@ async def test_xms_text(self, client):
xml_object = await client.xml.get_xms_text()
assert xml_object.language == "english"
assert xml_object.content == "I am text"

@pytest.mark.asyncio
async def test_get_bytes(self, client):
bytes_object = await client.xml.get_bytes()
assert isinstance(bytes_object, ModelWithByteProperty)
assert bytes_object.bytes == b"Hello world"

@pytest.mark.asyncio
async def test_put_bytes(self, client):
await client.xml.put_binary(b"Hello world")

@pytest.mark.asyncio
async def test_get_url(self, client):
url_object = await client.xml.get_uri()
assert isinstance(url_object, ModelWithUrlProperty)
assert url_object.url == 'https://myaccount.blob.core.windows.net/'

@pytest.mark.asyncio
async def test_put_url(self, client):
await client.xml.put_uri('https://myaccount.blob.core.windows.net/')
18 changes: 17 additions & 1 deletion test/vanilla/AcceptanceTests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from os.path import dirname, pardir, join, realpath

from xmlservice import AutoRestSwaggerBATXMLService
from xmlservice.models import BlobType
from xmlservice.models import BlobType, ModelWithByteProperty, ModelWithUrlProperty

import pytest

Expand Down Expand Up @@ -188,3 +188,19 @@ def test_xms_text(self, client):
xml_object = client.xml.get_xms_text()
assert xml_object.language == "english"
assert xml_object.content == "I am text"

def test_get_bytes(self, client):
bytes_object = client.xml.get_bytes()
assert isinstance(bytes_object, ModelWithByteProperty)
assert bytes_object.bytes == b"Hello world"

def test_put_bytes(self, client):
bytes_object = client.xml.put_binary(b"Hello world")

def test_get_url(self, client):
url_object = client.xml.get_uri()
assert isinstance(url_object, ModelWithUrlProperty)
assert url_object.url == 'https://myaccount.blob.core.windows.net/'

def test_put_url(self, client):
client.xml.put_uri('https://myaccount.blob.core.windows.net/')
Original file line number Diff line number Diff line change
Expand Up @@ -1325,3 +1325,181 @@ async def get_xms_text(self, **kwargs) -> "_models.ObjectWithXMsTextProperty":
return deserialized

get_xms_text.metadata = {"url": "/xml/x-ms-text"} # type: ignore

@distributed_trace_async
async def get_bytes(self, **kwargs) -> "_models.ModelWithByteProperty":
"""Get an XML document with binary property.

:keyword callable cls: A custom type or function that will be passed the direct response
:return: ModelWithByteProperty, or the result of cls(response)
:rtype: ~xmlservice.models.ModelWithByteProperty
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithByteProperty"]
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}))
accept = "application/xml"

# Construct URL
url = self.get_bytes.metadata["url"] # type: ignore

# Construct parameters
query_parameters = {} # type: Dict[str, Any]

# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters["Accept"] = self._serialize.header("accept", accept, "str")

request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

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

deserialized = self._deserialize("ModelWithByteProperty", pipeline_response)

if cls:
return cls(pipeline_response, deserialized, {})

return deserialized

get_bytes.metadata = {"url": "/xml/bytes"} # type: ignore

@distributed_trace_async
async def put_binary(self, bytes: Optional[bytearray] = None, **kwargs) -> None:
"""Put an XML document with binary property.

:param bytes:
:type bytes: bytearray
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop("cls", None) # type: ClsType[None]
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}))

_slideshow = _models.ModelWithByteProperty(bytes=bytes)
content_type = kwargs.pop("content_type", "application/xml")
accept = "application/xml"

# Construct URL
url = self.put_binary.metadata["url"] # type: ignore

# Construct parameters
query_parameters = {} # type: Dict[str, Any]

# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str")
header_parameters["Accept"] = self._serialize.header("accept", accept, "str")

body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(_slideshow, "ModelWithByteProperty", is_xml=True)
body_content_kwargs["content"] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, response)
raise HttpResponseError(response=response, model=error)

if cls:
return cls(pipeline_response, None, {})

put_binary.metadata = {"url": "/xml/bytes"} # type: ignore

@distributed_trace_async
async def get_uri(self, **kwargs) -> "_models.ModelWithUrlProperty":
"""Get an XML document with uri property.

:keyword callable cls: A custom type or function that will be passed the direct response
:return: ModelWithUrlProperty, or the result of cls(response)
:rtype: ~xmlservice.models.ModelWithUrlProperty
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithUrlProperty"]
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}))
accept = "application/xml"

# Construct URL
url = self.get_uri.metadata["url"] # type: ignore

# Construct parameters
query_parameters = {} # type: Dict[str, Any]

# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters["Accept"] = self._serialize.header("accept", accept, "str")

request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

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

deserialized = self._deserialize("ModelWithUrlProperty", pipeline_response)

if cls:
return cls(pipeline_response, deserialized, {})

return deserialized

get_uri.metadata = {"url": "/xml/url"} # type: ignore

@distributed_trace_async
async def put_uri(self, url: Optional[str] = None, **kwargs) -> None:
"""Put an XML document with uri property.

:param url:
:type url: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop("cls", None) # type: ClsType[None]
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}))

_model = _models.ModelWithUrlProperty(url=url)
content_type = kwargs.pop("content_type", "application/xml")
accept = "application/xml"

# Construct URL
url = self.put_uri.metadata["url"] # type: ignore

# Construct parameters
query_parameters = {} # type: Dict[str, Any]

# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str")
header_parameters["Accept"] = self._serialize.header("accept", accept, "str")

body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(_model, "ModelWithUrlProperty", is_xml=True)
body_content_kwargs["content"] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, response)
raise HttpResponseError(response=response, model=error)

if cls:
return cls(pipeline_response, None, {})

put_uri.metadata = {"url": "/xml/url"} # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from ._models_py3 import ListContainersResponse
from ._models_py3 import Logging
from ._models_py3 import Metrics
from ._models_py3 import ModelWithByteProperty
from ._models_py3 import ModelWithUrlProperty
from ._models_py3 import ObjectWithXMsTextProperty
from ._models_py3 import RetentionPolicy
from ._models_py3 import RootWithRefAndMeta
Expand Down Expand Up @@ -54,6 +56,8 @@
from ._models import ListContainersResponse # type: ignore
from ._models import Logging # type: ignore
from ._models import Metrics # type: ignore
from ._models import ModelWithByteProperty # type: ignore
from ._models import ModelWithUrlProperty # type: ignore
from ._models import ObjectWithXMsTextProperty # type: ignore
from ._models import RetentionPolicy # type: ignore
from ._models import RootWithRefAndMeta # type: ignore
Expand Down Expand Up @@ -94,6 +98,8 @@
"ListContainersResponse",
"Logging",
"Metrics",
"ModelWithByteProperty",
"ModelWithUrlProperty",
"ObjectWithXMsTextProperty",
"RetentionPolicy",
"RootWithRefAndMeta",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,38 @@ def __init__(self, **kwargs):
self.retention_policy = kwargs.get("retention_policy", None)


class ModelWithByteProperty(msrest.serialization.Model):
"""ModelWithByteProperty.

:param bytes:
:type bytes: bytearray
"""

_attribute_map = {
"bytes": {"key": "Bytes", "type": "bytearray"},
}

def __init__(self, **kwargs):
super(ModelWithByteProperty, self).__init__(**kwargs)
self.bytes = kwargs.get("bytes", None)


class ModelWithUrlProperty(msrest.serialization.Model):
"""ModelWithUrlProperty.

:param url:
:type url: str
"""

_attribute_map = {
"url": {"key": "Url", "type": "str"},
}

def __init__(self, **kwargs):
super(ModelWithUrlProperty, self).__init__(**kwargs)
self.url = kwargs.get("url", None)


class ObjectWithXMsTextProperty(msrest.serialization.Model):
"""Contans property.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,38 @@ def __init__(
self.retention_policy = retention_policy


class ModelWithByteProperty(msrest.serialization.Model):
"""ModelWithByteProperty.

:param bytes:
:type bytes: bytearray
"""

_attribute_map = {
"bytes": {"key": "Bytes", "type": "bytearray"},
}

def __init__(self, *, bytes: Optional[bytearray] = None, **kwargs):
super(ModelWithByteProperty, self).__init__(**kwargs)
self.bytes = bytes


class ModelWithUrlProperty(msrest.serialization.Model):
"""ModelWithUrlProperty.

:param url:
:type url: str
"""

_attribute_map = {
"url": {"key": "Url", "type": "str"},
}

def __init__(self, *, url: Optional[str] = None, **kwargs):
super(ModelWithUrlProperty, self).__init__(**kwargs)
self.url = url


class ObjectWithXMsTextProperty(msrest.serialization.Model):
"""Contans property.

Expand Down
Loading