Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Voice-Service] Microsoft.VoiceServices GA Release #5845

Merged
merged 5 commits into from
Feb 8, 2023
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: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,5 @@
/src/mobile-network/ @jsntcy

/src/automanage/ @calvinhzy

/src/voice-service/ @jsntcy
5 changes: 5 additions & 0 deletions src/service_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,5 +693,10 @@
"Command": "az automanage",
"AzureServiceName": "Azure Automanage",
"URL": "https://learn.microsoft.com/en-us/azure/automanage/"
},
{
"Command": "az voice-service",
"AzureServiceName": "Azure VoiceServices",
"URL": ""
}
]
8 changes: 8 additions & 0 deletions src/voice-service/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
62 changes: 62 additions & 0 deletions src/voice-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Azure CLI VoiceService Extension #
This is an extension to Azure CLI to manage VoiceService resources.

## How to use ##
Install this extension using the below CLI command
```
az extension add --name voice-service
```

### Included Features ###
#### voice-service gateway ####
##### Create #####
```
az voice-service gateway create -n gateway-name -g rg --service-locations '[{name:useast,PrimaryRegionProperties:{operatorAddresses:[198.51.100.1],allowedSignalingSourceAddressPrefixes:[10.1.1.0/24],allowedMediaSourceAddressPrefixes:[10.1.2.0/24]}},{name:useast2,PrimaryRegionProperties:{operatorAddresses:[198.51.100.2],allowedSignalingSourceAddressPrefixes:[10.2.1.0/24],allowedMediaSourceAddressPrefixes:[10.2.2.0/24]}}]' --connectivity PublicAddress --codecs '[PCMA]' --e911-type Standard --platforms '[OperatorConnect]'

```
##### Show #####
```
az voice-service gateway show -n gateway-name -g rg
```
##### List #####
```
az voice-service gateway list -g rg
```
##### Update #####
```
az voice-service gateway update -n gateway-name -g rg --tags "{tag:test,tag2:test2}"
```

##### Delete #####
```
az voice-service gateway delete -n gateway-name -g rg -y
```

#### voice-service test-line ####
##### Create #####
```
az voice-service test-line create -n test-line-name -g rg --gateway-name gateway-name --phone-number "+1-555-1234" --purpose Automated

```
##### Show #####
```
az voice-service test-line show -n test-line-name --gateway-name gateway-name -g rg
```
##### List #####
```
az voice-service test-line list -g rg --gateway-name gateway-name
```
##### Update #####
```
az voice-service test-line update -n test-line-name -g rg --gateway-name gateway-name --tags "{tag:test,tag2:test2}"
```

##### Delete #####
```
az voice-service test-line delete -n test-line-name -g rg --gateway-name gateway-name -y
```

#### voice-service check-name-availability ####
```
az voice-service check-name-availability -l centraluseuap --name voicenametest --type microsoft.voiceservices/communicationsgateways/testlines
```
42 changes: 42 additions & 0 deletions src/voice-service/azext_voice_service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_voice_service._help import helps # pylint: disable=unused-import


class VoiceServiceCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_command_type = CliCommandType(
operations_tmpl='azext_voice_service.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_voice_service.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_voice_service._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = VoiceServiceCommandsLoader
11 changes: 11 additions & 0 deletions src/voice-service/azext_voice_service/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import
13 changes: 13 additions & 0 deletions src/voice-service/azext_voice_service/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=too-many-lines
# pylint: disable=too-many-statements


def load_arguments(self, _): # pylint: disable=unused-argument
pass
6 changes: 6 additions & 0 deletions src/voice-service/azext_voice_service/aaz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"voice-service",
)
class __CMDGroup(AAZCommandGroup):
"""Manage voice services
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._check_name_availability import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"voice-service check-name-availability",
)
class CheckNameAvailability(AAZCommand):
"""Check whether the resource name is available in the given region.

:example: check name availability
az voice-service check-name-availability -l centraluseuap --name voicenametest --type microsoft.voiceservices/communicationsgateways/testlines
"""

_aaz_info = {
"version": "2023-01-31",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.voiceservices/locations/{}/checknameavailability", "2023-01-31"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.location = AAZResourceLocationArg(
required=True,
id_part="name",
)

# define Arg Group "Body"

_args_schema = cls._args_schema
_args_schema.name = AAZStrArg(
options=["--name"],
arg_group="Body",
help="The name of the resource for which availability needs to be checked.",
)
_args_schema.type = AAZStrArg(
options=["--type"],
arg_group="Body",
help="The resource type.",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.NameAvailabilityCheckLocal(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class NameAvailabilityCheckLocal(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/locations/{location}/checkNameAvailability",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"location", self.ctx.args.location,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-31",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("name", AAZStrType, ".name")
_builder.set_prop("type", AAZStrType, ".type")

return self.serialize_content(_content_value)

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.message = AAZStrType()
_schema_on_200.name_available = AAZBoolType(
serialized_name="nameAvailable",
)
_schema_on_200.reason = AAZStrType()

return cls._schema_on_200


class _CheckNameAvailabilityHelper:
"""Helper class for CheckNameAvailability"""


__all__ = ["CheckNameAvailability"]
Loading