Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/communication/azext_communication/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.11.0"
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.15.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ def cf_communication_cl(cli_ctx, *_):

def cf_communication_service(cli_ctx, *_):
return cf_communication_cl(cli_ctx).communication_service


def cf_operation_statuses(cli_ctx, *_):
return cf_communication_cl(cli_ctx).operation_statuses
25 changes: 10 additions & 15 deletions src/communication/azext_communication/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

helps['communication'] = """
type: group
short-summary: Manage service with communication
short-summary: Manage communication service with communication
"""

helps['communication list'] = """
Expand Down Expand Up @@ -100,6 +100,15 @@
"MyResourceGroup"
"""

helps['communication show-status'] = """
type: command
short-summary: "Gets the current status of an async operation."
examples:
- name: Get OperationStatus
text: |-
az communication show-status --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2"
"""

helps['communication wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the communication is met.
Expand All @@ -111,17 +120,3 @@
text: |-
az communication wait --name "MyCommunicationResource" --resource-group "MyResourceGroup" --deleted
"""

helps['communication'] = """
type: group
short-summary: Manage status with communication
"""

helps['communication show-status'] = """
type: command
short-summary: "Gets the current status of an async operation."
examples:
- name: Get OperationStatus
text: |-
az communication show-status --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2"
"""
12 changes: 8 additions & 4 deletions src/communication/azext_communication/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def load_arguments(self, _):
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService '
'resource.', id_part='name')
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('data_location', type=str, help='The location where the communication service stores its data at '
'rest.')

with self.argument_context('communication delete') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand All @@ -69,11 +73,11 @@ def load_arguments(self, _):
c.argument('key_type', arg_type=get_enum_type(['Primary', 'Secondary']), help='The keyType to regenerate. Must '
'be either \'primary\' or \'secondary\'(case-insensitive).')

with self.argument_context('communication show-status') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))
c.argument('operation_id', type=str, help='The ID of an ongoing async operation')

with self.argument_context('communication wait') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService '
'resource.', id_part='name')

with self.argument_context('communication show-status') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))
c.argument('operation_id', type=str, help='The ID of an ongoing async operation')
10 changes: 1 addition & 9 deletions src/communication/azext_communication/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,5 @@ def load_command_table(self, _):
g.custom_command('link-notification-hub', 'communication_link_notification_hub')
g.custom_command('list-key', 'communication_list_key')
g.custom_command('regenerate-key', 'communication_regenerate_key')
g.custom_wait_command('wait', 'communication_show')

from azext_communication.generated._client_factory import cf_operation_statuses
communication_operation_statuses = CliCommandType(
operations_tmpl='azext_communication.vendored_sdks.communication.operations._operation_statuses_operations#Oper'
'ationStatusesOperations.{}',
client_factory=cf_operation_statuses)
with self.command_group('communication', communication_operation_statuses, client_factory=cf_operation_statuses,
is_preview=True) as g:
g.custom_command('show-status', 'communication_show_status')
g.custom_wait_command('wait', 'communication_show')
32 changes: 22 additions & 10 deletions src/communication/azext_communication/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,30 @@ def communication_create(client,
tags=None,
data_location=None,
no_wait=False):
parameters = {}
parameters['location'] = location
parameters['tags'] = tags
parameters['data_location'] = data_location
return sdk_no_wait(no_wait,
client.begin_create_or_update,
resource_group_name=resource_group_name,
communication_service_name=name,
location=location,
tags=tags,
data_location=data_location)
parameters=parameters)


def communication_update(client,
resource_group_name,
name,
tags=None):
location=None,
tags=None,
data_location=None):
parameters = {}
parameters['location'] = location
parameters['tags'] = tags
parameters['data_location'] = data_location
return client.update(resource_group_name=resource_group_name,
communication_service_name=name,
tags=tags)
parameters=parameters)


def communication_delete(client,
Expand All @@ -66,26 +74,30 @@ def communication_link_notification_hub(client,
name,
resource_id=None,
connection_string=None):
link_notification_hub_parameters = {}
link_notification_hub_parameters['resource_id'] = resource_id
link_notification_hub_parameters['connection_string'] = connection_string
return client.link_notification_hub(resource_group_name=resource_group_name,
communication_service_name=name,
resource_id=resource_id,
connection_string=connection_string)
link_notification_hub_parameters=link_notification_hub_parameters)


def communication_list_key(client,
resource_group_name,
name):
return client.list_key(resource_group_name=resource_group_name,
communication_service_name=name)
return client.list_keys(resource_group_name=resource_group_name,
communication_service_name=name)


def communication_regenerate_key(client,
resource_group_name,
name,
key_type=None):
parameters = {}
parameters['key_type'] = key_type
return client.regenerate_key(resource_group_name=resource_group_name,
communication_service_name=name,
key_type=key_type)
parameters=parameters)


def communication_show_status(client,
Expand Down
8 changes: 5 additions & 3 deletions src/communication/azext_communication/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
def try_manual(func):
def import_manual_function(origin_func):
from importlib import import_module
decorated_path = inspect.getfile(origin_func)
module_path = __path__[0]
decorated_path = inspect.getfile(origin_func).lower()
module_path = __path__[0].lower()
if not decorated_path.startswith(module_path):
raise Exception("Decorator can only be used in submodules!")
manual_path = os.path.join(
Expand All @@ -46,7 +46,6 @@ def import_manual_function(origin_func):
def get_func_to_call():
func_to_call = func
try:
func_to_call = import_manual_function(func)
func_to_call = import_manual_function(func)
logger.info("Found manual override for %s(...)", func.__name__)
except (ImportError, AttributeError):
Expand All @@ -66,6 +65,9 @@ def wrapper(*args, **kwargs):
ret = func_to_call(*args, **kwargs)
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
JMESPathCheckAssertionError) as e:
use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE")
if use_exception_cache is None or use_exception_cache.lower() != "true":
raise
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
test_map[func.__name__]["result"] = FAILED
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
Expand Down
33 changes: 21 additions & 12 deletions src/communication/azext_communication/tests/latest/example_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ def step_create(test, rg_2, rg, checks=None):
'--location "Global" '
'--data-location "United States" '
'--resource-group "{rg}"',
checks=checks)
checks=[])
test.cmd('az communication wait --created '
'--name "{myCommunicationService}" '
'--resource-group "{rg}"',
checks=[])
checks=checks)


# EXAMPLE: /CommunicationService/get/Get OperationStatus
@try_manual
def step_show_status(test, rg_2, rg, checks=None):
if checks is None:
checks = []
test.cmd('az communication show-status '
'--operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" '
'--location "westus2"',
checks=checks)


# EXAMPLE: /CommunicationService/get/Get resource
Expand Down Expand Up @@ -60,6 +71,14 @@ def step_list2(test, rg_2, rg, checks=None):
checks=checks)


def step_list2(test, rg_2, rg, checks=None):
if checks is None:
checks = []
test.cmd('az communication list '
'-g ""',
checks=checks)


# EXAMPLE: /CommunicationService/patch/Update resource
@try_manual
def step_update(test, rg_2, rg, checks=None):
Expand Down Expand Up @@ -119,13 +138,3 @@ def step_delete(test, rg_2, rg, checks=None):
'--resource-group "{rg}"',
checks=checks)


# EXAMPLE: /OperationStatuses/get/Get OperationStatus
@try_manual
def step_show_status(test, rg_2, rg, checks=None):
if checks is None:
checks = []
test.cmd('az communication show-status '
'--operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" '
'--location "westus2"',
checks=checks)
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
from azure.cli.testsdk import ScenarioTest, record_only
from azure.cli.testsdk import ResourceGroupPreparer
from .example_steps import step_create
from .example_steps import step_show_status
from .example_steps import step_show
from .example_steps import step_list
from .example_steps import step_list
from .example_steps import step_list2
from .example_steps import step_update
from .example_steps import step_link_notification_hub
from .example_steps import step_list_key
from .example_steps import step_regenerate_key
from .example_steps import step_delete
from .example_steps import step_show_status
from .. import (
try_manual,
# raise_if,
Expand Down Expand Up @@ -172,3 +172,58 @@ def test_service_link_to_notification_hub(self, resource_group):

# delete that service
step_delete(self, rg_2=None, rg=resource_group)
def call_scenario(test, rg_2, rg):
setup_scenario(test, rg_2, rg)
step_create(test, rg_2, rg, checks=[
test.check("name", "{myCommunicationService}", case_sensitive=False),
test.check("location", "Global", case_sensitive=False),
test.check("dataLocation", "United States", case_sensitive=False),
])
step_show_status(test, rg_2, rg, checks=[])
step_show(test, rg_2, rg, checks=[
test.check("name", "{myCommunicationService}", case_sensitive=False),
test.check("location", "Global", case_sensitive=False),
test.check("dataLocation", "United States", case_sensitive=False),
])
step_list(test, rg_2, rg, checks=[
test.check('length(@)', 1),
])
step_list2(test, rg_2, rg, checks=[
test.check('length(@)', 1),
])
step_update(test, rg_2, rg, checks=[
test.check("name", "{myCommunicationService}", case_sensitive=False),
test.check("location", "Global", case_sensitive=False),
test.check("dataLocation", "United States", case_sensitive=False),
test.check("tags.newTag", "newVal", case_sensitive=False),
])
step_link_notification_hub(test, rg_2, rg, checks=[])
step_list_key(test, rg_2, rg, checks=[])
step_regenerate_key(test, rg_2, rg, checks=[])
step_delete(test, rg_2, rg, checks=[])
cleanup_scenario(test, rg_2, rg)


# Test class for Scenario
@try_manual
class CommunicationScenarioTest(ScenarioTest):

def __init__(self, *args, **kwargs):
super(CommunicationScenarioTest, self).__init__(*args, **kwargs)
self.kwargs.update({
'subscription_id': self.get_subscription_id()
})

self.kwargs.update({
'myCommunicationService': self.create_random_name(prefix='MyCommunicationResource'[:11], length=23),
})


@ResourceGroupPreparer(name_prefix='clitestcommunication_MyOtherResourceGroup'[:7], key='rg_2',
parameter_name='rg_2')
@ResourceGroupPreparer(name_prefix='clitestcommunication_MyResourceGroup'[:7], key='rg', parameter_name='rg')
def test_communication_Scenario(self, rg_2, rg):
call_scenario(self, rg_2, rg)
calc_coverage(__file__)
raise_if()

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from azure.core.credentials import TokenCredential

from ._configuration import CommunicationServiceManagementClientConfiguration
from .operations import OperationOperations
from .operations import Operations
from .operations import CommunicationServiceOperations
from .operations import OperationStatusesOperations
from . import models
Expand All @@ -27,8 +27,8 @@
class CommunicationServiceManagementClient(object):
"""REST API for Azure Communication Services.

:ivar operation: OperationOperations operations
:vartype operation: communication_service_management_client.operations.OperationOperations
:ivar operations: Operations operations
:vartype operations: communication_service_management_client.operations.Operations
:ivar communication_service: CommunicationServiceOperations operations
:vartype communication_service: communication_service_management_client.operations.CommunicationServiceOperations
:ivar operation_statuses: OperationStatusesOperations operations
Expand Down Expand Up @@ -56,10 +56,9 @@ def __init__(

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.operation = OperationOperations(
self.operations = Operations(
self._client, self._config, self._serialize, self._deserialize)
self.communication_service = CommunicationServiceOperations(
self._client, self._config, self._serialize, self._deserialize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(

self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2020-08-20-preview"
self.api_version = "2020-08-20"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'communicationservicemanagementclient/{}'.format(VERSION))
self._configure(**kwargs)
Expand Down
Loading