diff --git a/src/connectedmachine/HISTORY.rst b/src/connectedmachine/HISTORY.rst index 5ea5175b1c8..1c139576ba0 100644 --- a/src/connectedmachine/HISTORY.rst +++ b/src/connectedmachine/HISTORY.rst @@ -3,19 +3,6 @@ Release History =============== -0.3.0 -+++++ -* Renamed machine-extension subgroup to extension -* Moved all commands under the machine subgroup to the extension level - -0.2.0 -+++++ -* machineextensions support - -0.1.1 -+++++ -* Remove the limitation of max compatible cli core version - 0.1.0 ++++++ * Initial release. diff --git a/src/connectedmachine/azext_connectedmachine/generated/_help.py b/src/connectedmachine/azext_connectedmachine/generated/_help.py index 590d6aae2d9..aedcab57b65 100644 --- a/src/connectedmachine/azext_connectedmachine/generated/_help.py +++ b/src/connectedmachine/azext_connectedmachine/generated/_help.py @@ -12,110 +12,119 @@ from knack.help_files import helps -helps['connectedmachine'] = """ +helps['connectedmachine machine'] = """ type: group - short-summary: connectedmachine + short-summary: connectedmachine machine """ -helps['connectedmachine list'] = """ +helps['connectedmachine machine list'] = """ type: command - short-summary: "Lists all the hybrid machines in the specified subscription." + short-summary: "Lists all the hybrid machines in the specified resource group. And Lists all the hybrid machines \ +in the specified subscription." examples: - name: List Machines by resource group text: |- - az connectedmachine list --resource-group "myResourceGroup" + az connectedmachine machine list --resource-group "myResourceGroup" + - name: List Machines by resource group + text: |- + az connectedmachine machine list """ -helps['connectedmachine show'] = """ +helps['connectedmachine machine show'] = """ type: command short-summary: "Retrieves information about the model view or the instance view of a hybrid machine." examples: - name: Get Machine text: |- - az connectedmachine show --name "myMachine" --resource-group "myResourceGroup" + az connectedmachine machine show --name "myMachine" --resource-group "myResourceGroup" """ -helps['connectedmachine delete'] = """ +helps['connectedmachine machine delete'] = """ type: command short-summary: "The operation to remove a hybrid machine identity in Azure." examples: - name: Delete a Machine text: |- - az connectedmachine delete --name "myMachine" --resource-group "myResourceGroup" + az connectedmachine machine delete --name "myMachine" --resource-group "myResourceGroup" """ -helps['connectedmachine extension'] = """ +helps['connectedmachine machine-extension'] = """ type: group - short-summary: connectedmachine extension + short-summary: connectedmachine machine-extension """ -helps['connectedmachine extension list'] = """ +helps['connectedmachine machine-extension list'] = """ type: command - short-summary: "The operation to get all extensions of a non-Azure machine" + short-summary: "The operation to get all extensions of a non-Azure machine." examples: - name: Get all Machine Extensions text: |- - az connectedmachine extension list --machine-name "myMachine" --resource-group "myResourceGroup" + az connectedmachine machine-extension list --machine-name "myMachine" --resource-group \ +"myResourceGroup" """ -helps['connectedmachine extension show'] = """ +helps['connectedmachine machine-extension show'] = """ type: command short-summary: "The operation to get the extension." examples: - name: Get Machine Extension text: |- - az connectedmachine extension show --machine-name "myMachine" --name "CustomScriptExtension" \ + az connectedmachine machine-extension show --machine-name "myMachine" --n "CustomScriptExtension" \ --resource-group "myResourceGroup" """ -helps['connectedmachine extension create'] = """ +helps['connectedmachine machine-extension create'] = """ type: command - short-summary: "The operation to create or update the extension." + short-summary: "The operation to Create the extension." examples: - - name: Create a Machine Extension (PUT) + - name: Create or Update a Machine Extension text: |- - az connectedmachine extension create --machine-name "myMachine" --name "CustomScriptExtension" --location \ -"eastus2euap" --type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings "{\\"commandToExecute\\":\\"pow\ -ershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" --type-handler-version "1.10" \ ---resource-group "myResourceGroup" + az connectedmachine machine-extension create --machine-name "myMachine" --n "CustomScriptExtension" \ +--location "eastus2euap" --type-properties-type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings \ +"{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" \ +--type-handler-version "1.10" --resource-group "myResourceGroup" """ -helps['connectedmachine extension update'] = """ +helps['connectedmachine machine-extension update'] = """ type: command short-summary: "The operation to update the extension." examples: - - name: Update a Machine Extension (PATCH) + - name: Create or Update a Machine Extension text: |- - az connectedmachine extension update --machine-name "myMachine" --name "CustomScriptExtension" --type \ -"CustomScriptExtension" --publisher "Microsoft.Compute" --settings "{\\"commandToExecute\\":\\"powershell.exe -c \ -\\\\\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" --type-handler-version "1.10" --resource-group \ + az connectedmachine machine-extension update --machine-name "myMachine" --n "CustomScriptExtension" \ +--type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings "{\\"commandToExecute\\":\\"powershell.exe \ +-c \\\\\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" --type-handler-version "1.10" --resource-group \ "myResourceGroup" """ -helps['connectedmachine extension delete'] = """ +helps['connectedmachine machine-extension delete'] = """ type: command short-summary: "The operation to delete the extension." examples: - name: Delete a Machine Extension text: |- - az connectedmachine extension delete --machine-name "myMachine" --name "MMA" --resource-group \ + az connectedmachine machine-extension delete --machine-name "myMachine" --n "MMA" --resource-group \ "myResourceGroup" """ -helps['connectedmachine extension wait'] = """ +helps['connectedmachine machine-extension wait'] = """ type: command - short-summary: Place the CLI in a waiting state until a condition of the connectedmachine extension is met. + short-summary: Place the CLI in a waiting state until a condition of the connectedmachine machine-extension is \ +met. examples: - - name: Pause executing next line of CLI script until the connectedmachine extension is successfully created. + - name: Pause executing next line of CLI script until the connectedmachine machine-extension is successfully \ +created. text: |- - az connectedmachine extension wait --machine-name "myMachine" --name "CustomScriptExtension" \ + az connectedmachine machine-extension wait --machine-name "myMachine" --n "CustomScriptExtension" \ --resource-group "myResourceGroup" --created - - name: Pause executing next line of CLI script until the connectedmachine extension is successfully updated. + - name: Pause executing next line of CLI script until the connectedmachine machine-extension is successfully \ +updated. text: |- - az connectedmachine extension wait --machine-name "myMachine" --name "CustomScriptExtension" \ + az connectedmachine machine-extension wait --machine-name "myMachine" --n "CustomScriptExtension" \ --resource-group "myResourceGroup" --updated - - name: Pause executing next line of CLI script until the connectedmachine extension is successfully deleted. + - name: Pause executing next line of CLI script until the connectedmachine machine-extension is successfully \ +deleted. text: |- - az connectedmachine extension wait --machine-name "myMachine" --name "CustomScriptExtension" \ + az connectedmachine machine-extension wait --machine-name "myMachine" --n "CustomScriptExtension" \ --resource-group "myResourceGroup" --deleted """ diff --git a/src/connectedmachine/azext_connectedmachine/generated/_params.py b/src/connectedmachine/azext_connectedmachine/generated/_params.py index 98c10acf5eb..067e762cb70 100644 --- a/src/connectedmachine/azext_connectedmachine/generated/_params.py +++ b/src/connectedmachine/azext_connectedmachine/generated/_params.py @@ -24,31 +24,31 @@ def load_arguments(self, _): - with self.argument_context('connectedmachine list') as c: + with self.argument_context('connectedmachine machine list') as c: c.argument('resource_group_name', resource_group_name_type) - with self.argument_context('connectedmachine show') as c: + with self.argument_context('connectedmachine machine show') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', options_list=['--name', '-n', '--machine-name'], type=str, help='The name of the ' 'hybrid machine.', id_part='name') - with self.argument_context('connectedmachine delete') as c: + with self.argument_context('connectedmachine machine delete') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', options_list=['--name', '-n', '--machine-name'], type=str, help='The name of the ' 'hybrid machine.', id_part='name') - with self.argument_context('connectedmachine extension list') as c: + with self.argument_context('connectedmachine machine-extension list') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine containing the extension.') c.argument('expand', type=str, help='The expand expression to apply on the operation.') - with self.argument_context('connectedmachine extension show') as c: + with self.argument_context('connectedmachine machine-extension show') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine containing the extension.', id_part='name') c.argument('name', options_list=['-n', '--extension-name', '--name'], type=str, help='The name of the machine ' 'extension.', id_part='child_name_1') - with self.argument_context('connectedmachine extension create') as c: + with self.argument_context('connectedmachine machine-extension create') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine where the extension should be created or ' 'updated.') @@ -60,8 +60,8 @@ def load_arguments(self, _): c.argument('force_update_tag', type=str, help='How the extension handler should be forced to update even if ' 'the extension configuration has not changed.') c.argument('publisher', type=str, help='The name of the extension handler publisher.') - c.argument('type_', options_list=['--type'], type=str, help='Specifies the type of the extension; an example ' - 'is "CustomScriptExtension".') + c.argument('type_properties_type', type=str, help='Specifies the type of the extension; an example is ' + '"CustomScriptExtension".') c.argument('type_handler_version', type=str, help='Specifies the version of the script handler.') c.argument('auto_upgrade_minor_version', options_list=['--auto-upgrade-minor'], arg_type=get_three_state_flag(), help='Indicates whether the extension should use a newer minor ' @@ -73,7 +73,7 @@ def load_arguments(self, _): 'protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. Expected ' 'value: json-string/@json-file.') - with self.argument_context('connectedmachine extension update') as c: + with self.argument_context('connectedmachine machine-extension update') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine where the extension should be created or ' 'updated.', id_part='name') @@ -96,14 +96,14 @@ def load_arguments(self, _): 'protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. Expected ' 'value: json-string/@json-file.') - with self.argument_context('connectedmachine extension delete') as c: + with self.argument_context('connectedmachine machine-extension delete') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine where the extension should be deleted.', id_part='name') c.argument('name', options_list=['-n', '--extension-name', '--name'], type=str, help='The name of the machine ' 'extension.', id_part='child_name_1') - with self.argument_context('connectedmachine extension wait') as c: + with self.argument_context('connectedmachine machine-extension wait') as c: c.argument('resource_group_name', resource_group_name_type) c.argument('machine_name', type=str, help='The name of the machine containing the extension.', id_part='name') c.argument('name', options_list=['-n', '--extension-name', '--name'], type=str, help='The name of the machine ' diff --git a/src/connectedmachine/azext_connectedmachine/generated/commands.py b/src/connectedmachine/azext_connectedmachine/generated/commands.py index 12d8b3956d7..39032d402e4 100644 --- a/src/connectedmachine/azext_connectedmachine/generated/commands.py +++ b/src/connectedmachine/azext_connectedmachine/generated/commands.py @@ -20,21 +20,23 @@ def load_command_table(self, _): operations_tmpl='azext_connectedmachine.vendored_sdks.connectedmachine.operations._machine_operations#MachineOp' 'erations.{}', client_factory=cf_machine) - with self.command_group('connectedmachine', connectedmachine_machine, client_factory=cf_machine) as g: - g.custom_command('list', 'connectedmachine_list') - g.custom_show_command('show', 'connectedmachine_show') - g.custom_command('delete', 'connectedmachine_delete', confirmation=True) + with self.command_group('connectedmachine machine', connectedmachine_machine, client_factory=cf_machine, + is_experimental=True) as g: + g.custom_command('list', 'connectedmachine_machine_list') + g.custom_show_command('show', 'connectedmachine_machine_show') + g.custom_command('delete', 'connectedmachine_machine_delete', confirmation=True) from azext_connectedmachine.generated._client_factory import cf_machine_extension connectedmachine_machine_extension = CliCommandType( operations_tmpl='azext_connectedmachine.vendored_sdks.connectedmachine.operations._machine_extension_operations' '#MachineExtensionOperations.{}', client_factory=cf_machine_extension) - with self.command_group('connectedmachine extension', connectedmachine_machine_extension, + with self.command_group('connectedmachine machine-extension', connectedmachine_machine_extension, client_factory=cf_machine_extension, is_experimental=True) as g: - g.custom_command('list', 'connectedmachine_extension_list') - g.custom_show_command('show', 'connectedmachine_extension_show') - g.custom_command('create', 'connectedmachine_extension_create', supports_no_wait=True) - g.custom_command('update', 'connectedmachine_extension_update', supports_no_wait=True) - g.custom_command('delete', 'connectedmachine_extension_delete', supports_no_wait=True, confirmation=True) - g.custom_wait_command('wait', 'connectedmachine_extension_show') + g.custom_command('list', 'connectedmachine_machine_extension_list') + g.custom_show_command('show', 'connectedmachine_machine_extension_show') + g.custom_command('create', 'connectedmachine_machine_extension_create', supports_no_wait=True) + g.custom_command('update', 'connectedmachine_machine_extension_update', supports_no_wait=True) + g.custom_command('delete', 'connectedmachine_machine_extension_delete', supports_no_wait=True, + confirmation=True) + g.custom_wait_command('wait', 'connectedmachine_machine_extension_show') diff --git a/src/connectedmachine/azext_connectedmachine/generated/custom.py b/src/connectedmachine/azext_connectedmachine/generated/custom.py index d388253eeb9..7f6b047441f 100644 --- a/src/connectedmachine/azext_connectedmachine/generated/custom.py +++ b/src/connectedmachine/azext_connectedmachine/generated/custom.py @@ -12,60 +12,60 @@ from azure.cli.core.util import sdk_no_wait -def connectedmachine_list(client, - resource_group_name=None): +def connectedmachine_machine_list(client, + resource_group_name=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name) return client.list_by_subscription() -def connectedmachine_show(client, - resource_group_name, - machine_name): +def connectedmachine_machine_show(client, + resource_group_name, + machine_name): return client.get(resource_group_name=resource_group_name, name=machine_name, expand="instanceView") -def connectedmachine_delete(client, - resource_group_name, - machine_name): +def connectedmachine_machine_delete(client, + resource_group_name, + machine_name): return client.delete(resource_group_name=resource_group_name, name=machine_name) -def connectedmachine_extension_list(client, - resource_group_name, - machine_name, - expand=None): +def connectedmachine_machine_extension_list(client, + resource_group_name, + machine_name, + expand=None): return client.list(resource_group_name=resource_group_name, name=machine_name, expand=expand) -def connectedmachine_extension_show(client, - resource_group_name, - machine_name, - name): +def connectedmachine_machine_extension_show(client, + resource_group_name, + machine_name, + name): return client.get(resource_group_name=resource_group_name, name=machine_name, extension_name=name) -def connectedmachine_extension_create(client, - resource_group_name, - machine_name, - name, - location, - tags=None, - force_update_tag=None, - publisher=None, - type_=None, - type_handler_version=None, - auto_upgrade_minor_version=None, - settings=None, - protected_settings=None, - no_wait=False): +def connectedmachine_machine_extension_create(client, + resource_group_name, + machine_name, + name, + location, + tags=None, + force_update_tag=None, + publisher=None, + type_properties_type=None, + type_handler_version=None, + auto_upgrade_minor_version=None, + settings=None, + protected_settings=None, + no_wait=False): return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name=resource_group_name, @@ -75,7 +75,7 @@ def connectedmachine_extension_create(client, location=location, force_update_tag=force_update_tag, publisher=publisher, - type_properties_type=type_, + type_properties_type=type_properties_type, type_handler_version=type_handler_version, auto_upgrade_minor_version=auto_upgrade_minor_version, settings=settings, @@ -83,19 +83,19 @@ def connectedmachine_extension_create(client, status=None) -def connectedmachine_extension_update(client, - resource_group_name, - machine_name, - name, - tags=None, - force_update_tag=None, - publisher=None, - type_=None, - type_handler_version=None, - auto_upgrade_minor_version=None, - settings=None, - protected_settings=None, - no_wait=False): +def connectedmachine_machine_extension_update(client, + resource_group_name, + machine_name, + name, + tags=None, + force_update_tag=None, + publisher=None, + type_=None, + type_handler_version=None, + auto_upgrade_minor_version=None, + settings=None, + protected_settings=None, + no_wait=False): return sdk_no_wait(no_wait, client.begin_update, resource_group_name=resource_group_name, @@ -111,11 +111,11 @@ def connectedmachine_extension_update(client, protected_settings=protected_settings) -def connectedmachine_extension_delete(client, - resource_group_name, - machine_name, - name, - no_wait=False): +def connectedmachine_machine_extension_delete(client, + resource_group_name, + machine_name, + name, + no_wait=False): return sdk_no_wait(no_wait, client.begin_delete, resource_group_name=resource_group_name, diff --git a/src/connectedmachine/azext_connectedmachine/tests/latest/test_connectedmachine_scenario.py b/src/connectedmachine/azext_connectedmachine/tests/latest/test_connectedmachine_scenario.py index 26549a387cd..4da4e900b79 100644 --- a/src/connectedmachine/azext_connectedmachine/tests/latest/test_connectedmachine_scenario.py +++ b/src/connectedmachine/azext_connectedmachine/tests/latest/test_connectedmachine_scenario.py @@ -12,210 +12,139 @@ from azure.cli.testsdk import ScenarioTest from .. import try_manual, raise_if, calc_coverage from azure.cli.testsdk import ResourceGroupPreparer -from azure_devtools.scenario_tests import AllowLargeResponse -TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) -CUSTOM_SCRIPT_EXTENSION_NAME = 'customScript' -DEPENDENCY_AGENT_EXTENSION_NAME = 'dependencyAgent' - -# Constants for Machine tests -MACHINES_RESOURCE_GROUP_NAME = 'AzcmagentTest' -MACHINES_MACHINE_NAME = 'dorothy-Virtual-Machine' -MACHINES_LOCATION = 'eastus2euap' - -# Constants for Machine Extension tests -EXTENSIONS_RESOURCE_GROUP_NAME = 'AzcmagentTest' -EXTENSIONS_MACHINE_NAME = 'dorothy-Virtual-Machine' -EXTENSIONS_LOCATION = 'eastus2euap' - -@try_manual -def setup(test): - # This machine needs to already exist - test.cmd('az connectedmachine show ' - f'--name "{EXTENSIONS_MACHINE_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('name', EXTENSIONS_MACHINE_NAME), - test.check('location', EXTENSIONS_LOCATION) - ]) +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) +# Env setup @try_manual -def cleanup(test): +def setup(test, rg): pass -# Machine tests +# EXAMPLE: /MachineExtensions/put/Create or Update a Machine Extension +@try_manual +def step__machineextensions_put(test, rg): + test.cmd('az connectedmachine machine-extension create ' + '--machine-name "myMachine" ' + '--n "CustomScriptExtension" ' + '--location "eastus2euap" ' + '--type-properties-type "CustomScriptExtension" ' + '--publisher "Microsoft.Compute" ' + '--settings "{{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object {{ $_.CPU ' + '-gt 10000 }}\\\\\\"\\"}}" ' + '--type-handler-version "1.10" ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /Machines/get/Get Machine +# EXAMPLE: /MachineExtensions/get/Get all Machine Extensions @try_manual -def step__machines_get_get_machine(test): - test.cmd('az connectedmachine show ' - f'--name "{MACHINES_MACHINE_NAME}" ' - f'--resource-group "{MACHINES_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('name', MACHINES_MACHINE_NAME), - test.check('location', MACHINES_LOCATION) - ]) +def step__machineextensions_get(test, rg): + test.cmd('az connectedmachine machine-extension list ' + '--machine-name "myMachine" ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /Machines/get/List Machines by resource group +# EXAMPLE: /MachineExtensions/get/Get Machine Extension @try_manual -def step__machines_get_list_machines_by_resource_group(test): - test.cmd('az connectedmachine list ' - f'--resource-group "{MACHINES_RESOURCE_GROUP_NAME}"', - checks=[ - test.greater_than('length(@)', 400) - ]) +def step__machineextensions_get_get_machine_extension(test, rg): + test.cmd('az connectedmachine machine-extension show ' + '--machine-name "myMachine" ' + '--n "CustomScriptExtension" ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /Machines/delete/Delete a Machine +# EXAMPLE: /MachineExtensions/patch/Create or Update a Machine Extension @try_manual -def step__machines_delete_delete_a_machine(test): - list = test.cmd('az connectedmachine list ' - f'--resource-group "{MACHINES_RESOURCE_GROUP_NAME}"', - checks=[ - test.greater_than('length(@)', 400) - ]).get_output_in_json() - - nameToDelete = next(machine['name'] for machine in list if machine['name'] != MACHINES_MACHINE_NAME) - test.cmd('az connectedmachine delete -y ' - f'--name "{nameToDelete}" ' - f'--resource-group "{MACHINES_RESOURCE_GROUP_NAME}"', +def step__machineextensions_patch(test, rg): + test.cmd('az connectedmachine machine-extension update ' + '--machine-name "myMachine" ' + '--n "CustomScriptExtension" ' + '--type "CustomScriptExtension" ' + '--publisher "Microsoft.Compute" ' + '--settings "{{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object {{ $_.CPU ' + '-lt 100 }}\\\\\\"\\"}}" ' + '--type-handler-version "1.10" ' + '--resource-group "{rg}"', checks=[]) -# Machine Extension tests +# EXAMPLE: /MachineExtensions/delete/Delete a Machine Extension +@try_manual +def step__machineextensions_delete(test, rg): + test.cmd('az connectedmachine machine-extension delete -y ' + '--machine-name "myMachine" ' + '--n "MMA" ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /MachineExtensions/put/Create or Update a Machine Extension +# EXAMPLE: /Machines/get/Get Machine @try_manual -def step__machineextensions_put(test): - test.cmd('az connectedmachine extension create ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--name "{DEPENDENCY_AGENT_EXTENSION_NAME}" ' - f'--location "{EXTENSIONS_LOCATION}" ' - '--type "DependencyAgentLinux" ' - '--publisher "Microsoft.Azure.Monitoring.DependencyAgent" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('name', DEPENDENCY_AGENT_EXTENSION_NAME) - ]) +def step__machines_get_get_machine(test, rg): + test.cmd('az connectedmachine machine show ' + '--name "myMachine" ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /MachineExtensions/patch/Create or Update a Machine Extension -@try_manual -def step__machineextensions_patch(test): - # Create an extension to update - # test.cmd('az connectedmachine extension create ' - # f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - # f'--name "{CUSTOM_SCRIPT_EXTENSION_NAME}" ' - # f'--location "{EXTENSIONS_LOCATION}" ' - # '--type "CustomScript" ' - # '--publisher "Microsoft.Azure.Extensions" ' - # r"""--settings '{{"commandToExecute":"ls"}}' """ - # '--type-handler-version "2.1" ' - # f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - # checks=[ - # test.check('name', CUSTOM_SCRIPT_EXTENSION_NAME), - # test.check('provisioningState', 'Succeeded'), - # test.check('settings.commandToExecute', 'ls') - # ]) - - # update the extension - test.cmd('az connectedmachine extension update ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--name "{CUSTOM_SCRIPT_EXTENSION_NAME}" ' - r"""--settings '{{"commandToExecute":"ls -a"}}' """ - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('name', CUSTOM_SCRIPT_EXTENSION_NAME), - test.check('provisioningState', 'Succeeded'), - test.check('settings.commandToExecute', 'ls -a') - ]) - - -# EXAMPLE: /MachineExtensions/get/GET Machine Extension -@try_manual -def step__machineextensions_get_get_machine_extension(test): - print('this happened') - test.cmd('az connectedmachine extension show ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--name "{CUSTOM_SCRIPT_EXTENSION_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('name', CUSTOM_SCRIPT_EXTENSION_NAME), - test.check('provisioningState', 'Succeeded') - ]) - - -# EXAMPLE: /MachineExtensions/get/GET all Machine Extensions +# EXAMPLE: /Machines/get/List Machines by resource group @try_manual -def step__machineextensions_get(test): - test.cmd('az connectedmachine extension list ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('length(@)', 2) - ]) +def step__machines_get_list_machines_by_resource_group(test, rg): + test.cmd('az connectedmachine machine list ' + '--resource-group "{rg}"', + checks=[]) -# EXAMPLE: /MachineExtensions/delete/Delete a Machine Extension +# EXAMPLE: /Machines/get/List Machines by resource group @try_manual -def step__machineextensions_delete(test): - test.cmd('az connectedmachine extension delete -y ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--name "{DEPENDENCY_AGENT_EXTENSION_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', +def step__machines_get_list_machines_by_resource_group(test, rg): + test.cmd('az connectedmachine machine list ' + '--resource-group "{rg}"', checks=[]) - test.cmd('az connectedmachine extension list ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('length(@)', 1) - ]) - - test.cmd('az connectedmachine extension delete -y ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--name "{CUSTOM_SCRIPT_EXTENSION_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[]) - test.cmd('az connectedmachine extension list ' - f'--machine-name "{EXTENSIONS_MACHINE_NAME}" ' - f'--resource-group "{EXTENSIONS_RESOURCE_GROUP_NAME}"', - checks=[ - test.check('length(@)', 0) - ]) +# EXAMPLE: /Machines/delete/Delete a Machine +@try_manual +def step__machines_delete_delete_a_machine(test, rg): + test.cmd('az connectedmachine machine delete -y ' + '--name "myMachine" ' + '--resource-group "{rg}"', + checks=[]) +# Env cleanup @try_manual -def call_scenario(test): - setup(test) - # Machines - step__machines_get_get_machine(test) - step__machines_get_list_machines_by_resource_group(test) - step__machines_get_list_machines_by_resource_group(test) - step__machines_delete_delete_a_machine(test) +def cleanup(test, rg): + pass - # Machine Extensions - step__machineextensions_put(test) - step__machineextensions_patch(test) - step__machineextensions_get_get_machine_extension(test) - step__machineextensions_get(test) - step__machineextensions_delete(test) - cleanup(test) +# Testcase +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__machineextensions_put(test, rg) + step__machineextensions_get(test, rg) + step__machineextensions_get_get_machine_extension(test, rg) + step__machineextensions_patch(test, rg) + step__machineextensions_delete(test, rg) + step__machines_get_get_machine(test, rg) + step__machines_get_list_machines_by_resource_group(test, rg) + step__machines_get_list_machines_by_resource_group(test, rg) + step__machines_delete_delete_a_machine(test, rg) + cleanup(test, rg) @try_manual class ConnectedMachineScenarioTest(ScenarioTest): - @AllowLargeResponse() - def test_connectedmachine(self): - call_scenario(self) + @ResourceGroupPreparer(name_prefix='clitestconnectedmachine_myResourceGroup'[:7], key='rg', parameter_name='rg') + def test_connectedmachine(self, rg): + + call_scenario(self, rg) calc_coverage(__file__) raise_if() diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_configuration.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_configuration.py index 30e13b4570d..a92f8c39ade 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_configuration.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_configuration.py @@ -48,8 +48,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = "2020-08-02" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'connectedmachine/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_connected_machine.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_connected_machine.py index 57cb7cd716f..c9fe364e257 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_connected_machine.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/_connected_machine.py @@ -56,7 +56,6 @@ 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.machine = MachineOperations( diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/__init__.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/__init__.py index 73b411ccdcb..5a8f3eca2b2 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/__init__.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._connected_machine_async import ConnectedMachine +from ._connected_machine import ConnectedMachine __all__ = ['ConnectedMachine'] diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_configuration.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_configuration.py new file mode 100644 index 00000000000..d5c4025cdf6 --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class ConnectedMachineConfiguration(Configuration): + """Configuration for ConnectedMachine. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(ConnectedMachineConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-08-02" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'connectedmachine/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_connected_machine.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_connected_machine.py new file mode 100644 index 00000000000..e20292bb9d0 --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/_connected_machine.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import ConnectedMachineConfiguration +from .operations import MachineOperations +from .operations import MachineExtensionOperations +from .operations import OperationOperations +from .. import models + + +class ConnectedMachine(object): + """The Hybrid Compute Management Client. + + :ivar machine: MachineOperations operations + :vartype machine: connected_machine.aio.operations.MachineOperations + :ivar machine_extension: MachineExtensionOperations operations + :vartype machine_extension: connected_machine.aio.operations.MachineExtensionOperations + :ivar operation: OperationOperations operations + :vartype operation: connected_machine.aio.operations.OperationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = ConnectedMachineConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.machine = MachineOperations( + self._client, self._config, self._serialize, self._deserialize) + self.machine_extension = MachineExtensionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ConnectedMachine": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/__init__.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/__init__.py new file mode 100644 index 00000000000..7a5d284a13f --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._machine_operations import MachineOperations +from ._machine_extension_operations import MachineExtensionOperations +from ._operation_operations import OperationOperations + +__all__ = [ + 'MachineOperations', + 'MachineExtensionOperations', + 'OperationOperations', +] diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_extension_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_extension_operations.py new file mode 100644 index 00000000000..ee33730c530 --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_extension_operations.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MachineExtensionOperations: + """MachineExtensionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~connected_machine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + name: str, + extension_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type_properties_type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[object] = None, + protected_settings: Optional[object] = None, + status: Optional["models.MachineExtensionInstanceViewStatus"] = None, + **kwargs + ) -> Optional["models.MachineExtension"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MachineExtension"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + extension_parameters = models.MachineExtension(tags=tags, location=location, force_update_tag=force_update_tag, publisher=publisher, type_properties_type=type_properties_type, type_handler_version_properties_type_handler_version=type_handler_version, auto_upgrade_minor_version=auto_upgrade_minor_version, settings=settings, protected_settings=protected_settings, status=status) + api_version = "2020-08-02" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # 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(extension_parameters, 'MachineExtension') + 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 [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type_properties_type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[object] = None, + protected_settings: Optional[object] = None, + status: Optional["models.MachineExtensionInstanceViewStatus"] = None, + **kwargs + ) -> AsyncLROPoller["models.MachineExtension"]: + """The operation to create or update the extension. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :param location: The geo-location where the resource lives. + :type location: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :type force_update_tag: str + :param publisher: The name of the extension handler publisher. + :type publisher: str + :param type_properties_type: Specifies the type of the extension; an example is + "CustomScriptExtension". + :type type_properties_type: str + :param type_handler_version: Specifies the version of the script handler. + :type type_handler_version: str + :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :type auto_upgrade_minor_version: bool + :param settings: Json formatted public settings for the extension. + :type settings: object + :param protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :type protected_settings: object + :param status: Instance view status. + :type status: ~connected_machine.models.MachineExtensionInstanceViewStatus + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~connected_machine.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + location=location, + tags=tags, + force_update_tag=force_update_tag, + publisher=publisher, + type_properties_type=type_properties_type, + type_handler_version=type_handler_version, + auto_upgrade_minor_version=auto_upgrade_minor_version, + settings=settings, + protected_settings=protected_settings, + status=status, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + name: str, + extension_name: str, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[object] = None, + protected_settings: Optional[object] = None, + **kwargs + ) -> Optional["models.MachineExtension"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MachineExtension"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + extension_parameters = models.MachineExtensionUpdate(tags=tags, force_update_tag=force_update_tag, publisher=publisher, type=type, type_handler_version=type_handler_version, auto_upgrade_minor_version=auto_upgrade_minor_version, settings=settings, protected_settings=protected_settings) + api_version = "2020-08-02" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # 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(extension_parameters, 'MachineExtensionUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(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 [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[object] = None, + protected_settings: Optional[object] = None, + **kwargs + ) -> AsyncLROPoller["models.MachineExtension"]: + """The operation to update the extension. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :type force_update_tag: str + :param publisher: The name of the extension handler publisher. + :type publisher: str + :param type: Specifies the type of the extension; an example is "CustomScriptExtension". + :type type: str + :param type_handler_version: Specifies the version of the script handler. + :type type_handler_version: str + :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :type auto_upgrade_minor_version: bool + :param settings: Json formatted public settings for the extension. + :type settings: object + :param protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :type protected_settings: object + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~connected_machine.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + tags=tags, + force_update_tag=force_update_tag, + publisher=publisher, + type=type, + type_handler_version=type_handler_version, + auto_upgrade_minor_version=auto_upgrade_minor_version, + settings=settings, + protected_settings=protected_settings, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """The operation to delete the extension. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the machine where the extension should be deleted. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs + ) -> "models.MachineExtension": + """The operation to get the extension. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the machine containing the extension. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachineExtension, or the result of cls(response) + :rtype: ~connected_machine.models.MachineExtension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}'} # type: ignore + + def list( + self, + resource_group_name: str, + name: str, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.MachineExtensionsListResult"]: + """The operation to get all extensions of a non-Azure machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the machine containing the extension. + :type name: str + :param expand: The expand expression to apply on the operation. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.MachineExtensionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtensionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('MachineExtensionsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions'} # type: ignore diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_operations.py new file mode 100644 index 00000000000..f8e703cbdae --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_machine_operations.py @@ -0,0 +1,300 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MachineOperations: + """MachineOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~connected_machine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + resource_group_name: str, + name: str, + **kwargs + ) -> None: + """The operation to remove a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the hybrid machine. + :type name: 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', {})) + api_version = "2020-08-02" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}'} # type: ignore + + async def get( + self, + resource_group_name: str, + name: str, + expand: Optional[Union[str, "models.InstanceViewTypes"]] = None, + **kwargs + ) -> "models.Machine": + """Retrieves information about the model view or the instance view of a hybrid machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the hybrid machine. + :type name: str + :param expand: The expand expression to apply on the operation. + :type expand: str or ~connected_machine.models.InstanceViewTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Machine, or the result of cls(response) + :rtype: ~connected_machine.models.Machine + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Machine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.MachineListResult"]: + """Lists all the hybrid machines in the specified resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.MachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('MachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["models.MachineListResult"]: + """Lists all the hybrid machines in the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.MachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('MachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/machines'} # type: ignore diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_operation_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_operation_operations.py new file mode 100644 index 00000000000..7797c09597d --- /dev/null +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/aio/operations/_operation_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~connected_machine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Gets a list of hybrid compute operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-02" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.HybridCompute/operations'} # type: ignore diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models.py index bd473d93b7d..96cc23d1af7 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models.py @@ -145,17 +145,17 @@ def __init__( class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -182,19 +182,19 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -233,13 +233,13 @@ class Machine(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -374,13 +374,13 @@ class MachineExtension(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models_py3.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models_py3.py index bb94fd14a3c..a48e7223d7d 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models_py3.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/models/_models_py3.py @@ -161,17 +161,17 @@ def __init__( class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -198,19 +198,19 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -252,13 +252,13 @@ class Machine(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -400,13 +400,13 @@ class MachineExtension(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_extension_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_extension_operations.py index 9de22f643e9..f31e2dec49c 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_extension_operations.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_extension_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse @@ -66,12 +66,15 @@ def _create_or_update_initial( ): # type: (...) -> Optional["models.MachineExtension"] cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MachineExtension"]] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) extension_parameters = models.MachineExtension(tags=tags, location=location, force_update_tag=force_update_tag, publisher=publisher, type_properties_type=type_properties_type, type_handler_version_properties_type_handler_version=type_handler_version, auto_upgrade_minor_version=auto_upgrade_minor_version, settings=settings, protected_settings=protected_settings, status=status) api_version = "2020-08-02" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self._create_or_update_initial.metadata['url'] # type: ignore @@ -90,13 +93,12 @@ def _create_or_update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(extension_parameters, 'MachineExtension') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,7 +213,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -242,12 +251,15 @@ def _update_initial( ): # type: (...) -> Optional["models.MachineExtension"] cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MachineExtension"]] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) extension_parameters = models.MachineExtensionUpdate(tags=tags, force_update_tag=force_update_tag, publisher=publisher, type=type, type_handler_version=type_handler_version, auto_upgrade_minor_version=auto_upgrade_minor_version, settings=settings, protected_settings=protected_settings) api_version = "2020-08-02" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self._update_initial.metadata['url'] # type: ignore @@ -266,13 +278,12 @@ def _update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -378,7 +389,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -401,7 +419,9 @@ def _delete_initial( ): # type: (...) -> None cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" @@ -484,7 +504,14 @@ def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -520,9 +547,12 @@ def get( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -540,7 +570,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -580,14 +610,17 @@ def list( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtensionsListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_operations.py index eabd3562611..2f95deeb531 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_operations.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_machine_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse @@ -64,9 +64,12 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -83,6 +86,7 @@ def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -120,9 +124,12 @@ def get( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -141,7 +148,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -176,14 +183,17 @@ def list_by_resource_group( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -242,14 +252,17 @@ def list_by_subscription( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL diff --git a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_operation_operations.py b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_operation_operations.py index 81080b1c7be..3bee43af66b 100644 --- a/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_operation_operations.py +++ b/src/connectedmachine/azext_connectedmachine/vendored_sdks/connectedmachine/operations/_operation_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse @@ -58,14 +58,17 @@ def list( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-08-02" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL diff --git a/src/connectedmachine/report.md b/src/connectedmachine/report.md index ef6bf5d4780..3ba5843da15 100644 --- a/src/connectedmachine/report.md +++ b/src/connectedmachine/report.md @@ -9,56 +9,56 @@ ### Command groups in `az connectedmachine` extension |CLI Command Group|Group Swagger name|Commands| |---------|------------|--------| -|az connectedmachine|Machines|[commands](#CommandsInMachines)| -|az connectedmachine extension|MachineExtensions|[commands](#CommandsInMachineExtensions)| +|az connectedmachine machine|Machines|[commands](#CommandsInMachines)| +|az connectedmachine machine-extension|MachineExtensions|[commands](#CommandsInMachineExtensions)| ## COMMANDS -### Commands in `az connectedmachine` group +### Commands in `az connectedmachine machine` group |CLI Command|Operation Swagger name|Parameters|Examples| |---------|------------|--------|-----------| -|[az connectedmachine list](#MachinesListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersMachinesListByResourceGroup)|[Example](#ExamplesMachinesListByResourceGroup)| -|[az connectedmachine list](#MachinesListBySubscription)|ListBySubscription|[Parameters](#ParametersMachinesListBySubscription)|[Example](#ExamplesMachinesListBySubscription)| -|[az connectedmachine show](#MachinesGet)|Get|[Parameters](#ParametersMachinesGet)|[Example](#ExamplesMachinesGet)| -|[az connectedmachine delete](#MachinesDelete)|Delete|[Parameters](#ParametersMachinesDelete)|[Example](#ExamplesMachinesDelete)| +|[az connectedmachine machine list](#MachinesListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersMachinesListByResourceGroup)|[Example](#ExamplesMachinesListByResourceGroup)| +|[az connectedmachine machine list](#MachinesListBySubscription)|ListBySubscription|[Parameters](#ParametersMachinesListBySubscription)|[Example](#ExamplesMachinesListBySubscription)| +|[az connectedmachine machine show](#MachinesGet)|Get|[Parameters](#ParametersMachinesGet)|[Example](#ExamplesMachinesGet)| +|[az connectedmachine machine delete](#MachinesDelete)|Delete|[Parameters](#ParametersMachinesDelete)|[Example](#ExamplesMachinesDelete)| -### Commands in `az connectedmachine extension` group +### Commands in `az connectedmachine machine-extension` group |CLI Command|Operation Swagger name|Parameters|Examples| |---------|------------|--------|-----------| -|[az connectedmachine extension list](#MachineExtensionsList)|List|[Parameters](#ParametersMachineExtensionsList)|[Example](#ExamplesMachineExtensionsList)| -|[az connectedmachine extension show](#MachineExtensionsGet)|Get|[Parameters](#ParametersMachineExtensionsGet)|[Example](#ExamplesMachineExtensionsGet)| -|[az connectedmachine extension create](#MachineExtensionsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersMachineExtensionsCreateOrUpdate#Create)|[Example](#ExamplesMachineExtensionsCreateOrUpdate#Create)| -|[az connectedmachine extension update](#MachineExtensionsUpdate)|Update|[Parameters](#ParametersMachineExtensionsUpdate)|[Example](#ExamplesMachineExtensionsUpdate)| -|[az connectedmachine extension delete](#MachineExtensionsDelete)|Delete|[Parameters](#ParametersMachineExtensionsDelete)|[Example](#ExamplesMachineExtensionsDelete)| +|[az connectedmachine machine-extension list](#MachineExtensionsList)|List|[Parameters](#ParametersMachineExtensionsList)|[Example](#ExamplesMachineExtensionsList)| +|[az connectedmachine machine-extension show](#MachineExtensionsGet)|Get|[Parameters](#ParametersMachineExtensionsGet)|[Example](#ExamplesMachineExtensionsGet)| +|[az connectedmachine machine-extension create](#MachineExtensionsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersMachineExtensionsCreateOrUpdate#Create)|[Example](#ExamplesMachineExtensionsCreateOrUpdate#Create)| +|[az connectedmachine machine-extension update](#MachineExtensionsUpdate)|Update|[Parameters](#ParametersMachineExtensionsUpdate)|[Example](#ExamplesMachineExtensionsUpdate)| +|[az connectedmachine machine-extension delete](#MachineExtensionsDelete)|Delete|[Parameters](#ParametersMachineExtensionsDelete)|[Example](#ExamplesMachineExtensionsDelete)| ## COMMAND DETAILS -### group `az connectedmachine` -#### Command `az connectedmachine list` +### group `az connectedmachine machine` +#### Command `az connectedmachine machine list` ##### Example ``` -az connectedmachine list --resource-group "myResourceGroup" +az connectedmachine machine list --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| |------|----|-----------|----------|------------| |**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| -#### Command `az connectedmachine list` +#### Command `az connectedmachine machine list` ##### Example ``` -az connectedmachine list +az connectedmachine machine list ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| |------|----|-----------|----------|------------| -#### Command `az connectedmachine show` +#### Command `az connectedmachine machine show` ##### Example ``` -az connectedmachine show --name "myMachine" --resource-group "myResourceGroup" +az connectedmachine machine show --name "myMachine" --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| @@ -66,11 +66,11 @@ az connectedmachine show --name "myMachine" --resource-group "myResourceGroup" |**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| |**--machine-name**|string|The name of the hybrid machine.|machine_name|name| -#### Command `az connectedmachine delete` +#### Command `az connectedmachine machine delete` ##### Example ``` -az connectedmachine delete --name "myMachine" --resource-group "myResourceGroup" +az connectedmachine machine delete --name "myMachine" --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| @@ -78,12 +78,12 @@ az connectedmachine delete --name "myMachine" --resource-group "myResourceGroup" |**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| |**--machine-name**|string|The name of the hybrid machine.|machine_name|name| -### group `az connectedmachine extension` -#### Command `az connectedmachine extension list` +### group `az connectedmachine machine-extension` +#### Command `az connectedmachine machine-extension list` ##### Example ``` -az connectedmachine extension list --machine-name "myMachine" --resource-group "myResourceGroup" +az connectedmachine machine-extension list --machine-name "myMachine" --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| @@ -92,11 +92,11 @@ az connectedmachine extension list --machine-name "myMachine" --resource-group " |**--machine-name**|string|The name of the machine containing the extension.|machine_name|name| |**--expand**|string|The expand expression to apply on the operation.|expand|$expand| -#### Command `az connectedmachine extension show` +#### Command `az connectedmachine machine-extension show` ##### Example ``` -az connectedmachine extension show --machine-name "myMachine" --n "CustomScriptExtension" --resource-group \ +az connectedmachine machine-extension show --machine-name "myMachine" --n "CustomScriptExtension" --resource-group \ "myResourceGroup" ``` ##### Parameters @@ -106,14 +106,14 @@ az connectedmachine extension show --machine-name "myMachine" --n "CustomScriptE |**--machine-name**|string|The name of the machine containing the extension.|machine_name|name| |**--name**|string|The name of the machine extension.|name|extensionName| -#### Command `az connectedmachine extension create` +#### Command `az connectedmachine machine-extension create` ##### Example ``` -az connectedmachine extension create --machine-name "myMachine" --n "CustomScriptExtension" --location "eastus2euap" \ ---type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings "{\\"commandToExecute\\":\\"powershell.exe \ --c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" --type-handler-version "1.10" --resource-group \ -"myResourceGroup" +az connectedmachine machine-extension create --machine-name "myMachine" --n "CustomScriptExtension" --location \ +"eastus2euap" --type-properties-type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings \ +"{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" \ +--type-handler-version "1.10" --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| @@ -125,17 +125,17 @@ az connectedmachine extension create --machine-name "myMachine" --n "CustomScrip |**--tags**|dictionary|Resource tags.|tags|tags| |**--force-update-tag**|string|How the extension handler should be forced to update even if the extension configuration has not changed.|force_update_tag|forceUpdateTag| |**--publisher**|string|The name of the extension handler publisher.|publisher|publisher| -|**--type**|string|Specifies the type of the extension; an example is "CustomScriptExtension".|type|type| +|**--type-properties-type**|string|Specifies the type of the extension; an example is "CustomScriptExtension".|type_properties_type|type| |**--type-handler-version**|string|Specifies the version of the script handler.|type_handler_version|typeHandlerVersion| |**--auto-upgrade-minor-version**|boolean|Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true.|auto_upgrade_minor_version|autoUpgradeMinorVersion| |**--settings**|any|Json formatted public settings for the extension.|settings|settings| |**--protected-settings**|any|The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all.|protected_settings|protectedSettings| -#### Command `az connectedmachine extension update` +#### Command `az connectedmachine machine-extension update` ##### Example ``` -az connectedmachine extension update --machine-name "myMachine" --n "CustomScriptExtension" --type \ +az connectedmachine machine-extension update --machine-name "myMachine" --n "CustomScriptExtension" --type \ "CustomScriptExtension" --publisher "Microsoft.Compute" --settings "{\\"commandToExecute\\":\\"powershell.exe -c \ \\\\\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" --type-handler-version "1.10" --resource-group \ "myResourceGroup" @@ -155,11 +155,11 @@ az connectedmachine extension update --machine-name "myMachine" --n "CustomScrip |**--settings**|any|Json formatted public settings for the extension.|settings|settings| |**--protected-settings**|any|The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all.|protected_settings|protectedSettings| -#### Command `az connectedmachine extension delete` +#### Command `az connectedmachine machine-extension delete` ##### Example ``` -az connectedmachine extension delete --machine-name "myMachine" --n "MMA" --resource-group "myResourceGroup" +az connectedmachine machine-extension delete --machine-name "myMachine" --n "MMA" --resource-group "myResourceGroup" ``` ##### Parameters |Option|Type|Description|Path (SDK)|Swagger name| diff --git a/src/connectedmachine/setup.py b/src/connectedmachine/setup.py index e18885c0d90..e0725124d3c 100644 --- a/src/connectedmachine/setup.py +++ b/src/connectedmachine/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages # HISTORY.rst entry. -VERSION = '0.3.0' +VERSION = '0.1.0' try: from azext_connectedmachine.manual.version import VERSION except ImportError: