Skip to content

Commit

Permalink
[TimeSeriesInsights] `az tsi access-policy/environment/reference-data…
Browse files Browse the repository at this point in the history
…-set`: Migrate to Codegen V2 (#6577)

* initial gen

* az tsi environment gen1 create tested

* az tsi access-policy tested

* location option list add -l

* change to patch for reference-data-set update, fix referenceDataSetName regex pattern for create, tests passed for reference-data-set

* tests passed for environment gen1

* tests passed for environment gen2

* unwrap more class into obj

* dont use aaz for event-source eventhub

* testsed event-source iothub which still uses sdk as well

* remove all unused code, lint, rerun test, update version

* move command import into function, use inheritance
  • Loading branch information
calvinhzy authored Aug 1, 2023
1 parent 89d2631 commit 8891292
Show file tree
Hide file tree
Showing 41 changed files with 5,397 additions and 1,418 deletions.
4 changes: 4 additions & 0 deletions src/timeseriesinsights/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.0b1
++++++
* Migrate `az tsi access-policy/environment/reference-data-set` to CodeGen

0.2.1
++++++
* Command group ``az tsi`` GA
Expand Down
19 changes: 13 additions & 6 deletions src/timeseriesinsights/azext_timeseriesinsights/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ class TimeSeriesInsightsClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_timeseriesinsights._client_factory import cf_timeseriesinsights_cl
timeseriesinsights_custom = CliCommandType(
operations_tmpl='azext_timeseriesinsights.custom#{}',
client_factory=cf_timeseriesinsights_cl)
parent = super(TimeSeriesInsightsClientCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=timeseriesinsights_custom)
custom_command_type = CliCommandType(operations_tmpl='azext_timeseriesinsights.custom#{}')
super(TimeSeriesInsightsClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_timeseriesinsights.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

Expand Down
12 changes: 0 additions & 12 deletions src/timeseriesinsights/azext_timeseriesinsights/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,5 @@ def cf_timeseriesinsights_cl(cli_ctx, *_):
TimeSeriesInsightsClient)


def cf_environment(cli_ctx, *_):
return cf_timeseriesinsights_cl(cli_ctx).environments


def cf_event_source(cli_ctx, *_):
return cf_timeseriesinsights_cl(cli_ctx).event_sources


def cf_reference_data_set(cli_ctx, *_):
return cf_timeseriesinsights_cl(cli_ctx).reference_data_sets


def cf_access_policy(cli_ctx, *_):
return cf_timeseriesinsights_cl(cli_ctx).access_policies
138 changes: 1 addition & 137 deletions src/timeseriesinsights/azext_timeseriesinsights/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@

from knack.help_files import helps

helps['tsi'] = """
type: group
short-summary: Manage Azure Time Series Insights.
"""

helps['tsi environment'] = """
type: group
short-summary: Manage environment with Azure Time Series Insights.
"""

helps['tsi environment list'] = """
type: command
short-summary: "List all the available environments associated with the subscription and within the specified \
resource group."
short-summary: "List all the available environments associated with the subscription and within the specified resource group."
examples:
- name: EnvironmentsByResourceGroup
text: |-
Expand All @@ -30,15 +19,6 @@
az tsi environment list
"""

helps['tsi environment show'] = """
type: command
short-summary: "Show the environment with the specified name in the specified subscription and resource group."
examples:
- name: EnvironmentsGet
text: |-
az tsi environment show --name "env1" --resource-group "rg1"
"""

helps['tsi environment gen1'] = """
type: group
short-summary: "Manage a gen1 environment in the specified subscription and resource group."
Expand Down Expand Up @@ -173,29 +153,6 @@
--storage-configuration account-name=your-account-name management-key=your-account-key
"""

helps['tsi environment delete'] = """
type: command
short-summary: "Delete the environment with the specified name in the specified subscription and resource group."
examples:
- name: EnvironmentsDelete
text: |-
az tsi environment delete --name "env1" --resource-group "rg1"
"""

helps['tsi environment wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the timeseriesinsights environment is met.
examples:
- name: Pause executing next line of CLI script until the timeseriesinsights environment is successfully \
created.
text: |-
az tsi environment wait --name "env1" --resource-group "rg1" --created
- name: Pause executing next line of CLI script until the timeseriesinsights environment is successfully \
updated.
text: |-
az tsi environment wait --name "env1" --resource-group "rg1" --updated
"""

helps['tsi event-source'] = """
type: group
short-summary: Manage event source with timeseriesinsights
Expand Down Expand Up @@ -283,11 +240,6 @@
az tsi event-source delete --environment-name "env1" --name "es1" --resource-group "rg1"
"""

helps['tsi reference-data-set'] = """
type: group
short-summary: Manage reference data set with timeseriesinsights
"""

helps['tsi reference-data-set list'] = """
type: command
short-summary: "List all the available reference data sets associated with the subscription and within the \
Expand All @@ -298,16 +250,6 @@
az tsi reference-data-set list --environment-name "env1" --resource-group "rg1"
"""

helps['tsi reference-data-set show'] = """
type: command
short-summary: "Show the reference data set with the specified name in the specified environment."
examples:
- name: ReferenceDataSetsGet
text: |-
az tsi reference-data-set show --environment-name "env1" --name "rds1" --resource-group \
"rg1"
"""

helps['tsi reference-data-set create'] = """
type: command
short-summary: "Create a reference data set in the specified environment."
Expand All @@ -328,81 +270,3 @@
--key-properties name="DeviceId1" type="String" --key-properties name="DeviceFloor" type="Double" --name "rds1" \
--resource-group "rg1"
"""

helps['tsi reference-data-set update'] = """
type: command
short-summary: "Update the reference data set."
examples:
- name: ReferenceDataSetsUpdate
text: |-
az tsi reference-data-set update --environment-name "env1" --name "rds1" --tags \
someKey="someValue" --resource-group "rg1"
"""

helps['tsi reference-data-set delete'] = """
type: command
short-summary: "Delete the reference data set."
examples:
- name: ReferenceDataSetsDelete
text: |-
az tsi reference-data-set delete --environment-name "env1" --name "rds1" \
--resource-group "rg1"
"""

helps['tsi access-policy'] = """
type: group
short-summary: Manage access policy with timeseriesinsights
"""

helps['tsi access-policy list'] = """
type: command
short-summary: "List all the available access policies associated with the environment."
examples:
- name: AccessPoliciesByEnvironment
text: |-
az tsi access-policy list --environment-name "env1" --resource-group "rg1"
"""

helps['tsi access-policy show'] = """
type: command
short-summary: "Show the access policy with the specified name in the specified environment."
examples:
- name: AccessPoliciesGet
text: |-
az tsi access-policy show --name "ap1" --environment-name "env1" --resource-group "rg1"
"""

helps['tsi access-policy create'] = """
type: command
short-summary: "Create an access policy in the specified environment."
parameters:
- name: --principal-object-id
populator-commands:
- az ad user
- az ad sp
examples:
- name: AccessPoliciesCreate
text: |-
az tsi access-policy create --name "ap1" --environment-name "env1" --description "some \
description" --principal-object-id "aGuid" --roles Reader Contributor --resource-group "rg1"
"""

helps['tsi access-policy update'] = """
type: command
short-summary: "Update the access policy."
examples:
- name: AccessPoliciesUpdate
text: |-
az tsi access-policy update --name "ap1" --roles "Reader" --roles "Contributor" \
--environment-name "env1" --resource-group "rg1"
"""

helps['tsi access-policy delete'] = """
type: command
short-summary: "Delete the access policy."
examples:
- name: AccessPoliciesDelete
text: |-
az tsi access-policy delete --name "ap1" --environment-name "env1" --resource-group \
"rg1"
"""
34 changes: 0 additions & 34 deletions src/timeseriesinsights/azext_timeseriesinsights/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@


def load_arguments(self, _):

with self.argument_context('tsi environment') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('environment_name', options_list=['--name', '-n', '--environment-name'], type=str, help='The name '
'of the Time Series Insights environment associated with the specified resource group.', id_part=''
'name')
c.argument('expand', type=str, help='Setting $expand=status will include the status of the internal services '
'of the environment in the Time Series Insights service.')

with self.argument_context('tsi environment list') as c:
c.argument('environment_name', id_part=None)

with self.argument_context('tsi environment gen1') as c:
c.argument('environment_name', options_list=['--name', '-n', '--environment-name'], type=str, help='Name of the'
' environment', id_part='name')
Expand Down Expand Up @@ -185,27 +173,5 @@ def load_arguments(self, _):
'reference data with events or while adding new reference data. When \'OrdinalIgnoreCase\' is set, '
'case insensitive comparison will be used.')

with self.argument_context('tsi reference-data-set create') as c:
c.argument('environment_name', id_part=None)
c.argument('reference_data_set_name', id_part=None)

with self.argument_context('tsi reference-data-set list') as c:
c.argument('environment_name', id_part=None)

with self.argument_context('tsi access-policy') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('environment_name', type=str, help='The name of the Time Series Insights environment associated '
'with the specified resource group.', id_part='name')
c.argument('access_policy_name', options_list=['--name', '-n', '--access-policy-name'], type=str, help='The '
'name of the Time Series Insights access policy associated with the specified environment.',
id_part='child_name_1')
c.argument('principal_object_id', type=str, help="The objectId of the principal in Azure Active Directory.")
c.argument('description', type=str, help='An description of the access policy.')
c.argument('roles', nargs='+', help='The list of roles the principal is assigned on the environment.')

with self.argument_context('tsi access-policy create') as c:
c.argument('environment_name', id_part=None)
c.argument('access_policy_name', id_part=None)

with self.argument_context('tsi access-policy list') as c:
c.argument('environment_name', id_part=None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"tsi",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Azure Time Series Insights.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"tsi access-policy",
)
class __CMDGroup(AAZCommandGroup):
"""Manage access policy with timeseriesinsights.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
Loading

0 comments on commit 8891292

Please sign in to comment.