Skip to content

Commit d1b8c56

Browse files
author
SDKAuto
committed
CodeGen from PR 13862 in Azure/azure-rest-api-specs
Merge d33174a2e064953347b0a47d102d32388d96d81b into 3f7cb7c
1 parent 8333b51 commit d1b8c56

33 files changed

+710
-1927
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"azext.isExperimental": true,
3-
"azext.minCliCoreVersion": "2.11.0"
2+
"azext.isPreview": true,
3+
"azext.minCliCoreVersion": "2.15.0"
44
}

src/communication/azext_communication/generated/_client_factory.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ def cf_communication_cl(cli_ctx, *_):
1818

1919
def cf_communication_service(cli_ctx, *_):
2020
return cf_communication_cl(cli_ctx).communication_service
21-
22-
23-
def cf_operation_statuses(cli_ctx, *_):
24-
return cf_communication_cl(cli_ctx).operation_statuses

src/communication/azext_communication/generated/_help.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
helps['communication'] = """
1616
type: group
17-
short-summary: Manage service with communication
17+
short-summary: Manage communication service with communication
1818
"""
1919

2020
helps['communication list'] = """
@@ -100,6 +100,15 @@
100100
"MyResourceGroup"
101101
"""
102102

103+
helps['communication show-status'] = """
104+
type: command
105+
short-summary: "Gets the current status of an async operation."
106+
examples:
107+
- name: Get OperationStatus
108+
text: |-
109+
az communication show-status --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2"
110+
"""
111+
103112
helps['communication wait'] = """
104113
type: command
105114
short-summary: Place the CLI in a waiting state until a condition of the communication is met.
@@ -111,17 +120,3 @@
111120
text: |-
112121
az communication wait --name "MyCommunicationResource" --resource-group "MyResourceGroup" --deleted
113122
"""
114-
115-
helps['communication'] = """
116-
type: group
117-
short-summary: Manage status with communication
118-
"""
119-
120-
helps['communication show-status'] = """
121-
type: command
122-
short-summary: "Gets the current status of an async operation."
123-
examples:
124-
- name: Get OperationStatus
125-
text: |-
126-
az communication show-status --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2"
127-
"""

src/communication/azext_communication/generated/_params.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ def load_arguments(self, _):
4343
c.argument('resource_group_name', resource_group_name_type)
4444
c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService '
4545
'resource.', id_part='name')
46+
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
47+
validator=get_default_location_from_resource_group)
4648
c.argument('tags', tags_type)
49+
c.argument('data_location', type=str, help='The location where the communication service stores its data at '
50+
'rest.')
4751

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

76+
with self.argument_context('communication show-status') as c:
77+
c.argument('location', arg_type=get_location_type(self.cli_ctx))
78+
c.argument('operation_id', type=str, help='The ID of an ongoing async operation')
79+
7280
with self.argument_context('communication wait') as c:
7381
c.argument('resource_group_name', resource_group_name_type)
7482
c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService '
7583
'resource.', id_part='name')
76-
77-
with self.argument_context('communication show-status') as c:
78-
c.argument('location', arg_type=get_location_type(self.cli_ctx))
79-
c.argument('operation_id', type=str, help='The ID of an ongoing async operation')

src/communication/azext_communication/generated/commands.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,5 @@ def load_command_table(self, _):
3030
g.custom_command('link-notification-hub', 'communication_link_notification_hub')
3131
g.custom_command('list-key', 'communication_list_key')
3232
g.custom_command('regenerate-key', 'communication_regenerate_key')
33-
g.custom_wait_command('wait', 'communication_show')
34-
35-
from azext_communication.generated._client_factory import cf_operation_statuses
36-
communication_operation_statuses = CliCommandType(
37-
operations_tmpl='azext_communication.vendored_sdks.communication.operations._operation_statuses_operations#Oper'
38-
'ationStatusesOperations.{}',
39-
client_factory=cf_operation_statuses)
40-
with self.command_group('communication', communication_operation_statuses, client_factory=cf_operation_statuses,
41-
is_preview=True) as g:
4233
g.custom_command('show-status', 'communication_show_status')
34+
g.custom_wait_command('wait', 'communication_show')

src/communication/azext_communication/generated/custom.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,30 @@ def communication_create(client,
3333
tags=None,
3434
data_location=None,
3535
no_wait=False):
36+
parameters = {}
37+
parameters['location'] = location
38+
parameters['tags'] = tags
39+
parameters['data_location'] = data_location
3640
return sdk_no_wait(no_wait,
3741
client.begin_create_or_update,
3842
resource_group_name=resource_group_name,
3943
communication_service_name=name,
40-
location=location,
41-
tags=tags,
42-
data_location=data_location)
44+
parameters=parameters)
4345

4446

