Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{monitor} az monitor log-analytics query-pack: Add new commands #22986

Merged
merged 4 commits into from
Jun 27, 2022
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/aaz/_arg_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def format_data(cls, data):
raise AAZInvalidValueError(f"list type value expected, got '{data}'({type(data)})")


class AAZGenericUpdateAction(Action):
class AAZGenericUpdateAction(Action): # pylint: disable=too-few-public-methods
DEST = '_generic_update_args'

def __call__(self, parser, namespace, values, option_string=None):
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli-core/azure/cli/core/aaz/_field_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
AAZInvalidFieldError

# pylint: disable=protected-access, too-few-public-methods, isinstance-second-argument-not-valid-type
# pylint: disable=too-many-instance-attributes


# build in types
Expand Down
11 changes: 11 additions & 0 deletions src/azure-cli/azure/cli/command_modules/monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def __init__(self, cli_ctx=None):

def load_command_table(self, args):
from azure.cli.command_modules.monitor.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
37 changes: 0 additions & 37 deletions src/azure-cli/azure/cli/command_modules/monitor/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,43 +792,6 @@
text: az monitor log-analytics cluster create -g MyResourceGroup -n MyCluster --sku-capacity 1000
"""

helps['monitor log-analytics cluster update'] = """
type: command
short-summary: Update a cluster instance.
examples:
- name: Update a cluster instance.
text: |
az monitor log-analytics cluster update -g MyResourceGroup -n MyCluster \\
--key-vault-uri https://myvault.vault.azure.net/ --key-name my-key \\
--key-version fe0adcedd8014aed9c22e9aefb81a1ds --sku-capacity 1000
"""

helps['monitor log-analytics cluster delete'] = """
type: command
short-summary: Delete a cluster instance.
examples:
- name: Delete a cluster instance.
text: az monitor log-analytics cluster delete -g MyResourceGroup -n MyCluster
"""

helps['monitor log-analytics cluster show'] = """
type: command
short-summary: Show the properties of a cluster instance.
examples:
- name: Show the properties of a cluster instance.
text: az monitor log-analytics cluster show -g MyResourceGroup -n MyCluster
"""

helps['monitor log-analytics cluster list'] = """
type: command
short-summary: Gets all cluster instances in a resource group or in current subscription.
examples:
- name: Gets all cluster instances in a resource group.
text: az monitor log-analytics cluster list -g MyResourceGroup
- name: Gets all cluster instances in current subscription.
text: az monitor log-analytics cluster list
"""

helps['monitor log-analytics cluster wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the cluster is met.
Expand Down
5 changes: 0 additions & 5 deletions src/azure-cli/azure/cli/command_modules/monitor/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,6 @@ def load_arguments(self, _):
' be in multiples of 100. If you want to increase the limit, please contact'
' LAIngestionRate@microsoft.com. It can be decreased only after 31 days.')
c.argument('identity_type', help='The identity type. Supported values: SystemAssigned')

with self.argument_context('monitor log-analytics cluster update') as c:
c.argument('key_vault_uri', help='The Key Vault uri which holds the key associated with the Log Analytics cluster.')
c.argument('key_name', help='The name of the key associated with the Log Analytics cluster.')
c.argument('key_version', help='The version of the key associated with the Log Analytics cluster.')
# endregion

# region Log Analytics Linked Storage Account
Expand Down
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(
"monitor",
)
class __CMDGroup(AAZCommandGroup):
"""Manage the Azure Monitor Service.
"""
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(
"monitor log-analytics",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Azure log analytics.
"""
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(
"monitor log-analytics cluster",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Azure log analytics cluster.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# --------------------------------------------------------------------------------------------
# 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 ._delete import *
from ._list import *
from ._show import *
from ._update import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# --------------------------------------------------------------------------------------------
# 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(
"monitor log-analytics cluster delete",
confirmation="Are you sure you want to perform this operation?",
)
class Delete(AAZCommand):
"""Deletes a cluster instance.

:example: Delete a cluster instance.
az monitor log-analytics cluster delete -g MyResourceGroup -n MyCluster
"""

_aaz_info = {
"version": "2021-06-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationalinsights/clusters/{}", "2021-06-01"],
]
}

AZ_SUPPORT_NO_WAIT = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_lro_poller(self._execute_operations, None)

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.cluster_name = AAZStrArg(
options=["-n", "--name", "--cluster-name"],
help="The name of the Log Analytics cluster.",
required=True,
id_part="name",
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
return cls._args_schema

def _execute_operations(self):
yield self.ClustersDelete(ctx=self.ctx)()

class ClustersDelete(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [202]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [200]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [204]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_204,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}",
**self.url_parameters
)

@property
def method(self):
return "DELETE"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"clusterName", self.ctx.args.cluster_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2021-06-01",
required=True,
),
}
return parameters

def on_200(self, session):
pass

def on_204(self, session):
pass


__all__ = ["Delete"]
Loading