Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c0f3ffb
Introducing IoT Hub dataplane RBAC support + various improvements (#341)
digimaun May 17, 2021
624d849
Iotc command versioning (#340)
valluriraj May 17, 2021
4bf999a
Add warning for qos deprecation and update contributing guide (#342)
avagraw May 18, 2021
b268dbe
Iotc command ga (#348)
valluriraj May 24, 2021
a4baacb
Use enum value instead of literal str. (#349)
digimaun May 25, 2021
79bf6cb
Managed identity support for device-identity import and export (#344)
c-ryan-k May 25, 2021
616e2c0
Update azext_metadata.json (#351)
digimaun May 25, 2021
9ee1ddc
Increment version to v0.10.13
digimaun May 25, 2021
3f12f21
Update README.md
digimaun May 25, 2021
058648a
Update HISTORY.rst
digimaun May 25, 2021
759503a
Add dataplane reset (#352)
vilit1 May 27, 2021
f82ef12
C2D messaging improvements. (#354)
digimaun May 27, 2021
48af558
Digital Twin wait commands (#345)
vilit1 May 27, 2021
354a98d
Add Identity Storage Account ID param to sentinel values (#355)
c-ryan-k May 28, 2021
b498a60
Module identity renew key (#356)
vilit1 Jun 1, 2021
72fa744
Update README.md
digimaun Jun 1, 2021
2ef0a41
Pipeline updates (#359)
c-ryan-k Jun 1, 2021
3170fd8
Check for conditionals before running test jobs (#363)
c-ryan-k Jun 2, 2021
bb3c5d9
Update d2c and simulate commands to return errors for non SaS devices…
avagraw Jun 3, 2021
f36ca7b
Update simulate message (#371)
rido-min Jun 10, 2021
d88c94c
Make gitHubConnection a variable. (#373)
digimaun Jun 11, 2021
6738afb
Iotc updates (#368)
valluriraj Jun 15, 2021
a2adb11
Edge deployment validation changes. (#382)
digimaun Jun 29, 2021
81c1153
Couple linter fixes. (#384)
digimaun Jun 29, 2021
5b30336
Extend generate token (#375)
vilit1 Jun 30, 2021
fdcdfbe
Roll pipeline ubuntu versions back to Ubuntu-16.04 (#386)
c-ryan-k Jun 30, 2021
0294711
Support for upcoming changes in Track 2 SDKs (#383)
c-ryan-k Jul 1, 2021
e10bed4
Remove six (#387)
vilit1 Jul 1, 2021
8c396d2
Separate IoT Hub per test suite to enable parallel test execution
avagraw Jul 1, 2021
d2406d0
Addressed comments
avagraw Jul 2, 2021
cd07a4e
minor update
avagraw Jul 2, 2021
c74cff1
test environment pipeline updates
avagraw Jul 2, 2021
be67f3d
Update help for --login and --hub-name (#389)
vilit1 Jul 7, 2021
83caf2e
Update mock import. (#391)
digimaun Jul 15, 2021
8ec6033
Refactoring and addressing comments
avagraw Jul 16, 2021
8b6592b
Update setup.py
avagraw Jul 17, 2021
c65b740
Merging from dev
avagraw Jul 17, 2021
2c88dcd
fstrings fix
avagraw Jul 19, 2021
91e7580
Formatting updates to tests
avagraw Jul 19, 2021
e56adab
Create one hub per test suite and provide Data contributor role to user
avagraw Jul 22, 2021
c9089d2
Account refresh and test class parallel run
avagraw Jul 24, 2021
828dfe6
remove commented parts of test
avagraw Jul 24, 2021
8c3a91c
lint updates
avagraw Jul 24, 2021
6081d3d
Merge with dev
avagraw Jul 27, 2021
932e679
Azure devops merge fix
avagraw Jul 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Release History
===============

0.10.15
+++++++++++++++

**IoT Central updates**

* Adds support for listing device groups
* Adds support for listing roles and get role by id

0.10.14
+++++++++++++++

Expand Down
6 changes: 2 additions & 4 deletions azext_iot/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ def iot_service_provisioning_factory(cli_ctx, *_):
service_client (IotDpsClient): operational resource for
working with IoT Hub Device Provisioning Service.
"""
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.iothubprovisioningservices.iot_dps_client import IotDpsClient

return get_mgmt_service_client(cli_ctx, IotDpsClient)
from azure.cli.command_modules.iot._client_factory import iot_service_provisioning_factory
return iot_service_provisioning_factory(cli_ctx=cli_ctx)


class SdkResolver(object):
Expand Down
11 changes: 8 additions & 3 deletions azext_iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ def load_arguments(self, _):
validator=mode2_iot_login_handler,
help="This command supports an entity connection string with rights to perform action. "
'Use to avoid session login via "az login". '
"If both an entity connection string and name are provided the connection string takes priority.",
"If both an entity connection string and name are provided the connection string takes priority. "
"Required if --hub-name is not provided.",
arg_group="IoT Hub Identifier"
)
context.argument("resource_group_name", arg_type=resource_group_name_type)
context.argument(
"hub_name", options_list=["--hub-name", "-n"], arg_type=hub_name_type
"hub_name", options_list=["--hub-name", "-n"], arg_type=hub_name_type,
help="IoT Hub name. Required if --login is not provided.",
arg_group="IoT Hub Identifier"
)
context.argument(
"device_id", options_list=["--device-id", "-d"], help="Target Device."
Expand Down Expand Up @@ -320,7 +324,8 @@ def load_arguments(self, _):
"start_time",
options_list=["--start-time", "--start"],
help="The scheduled start of the job in ISO 8601 date time format. "
"If no start time is provided, the job is queued for asap execution.",
"If no start time is provided, the job is queued for asap execution. "
"Using a custom start time that's in the past may cause the operation to fail.",
)
context.argument(
"ttl",
Expand Down
59 changes: 59 additions & 0 deletions azext_iot/central/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def load_central_help():
_load_central_users_help()
_load_central_api_token_help()
_load_central_device_templates_help()
_load_central_device_groups_help()
_load_central_roles_help()
_load_central_monitors_help()
_load_central_command_help()
_load_central_compute_device_key()
Expand Down Expand Up @@ -429,6 +431,63 @@ def _load_central_device_templates_help():
"""


def _load_central_device_groups_help():
helps[
"iot central device-group"
] = """
type: group
short-summary: Manage and configure IoT Central device groups
"""

helps[
"iot central device-group list"
] = """
type: command
short-summary: Get the list of device groups for an IoT Central application.

examples:
- name: List device groups in an application
text: >
az iot central device-group list
--app-id {appid}
"""


def _load_central_roles_help():
helps[
"iot central role"
] = """
type: group
short-summary: Manage and configure IoT Central roles
"""

helps[
"iot central role list"
] = """
type: command
short-summary: Get the list of roles for an IoT Central application.

examples:
- name: List roles in an application
text: >
az iot central role list
--app-id {appid}
"""

helps[
"iot central role show"
] = """
type: command
short-summary: Get the details of a role by ID
examples:
- name: Get details of role
text: >
az iot central role show
--app-id {appid}
--role-id {roleId}
"""


def _load_central_monitors_help():

helps[
Expand Down
19 changes: 19 additions & 0 deletions azext_iot/central/command_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
operations_tmpl="azext_iot.central.commands_device_template#{}"
)

central_device_groups_ops = CliCommandType(
operations_tmpl="azext_iot.central.commands_device_group#{}"
)

central_roles_ops = CliCommandType(
operations_tmpl="azext_iot.central.commands_role#{}"
)

central_device_twin_ops = CliCommandType(
operations_tmpl="azext_iot.central.commands_device_twin#{}"
)
Expand Down Expand Up @@ -103,6 +111,17 @@ def load_central_commands(self, _):
cmd_group.command("create", "create_device_template")
cmd_group.command("delete", "delete_device_template")

with self.command_group(
"iot central device-group", command_type=central_device_groups_ops, is_preview=True
) as cmd_group:
cmd_group.command("list", "list_device_groups")

with self.command_group(
"iot central role", command_type=central_roles_ops, is_preview=True
) as cmd_group:
cmd_group.show_command("show", "get_role")
cmd_group.command("list", "list_roles")

with self.command_group(
"iot central device twin", command_type=central_device_twin_ops,
) as cmd_group:
Expand Down
21 changes: 21 additions & 0 deletions azext_iot/central/commands_device_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.
# --------------------------------------------------------------------------------------------
# Dev note - think of this as a controller

from azext_iot.constants import CENTRAL_ENDPOINT
from azext_iot.central.providers.preview import CentralDeviceGroupProviderPreview
from azext_iot.central.models.enum import ApiVersion


def list_device_groups(
cmd,
app_id: str,
token=None,
central_dns_suffix=CENTRAL_ENDPOINT,
api_version=ApiVersion.preview.value,
):
provider = CentralDeviceGroupProviderPreview(cmd=cmd, app_id=app_id, token=token)
return provider.list_device_groups(central_dns_suffix=central_dns_suffix)
35 changes: 35 additions & 0 deletions azext_iot/central/commands_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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.
# --------------------------------------------------------------------------------------------
# Dev note - think of this as a controller

from azext_iot.constants import CENTRAL_ENDPOINT
from azext_iot.central.providers.preview import CentralRoleProviderPreview
from azext_iot.central.models.enum import ApiVersion


def get_role(
cmd,
app_id: str,
role_id: str,
token=None,
central_dns_suffix=CENTRAL_ENDPOINT,
api_version=ApiVersion.preview.value,
):
provider = CentralRoleProviderPreview(cmd=cmd, app_id=app_id, token=token)

return provider.get_role(role_id=role_id, central_dns_suffix=central_dns_suffix)


def list_roles(
cmd,
app_id: str,
token=None,
central_dns_suffix=CENTRAL_ENDPOINT,
api_version=ApiVersion.preview.value,
):
provider = CentralRoleProviderPreview(cmd=cmd, app_id=app_id, token=token)

return provider.list_roles(central_dns_suffix=central_dns_suffix)
4 changes: 4 additions & 0 deletions azext_iot/central/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
from azext_iot.central.models.devicetwin import DeviceTwin
from azext_iot.central.models.templatepreview import TemplatePreview
from azext_iot.central.models.templatev1 import TemplateV1
from azext_iot.central.models.deviceGroupPreview import DeviceGroupPreview
from azext_iot.central.models.rolePreview import RolePreview


__all__ = [
"DevicePreview",
"DeviceGroupPreview",
"DeviceV1",
"DeviceTwin",
"TemplatePreview",
"TemplateV1",
"RolePreview"
]
11 changes: 11 additions & 0 deletions azext_iot/central/models/deviceGroupPreview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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.
# --------------------------------------------------------------------------------------------

class DeviceGroupPreview:
def __init__(self, group: dict):
self.display_name = group.get("displayName")
self.id = group.get("id")
pass
11 changes: 11 additions & 0 deletions azext_iot/central/models/rolePreview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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.
# --------------------------------------------------------------------------------------------

class RolePreview:
def __init__(self, device: dict):
self.display_name = device.get("displayName")
self.id = device.get("id")
pass
7 changes: 7 additions & 0 deletions azext_iot/central/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,10 @@ def load_central_arguments(self, _):
options_list=["--module-id", "-m"],
help="Provide IoT Edge Module ID if the device type is IoT Edge.",
)

with self.argument_context("iot central role") as context:
context.argument(
"role_id",
options_list=["--role-id", "-r"],
help="Provide a unique identifier for the role"
)
9 changes: 9 additions & 0 deletions azext_iot/central/providers/preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
from azext_iot.central.providers.preview.api_token_provider_preview import (
CentralApiTokenProviderPreview,
)
from azext_iot.central.providers.preview.device_group_provider_preview import (
CentralDeviceGroupProviderPreview
)
from azext_iot.central.providers.preview.role_provider_preview import (
CentralRoleProviderPreview
)

__all__ = [
"CentralDeviceProviderPreview",
"CentralDeviceTemplateProviderPreview",
"CentralUserProviderPreview",
"CentralApiTokenProviderPreview",
"CentralDeviceGroupProviderPreview",
"CentralRoleProviderPreview"

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.
# --------------------------------------------------------------------------------------------


from typing import List
from azext_iot.central.models.deviceGroupPreview import DeviceGroupPreview
from knack.log import get_logger
from azext_iot.constants import CENTRAL_ENDPOINT
from azext_iot.central import services as central_services
from azext_iot.central.models.enum import ApiVersion

logger = get_logger(__name__)


class CentralDeviceGroupProviderPreview:
def __init__(self, cmd, app_id: str, token=None):
"""
Provider for device groups APIs

Args:
cmd: command passed into az
app_id: name of app (used for forming request URL)
token: (OPTIONAL) authorization token to fetch device details from IoTC.
MUST INCLUDE type (e.g. 'SharedAccessToken ...', 'Bearer ...')
Useful in scenarios where user doesn't own the app
therefore AAD token won't work, but a SAS token generated by owner will
"""
self._cmd = cmd
self._app_id = app_id
self._token = token
self._device_groups = {}

def list_device_groups(self, central_dns_suffix=CENTRAL_ENDPOINT) -> List[DeviceGroupPreview]:
device_groups = central_services.device_group.list_device_groups(
cmd=self._cmd,
app_id=self._app_id,
token=self._token,
central_dns_suffix=central_dns_suffix,
api_version=ApiVersion.preview.value,
)

# add to cache
self._device_groups.update({device_group.id: device_group for device_group in device_groups})

return self._device_groups
Loading