Skip to content

Added new cmdlets for flowLog resource #11193

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 3 commits into from
Mar 1, 2020
Merged

Added new cmdlets for flowLog resource #11193

merged 3 commits into from
Mar 1, 2020

Conversation

irrogozh
Copy link
Member

@irrogozh irrogozh commented Feb 26, 2020

Description

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:

@wyunchi-ms
Copy link
Contributor

{
base.Execute();

if (ParameterSetName.Contains("SetByResourceId"))
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to set ParameterSetName as const and use string equal to check the condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

private void ValidateInput()
{
string[] splittedTargetResourceId = this.TargetResourceId.Split('/');
if (splittedTargetResourceId.Count() < 9 || string.IsNullOrEmpty(splittedTargetResourceId[7]) || !splittedTargetResourceId[7].Equals("networkSecurityGroups", StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

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

9 and 7 seems a magic number. It's better to create a function handle the logic of spliting StorageResourceId.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

return NetworkResourceManagerProfile.Mapper.Map<PSFlowLogResource>(flowLogResult);
}

private void ValidateInput()
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is same with AddAzNetworkWatcherFlowLogCommand, you can move it into base class and reuse it.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

string parent = flowLogInfo.ParentResource;
string[] tokens = parent.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

this.NetworkWatcherName = tokens[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

What if tokens length is 0?

Copy link
Member Author

@irrogozh irrogozh Feb 26, 2020

Choose a reason for hiding this comment

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

added validation

@wyunchi-ms
Copy link
Contributor

Hi @irrogozh , could you please also add test case and help files for these cmdlets.

@wyunchi-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@wyunchi-ms wyunchi-ms merged commit dbc622c into Azure:network-january Mar 1, 2020
dingmeng-xue pushed a commit to dingmeng-xue/azure-powershell that referenced this pull request Mar 29, 2020
Added new cmdlets for flowLog resource
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.

2 participants