diff --git a/src/windowsiot/HISTORY.rst b/src/windowsiot/HISTORY.rst new file mode 100644 index 00000000000..27f152061e8 --- /dev/null +++ b/src/windowsiot/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/windowsiot/README.md b/src/windowsiot/README.md new file mode 100644 index 00000000000..bb6c31154e2 --- /dev/null +++ b/src/windowsiot/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'windowsiotservices' Extension +========================================== + +This package is for the 'windowsiotservices' extension. +i.e. 'az windowsiotservices' diff --git a/src/windowsiot/azext_windowsiotservices/__init__.py b/src/windowsiot/azext_windowsiotservices/__init__.py new file mode 100644 index 00000000000..092a13ff55d --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/__init__.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core import AzCommandsLoader +from azext_windowsiotservices.generated._help import helps # pylint: disable=unused-import + + +class DeviceServicesCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_windowsiotservices.generated._client_factory import cf_windowsiotservices + windowsiotservices_custom = CliCommandType( + operations_tmpl='azext_windowsiotservices.custom#{}', + client_factory=cf_windowsiotservices) + super(DeviceServicesCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=windowsiotservices_custom) + + def load_command_table(self, args): + from azext_windowsiotservices.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_windowsiotservices.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_windowsiotservices.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_windowsiotservices.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = DeviceServicesCommandsLoader diff --git a/src/windowsiot/azext_windowsiotservices/action.py b/src/windowsiot/azext_windowsiotservices/action.py new file mode 100644 index 00000000000..a846b2766c4 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/windowsiot/azext_windowsiotservices/azext_metadata.json b/src/windowsiot/azext_windowsiotservices/azext_metadata.json new file mode 100644 index 00000000000..7b56fb1e11a --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" +} \ No newline at end of file diff --git a/src/windowsiot/azext_windowsiotservices/custom.py b/src/windowsiot/azext_windowsiotservices/custom.py new file mode 100644 index 00000000000..7f31674ce96 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/windowsiot/azext_windowsiotservices/generated/__init__.py b/src/windowsiot/azext_windowsiotservices/generated/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/windowsiot/azext_windowsiotservices/generated/_client_factory.py b/src/windowsiot/azext_windowsiotservices/generated/_client_factory.py new file mode 100644 index 00000000000..059c24cdef2 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_client_factory.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_windowsiotservices(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.windowsiot import DeviceServices + return get_mgmt_service_client(cli_ctx, DeviceServices) + + +def cf_service(cli_ctx, *_): + return cf_windowsiotservices(cli_ctx).service diff --git a/src/windowsiot/azext_windowsiotservices/generated/_help.py b/src/windowsiot/azext_windowsiotservices/generated/_help.py new file mode 100644 index 00000000000..5090a8761b5 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_help.py @@ -0,0 +1,78 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['windowsiotservices service'] = """ + type: group + short-summary: windowsiotservices service +""" + +helps['windowsiotservices service list'] = """ + type: command + short-summary: Get all the IoT hubs in a subscription. + examples: + - name: Service_ListByResourceGroup + text: |- + az windowsiotservices service list --resource-group "res6117" +""" + +helps['windowsiotservices service show'] = """ + type: command + short-summary: Get the non-security related metadata of a Windows IoT Device Service. + examples: + - name: Services_GetProperties + text: |- + az windowsiotservices service show --device-name "service8596" --resource-group "res9407" +""" + +helps['windowsiotservices service create'] = """ + type: command + short-summary: Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a propert\ +y is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified\ + values in a new body to update the Windows IoT Device Service. + examples: + - name: Service_Create + text: |- + az windowsiotservices service create --device-name "service4445" --admin-domain-name "d.e.f" --billing-d\ +omain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9101" +""" + +helps['windowsiotservices service update'] = """ + type: command + short-summary: Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to r\ +etrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified values i\ +n a new body to update the Windows IoT Device Service. + examples: + - name: Service_Update + text: |- + az windowsiotservices service update --device-name "service8596" --admin-domain-name "d.e.f" --billing-d\ +omain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9407" +""" + +helps['windowsiotservices service delete'] = """ + type: command + short-summary: Delete a Windows IoT Device Service. + examples: + - name: Service_Delete + text: |- + az windowsiotservices service delete --device-name "service2434" --resource-group "res4228" +""" + +helps['windowsiotservices service check-device-service-name-availability'] = """ + type: command + short-summary: Check if a Windows IoT Device Service name is available. + examples: + - name: Service_CheckNameAvailability + text: |- + az windowsiotservices service check-device-service-name-availability --name "service3363" +""" diff --git a/src/windowsiot/azext_windowsiotservices/generated/_params.py b/src/windowsiot/azext_windowsiotservices/generated/_params.py new file mode 100644 index 00000000000..8a6f8438230 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_params.py @@ -0,0 +1,51 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.arguments import CLIArgumentType +from azure.cli.core.commands.parameters import resource_group_name_type + + +def load_arguments(self, _): + + with self.argument_context('windowsiotservices service list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('windowsiotservices service show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('device_name', help='The name of the Windows IoT Device Service.') + + with self.argument_context('windowsiotservices service create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('device_name', help='The name of the Windows IoT Device Service.') + c.argument('if_match', help='ETag of the Windows IoT Device Service. Do not specify for creating a new Windows ' + 'IoT Device Service. Required to update an existing Windows IoT Device Service.') + c.argument('notes', help='Windows IoT Device Service notes.') + c.argument('quantity', help='Windows IoT Device Service device allocation,') + c.argument('billing_domain_name', help='Windows IoT Device Service ODM AAD domain') + c.argument('admin_domain_name', help='Windows IoT Device Service OEM AAD domain') + + with self.argument_context('windowsiotservices service update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('device_name', help='The name of the Windows IoT Device Service.') + c.argument('if_match', help='ETag of the Windows IoT Device Service. Do not specify for creating a brand new Wi' + 'ndows IoT Device Service. Required to update an existing Windows IoT Device Service.') + c.argument('notes', help='Windows IoT Device Service notes.') + c.argument('quantity', help='Windows IoT Device Service device allocation,') + c.argument('billing_domain_name', help='Windows IoT Device Service ODM AAD domain') + c.argument('admin_domain_name', help='Windows IoT Device Service OEM AAD domain') + + with self.argument_context('windowsiotservices service delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('device_name', help='The name of the Windows IoT Device Service.') + + with self.argument_context('windowsiotservices service check-device-service-name-availability') as c: + c.argument('name', help='The name of the Windows IoT Device Service to check.') diff --git a/src/windowsiot/azext_windowsiotservices/generated/_validators.py b/src/windowsiot/azext_windowsiotservices/generated/_validators.py new file mode 100644 index 00000000000..7536d0531ea --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_validators.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/windowsiot/azext_windowsiotservices/generated/action.py b/src/windowsiot/azext_windowsiotservices/generated/action.py new file mode 100644 index 00000000000..01ed94902ce --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/action.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from knack.util import CLIError +from collections import defaultdict diff --git a/src/windowsiot/azext_windowsiotservices/generated/commands.py b/src/windowsiot/azext_windowsiotservices/generated/commands.py new file mode 100644 index 00000000000..20929e56a48 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/commands.py @@ -0,0 +1,29 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_windowsiotservices.generated._client_factory import cf_service + windowsiotservices_service = CliCommandType( + operations_tmpl='azext_windowsiotservices.vendored_sdks.windowsiot.operations._service_operations#ServiceOperat' + 'ions.{}', + client_factory=cf_service) + with self.command_group('windowsiotservices service', windowsiotservices_service, client_factory=cf_service, + is_experimental=True) as g: + g.custom_command('list', 'windowsiotservices_service_list') + g.custom_show_command('show', 'windowsiotservices_service_show') + g.custom_command('create', 'windowsiotservices_service_create') + g.custom_command('update', 'windowsiotservices_service_update') + g.custom_command('delete', 'windowsiotservices_service_delete') + g.custom_command('check-device-service-name-availability', 'windowsiotservices_service_check_device_service_nam' + 'e_availability') diff --git a/src/windowsiot/azext_windowsiotservices/generated/custom.py b/src/windowsiot/azext_windowsiotservices/generated/custom.py new file mode 100644 index 00000000000..a9004b0956b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/custom.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + + +def windowsiotservices_service_list(cmd, client, + resource_group_name=None): + if resource_group_name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list() + + +def windowsiotservices_service_show(cmd, client, + resource_group_name, + device_name): + return client.get(resource_group_name=resource_group_name, + device_name=device_name) + + +def windowsiotservices_service_create(cmd, client, + resource_group_name, + device_name, + if_match=None, + notes=None, + quantity=None, + billing_domain_name=None, + admin_domain_name=None): + return client.create_or_update(resource_group_name=resource_group_name, + device_name=device_name, + if_match=if_match, + notes=notes, + quantity=quantity, + billing_domain_name=billing_domain_name, + admin_domain_name=admin_domain_name) + + +def windowsiotservices_service_update(cmd, client, + resource_group_name, + device_name, + if_match=None, + notes=None, + quantity=None, + billing_domain_name=None, + admin_domain_name=None): + return client.update(resource_group_name=resource_group_name, + device_name=device_name, + if_match=if_match, + notes=notes, + quantity=quantity, + billing_domain_name=billing_domain_name, + admin_domain_name=admin_domain_name) + + +def windowsiotservices_service_delete(cmd, client, + resource_group_name, + device_name): + return client.delete(resource_group_name=resource_group_name, + device_name=device_name) + + +def windowsiotservices_service_check_device_service_name_availability(cmd, client, + name): + return client.check_device_service_name_availability(name=name) diff --git a/src/windowsiot/azext_windowsiotservices/manual/__init__.py b/src/windowsiot/azext_windowsiotservices/manual/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/manual/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/windowsiot/azext_windowsiotservices/tests/__init__.py b/src/windowsiot/azext_windowsiotservices/tests/__init__.py new file mode 100644 index 00000000000..fe1bd438b46 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/__init__.py @@ -0,0 +1,49 @@ +# 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. +# -------------------------------------------------------------------------- +import inspect +import os + + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + print("running {}()...".format(func.__name__)) + return func_to_call(*args, **kwargs) + + if inspect.isclass(func): + return get_func_to_call() + else: + return wrapper diff --git a/src/windowsiot/azext_windowsiotservices/tests/latest/__init__.py b/src/windowsiot/azext_windowsiotservices/tests/latest/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/windowsiot/azext_windowsiotservices/tests/latest/preparers.py b/src/windowsiot/azext_windowsiotservices/tests/latest/preparers.py new file mode 100644 index 00000000000..3d6672de64f --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/latest/preparers.py @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + vnet_name=None, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + random_name_length=24, key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.vnet_name = vnet_name + self.vnet_key = vnet_key + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + if not self.vnet_name: + self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) + if not self.vnet_name: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + pass diff --git a/src/windowsiot/azext_windowsiotservices/tests/latest/test_windowsiotservices_scenario.py b/src/windowsiot/azext_windowsiotservices/tests/latest/test_windowsiotservices_scenario.py new file mode 100644 index 00000000000..14808581473 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/latest/test_windowsiotservices_scenario.py @@ -0,0 +1,122 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import ScenarioTest +from .. import try_manual +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test, rg, rg_2, rg_3, rg_4): + pass + + +# EXAMPLE: /Services/put/Service_Create +@try_manual +def step__services_put_service_create(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service create ' + '--device-name "service4445" ' + '--admin-domain-name "d.e.f" ' + '--billing-domain-name "a.b.c" ' + '--notes "blah" ' + '--quantity 1000000 ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Services/get/Service_List +@try_manual +def step__services_get_service_list(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service list', + checks=[]) + + +# EXAMPLE: /Services/get/Service_ListByResourceGroup +@try_manual +def step__services_get_service_listbyresourcegroup(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service list ' + '--resource-group "{rg_2}"', + checks=[]) + + +# EXAMPLE: /Services/get/Services_GetProperties +@try_manual +def step__services_get_services_getproperties(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service show ' + '--device-name "service8596" ' + '--resource-group "{rg_3}"', + checks=[]) + + +# EXAMPLE: /Services/post/Service_CheckNameAvailability +@try_manual +def step__services_post_service_checknameavailability(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service check-device-service-name-availability ' + '--name "service3363"', + checks=[]) + + +# EXAMPLE: /Services/patch/Service_Update +@try_manual +def step__services_patch_service_update(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service update ' + '--device-name "service8596" ' + '--admin-domain-name "d.e.f" ' + '--billing-domain-name "a.b.c" ' + '--notes "blah" ' + '--quantity 1000000 ' + '--resource-group "{rg_3}"', + checks=[]) + + +# EXAMPLE: /Services/delete/Service_Delete +@try_manual +def step__services_delete_service_delete(test, rg, rg_2, rg_3, rg_4): + test.cmd('az windowsiotservices service delete ' + '--device-name "service2434" ' + '--resource-group "{rg_4}"', + checks=[]) + + +@try_manual +def cleanup(test, rg, rg_2, rg_3, rg_4): + pass + + +@try_manual +def call_scenario(test, rg, rg_2, rg_3, rg_4): + setup(test, rg, rg_2, rg_3, rg_4) + step__services_put_service_create(test, rg, rg_2, rg_3, rg_4) + step__services_get_service_list(test, rg, rg_2, rg_3, rg_4) + step__services_get_service_listbyresourcegroup(test, rg, rg_2, rg_3, rg_4) + step__services_get_services_getproperties(test, rg, rg_2, rg_3, rg_4) + step__services_post_service_checknameavailability(test, rg, rg_2, rg_3, rg_4) + step__services_patch_service_update(test, rg, rg_2, rg_3, rg_4) + step__services_delete_service_delete(test, rg, rg_2, rg_3, rg_4) + cleanup(test, rg, rg_2, rg_3, rg_4) + + +@try_manual +class DeviceServicesScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res9101'[:7], key='rg', parameter_name='rg') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res6117'[:7], key='rg_2', parameter_name='rg_2') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res9407'[:7], key='rg_3', parameter_name='rg_3') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res4228'[:7], key='rg_4', parameter_name='rg_4') + def test_windowsiotservices(self, rg, rg_2, rg_3, rg_4): + + call_scenario(self, rg, rg_2, rg_3, rg_4) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/__init__.py new file mode 100644 index 00000000000..4c9bfd81c14 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/__init__.py @@ -0,0 +1,19 @@ +# 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 ._device_services import DeviceServices +from ._version import VERSION + +__version__ = VERSION +__all__ = ['DeviceServices'] + +try: + from .patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_configuration.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_configuration.py new file mode 100644 index 00000000000..8ac9fc6702b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_configuration.py @@ -0,0 +1,69 @@ +# 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 TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class DeviceServicesConfiguration(Configuration): + """Configuration for DeviceServices. + + 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.TokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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(DeviceServicesConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-06-02" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-windowsiot/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> 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.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_device_services.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_device_services.py new file mode 100644 index 00000000000..e9623faf207 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_device_services.py @@ -0,0 +1,71 @@ +# 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 TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +from ._configuration import DeviceServicesConfiguration +from .operations import OperationOperations +from .operations import ServiceOperations +from . import models + + +class DeviceServices(object): + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.windowsiot.operations.OperationOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.windowsiot.operations.ServiceOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = DeviceServicesConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(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.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DeviceServices + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_version.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/__init__.py new file mode 100644 index 00000000000..69c9eb993e7 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._device_services_async import DeviceServices +__all__ = ['DeviceServices'] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration_async.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration_async.py new file mode 100644 index 00000000000..bbd2ff88bda --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# 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 .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DeviceServicesConfiguration(Configuration): + """Configuration for DeviceServices. + + 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: The subscription identifier. + :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(DeviceServicesConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-06-02" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-windowsiot/{}'.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.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/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services_async.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services_async.py new file mode 100644 index 00000000000..1a8871461c7 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services_async.py @@ -0,0 +1,63 @@ +# 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 + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import DeviceServicesConfiguration +from .operations_async import OperationOperations +from .operations_async import ServiceOperations +from .. import models + + +class DeviceServices(object): + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.windowsiot.aio.operations_async.OperationOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.windowsiot.aio.operations_async.ServiceOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + """ + + 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 = DeviceServicesConfiguration(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.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DeviceServices": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/__init__.py new file mode 100644 index 00000000000..44d28a13252 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# 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 ._operation_operations_async import OperationOperations +from ._service_operations_async import ServiceOperations + +__all__ = [ + 'OperationOperations', + 'ServiceOperations', +] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_operation_operations_async.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..dcb879ee92b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,101 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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: ~azure.mgmt.windowsiot.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 + ) -> "models.OperationListResult": + """Lists all of the available Windows IoT Services REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + 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 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.ErrorDetails, 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.WindowsIoT/operations'} diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_service_operations_async.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_service_operations_async.py new file mode 100644 index 00000000000..ef48b865f8e --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations_async/_service_operations_async.py @@ -0,0 +1,516 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ServiceOperations: + """ServiceOperations 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: ~azure.mgmt.windowsiot.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 get( + self, + resource_group_name: str, + device_name: str, + **kwargs + ) -> "models.DeviceService": + """Get the non-security related metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + # Construct URL + url = self.get.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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'] = 'application/json' + + # Construct and send request + 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.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + async def create_or_update( + self, + resource_group_name: str, + device_name: str, + if_match: Optional[str] = None, + notes: Optional[str] = None, + quantity: Optional[int] = None, + billing_domain_name: Optional[str] = None, + admin_domain_name: Optional[str] = None, + **kwargs + ) -> "models.DeviceService": + """Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a new body to update the Windows IoT Device Service. + + Create or update the metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a new + Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service = models.DeviceServiceProperties(notes=notes, quantity=quantity, billing_domain_name=billing_domain_name, admin_domain_name=admin_domain_name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create_or_update.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service, 'DeviceServiceProperties') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + async def update( + self, + resource_group_name: str, + device_name: str, + if_match: Optional[str] = None, + notes: Optional[str] = None, + quantity: Optional[int] = None, + billing_domain_name: Optional[str] = None, + admin_domain_name: Optional[str] = None, + **kwargs + ) -> "models.DeviceService": + """Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a new body to update the Windows IoT Device Service. + + Updates the metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a brand + new Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service = models.DeviceServiceProperties(notes=notes, quantity=quantity, billing_domain_name=billing_domain_name, admin_domain_name=admin_domain_name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service, 'DeviceServiceProperties') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + async def delete( + self, + resource_group_name: str, + device_name: str, + **kwargs + ) -> "models.DeviceService": + """Delete a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + # Construct URL + url = self.delete.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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'] = 'application/json' + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "models.DeviceServiceDescriptionListResult": + """Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeviceServiceDescriptionListResult', 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.ErrorDetails, 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.WindowsIoT/deviceServices'} + + def list( + self, + **kwargs + ) -> "models.DeviceServiceDescriptionListResult": + """Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeviceServiceDescriptionListResult', 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.ErrorDetails, 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': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices'} + + async def check_device_service_name_availability( + self, + name: str, + **kwargs + ) -> "models.DeviceServiceNameAvailabilityInfo": + """Check if a Windows IoT Device Service name is available. + + :param name: The name of the Windows IoT Device Service to check. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceNameAvailabilityInfo"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service_check_name_availability_parameters = models.DeviceServiceCheckNameAvailabilityParameters(name=name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.check_device_service_name_availability.metadata['url'] + 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') + + # 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' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service_check_name_availability_parameters, 'DeviceServiceCheckNameAvailabilityParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceServiceNameAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_device_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability'} diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/__init__.py new file mode 100644 index 00000000000..0124cc85701 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/__init__.py @@ -0,0 +1,54 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import DeviceService + from ._models_py3 import DeviceServiceCheckNameAvailabilityParameters + from ._models_py3 import DeviceServiceDescriptionListResult + from ._models_py3 import DeviceServiceNameAvailabilityInfo + from ._models_py3 import DeviceServiceProperties + from ._models_py3 import ErrorDetails + from ._models_py3 import OperationDisplayInfo + from ._models_py3 import OperationEntity + from ._models_py3 import OperationListResult + from ._models_py3 import ProxyResource + from ._models_py3 import Resource + from ._models_py3 import TrackedResource +except (SyntaxError, ImportError): + from ._models import DeviceService # type: ignore + from ._models import DeviceServiceCheckNameAvailabilityParameters # type: ignore + from ._models import DeviceServiceDescriptionListResult # type: ignore + from ._models import DeviceServiceNameAvailabilityInfo # type: ignore + from ._models import DeviceServiceProperties # type: ignore + from ._models import ErrorDetails # type: ignore + from ._models import OperationDisplayInfo # type: ignore + from ._models import OperationEntity # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore + from ._models import TrackedResource # type: ignore + +from ._device_services_enums import ( + ServiceNameUnavailabilityReason, +) + +__all__ = [ + 'DeviceService', + 'DeviceServiceCheckNameAvailabilityParameters', + 'DeviceServiceDescriptionListResult', + 'DeviceServiceNameAvailabilityInfo', + 'DeviceServiceProperties', + 'ErrorDetails', + 'OperationDisplayInfo', + 'OperationEntity', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'TrackedResource', + 'ServiceNameUnavailabilityReason', +] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_device_services_enums.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_device_services_enums.py new file mode 100644 index 00000000000..81c3a0b977c --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_device_services_enums.py @@ -0,0 +1,16 @@ +# 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 enum import Enum + +class ServiceNameUnavailabilityReason(str, Enum): + """The reason for unavailability. + """ + + invalid = "Invalid" + already_exists = "AlreadyExists" diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models.py new file mode 100644 index 00000000000..afacadffd24 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models.py @@ -0,0 +1,427 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Resource(msrest.serialization.Model): + """The core properties of ARM 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. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: The Azure Region where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.location = kwargs.get('location', None) + + +class DeviceService(TrackedResource): + """The description of the Windows IoT Device Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: The Azure Region where the resource lives. + :type location: str + :param etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :type etag: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :ivar start_date: Windows IoT Device Service start date,. + :vartype start_date: ~datetime.datetime + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'start_date': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'long'}, + 'billing_domain_name': {'key': 'properties.billingDomainName', 'type': 'str'}, + 'admin_domain_name': {'key': 'properties.adminDomainName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeviceService, self).__init__(**kwargs) + self.etag = kwargs.get('etag', None) + self.notes = kwargs.get('notes', None) + self.start_date = None + self.quantity = kwargs.get('quantity', None) + self.billing_domain_name = kwargs.get('billing_domain_name', None) + self.admin_domain_name = kwargs.get('admin_domain_name', None) + + +class DeviceServiceCheckNameAvailabilityParameters(msrest.serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the Windows IoT Device Service to check. + :type name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeviceServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) + self.name = kwargs['name'] + + +class DeviceServiceDescriptionListResult(msrest.serialization.Model): + """The JSON-serialized array of DeviceService objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: The array of DeviceService objects. + :type value: list[~azure.mgmt.windowsiot.models.DeviceService] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceService]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeviceServiceDescriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeviceServiceNameAvailabilityInfo(msrest.serialization.Model): + """The properties indicating whether a given Windows IoT Device Service name is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. Possible values include: "Invalid", + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.windowsiot.models.ServiceNameUnavailabilityReason + :param message: The detailed reason message. + :type message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeviceServiceNameAvailabilityInfo, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = kwargs.get('message', None) + + +class DeviceServiceProperties(msrest.serialization.Model): + """The properties of a Windows IoT Device Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param notes: Windows IoT Device Service notes. + :type notes: str + :ivar start_date: Windows IoT Device Service start date,. + :vartype start_date: ~datetime.datetime + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + """ + + _validation = { + 'start_date': {'readonly': True}, + } + + _attribute_map = { + 'notes': {'key': 'notes', 'type': 'str'}, + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'quantity', 'type': 'long'}, + 'billing_domain_name': {'key': 'billingDomainName', 'type': 'str'}, + 'admin_domain_name': {'key': 'adminDomainName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeviceServiceProperties, self).__init__(**kwargs) + self.notes = kwargs.get('notes', None) + self.start_date = None + self.quantity = kwargs.get('quantity', None) + self.billing_domain_name = kwargs.get('billing_domain_name', None) + self.admin_domain_name = kwargs.get('admin_domain_name', None) + + +class ErrorDetails(msrest.serialization.Model): + """The details of the error. + + :param code: One of a server-defined set of error codes. + :type code: str + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the particular error. + :type target: str + :param details: A human-readable representation of the error's details. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + +class OperationDisplayInfo(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :param description: The description of the operation. + :type description: str + :param operation: The action that users can perform, based on their permission level. + :type operation: str + :param provider: Service provider: Azure Data Catalog Service. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplayInfo, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.operation = kwargs.get('operation', None) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + + +class OperationEntity(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The operation supported by Azure Data Catalog Service. + :type display: ~azure.mgmt.windowsiot.models.OperationDisplayInfo + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationEntity, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Windows IoT Device Service operations. It contains a list of operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Windows IoT Device Service operations supported by the + Microsoft.WindowsIoT resource provider. + :vartype value: list[~azure.mgmt.windowsiot.models.OperationEntity] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationEntity]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models_py3.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models_py3.py new file mode 100644 index 00000000000..d98fbbf92ad --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models_py3.py @@ -0,0 +1,464 @@ +# 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 Dict, List, Optional + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Resource(msrest.serialization.Model): + """The core properties of ARM 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. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: The Azure Region where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class DeviceService(TrackedResource): + """The description of the Windows IoT Device Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: The Azure Region where the resource lives. + :type location: str + :param etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :type etag: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :ivar start_date: Windows IoT Device Service start date,. + :vartype start_date: ~datetime.datetime + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'start_date': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'long'}, + 'billing_domain_name': {'key': 'properties.billingDomainName', 'type': 'str'}, + 'admin_domain_name': {'key': 'properties.adminDomainName', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + etag: Optional[str] = None, + notes: Optional[str] = None, + quantity: Optional[int] = None, + billing_domain_name: Optional[str] = None, + admin_domain_name: Optional[str] = None, + **kwargs + ): + super(DeviceService, self).__init__(tags=tags, location=location, **kwargs) + self.etag = etag + self.notes = notes + self.start_date = None + self.quantity = quantity + self.billing_domain_name = billing_domain_name + self.admin_domain_name = admin_domain_name + + +class DeviceServiceCheckNameAvailabilityParameters(msrest.serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the Windows IoT Device Service to check. + :type name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + super(DeviceServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) + self.name = name + + +class DeviceServiceDescriptionListResult(msrest.serialization.Model): + """The JSON-serialized array of DeviceService objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: The array of DeviceService objects. + :type value: list[~azure.mgmt.windowsiot.models.DeviceService] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceService]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeviceService"]] = None, + **kwargs + ): + super(DeviceServiceDescriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeviceServiceNameAvailabilityInfo(msrest.serialization.Model): + """The properties indicating whether a given Windows IoT Device Service name is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. Possible values include: "Invalid", + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.windowsiot.models.ServiceNameUnavailabilityReason + :param message: The detailed reason message. + :type message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + **kwargs + ): + super(DeviceServiceNameAvailabilityInfo, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = message + + +class DeviceServiceProperties(msrest.serialization.Model): + """The properties of a Windows IoT Device Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param notes: Windows IoT Device Service notes. + :type notes: str + :ivar start_date: Windows IoT Device Service start date,. + :vartype start_date: ~datetime.datetime + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + """ + + _validation = { + 'start_date': {'readonly': True}, + } + + _attribute_map = { + 'notes': {'key': 'notes', 'type': 'str'}, + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'quantity', 'type': 'long'}, + 'billing_domain_name': {'key': 'billingDomainName', 'type': 'str'}, + 'admin_domain_name': {'key': 'adminDomainName', 'type': 'str'}, + } + + def __init__( + self, + *, + notes: Optional[str] = None, + quantity: Optional[int] = None, + billing_domain_name: Optional[str] = None, + admin_domain_name: Optional[str] = None, + **kwargs + ): + super(DeviceServiceProperties, self).__init__(**kwargs) + self.notes = notes + self.start_date = None + self.quantity = quantity + self.billing_domain_name = billing_domain_name + self.admin_domain_name = admin_domain_name + + +class ErrorDetails(msrest.serialization.Model): + """The details of the error. + + :param code: One of a server-defined set of error codes. + :type code: str + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the particular error. + :type target: str + :param details: A human-readable representation of the error's details. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[str] = None, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class OperationDisplayInfo(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :param description: The description of the operation. + :type description: str + :param operation: The action that users can perform, based on their permission level. + :type operation: str + :param provider: Service provider: Azure Data Catalog Service. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + operation: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + **kwargs + ): + super(OperationDisplayInfo, self).__init__(**kwargs) + self.description = description + self.operation = operation + self.provider = provider + self.resource = resource + + +class OperationEntity(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The operation supported by Azure Data Catalog Service. + :type display: ~azure.mgmt.windowsiot.models.OperationDisplayInfo + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplayInfo"] = None, + **kwargs + ): + super(OperationEntity, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Windows IoT Device Service operations. It contains a list of operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Windows IoT Device Service operations supported by the + Microsoft.WindowsIoT resource provider. + :vartype value: list[~azure.mgmt.windowsiot.models.OperationEntity] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationEntity]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/__init__.py new file mode 100644 index 00000000000..80d417d27c4 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._operation_operations import OperationOperations +from ._service_operations import ServiceOperations + +__all__ = [ + 'OperationOperations', + 'ServiceOperations', +] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operation_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operation_operations.py new file mode 100644 index 00000000000..b1f064f6895 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operation_operations.py @@ -0,0 +1,106 @@ +# 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 TYPE_CHECKING +import warnings + +from azure.core.exceptions import 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 +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations 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: ~azure.mgmt.windowsiot.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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.OperationListResult" + """Lists all of the available Windows IoT Services REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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 deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorDetails, 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 ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.WindowsIoT/operations'} diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_service_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_service_operations.py new file mode 100644 index 00000000000..97b3f76696d --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_service_operations.py @@ -0,0 +1,527 @@ +# 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 TYPE_CHECKING +import warnings + +from azure.core.exceptions import 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 +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ServiceOperations(object): + """ServiceOperations 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: ~azure.mgmt.windowsiot.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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + device_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Get the non-security related metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + # Construct URL + url = self.get.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + def create_or_update( + self, + resource_group_name, # type: str + device_name, # type: str + if_match=None, # type: Optional[str] + notes=None, # type: Optional[str] + quantity=None, # type: Optional[int] + billing_domain_name=None, # type: Optional[str] + admin_domain_name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a new body to update the Windows IoT Device Service. + + Create or update the metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a new + Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service = models.DeviceServiceProperties(notes=notes, quantity=quantity, billing_domain_name=billing_domain_name, admin_domain_name=admin_domain_name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create_or_update.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service, 'DeviceServiceProperties') + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + def update( + self, + resource_group_name, # type: str + device_name, # type: str + if_match=None, # type: Optional[str] + notes=None, # type: Optional[str] + quantity=None, # type: Optional[int] + billing_domain_name=None, # type: Optional[str] + admin_domain_name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a new body to update the Windows IoT Device Service. + + Updates the metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a brand + new Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :param notes: Windows IoT Device Service notes. + :type notes: str + :param quantity: Windows IoT Device Service device allocation,. + :type quantity: long + :param billing_domain_name: Windows IoT Device Service ODM AAD domain. + :type billing_domain_name: str + :param admin_domain_name: Windows IoT Device Service OEM AAD domain. + :type admin_domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service = models.DeviceServiceProperties(notes=notes, quantity=quantity, billing_domain_name=billing_domain_name, admin_domain_name=admin_domain_name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service, 'DeviceServiceProperties') + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + def delete( + self, + resource_group_name, # type: str + device_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Delete a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + # Construct URL + url = self.delete.metadata['url'] + 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'), + 'deviceName': self._serialize.url("device_name", device_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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = 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.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceServiceDescriptionListResult" + """Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeviceServiceDescriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorDetails, 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 ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices'} + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceServiceDescriptionListResult" + """Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-06-02" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeviceServiceDescriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorDetails, 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 ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices'} + + def check_device_service_name_availability( + self, + name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceServiceNameAvailabilityInfo" + """Check if a Windows IoT Device Service name is available. + + :param name: The name of the Windows IoT Device Service to check. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceNameAvailabilityInfo"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _device_service_check_name_availability_parameters = models.DeviceServiceCheckNameAvailabilityParameters(name=name) + api_version = "2019-06-02" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.check_device_service_name_availability.metadata['url'] + 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') + + # 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' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_device_service_check_name_availability_parameters, 'DeviceServiceCheckNameAvailabilityParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = 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.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceServiceNameAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_device_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability'} diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/py.typed b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/setup.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/setup.py new file mode 100644 index 00000000000..bd771d4e3a5 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/setup.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "deviceservices" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"] + +setup( + name=NAME, + version=VERSION, + description="DeviceServices", + author_email="", + url="", + keywords=["Swagger", "DeviceServices"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Use this API to manage the Windows IoT device services in your Azure subscription. + """ +) diff --git a/src/windowsiot/report.md b/src/windowsiot/report.md new file mode 100644 index 00000000000..27c8e96e563 --- /dev/null +++ b/src/windowsiot/report.md @@ -0,0 +1,58 @@ +# Azure CLI Module Creation Report + +### windowsiotservices service check-device-service-name-availability + +check-device-service-name-availability a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--name**|string|The name of the Windows IoT Device Service to check.|name| +### windowsiotservices service create + +create a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name| +|**--if-match**|string|ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device Service. Required to update an existing Windows IoT Device Service.|if_match| +|**--notes**|string|Windows IoT Device Service notes.|notes| +|**--quantity**|integer|Windows IoT Device Service device allocation,|quantity| +|**--billing-domain-name**|string|Windows IoT Device Service ODM AAD domain|billing_domain_name| +|**--admin-domain-name**|string|Windows IoT Device Service OEM AAD domain|admin_domain_name| +### windowsiotservices service delete + +delete a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name| +### windowsiotservices service list + +list a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name| +### windowsiotservices service show + +show a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name| +### windowsiotservices service update + +update a windowsiotservices service. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name| +|**--if-match**|string|ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device Service. Required to update an existing Windows IoT Device Service.|if_match| +|**--notes**|string|Windows IoT Device Service notes.|notes| +|**--quantity**|integer|Windows IoT Device Service device allocation,|quantity| +|**--billing-domain-name**|string|Windows IoT Device Service ODM AAD domain|billing_domain_name| +|**--admin-domain-name**|string|Windows IoT Device Service OEM AAD domain|admin_domain_name| \ No newline at end of file diff --git a/src/windowsiot/setup.cfg b/src/windowsiot/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/windowsiot/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/windowsiot/setup.py b/src/windowsiot/setup.py new file mode 100644 index 00000000000..2ac32b89190 --- /dev/null +++ b/src/windowsiot/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='windowsiotservices', + version=VERSION, + description='Microsoft Azure Command-Line Tools DeviceServices Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_windowsiotservices': ['azext_metadata.json']}, +)