diff --git a/src/windowsiot/HISTORY.rst b/src/windowsiot/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /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..479180d049a --- /dev/null +++ b/src/windowsiot/README.md @@ -0,0 +1,37 @@ +# Azure CLI windowsiotservices Extension # +This is the extension for windowsiotservices + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name windowsiotservices +``` + +### Included Features ### +#### windowsiotservices service #### +##### Create ##### +``` +az windowsiotservices service create --device-name "service4445" --location "East US" --admin-domain-name "d.e.f" \ + --billing-domain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9101" +``` +##### Show ##### +``` +az windowsiotservices service show --device-name "service8596" --resource-group "res9407" +``` +##### List ##### +``` +az windowsiotservices service list --resource-group "res6117" +``` +##### Update ##### +``` +az windowsiotservices service update --device-name "service8596" --location "East US" --admin-domain-name "d.e.f" \ + --billing-domain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9407" +``` +##### Check-device-service-name-availability ##### +``` +az windowsiotservices service check-device-service-name-availability --name "service3363" +``` +##### Delete ##### +``` +az windowsiotservices service delete --device-name "service2434" --resource-group "res4228" +``` \ No newline at end of file diff --git a/src/windowsiot/azext_windowsiotservices/__init__.py b/src/windowsiot/azext_windowsiotservices/__init__.py new file mode 100644 index 00000000000..7262f702e06 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# 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 +try: + from azext_windowsiotservices.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +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_cl + windowsiotservices_custom = CliCommandType( + operations_tmpl='azext_windowsiotservices.custom#{}', + client_factory=cf_windowsiotservices_cl) + parent = super(DeviceServicesCommandsLoader, self) + parent.__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..d95d53bf711 --- /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..cfc30c747c7 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.15.0" +} \ 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..dbe9d5f9742 --- /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..c9cfdc73e77 --- /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..b9abf38ad3f --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_client_factory.py @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------- +# 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_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azext_windowsiotservices.vendored_sdks.windowsiot import DeviceServices + return get_mgmt_service_client(cli_ctx, + DeviceServices) + + +def cf_service(cli_ctx, *_): + return cf_windowsiotservices_cl(cli_ctx).services diff --git a/src/windowsiot/azext_windowsiotservices/generated/_help.py b/src/windowsiot/azext_windowsiotservices/generated/_help.py new file mode 100644 index 00000000000..50d6a7c5bab --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_help.py @@ -0,0 +1,81 @@ +# -------------------------------------------------------------------------- +# 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: Manage service with windowsiotservices +""" + +helps['windowsiotservices service list'] = """ + type: command + short-summary: "Get all the IoT hubs in a resource group. And Get all the IoT hubs in a subscription." + examples: + - name: Service_ListByResourceGroup + text: |- + az windowsiotservices service list --resource-group "res6117" + - name: Service_List + text: |- + az windowsiotservices service list +""" + +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 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." + examples: + - name: Service_Create + text: |- + az windowsiotservices service create --device-name "service4445" --location "East US" \ +--admin-domain-name "d.e.f" --billing-domain-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 \ +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_Update + text: |- + az windowsiotservices service update --device-name "service8596" --location "East US" \ +--admin-domain-name "d.e.f" --billing-domain-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..4d3a33741ba --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_params.py @@ -0,0 +1,65 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core.commands.parameters import ( + tags_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group + + +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', type=str, help='The name of the Windows IoT Device Service.', id_part='name') + + with self.argument_context('windowsiotservices service create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('device_name', type=str, help='The name of the Windows IoT Device Service.') + c.argument('if_match', type=str, 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('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False, + validator=get_default_location_from_resource_group) + c.argument('etag', type=str, help='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.') + c.argument('notes', type=str, help='Windows IoT Device Service notes.') + c.argument('quantity', type=int, help='Windows IoT Device Service device allocation,') + c.argument('billing_domain_name', type=str, help='Windows IoT Device Service ODM AAD domain') + c.argument('admin_domain_name', type=str, 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', type=str, help='The name of the Windows IoT Device Service.', id_part='name') + c.argument('if_match', type=str, help='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.') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False, + validator=get_default_location_from_resource_group) + c.argument('etag', type=str, help='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.') + c.argument('notes', type=str, help='Windows IoT Device Service notes.') + c.argument('quantity', type=int, help='Windows IoT Device Service device allocation,') + c.argument('billing_domain_name', type=str, help='Windows IoT Device Service ODM AAD domain') + c.argument('admin_domain_name', type=str, 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', type=str, help='The name of the Windows IoT Device Service.', id_part='name') + + with self.argument_context('windowsiotservices service check-device-service-name-availability') as c: + c.argument('name', type=str, 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..b33a44c1ebf --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/windowsiot/azext_windowsiotservices/generated/action.py b/src/windowsiot/azext_windowsiotservices/generated/action.py new file mode 100644 index 00000000000..b49bfaeeefe --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/action.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------- +# 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 diff --git a/src/windowsiot/azext_windowsiotservices/generated/commands.py b/src/windowsiot/azext_windowsiotservices/generated/commands.py new file mode 100644 index 00000000000..de67b145ff2 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/commands.py @@ -0,0 +1,33 @@ +# -------------------------------------------------------------------------- +# 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-statements +# pylint: disable=too-many-locals + +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._services_operations#ServicesOper' + 'ations.{}', + client_factory=cf_service) + with self.command_group('windowsiotservices service', windowsiotservices_service, client_factory=cf_service) 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', confirmation=True) + g.custom_command('check-device-service-name-availability', 'windowsiotservices_service_check_device_service_nam' + 'e_availability') + + with self.command_group('windowsiotservices', is_experimental=True): + pass diff --git a/src/windowsiot/azext_windowsiotservices/generated/custom.py b/src/windowsiot/azext_windowsiotservices/generated/custom.py new file mode 100644 index 00000000000..41d9ebee3f9 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/generated/custom.py @@ -0,0 +1,89 @@ +# -------------------------------------------------------------------------- +# 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=line-too-long +# pylint: disable=too-many-lines + + +def windowsiotservices_service_list(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list() + + +def windowsiotservices_service_show(client, + resource_group_name, + device_name): + return client.get(resource_group_name=resource_group_name, + device_name=device_name) + + +def windowsiotservices_service_create(client, + resource_group_name, + device_name, + if_match=None, + tags=None, + location=None, + etag=None, + notes=None, + quantity=None, + billing_domain_name=None, + admin_domain_name=None): + device_service = {} + device_service['tags'] = tags + device_service['location'] = location + device_service['etag'] = etag + device_service['notes'] = notes + device_service['quantity'] = quantity + device_service['billing_domain_name'] = billing_domain_name + device_service['admin_domain_name'] = admin_domain_name + return client.create_or_update(resource_group_name=resource_group_name, + device_name=device_name, + if_match=if_match, + device_service=device_service) + + +def windowsiotservices_service_update(client, + resource_group_name, + device_name, + if_match=None, + tags=None, + location=None, + etag=None, + notes=None, + quantity=None, + billing_domain_name=None, + admin_domain_name=None): + device_service = {} + device_service['tags'] = tags + device_service['location'] = location + device_service['etag'] = etag + device_service['notes'] = notes + device_service['quantity'] = quantity + device_service['billing_domain_name'] = billing_domain_name + device_service['admin_domain_name'] = admin_domain_name + return client.update(resource_group_name=resource_group_name, + device_name=device_name, + if_match=if_match, + device_service=device_service) + + +def windowsiotservices_service_delete(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(client, + name): + device_service_check_name_availability_parameters = {} + device_service_check_name_availability_parameters['name'] = name + return client.check_device_service_name_availability(device_service_check_name_availability_parameters=device_service_check_name_availability_parameters) diff --git a/src/windowsiot/azext_windowsiotservices/manual/__init__.py b/src/windowsiot/azext_windowsiotservices/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /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..70488e93851 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/__init__.py @@ -0,0 +1,116 @@ +# 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 logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func).lower() + module_path = __path__[0].lower() + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + 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) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE") + if use_exception_cache is None or use_exception_cache.lower() != "true": + raise + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) 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..c9cfdc73e77 --- /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/example_steps.py b/src/windowsiot/azext_windowsiotservices/tests/latest/example_steps.py new file mode 100644 index 00000000000..e142e2f39bb --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/latest/example_steps.py @@ -0,0 +1,97 @@ +# -------------------------------------------------------------------------- +# 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 .. import try_manual + + +# EXAMPLE: /Services/put/Service_Create +@try_manual +def step_service_create(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service create ' + '--device-name "service4445" ' + '--location "East US" ' + '--admin-domain-name "d.e.f" ' + '--billing-domain-name "a.b.c" ' + '--notes "blah" ' + '--quantity 1000000 ' + '--resource-group "{rg_3}"', + checks=checks) + + +# EXAMPLE: /Services/get/Service_List +@try_manual +def step_service_list(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service list ' + '-g ""', + checks=checks) + + +# EXAMPLE: /Services/get/Service_ListByResourceGroup +@try_manual +def step_service_list2(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service list ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Services/get/Services_GetProperties +@try_manual +def step_service_show(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service show ' + '--device-name "service8596" ' + '--resource-group "{rg_2}"', + checks=checks) + + +# EXAMPLE: /Services/patch/Service_Update +@try_manual +def step_service_update(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service update ' + '--device-name "service8596" ' + '--location "East US" ' + '--admin-domain-name "d.e.f" ' + '--billing-domain-name "a.b.c" ' + '--notes "blah" ' + '--quantity 1000000 ' + '--resource-group "{rg_2}"', + checks=checks) + + +# EXAMPLE: /Services/post/Service_CheckNameAvailability +@try_manual +def step_service_check_device(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service check-device-service-name-availability ' + '--name "service3363"', + checks=checks) + + +# EXAMPLE: /Services/delete/Service_Delete +@try_manual +def step_service_delete(test, rg, rg_2, rg_3, rg_4, checks=None): + if checks is None: + checks = [] + test.cmd('az windowsiotservices service delete -y ' + '--device-name "service2434" ' + '--resource-group "{rg_4}"', + checks=checks) + 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..ee48193769b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/tests/latest/test_windowsiotservices_scenario.py @@ -0,0 +1,73 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.testsdk import ScenarioTest +from azure.cli.testsdk import ResourceGroupPreparer +from .example_steps import step_service_create +from .example_steps import step_service_list +from .example_steps import step_service_list2 +from .example_steps import step_service_show +from .example_steps import step_service_update +from .example_steps import step_service_check_device +from .example_steps import step_service_delete +from .. import ( + try_manual, + raise_if, + calc_coverage +) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup_scenario +@try_manual +def setup_scenario(test, rg, rg_2, rg_3, rg_4): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test, rg, rg_2, rg_3, rg_4): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test, rg, rg_2, rg_3, rg_4): + setup_scenario(test, rg, rg_2, rg_3, rg_4) + step_service_create(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_list(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_list2(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_show(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_update(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_check_device(test, rg, rg_2, rg_3, rg_4, checks=[]) + step_service_delete(test, rg, rg_2, rg_3, rg_4, checks=[]) + cleanup_scenario(test, rg, rg_2, rg_3, rg_4) + + +# Test class for Scenario +@try_manual +class WindowsiotservicesScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(WindowsiotservicesScenarioTest, self).__init__(*args, **kwargs) + + + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res6117'[:7], key='rg', parameter_name='rg') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res9407'[:7], key='rg_2', parameter_name='rg_2') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res9101'[:7], key='rg_3', parameter_name='rg_3') + @ResourceGroupPreparer(name_prefix='clitestwindowsiotservices_res4228'[:7], key='rg_4', parameter_name='rg_4') + def test_windowsiotservices_Scenario(self, rg, rg_2, rg_3, rg_4): + call_scenario(self, rg, rg_2, rg_3, rg_4) + calc_coverage(__file__) + raise_if() + 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..c9cfdc73e77 --- /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..2af1fb490c6 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/__init__.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 ._device_services import DeviceServices +__all__ = ['DeviceServices'] + +try: + from ._patch import patch_sdk # type: ignore + 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..ae0e9bc8cbe --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_configuration.py @@ -0,0 +1,70 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +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-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'deviceservices/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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..e64ce684d5b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/_device_services.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import 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 azure.core.credentials import TokenCredential + +from ._configuration import DeviceServicesConfiguration +from .operations import Operations +from .operations import ServicesOperations +from . import models + + +class DeviceServices(object): + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: device_services.operations.Operations + :ivar services: ServicesOperations operations + :vartype services: device_services.operations.ServicesOperations + :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.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations( + 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/aio/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/__init__.py new file mode 100644 index 00000000000..ba6845d4609 --- /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 import DeviceServices +__all__ = ['DeviceServices'] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration.py new file mode 100644 index 00000000000..04337e3da2d --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class 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-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'deviceservices/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services.py new file mode 100644 index 00000000000..b730f163499 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/_device_services.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import DeviceServicesConfiguration +from .operations import Operations +from .operations import ServicesOperations +from .. import models + + +class DeviceServices(object): + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: device_services.aio.operations.Operations + :ivar services: ServicesOperations operations + :vartype services: device_services.aio.operations.ServicesOperations + :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.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations( + 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/__init__.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/__init__.py new file mode 100644 index 00000000000..93a0635dd99 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/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 ._operations import Operations +from ._services_operations import ServicesOperations + +__all__ = [ + 'Operations', + 'ServicesOperations', +] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_operations.py new file mode 100644 index 00000000000..5f57f3dca3b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations 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: ~device_services.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """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: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_services.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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'} # type: ignore diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_services_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_services_operations.py new file mode 100644 index 00000000000..2846f74468e --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/aio/operations/_services_operations.py @@ -0,0 +1,526 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServicesOperations: + """ServicesOperations 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: ~device_services.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: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.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}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + device_name: str, + device_service: "models.DeviceService", + if_match: Optional[str] = None, + **kwargs + ) -> "models.DeviceService": + """Create or update the metadata of a Windows IoT Device Service. + + 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. + + :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 device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~device_services.models.DeviceService + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(device_service, 'DeviceService') + 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, 201]: + 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) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 201: + 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}'} # type: ignore + + async def update( + self, + resource_group_name: str, + device_name: str, + device_service: "models.DeviceService", + if_match: Optional[str] = None, + **kwargs + ) -> "models.DeviceService": + """Updates the metadata of a Windows IoT Device Service. + + 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. + + :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 device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~device_services.models.DeviceService + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(device_service, 'DeviceService') + 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}'} # type: ignore + + 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: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 204: + 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}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["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: An iterator like instance of either DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_services.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('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'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["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: An iterator like instance of either DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_services.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('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'} # type: ignore + + async def check_device_service_name_availability( + self, + device_service_check_name_availability_parameters: "models.DeviceServiceCheckNameAvailabilityParameters", + **kwargs + ) -> "models.DeviceServiceNameAvailabilityInfo": + """Check if a Windows IoT Device Service name is available. + + :param device_service_check_name_availability_parameters: Set the name parameter in the + DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device + Service to check. + :type device_service_check_name_availability_parameters: ~device_services.models.DeviceServiceCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo, or the result of cls(response) + :rtype: ~device_services.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceNameAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_device_service_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(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'} # type: ignore 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..6a6be8640b0 --- /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 ErrorDetails + from ._models_py3 import ErrorDetailsError + 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 ErrorDetails # type: ignore + from ._models import ErrorDetailsError # 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', + 'ErrorDetails', + 'ErrorDetailsError', + '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..2059b382639 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_device_services_enums.py @@ -0,0 +1,34 @@ +# 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ServiceNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, 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..ce334a48163 --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models.py @@ -0,0 +1,413 @@ +# 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[~device_services.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 ~device_services.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 ErrorDetails(msrest.serialization.Model): + """The details of the error. + + :param error: The error object. + :type error: ~device_services.models.ErrorDetailsError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetailsError'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorDetailsError(msrest.serialization.Model): + """The error object. + + :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(ErrorDetailsError, 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: ~device_services.models.OperationDisplayInfo + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + :param origin: Indicates the executor of the operation. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationEntity, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.is_data_action = kwargs.get('is_data_action', None) + self.origin = kwargs.get('origin', 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[~device_services.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..16cbf164d9d --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/models/_models_py3.py @@ -0,0 +1,449 @@ +# 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[~device_services.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 ~device_services.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 ErrorDetails(msrest.serialization.Model): + """The details of the error. + + :param error: The error object. + :type error: ~device_services.models.ErrorDetailsError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetailsError'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetailsError"] = None, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.error = error + + +class ErrorDetailsError(msrest.serialization.Model): + """The error object. + + :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(ErrorDetailsError, 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: ~device_services.models.OperationDisplayInfo + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + :param origin: Indicates the executor of the operation. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplayInfo"] = None, + is_data_action: Optional[bool] = None, + origin: Optional[str] = None, + **kwargs + ): + super(OperationEntity, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = is_data_action + self.origin = origin + + +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[~device_services.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..93a0635dd99 --- /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 ._operations import Operations +from ._services_operations import ServicesOperations + +__all__ = [ + 'Operations', + 'ServicesOperations', +] diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operations.py new file mode 100644 index 00000000000..b8e28328bea --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_operations.py @@ -0,0 +1,110 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +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, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations 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: ~device_services.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: (...) -> Iterable["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: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~device_services.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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'} # type: ignore diff --git a/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_services_operations.py b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_services_operations.py new file mode 100644 index 00000000000..d8f9e73338b --- /dev/null +++ b/src/windowsiot/azext_windowsiotservices/vendored_sdks/windowsiot/operations/_services_operations.py @@ -0,0 +1,537 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +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, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ServicesOperations(object): + """ServicesOperations 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: ~device_services.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: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + device_name, # type: str + device_service, # type: "models.DeviceService" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Create or update the metadata of a Windows IoT Device Service. + + 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. + + :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 device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~device_services.models.DeviceService + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(device_service, 'DeviceService') + 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, 201]: + 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) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 201: + 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}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + device_name, # type: str + device_service, # type: "models.DeviceService" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceService" + """Updates the metadata of a Windows IoT Device Service. + + 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. + + :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 device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~device_services.models.DeviceService + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(device_service, 'DeviceService') + 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}'} # type: ignore + + 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: ~device_services.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorDetails, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 204: + 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}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["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: An iterator like instance of either DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~device_services.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["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: An iterator like instance of either DeviceServiceDescriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~device_services.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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'} # type: ignore + + def check_device_service_name_availability( + self, + device_service_check_name_availability_parameters, # type: "models.DeviceServiceCheckNameAvailabilityParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.DeviceServiceNameAvailabilityInfo" + """Check if a Windows IoT Device Service name is available. + + :param device_service_check_name_availability_parameters: Set the name parameter in the + DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device + Service to check. + :type device_service_check_name_availability_parameters: ~device_services.models.DeviceServiceCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo, or the result of cls(response) + :rtype: ~device_services.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeviceServiceNameAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_device_service_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(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'} # type: ignore 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/report.md b/src/windowsiot/report.md new file mode 100644 index 00000000000..d376fd75768 --- /dev/null +++ b/src/windowsiot/report.md @@ -0,0 +1,125 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az windowsiotservices|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az windowsiotservices` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az windowsiotservices service|Services|[commands](#CommandsInServices)| + +## COMMANDS +### Commands in `az windowsiotservices service` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az windowsiotservices service list](#ServicesListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersServicesListByResourceGroup)|[Example](#ExamplesServicesListByResourceGroup)| +|[az windowsiotservices service list](#ServicesList)|List|[Parameters](#ParametersServicesList)|[Example](#ExamplesServicesList)| +|[az windowsiotservices service show](#ServicesGet)|Get|[Parameters](#ParametersServicesGet)|[Example](#ExamplesServicesGet)| +|[az windowsiotservices service create](#ServicesCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersServicesCreateOrUpdate#Create)|[Example](#ExamplesServicesCreateOrUpdate#Create)| +|[az windowsiotservices service update](#ServicesUpdate)|Update|[Parameters](#ParametersServicesUpdate)|[Example](#ExamplesServicesUpdate)| +|[az windowsiotservices service delete](#ServicesDelete)|Delete|[Parameters](#ParametersServicesDelete)|[Example](#ExamplesServicesDelete)| +|[az windowsiotservices service check-device-service-name-availability](#ServicesCheckDeviceServiceNameAvailability)|CheckDeviceServiceNameAvailability|[Parameters](#ParametersServicesCheckDeviceServiceNameAvailability)|[Example](#ExamplesServicesCheckDeviceServiceNameAvailability)| + + +## COMMAND DETAILS + +### group `az windowsiotservices service` +#### Command `az windowsiotservices service list` + +##### Example +``` +az windowsiotservices service list --resource-group "res6117" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name|resourceGroupName| + +#### Command `az windowsiotservices service list` + +##### Example +``` +az windowsiotservices service list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az windowsiotservices service show` + +##### Example +``` +az windowsiotservices service show --device-name "service8596" --resource-group "res9407" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name|resourceGroupName| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name|deviceName| + +#### Command `az windowsiotservices service create` + +##### Example +``` +az windowsiotservices service create --device-name "service4445" --location "East US" --admin-domain-name "d.e.f" \ +--billing-domain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9101" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name|resourceGroupName| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name|deviceName| +|**--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|If-Match| +|**--tags**|dictionary|Resource tags.|tags|tags| +|**--location**|string|The Azure Region where the resource lives|location|location| +|**--etag**|string|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.|etag|etag| +|**--notes**|string|Windows IoT Device Service notes.|notes|notes| +|**--quantity**|integer|Windows IoT Device Service device allocation,|quantity|quantity| +|**--billing-domain-name**|string|Windows IoT Device Service ODM AAD domain|billing_domain_name|billingDomainName| +|**--admin-domain-name**|string|Windows IoT Device Service OEM AAD domain|admin_domain_name|adminDomainName| + +#### Command `az windowsiotservices service update` + +##### Example +``` +az windowsiotservices service update --device-name "service8596" --location "East US" --admin-domain-name "d.e.f" \ +--billing-domain-name "a.b.c" --notes "blah" --quantity 1000000 --resource-group "res9407" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name|resourceGroupName| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name|deviceName| +|**--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|If-Match| +|**--tags**|dictionary|Resource tags.|tags|tags| +|**--location**|string|The Azure Region where the resource lives|location|location| +|**--etag**|string|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.|etag|etag| +|**--notes**|string|Windows IoT Device Service notes.|notes|notes| +|**--quantity**|integer|Windows IoT Device Service device allocation,|quantity|quantity| +|**--billing-domain-name**|string|Windows IoT Device Service ODM AAD domain|billing_domain_name|billingDomainName| +|**--admin-domain-name**|string|Windows IoT Device Service OEM AAD domain|admin_domain_name|adminDomainName| + +#### Command `az windowsiotservices service delete` + +##### Example +``` +az windowsiotservices service delete --device-name "service2434" --resource-group "res4228" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the Windows IoT Device Service.|resource_group_name|resourceGroupName| +|**--device-name**|string|The name of the Windows IoT Device Service.|device_name|deviceName| + +#### Command `az windowsiotservices service check-device-service-name-availability` + +##### Example +``` +az windowsiotservices service check-device-service-name-availability --name "service3363" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--name**|string|The name of the Windows IoT Device Service to check.|name|name| 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..1c09b4f3b03 --- /dev/null +++ b/src/windowsiot/setup.py @@ -0,0 +1,58 @@ +#!/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 + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_windowsiotservices.manual.version import VERSION +except ImportError: + pass + +# 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', +] + +DEPENDENCIES = [] + +try: + from azext_windowsiotservices.manual.dependency import DEPENDENCIES +except ImportError: + pass + +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', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/windowsiot', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_windowsiotservices': ['azext_metadata.json']}, +)