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

[AzurePolicy] Migrate to track 2 SDK #18740

Merged
merged 1 commit into from
Jul 6, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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)
return get_mgmt_service_client(cli_ctx, PolicyInsightsClient)


def policy_events_operations(cli_ctx, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


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

if isinstance(ex, QueryFailureException):
if isinstance(ex, QueryFailure):
message = '({}) {}'.format(ex.error.error.code, ex.error.error.message)
raise CLIError(message)
import sys
Expand Down
12 changes: 6 additions & 6 deletions src/azure-cli/azure/cli/command_modules/policyinsights/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def list_policy_events(
subscription_id,
query_options)

return events.value
return events


def list_policy_states(
Expand Down Expand Up @@ -195,7 +195,7 @@ def list_policy_states(
subscription_id,
query_options)

return states.value
return states


def summarize_policy_states(
Expand Down Expand Up @@ -283,10 +283,10 @@ def trigger_policy_scan(

subscription_id = get_subscription_id(cmd.cli_ctx)
if resource_group_name:
return sdk_no_wait(no_wait, client.trigger_resource_group_evaluation,
return sdk_no_wait(no_wait, client.begin_trigger_resource_group_evaluation,
subscription_id, resource_group_name)

return sdk_no_wait(no_wait, client.trigger_subscription_evaluation,
return sdk_no_wait(no_wait, client.begin_trigger_subscription_evaluation,
subscription_id)


Expand Down Expand Up @@ -475,12 +475,12 @@ def show_policy_metadata(cmd, client, resource_name): # pylint: disable=unused
def list_policy_metadata(cmd, client, top_value=None): # pylint: disable=unused-argument
if top_value is not None:
from azure.mgmt.policyinsights.models import QueryOptions
page_iter = client.list(QueryOptions(top=top_value))
page_iter = client.list(QueryOptions(top=top_value)).by_page()
results = []

while len(results) < top_value:
try:
results.extend(list(page_iter.advance_page()))
results += list(next(page_iter))
except StopIteration:
break

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class PolicyInsightsTests(ScenarioTest):

# Current recording was recorded against "Azure Governance Policy UX Test" (e78961ba-36fe-4739-9212-e3031b4c8db7)
@record_only()
@AllowLargeResponse()
def test_policy_insights(self):
top_clause = '--top 2'
filter_clause = '--filter "isCompliant eq false"'
apply_clause = '--apply "groupby((policyAssignmentId, resourceId), aggregate($count as numRecords))"'
select_clause = '--select "policyAssignmentId, resourceId, numRecords"'
order_by_clause = '--order-by "numRecords desc"'
from_clause = '--from "2020-04-01T00:00:00Z"'
to_clause = '--to "2020-04-07T01:30:00Z"'
from_clause = '--from "2021-07-01T00:00:00Z"'
to_clause = '--to "2021-07-03T01:30:00Z"'
scopes = [
'-m "azgovtest5"',
'',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ azure-mgmt-monitor==2.0.0
azure-mgmt-msi==0.2.0
azure-mgmt-netapp==4.0.0
azure-mgmt-network==19.0.0
azure-mgmt-policyinsights==0.5.0
azure-mgmt-policyinsights==1.0.0
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==8.1.0b4
azure-mgmt-recoveryservices==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ azure-mgmt-monitor==2.0.0
azure-mgmt-msi==0.2.0
azure-mgmt-netapp==4.0.0
azure-mgmt-network==19.0.0
azure-mgmt-policyinsights==0.5.0
azure-mgmt-policyinsights==1.0.0
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==8.1.0b4
azure-mgmt-recoveryservices==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ azure-mgmt-monitor==2.0.0
azure-mgmt-msi==0.2.0
azure-mgmt-netapp==4.0.0
azure-mgmt-network==19.0.0
azure-mgmt-policyinsights==0.5.0
azure-mgmt-policyinsights==1.0.0
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==8.1.0b4
azure-mgmt-recoveryservices==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
'azure-mgmt-msi~=0.2',
'azure-mgmt-netapp~=4.0.0',
'azure-mgmt-network~=19.0.0',
'azure-mgmt-policyinsights~=0.5.0',
'azure-mgmt-policyinsights~=1.0.0',
'azure-mgmt-privatedns~=1.0.0',
'azure-mgmt-rdbms~=8.1.0b4',
'azure-mgmt-recoveryservicesbackup~=0.12.0',
Expand Down