4547
def communication_update(client,
4648
resource_group_name,
4749
name,
48-
tags=None):
50+
location=None,
51+
tags=None,
52+
data_location=None):
53+
parameters = {}
54+
parameters['location'] = location
55+
parameters['tags'] = tags
56+
parameters['data_location'] = data_location
4957
return client.update(resource_group_name=resource_group_name,
5058
communication_service_name=name,
51-
tags=tags)
59+
parameters=parameters)
5260

5361

5462
def communication_delete(client,
@@ -66,26 +74,30 @@ def communication_link_notification_hub(client,
6674
name,
6775
resource_id=None,
6876
connection_string=None):
77+
link_notification_hub_parameters = {}
78+
link_notification_hub_parameters['resource_id'] = resource_id
79+
link_notification_hub_parameters['connection_string'] = connection_string
6980
return client.link_notification_hub(resource_group_name=resource_group_name,
7081
communication_service_name=name,
71-
resource_id=resource_id,
72-
connection_string=connection_string)
82+
link_notification_hub_parameters=link_notification_hub_parameters)
7383

7484

7585
def communication_list_key(client,
7686
resource_group_name,
7787
name):
78-
return client.list_key(resource_group_name=resource_group_name,
79-
communication_service_name=name)
88+
return client.list_keys(resource_group_name=resource_group_name,
89+
communication_service_name=name)
8090

8191

8292
def communication_regenerate_key(client,
8393
resource_group_name,
8494
name,
8595
key_type=None):
96+
parameters = {}
97+
parameters['key_type'] = key_type
8698
return client.regenerate_key(resource_group_name=resource_group_name,
8799
communication_service_name=name,
88-
key_type=key_type)
100+
parameters=parameters)
89101

90102

91103
def communication_show_status(client,

src/communication/azext_communication/tests/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
def try_manual(func):
3232
def import_manual_function(origin_func):
3333
from importlib import import_module
34-
decorated_path = inspect.getfile(origin_func)
35-
module_path = __path__[0]
34+
decorated_path = inspect.getfile(origin_func).lower()
35+
module_path = __path__[0].lower()
3636
if not decorated_path.startswith(module_path):
3737
raise Exception("Decorator can only be used in submodules!")
3838
manual_path = os.path.join(
@@ -46,7 +46,6 @@ def import_manual_function(origin_func):
4646
def get_func_to_call():
4747
func_to_call = func
4848
try:
49-
func_to_call = import_manual_function(func)
5049
func_to_call = import_manual_function(func)
5150
logger.info("Found manual override for %s(...)", func.__name__)
5251
except (ImportError, AttributeError):
@@ -66,6 +65,9 @@ def wrapper(*args, **kwargs):
6665
ret = func_to_call(*args, **kwargs)
6766
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
6867
JMESPathCheckAssertionError) as e:
68+
use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE")
69+
if use_exception_cache is None or use_exception_cache.lower() != "true":
70+
raise
6971
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
7072
test_map[func.__name__]["result"] = FAILED
7173
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]

src/communication/azext_communication/tests/latest/example_steps.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,22 @@ def step_create(test, rg_2, rg, checks=None):
2222
'--location "Global" '
2323
'--data-location "United States" '
2424
'--resource-group "{rg}"',
25-
checks=checks)
25+
checks=[])
2626
test.cmd('az communication wait --created '
2727
'--name "{myCommunicationService}" '
2828
'--resource-group "{rg}"',
29-
checks=[])
29+
checks=checks)
30+
31+
32+
# EXAMPLE: /CommunicationService/get/Get OperationStatus
33+
@try_manual
34+
def step_show_status(test, rg_2, rg, checks=None):
35+
if checks is None:
36+
checks = []
37+
test.cmd('az communication show-status '
38+
'--operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" '
39+
'--location "westus2"',
40+
checks=checks)
3041

3142

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

6273

74+
def step_list2(test, rg_2, rg, checks=None):
75+
if checks is None:
76+
checks = []
77+
test.cmd('az communication list '
78+
'-g ""',
79+
checks=checks)
80+
81+
6382
# EXAMPLE: /CommunicationService/patch/Update resource
6483
@try_manual
6584
def step_update(test, rg_2, rg, checks=None):
@@ -119,13 +138,3 @@ def step_delete(test, rg_2, rg, checks=None):
119138
'--resource-group "{rg}"',
120139
checks=checks)
121140

122-
123-
# EXAMPLE: /OperationStatuses/get/Get OperationStatus
124-
@try_manual
125-
def step_show_status(test, rg_2, rg, checks=None):
126-
if checks is None:
127-
checks = []
128-
test.cmd('az communication show-status '
129-
'--operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" '
130-
'--location "westus2"',
131-
checks=checks)

