Skip to content

Powershell Cmdlets for Alerts Management #9495

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

Merged
merged 43 commits into from
Jul 23, 2019
Merged

Conversation

mahakjain314
Copy link
Contributor

Description

This feature enables customers to perform the operations supported by AlertsManagement RP on alerts, action rule and smart groups through Powershell.
Design Review - https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/315

Checklist

@adxsdkps
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soem review comments - also, there appears to be a build failure

@mahakjain314
Copy link
Contributor Author

mahakjain314 commented Jun 26, 2019

@markcowl I have few queries -

  1. Is taking Json input for complex properties recommended or I should always break it down to simple parameters or both?
  2. The build is failing because - "The online version in help file is incorrect". How do I go about it?
  3. Is WriteInformation() correct way to convey information like - successful deletion etc.?
  4. What is the correct way to skip writing the properties which are null?
  5. How to deal with paging when we have huge data? Any way to display data in pages?

@markcowl
Copy link
Member

@mahakjain314 I identified the issue you are having in the analysis runs, and the security-tools issue is just that you need to check the issues it identified and suppress them if they are not existing credentials

Please let us know if you have any questions

@mahakjain314
Copy link
Contributor Author

mahakjain314 commented Jul 15, 2019

Few questions -
Is the a way to skip a particular property while displaying the output model when it is null or empty? For example - In PSActionRule, SuppressionConfig and ActionGroupId will not be populated together. They are mutually exclusive. Is there a way to deal with such cases?

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the number of issues are getting smaller every time, so progress

[Parameter(Mandatory = false,
ParameterSetName = BySimplifiedFormatDiagnosticsActionRuleParameterSet,
HelpMessage = "Description of Action Rule")]
public string Description { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter must be in the InputObject poarameter set - when someone supplies an InputObject, they should be able to override any particular property using the parameters. This enables scenarios like:

Get-AzActionRule | Select {...} | Set-AzActionRule -Status Disabled

This is explicitly called out in the sample Set cmdlet here: https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/examples/set-cmdlet-example.md although it is fine to simply use the passed-in object and override its properties with the specified ones.

[Parameter(Mandatory = false,
ParameterSetName = AlertsListByTargetResourceGroupFilterParameterSet,
HelpMessage = "Filter on Moniter Service")]
[Parameter(Mandatory = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification note for the future (not a required change now) Optional parameters that occur in every parameter set just need a single parameter attribute with no parametersetname

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll prefer mentioning explicitly initially to avoid confusion.

[Parameter(Mandatory = false,
ParameterSetName = AlertsListByTargetResourceGroupFilterParameterSet,
HelpMessage = "Include EgressConfig - true/false")]
public bool IncludeEgressConfig { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my above response. InputObject parameter set for Set cmdlets should include all the non-identity parameters. This allows a user to override proeprties of an input object in piping scenarios.

@markcowl
Copy link
Member

/azp run azure-powershell - powershell-core

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

[Parameter(Mandatory = false,
ParameterSetName = BySimplifiedFormatDiagnosticsActionRuleParameterSet,
HelpMessage = "Description of Action Rule")]
public string Description { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is deferred until GA

HelpMessage = "Status of Action Rule.")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter("Enabled", "Disabled")]
public string Status { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is deferred until GA

[Parameter(ParameterSetName = ByInputObjectParameterSet, Mandatory = false, HelpMessage = "Action rule status")]
[Parameter(ParameterSetName = ByNameSimplifiedPatchParameterSet, Mandatory = false, HelpMessage = "Action rule status")]
[PSArgumentCompleter(ActionRuleStatus.Enabled, ActionRuleStatus.Disabled)]
public string Status { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: this should be split into Enable/Disable cmdlets, since there is no other function of the update cmdlet.

[Parameter(Mandatory = false,
ParameterSetName = AlertsListByTargetResourceGroupFilterParameterSet,
HelpMessage = "Include EgressConfig - true/false")]
public bool IncludeEgressConfig { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated for GA

@markcowl markcowl merged commit cb0c1c4 into Azure:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants