Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
214f1ba
Draft implementation of policy insights command module (no tests, par…
bulentelmaci May 11, 2018
7d4e574
Various fixes (all commands and exception works now)
bulentelmaci May 11, 2018
93aa726
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 14, 2018
34b1d7a
Help, params and completers
bulentelmaci May 16, 2018
af11e06
Integrate into existing "policy" command group (instead of a new "pol…
bulentelmaci May 16, 2018
f823652
Add scenario test
bulentelmaci May 16, 2018
b09ac30
Add __init__ files as well
bulentelmaci May 16, 2018
9ab08f9
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 16, 2018
1c1a02c
Add doc mapping
bulentelmaci May 16, 2018
e6adc3e
Fix params and test
bulentelmaci May 17, 2018
12bc0c9
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 17, 2018
81bca6f
Fix for CI errors
bulentelmaci May 17, 2018
2d0abe9
History.rst fix for CI failure
bulentelmaci May 17, 2018
0a21e54
More params and help fixes for CI failures
bulentelmaci May 17, 2018
caf23af
Requested changes
bulentelmaci May 17, 2018
504ede2
PR feedback fixes
bulentelmaci May 18, 2018
ad373c9
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 18, 2018
eab48a8
precheck_pep8.sh fixes
bulentelmaci May 19, 2018
d4f218f
Changes for the latest feedback
bulentelmaci May 22, 2018
d71701f
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 22, 2018
fdef1f7
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
bulentelmaci May 22, 2018
3248fc0
Fix automation error caused by hardcoded subscription id in resourceid
bulentelmaci May 22, 2018
f44b7d3
Remove shortcut for --resource; change -p to -s
bulentelmaci May 23, 2018
89a62f8
Add to code owners
bulentelmaci May 23, 2018
eae8d09
Remove -name from mg, and policy scope parameters
bulentelmaci May 24, 2018
dd1fa77
Remove reduntant options_list instances; add more help to --resource …
bulentelmaci May 24, 2018
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
1 change: 1 addition & 0 deletions doc/sphinx/azhelpgen/doc_source_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"monitor": "src/command_modules/azure-cli-monitor/azure/cli/command_modules/monitor/_help.py",
"network": "src/command_modules/azure-cli-network/azure/cli/command_modules/network/_help.py",
"policy": "src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py",
"policyinsights": "src/command_modules/azure-cli-policyinsights/azure/cli/command_modules/policyinsights/_help.py",
"provider": "src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py",
"rdbms": "src/command_modules/azure-cli-rdbms/azure/cli/command_modules/rdbms/_help.py",
"redis": "src/command_modules/azure-cli-redis/azure/cli/command_modules/redis/_help.py",
Expand Down
9 changes: 9 additions & 0 deletions src/command_modules/azure-cli-policyinsights/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. :changelog:

Release History
===============

0.1.0
++++++++++++++++++

* Initial Release
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-policyinsights/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.rst
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-policyinsights/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Microsoft Azure CLI 'policyinsights' Command Module
===================================================

This package is for the 'policyinsights' module.
i.e. 'az policy event' and 'az policy state'


Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-import

from azure.cli.command_modules.policyinsights._help import helps
from azure.cli.core import AzCommandsLoader


class PolicyInsightsCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from ._exception_handler import policy_insights_exception_handler

policyinsights_custom = CliCommandType(
operations_tmpl='azure.cli.command_modules.policyinsights.custom#{}',
exception_handler=policy_insights_exception_handler)

super(PolicyInsightsCommandsLoader, self).__init__(
cli_ctx=cli_ctx,
min_profile='2017-03-10-profile',
custom_command_type=policyinsights_custom)

def load_command_table(self, args):
from .commands import load_command_table

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from ._params import load_arguments

load_arguments(self, command)


COMMAND_LOADER_CLS = PolicyInsightsCommandsLoader
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def _cf_policy_insights(cli_ctx, **_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.policyinsights import PolicyInsightsClient

return get_mgmt_service_client(cli_ctx, PolicyInsightsClient, subscription_bound=False)


def policy_events_operations(cli_ctx, _):
return _cf_policy_insights(cli_ctx).policy_events


def policy_states_operations(cli_ctx, _):
return _cf_policy_insights(cli_ctx).policy_states
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.util import CLIError


def policy_insights_exception_handler(ex):
from azure.mgmt.policyinsights.models import QueryFailureException

if isinstance(ex, QueryFailureException):
message = '({}) {}'.format(ex.error.error.code, ex.error.error.message)
raise CLIError(message)
else:
import sys
from six import reraise

reraise(*sys.exc_info())
Loading