src/communication/azext_communication/tests/latest/test_communication_scenario.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from azure.cli.testsdk import ScenarioTest, record_only
1313
from azure.cli.testsdk import ResourceGroupPreparer
1414
from .example_steps import step_create
15+
from .example_steps import step_show_status
1516
from .example_steps import step_show
1617
from .example_steps import step_list
17-
from .example_steps import step_list
18+
from .example_steps import step_list2
1819
from .example_steps import step_update
1920
from .example_steps import step_link_notification_hub
2021
from .example_steps import step_list_key
2122
from .example_steps import step_regenerate_key
2223
from .example_steps import step_delete
23-
from .example_steps import step_show_status
2424
from .. import (
2525
try_manual,
2626
# raise_if,
@@ -172,3 +172,58 @@ def test_service_link_to_notification_hub(self, resource_group):
172172

173173
# delete that service
174174
step_delete(self, rg_2=None, rg=resource_group)
175+
def call_scenario(test, rg_2, rg):
176+
setup_scenario(test, rg_2, rg)
177+
step_create(test, rg_2, rg, checks=[
178+
test.check("name", "{myCommunicationService}", case_sensitive=False),
179+
test.check("location", "Global", case_sensitive=False),
180+
test.check("dataLocation", "United States", case_sensitive=False),
181+
])
182+
step_show_status(test, rg_2, rg, checks=[])
183+
step_show(test, rg_2, rg, checks=[
184+
test.check("name", "{myCommunicationService}", case_sensitive=False),
185+
test.check("location", "Global", case_sensitive=False),
186+
test.check("dataLocation", "United States", case_sensitive=False),
187+
])
188+
step_list(test, rg_2, rg, checks=[
189+
test.check('length(@)', 1),
190+
])
191+
step_list2(test, rg_2, rg, checks=[
192+
test.check('length(@)', 1),
193+
])
194+
step_update(test, rg_2, rg, checks=[
195+
test.check("name", "{myCommunicationService}", case_sensitive=False),
196+
test.check("location", "Global", case_sensitive=False),
197+
test.check("dataLocation", "United States", case_sensitive=False),
198+
test.check("tags.newTag", "newVal", case_sensitive=False),
199+
])
200+
step_link_notification_hub(test, rg_2, rg, checks=[])
201+
step_list_key(test, rg_2, rg, checks=[])
202+
step_regenerate_key(test, rg_2, rg, checks=[])
203+
step_delete(test, rg_2, rg, checks=[])
204+
cleanup_scenario(test, rg_2, rg)
205+
206+
207+
# Test class for Scenario
208+
@try_manual
209+
class CommunicationScenarioTest(ScenarioTest):
210+
211+
def __init__(self, *args, **kwargs):
212+
super(CommunicationScenarioTest, self).__init__(*args, **kwargs)
213+
self.kwargs.update({
214+
'subscription_id': self.get_subscription_id()
215+
})
216+
217+
self.kwargs.update({
218+
'myCommunicationService': self.create_random_name(prefix='MyCommunicationResource'[:11], length=23),
219+
})
220+
221+
222+
@ResourceGroupPreparer(name_prefix='clitestcommunication_MyOtherResourceGroup'[:7], key='rg_2',
223+
parameter_name='rg_2')
224+
@ResourceGroupPreparer(name_prefix='clitestcommunication_MyResourceGroup'[:7], key='rg', parameter_name='rg')
225+
def test_communication_Scenario(self, rg_2, rg):
226+
call_scenario(self, rg_2, rg)
227+
calc_coverage(__file__)
228+
raise_if()
229+

src/communication/azext_communication/vendored_sdks/communication/_communication_service_management_client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from azure.core.credentials import TokenCredential
1919

2020
from ._configuration import CommunicationServiceManagementClientConfiguration
21-
from .operations import OperationOperations
21+
from .operations import Operations
2222
from .operations import CommunicationServiceOperations
2323
from .operations import OperationStatusesOperations
2424
from . import models
@@ -27,8 +27,8 @@
2727
class CommunicationServiceManagementClient(object):
2828
"""REST API for Azure Communication Services.
2929
30-
:ivar operation: OperationOperations operations
31-
:vartype operation: communication_service_management_client.operations.OperationOperations
30+
:ivar operations: Operations operations
31+
:vartype operations: communication_service_management_client.operations.Operations
3232
:ivar communication_service: CommunicationServiceOperations operations
3333
:vartype communication_service: communication_service_management_client.operations.CommunicationServiceOperations
3434
:ivar operation_statuses: OperationStatusesOperations operations
@@ -56,10 +56,9 @@ def __init__(
5656

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

62-
self.operation = OperationOperations(
61+
self.operations = Operations(
6362
self._client, self._config, self._serialize, self._deserialize)
6463
self.communication_service = CommunicationServiceOperations(
6564
self._client, self._config, self._serialize, self._deserialize)

0 commit comments

Comments
 (0)