Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def default_api_version(self):
ResourceType.MGMT_APPSERVICE: '2021-03-01',
ResourceType.MGMT_IOTHUB: '2021-07-02',
ResourceType.MGMT_IOTDPS: '2021-10-15',
ResourceType.MGMT_IOTCENTRAL: '2018-09-01',
ResourceType.MGMT_IOTCENTRAL: '2021-11-01-preview',
ResourceType.MGMT_ARO: '2022-04-01',
ResourceType.MGMT_DATABOXEDGE: '2021-02-01-preview',
ResourceType.MGMT_CUSTOMLOCATION: '2021-03-15-preview',
Expand Down
126 changes: 126 additions & 0 deletions src/azure-cli/azure/cli/command_modules/iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,3 +959,129 @@
text: >
az iot central app identity remove --name my-iotc-app --resource-group MyResourceGroup --system-assigned
"""

helps['iot central app private-endpoint-connection'] = """
type: group
short-summary: Manage private endpoint connection of IoT Central application.
"""

helps['iot central app private-endpoint-connection approve'] = """
type: command
short-summary: Approve a private endpoint connection request for an IoT Central application.
examples:
- name: Approve a private endpoint connection request for an IoT Central application by ID.
text: |
az iot central app private-endpoint-connection approve --id "/subscriptions/0000-0000-0000-0000/resourceGroups/MyResourceGroup/providers/Microsoft.IoTCentral/IoTApps/my-iotc-app/privateEndpointConnections/my-iotc-app.b56b5a95-0588-4f8b-b348-15db61590a6c"
- name: Approve a private endpoint connection request for an IoT Central application by ID.
text: |
id = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].id")
az iot central app private-endpoint-connection approve --id $id
- name: Approve a private endpoint connection request for an IoT Central application using account name and connection name.
text: |
az iot central app private-endpoint-connection approve -g myRg --account-name my-iotc-app --name myconnection
- name: Approve a private endpoint connection request for an IoT Central application using account name and connection name.
text: |
name = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].name")
az iot central app private-endpoint-connection approve -g myRg --account-name my-iotc-app --name $name
"""

helps['iot central app private-endpoint-connection delete'] = """
type: command
short-summary: Delete a private endpoint connection for an IoT Central application.
examples:
- name: Delete a private endpoint connection for an IoT Central application by ID.
text: |
az iot central app private-endpoint-connection delete --id "/subscriptions/0000-0000-0000-0000/resourceGroups/MyResourceGroup/providers/Microsoft.IoTCentral/IoTApps/my-iotc-app/privateEndpointConnections/my-iotc-app.b56b5a95-0588-4f8b-b348-15db61590a6c"
- name: Delete a private endpoint connection for an IoT Central application by ID.
text: |
id = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].id")
az iot central app private-endpoint-connection delete --id $id
- name: Delete a private endpoint connection for an IoT Central application using account name and connection name.
text: |
az iot central app private-endpoint-connection delete -g myRg --account-name my-iotc-app --name myconnection
- name: Delete a private endpoint connection for an IoT Central application using account name and connection name.
text: |
name = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].name")
az iot central app private-endpoint-connection delete -g myRg --account-name my-iotc-app --name $name
"""

helps['iot central app private-endpoint-connection reject'] = """
type: command
short-summary: Reject a private endpoint connection request for an IoT Central application.
examples:
- name: Reject a private endpoint connection request for an IoT Central application by ID.
text: |
az iot central app private-endpoint-connection reject --id "/subscriptions/0000-0000-0000-0000/resourceGroups/MyResourceGroup/providers/Microsoft.IoTCentral/IoTApps/my-iotc-app/privateEndpointConnections/my-iotc-app.b56b5a95-0588-4f8b-b348-15db61590a6c"
- name: Reject a private endpoint connection request for an IoT Central application by ID.
text: |
id = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].id")
az iot central app private-endpoint-connection reject --id $id
- name: Reject a private endpoint connection request for an IoT Central application app using account name and connection name.
text: |
az iot central app private-endpoint-connection reject -g myRg --account-name my-iotc-app --name myconnection
- name: Reject a private endpoint connection request for an IoT Central application using account name and connection name.
text: |
name = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].name")
az iot central app private-endpoint-connection reject -g myRg --account-name my-iotc-app --name $name
"""

helps['iot central app private-endpoint-connection show'] = """
type: command
short-summary: Show details of a private endpoint connection request for an IoT Central application.
examples:
- name: Show details of a private endpoint connection request for an IoT Central application by ID.
text: |
az iot central app private-endpoint-connection show --id "/subscriptions/0000-0000-0000-0000/resourceGroups/MyResourceGroup/providers/Microsoft.IoTCentral/IoTApps/my-iotc-app/privateEndpointConnections/my-iotc-app.b56b5a95-0588-4f8b-b348-15db61590a6c"
- name: Show details of a private endpoint connection request for an IoT Central application by ID.
text: |
id = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].id")
az iot central app private-endpoint-connection show --id $id
- name: Show details of a private endpoint connection request for an IoT Central application using account name and connection name.
text: |
az iot central app private-endpoint-connection show -g myRg --account-name my-iotc-app --name myconnection
- name: Show details of a private endpoint connection request for an IoT Central application using account name and connection name.
text: |
name = (az iot central app show -n my-iotc-app --query "privateEndpointConnections[0].name")
az iot central app private-endpoint-connection show -g myRg --account-name my-iotc-app --name $name
"""

helps['iot central app private-endpoint-connection list'] = """
type: command
short-summary: List all of the private endpoint connections for an IoT Central application.
examples:
- name: List all of the private endpoint connections in the IoT Central application given the resource group and application name.
text: |
az iot central app private-endpoint-connection list -g MyResourceGroup --account-name my-iotc-app
- name: List all of the private endpoint connections in the IoT Central application given a connection id
text: |
az iot central app private-endpoint-connection list --id "/subscriptions/0000-0000-0000-0000/resourceGroups/MyResourceGroup/providers/Microsoft.IoTCentral/IoTApps/my-iotc-app/privateEndpointConnections/my-iotc-app.b56b5a95-0588-4f8b-b348-15db61590a6c"
"""

helps['iot central app private-link-resource'] = """
type: group
short-summary: Manage an IoT Central application private link resources.
"""

helps['iot central app private-link-resource list'] = """
type: command
short-summary: List all of the IoT Central application private link resources in the specified account.
examples:
- name: List all of the private link resources in the IoT Central application given the resource group and application name.
text: |
az iot central app private-link-resource list -g MyResourceGroup --n my-iotc-app
- name: List all of the private link resources in the IoT Central application given a connection id
text: |
az iot central app private-link-resource list --id PrivateLinkResourceID
"""

helps['iot central app private-link-resource show'] = """
type: command
short-summary: Show details of a private link resource in the specified IoT Central application.
examples:
- name: Show details of the private link resources in the IoT Central application given the resource group application name and group id.
text: |
az iot central app private-link-resource show -g MyResourceGroup --n my-iotc-app --group-id iotApp
- name: Show details of the private link resources in the IoT Central application given a connection id
text: |
az iot central app private-link-resource show --id PrivateLinkResourceID
"""
94 changes: 81 additions & 13 deletions src/azure-cli/azure/cli/command_modules/iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from argcomplete.completers import FilesCompleter
from knack.arguments import CLIArgumentType

from azure.cli.core.commands.parameters import (get_location_type,
file_type,
get_resource_name_completion_list,
Expand All @@ -22,18 +21,18 @@
EncodingFormat,
RenewKeyType,
AuthenticationType)
from .custom import KeyType, SimpleAccessRights
from ._validators import (validate_policy_permissions,
validate_retention_days,
validate_fileupload_notification_max_delivery_count,
validate_fileupload_notification_ttl,
validate_fileupload_sas_ttl,
validate_feedback_ttl,
validate_feedback_lock_duration,
validate_fileupload_notification_lock_duration,
validate_feedback_max_delivery_count,
validate_c2d_max_delivery_count,
validate_c2d_ttl)
from azure.cli.command_modules.iot.custom import KeyType, SimpleAccessRights
from azure.cli.command_modules.iot._validators import (validate_policy_permissions,
validate_retention_days,
validate_fileupload_notification_max_delivery_count,
validate_fileupload_notification_ttl,
validate_fileupload_sas_ttl,
validate_feedback_ttl,
validate_feedback_lock_duration,
validate_fileupload_notification_lock_duration,
validate_feedback_max_delivery_count,
validate_c2d_max_delivery_count,
validate_c2d_ttl)


hub_name_type = CLIArgumentType(
Expand Down Expand Up @@ -405,3 +404,72 @@ def load_arguments(self, _): # pylint: disable=too-many-statements

with self.argument_context('iot central app identity show') as c:
c.argument('app_name', app_name_type, options_list=['--name', '-n'])

with self.argument_context('iot central app private-endpoint-connection') as c:
c.argument('private_endpoint_connection_name', options_list=['--name', '-n'],
help='The name of the private endpoint connection associated with IoT Central application. '
'Required if --id is not specified')
c.argument('account_name', app_name_type,
help='Name of the IoT Central application. Required if --id is not specified')
c.argument('resource_group_name',
help='The resource group name of specified IoT Central application. '
'Required if --id is not specified', options_list=['--resource-group', '-g'])

for item in ['approve', 'reject']:
with self.argument_context('iot central app private-endpoint-connection {}'.format(item)) as c:
c.extra('connection_id', options_list=['--id'],
help='The ID of the private endpoint connection associated with the IoT Central application. '
'If --account-name --resource-group/-g and --name/-n are specified, this should be omitted.')
c.extra('description', options_list=['--description'],
help='Comments for the {} operation.'.format(item))

with self.argument_context('iot central app private-endpoint-connection delete') as c:
c.argument('private_endpoint_connection_name', options_list=['--name', '-n'],
help='The name of the private endpoint connection associated with IoT Central application. '
'Required if --id is not specified')
c.argument('account_name', app_name_type,
help='Name of the IoT Central application. Required if --id is not specified')
c.argument('resource_group_name',
help='The resource group name of specified IoT Central application. '
'Required if --id is not specified', options_list=['--resource-group', '-g'])
c.extra('connection_id', options_list=['--id'],
help='The ID of the private endpoint connection associated with the IoT Central application. '
'If --account-name --resource-group/-g and --name/-n are specified, this should be omitted.')

with self.argument_context('iot central app private-endpoint-connection show') as c:
c.argument('private_endpoint_connection_name', options_list=['--name', '-n'],
help='The name of the private endpoint connection associated with IoT Central application. '
'Required if --id is not specified')
c.argument('account_name', app_name_type,
help='Name of the IoT Central application. Required if --id is not specified')
c.argument('resource_group_name',
help='The resource group name of specified IoT Central application. '
'Required if --id is not specified', options_list=['--resource-group', '-g'])
c.extra('connection_id', options_list=['--id'],
help='The ID of the private endpoint connection associated with the IoT Central application. '
'If --account-name --resource-group/-g and --name/-n are specified, this should be omitted.')

with self.argument_context('iot central app private-endpoint-connection list') as c:
c.argument('account_name', app_name_type,
help='Name of the IoT Central application. Required if --id is not specified')
c.argument('resource_group_name', help='Name of resource group. '
'If provided, --name must be provided too', options_list=['--resource-group', '-g'])
c.extra('connection_id', help='ID of the resource', options_list=['--id'])

with self.argument_context('iot central app private-link-resource list') as c:
c.argument('name', help='Name of the resource. '
'If provided, --type and --resource-group must be provided too', options_list=['--name', '-n'])
c.argument('resource_group_name', help='Name of resource group. '
'If provided, --name and --type must be provided too', options_list=['--resource-group', '-g'])
c.argument('source_type', help='Type of the resource. '
'If provided, --name and --resource-group must be provided too', options_list=['--type'])
c.extra('connection_id', help='ID of the resource', options_list=['--id'])

with self.argument_context('iot central app private-link-resource show') as c:
c.argument('name', help='Name of the resource. '
'If provided, --type and --resource-group must be provided too', options_list=['--name', '-n'])
c.argument('resource_group_name', help='Name of resource group. '
'If provided, --name and --type must be provided too', options_list=['--resource-group', '-g'])
c.argument('group_id', help='Name of the private link resource. '
'If provided, --name and --type must be provided too', options_list=['--group-id'])
c.extra('connection_id', help='ID of the resource', options_list=['--id'])
19 changes: 17 additions & 2 deletions src/azure-cli/azure/cli/command_modules/iot/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# --------------------------------------------------------------------------------------------

from argparse import ArgumentError
from azure.cli.core.azclierror import InvalidArgumentValueError
from .custom import SimpleAccessRights
from azure.cli.core.azclierror import InvalidArgumentValueError, ArgumentUsageError
from azure.cli.command_modules.iot.custom import SimpleAccessRights, iot_central_app_get


def validate_policy_permissions(ns):
Expand Down Expand Up @@ -82,3 +82,18 @@ def validate_c2d_ttl(ns):
ns.c2d_ttl not in range(1, 49, 1)):
raise ArgumentError(None, 'Please specify the default time from 1 to 48 hours to live for cloud-to-device'
' messages in the device queue.')


def validate_private_endpoint_connection_id(cmd, namespace):
ns = namespace
if ns.connection_id:
id_parts = ns.connection_id.split('/')
ns.private_endpoint_connection_name = id_parts[-1]
ns.account_name = id_parts[-3]
ns.resource_group_name = id_parts[-7]
del ns.connection_id
if ns.account_name and not ns.resource_group_name:
ns.resource_group_name = iot_central_app_get(cmd.cli_ctx, ns.account_name).resourceGroup

if not all([ns.account_name, ns.resource_group_name, ns.private_endpoint_connection_name]):
raise ArgumentUsageError('incorrect usage: [--id ID | --name NAME --account-name NAME]')
Loading