Skip to content

Commit

Permalink
RouteType option and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AriZavala2 committed Nov 10, 2021
1 parent 8a16451 commit 41be7de
Show file tree
Hide file tree
Showing 26 changed files with 568 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

# pylint: disable=bad-option-value, unused-import
from ._communication_relay_client import CommunicationRelayClient
from ._generated.models import RouteType
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def from_connection_string(
def get_relay_configuration(
self,
user=None, # type: CommunicationUserIdentifier
route_type=None, #type: RouteType
**kwargs # type: Any
):
# type: (Any) -> CommunicationRelayConfiguration
Expand All @@ -96,7 +97,8 @@ def get_relay_configuration(
"""
if user is None:
return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration(
None, **kwargs)
None, route_type, **kwargs)
return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration(
user.properties['id'],
route_type,
**kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class CommunicationNetworkTraversalClient(object):
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com.
:type endpoint: str
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -40,7 +43,7 @@ def __init__(
):
# type: (...) -> None
_base_url = '{endpoint}'
self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs)
self._config = CommunicationNetworkTraversalClientConfiguration(endpoint=endpoint, **kwargs)
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class CommunicationNetworkTraversalClientConfiguration(Configuration):
:param endpoint: The communication resource, for example https://my-resource.communication.azure.com.
:type endpoint: str
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -33,12 +35,14 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.api_version = "2021-10-08-preview"
self.api_version = api_version
kwargs.setdefault('sdk_moniker', 'communicationnetworktraversalclient/{}'.format(VERSION))
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._communication_network_traversal_client import CommunicationNetworkTraversalClient
__all__ = ['CommunicationNetworkTraversalClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class CommunicationNetworkTraversalClient:
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com.
:type endpoint: str
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -34,7 +37,7 @@ def __init__(
**kwargs: Any
) -> None:
_base_url = '{endpoint}'
self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs)
self._config = CommunicationNetworkTraversalClientConfiguration(endpoint=endpoint, **kwargs)
self._client = AsyncPipelineClient(base_url=_base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ class CommunicationNetworkTraversalClientConfiguration(Configuration):
:param endpoint: The communication resource, for example https://my-resource.communication.azure.com.
:type endpoint: str
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
**kwargs: Any
) -> None:
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.api_version = "2021-10-08-preview"
self.api_version = api_version
kwargs.setdefault('sdk_moniker', 'communicationnetworktraversalclient/{}'.format(VERSION))
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._communication_network_traversal_operations import build_issue_relay_configuration_request

T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]

Expand Down Expand Up @@ -48,7 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:
async def issue_relay_configuration(
self,
id: Optional[str] = None,
route_type: Optional[Union[str, "_models.CommunicationRelayConfigurationRequestRouteType"]] = None,
route_type: Optional[Union[str, "_models.RouteType"]] = None,
**kwargs: Any
) -> "_models.CommunicationRelayConfiguration":
"""Issue a configuration for an STUN/TURN server for an existing identity.
Expand All @@ -59,8 +58,10 @@ async def issue_relay_configuration(
:type id: str
:param route_type: The routing methodology to where the ICE server will be located from the
client.
:type route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:type route_type: str or ~azure.communication.networktraversal.models.RouteType
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CommunicationRelayConfiguration, or the result of cls(response)
:rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration
Expand All @@ -72,6 +73,7 @@ async def issue_relay_configuration(
}
error_map.update(kwargs.pop('error_map', {}))

api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]

_body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type)
Expand All @@ -81,6 +83,7 @@ async def issue_relay_configuration(
json = None

request = build_issue_relay_configuration_request(
api_version=api_version,
content_type=content_type,
json=json,
template_url=self.issue_relay_configuration.metadata['url'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from ._models import CommunicationRelayConfigurationRequest # type: ignore

from ._communication_network_traversal_client_enums import (
CommunicationIceServerRouteType,
CommunicationRelayConfigurationRequestRouteType,
RouteType,
)

__all__ = [
Expand All @@ -30,6 +29,5 @@
'CommunicationIceServer',
'CommunicationRelayConfiguration',
'CommunicationRelayConfigurationRequest',
'CommunicationIceServerRouteType',
'CommunicationRelayConfigurationRequestRouteType',
'RouteType',
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@
from azure.core import CaseInsensitiveEnumMeta


class CommunicationIceServerRouteType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""The routing methodology to where the ICE server will be located from the client.
"""

ANY = "any"
NEAREST = "nearest"

class CommunicationRelayConfigurationRequestRouteType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RouteType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""The routing methodology to where the ICE server will be located from the client.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class CommunicationIceServer(msrest.serialization.Model):
:vartype credential: str
:ivar route_type: Required. The routing methodology to where the ICE server will be located
from the client. Possible values include: "any", "nearest".
:vartype route_type: str or
~azure.communication.networktraversal.models.CommunicationIceServerRouteType
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""

_validation = {
Expand Down Expand Up @@ -136,8 +135,7 @@ def __init__(
:paramtype credential: str
:keyword route_type: Required. The routing methodology to where the ICE server will be located
from the client. Possible values include: "any", "nearest".
:paramtype route_type: str or
~azure.communication.networktraversal.models.CommunicationIceServerRouteType
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""
super(CommunicationIceServer, self).__init__(**kwargs)
self.urls = kwargs['urls']
Expand Down Expand Up @@ -194,8 +192,7 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model):
:vartype id: str
:ivar route_type: The routing methodology to where the ICE server will be located from the
client. Possible values include: "any", "nearest".
:vartype route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""

_attribute_map = {
Expand All @@ -212,8 +209,7 @@ def __init__(
:paramtype id: str
:keyword route_type: The routing methodology to where the ICE server will be located from the
client. Possible values include: "any", "nearest".
:paramtype route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""
super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs)
self.id = kwargs.get('id', None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ class CommunicationIceServer(msrest.serialization.Model):
:vartype credential: str
:ivar route_type: Required. The routing methodology to where the ICE server will be located
from the client. Possible values include: "any", "nearest".
:vartype route_type: str or
~azure.communication.networktraversal.models.CommunicationIceServerRouteType
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""

_validation = {
Expand All @@ -139,7 +138,7 @@ def __init__(
urls: List[str],
username: str,
credential: str,
route_type: Union[str, "CommunicationIceServerRouteType"],
route_type: Union[str, "RouteType"],
**kwargs
):
"""
Expand All @@ -151,8 +150,7 @@ def __init__(
:paramtype credential: str
:keyword route_type: Required. The routing methodology to where the ICE server will be located
from the client. Possible values include: "any", "nearest".
:paramtype route_type: str or
~azure.communication.networktraversal.models.CommunicationIceServerRouteType
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""
super(CommunicationIceServer, self).__init__(**kwargs)
self.urls = urls
Expand Down Expand Up @@ -212,8 +210,7 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model):
:vartype id: str
:ivar route_type: The routing methodology to where the ICE server will be located from the
client. Possible values include: "any", "nearest".
:vartype route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""

_attribute_map = {
Expand All @@ -225,16 +222,15 @@ def __init__(
self,
*,
id: Optional[str] = None,
route_type: Optional[Union[str, "CommunicationRelayConfigurationRequestRouteType"]] = None,
route_type: Optional[Union[str, "RouteType"]] = None,
**kwargs
):
"""
:keyword id: An existing ACS identity.
:paramtype id: str
:keyword route_type: The routing methodology to where the ICE server will be located from the
client. Possible values include: "any", "nearest".
:paramtype route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
"""
super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs)
self.id = id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union

T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
# fmt: off

def build_issue_relay_configuration_request(
**kwargs # type: Any
):
# type: (...) -> HttpRequest
api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str
content_type = kwargs.pop('content_type', None) # type: Optional[str]

api_version = "2021-10-08-preview"
accept = "application/json"
# Construct URL
url = kwargs.pop("template_url", '/networktraversal/:issueRelayConfiguration')
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self, client, config, serializer, deserializer):
def issue_relay_configuration(
self,
id=None, # type: Optional[str]
route_type=None, # type: Optional[Union[str, "_models.CommunicationRelayConfigurationRequestRouteType"]]
route_type=None, # type: Optional[Union[str, "_models.RouteType"]]
**kwargs # type: Any
):
# type: (...) -> "_models.CommunicationRelayConfiguration"
Expand All @@ -97,8 +97,10 @@ def issue_relay_configuration(
:type id: str
:param route_type: The routing methodology to where the ICE server will be located from the
client.
:type route_type: str or
~azure.communication.networktraversal.models.CommunicationRelayConfigurationRequestRouteType
:type route_type: str or ~azure.communication.networktraversal.models.RouteType
:keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CommunicationRelayConfiguration, or the result of cls(response)
:rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration
Expand All @@ -110,6 +112,7 @@ def issue_relay_configuration(
}
error_map.update(kwargs.pop('error_map', {}))

api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]

_body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type)
Expand All @@ -119,6 +122,7 @@ def issue_relay_configuration(
json = None

request = build_issue_relay_configuration_request(
api_version=api_version,
content_type=content_type,
json=json,
template_url=self.issue_relay_configuration.metadata['url'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# --------------------------------------------------------------------------

from ._communication_relay_client_async import CommunicationRelayClient
from .._generated.models import RouteType

__all__ = [
'CommunicationRelayClient'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def from_connection_string(
async def get_relay_configuration(
self,
user: 'CommunicationUserIdentifier' = None,
route_type: 'CommunicationRelayConfigurationRequestRouteType' = None,
**kwargs # type: Any
) -> 'CommunicationRelayConfiguration':
"""get a Communication Relay configuration.
Expand All @@ -93,9 +94,10 @@ async def get_relay_configuration(
"""
if user is None:
return await self._network_traversal_service_client.communication_network_traversal. \
issue_relay_configuration(None, **kwargs)
issue_relay_configuration(None, route_type, **kwargs)
return await self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration(
user.properties['id'],
route_type,
**kwargs)

async def __aenter__(self) -> "CommunicationRelayClient":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ autorest ./SWAGGER.md
### Settings
``` yaml
tag: package-2021-10-08-preview
require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/283fd578dca61390523cae07a2312a34ea87ec90/specification/communication/data-plane/NetworkTraversal/readme.md
require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/f2e08ab373eb0e96b54920e89f9fc96d683355ca/specification/communication/data-plane/NetworkTraversal/readme.md
output-folder: ../azure/communication/networktraversal/_generated/
namespace: azure.communication.networktraversal
license-header: MICROSOFT_MIT_NO_VERSION
Expand Down
Loading

0 comments on commit 41be7de

Please sign in to comment.