-
Notifications
You must be signed in to change notification settings - Fork 0
Implement filter & select in activity-logs and tenant-activity-logs #3
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
Conversation
tjprescott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few changes--a few questions.
| return result_time | ||
|
|
||
|
|
||
| def list_activity_logs(client, correlation_id=None, resource_group=None, resource_uri=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource_uri is not a URI--at least from your example, it is a resource ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahaa then i've been calling it wrong at all the places. Let me update that to resource_id
|
|
||
| if present_switch > 1: | ||
| raise CLIError("'--correlation-id', '--resource-group', '--resource-uri'" | ||
| " and '--resource-provider' are optional and mutually exclusive.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more consistent error string would be: "usage error: [--correlation-id ID | --resource-group NAME | --resource-id ID | --resource-provider PROVIDER]" This fits with the argparse nomenclature and usage string syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| for param in [correlation_id, resource_group, resource_uri, resource_provider]: | ||
| present_switch = present_switch + (1 if param else 0) | ||
|
|
||
| if present_switch > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify lines 120-124 this with the more Pythonic: if len([x for x in [...] if x]) > 1:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
| formatter=formatter) | ||
|
|
||
| if correlation_id: | ||
| odata_filters = _process_prameter(odata_filters, 'correlation_id', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: _process_parameter
Additionally that is not a very descriptive name. Perhaps something like "_build_odata_filter"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| caller, 'caller') | ||
| if status: | ||
| odata_filters = _process_prameter(odata_filters, 'status', | ||
| status, 'status') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like all of the validation and filter building can and should be done within a validator. This would make it easier to test with unit tests, which is the direction we will be increasingly moving toward.
|
|
||
| def _add_condition_if_present(default_filter, field_label, field_value): | ||
| if not field_value: | ||
| return default_filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it the purpose of this if "_process_parameter" already throws an error if the thing in question is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup i can just say _add_condition and format as long as we have field_value because function _process_prarameter would have thrown if field_value is not there.
derekbekoe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@tjprescott I've addressed review comments, let me know how does changes look now :) Thanks! |
tjprescott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Thanks for the review guys!! |
Usage
Example 1:
Example 2:
Example(s):
XPlat CLI Reference: https://github.com/Azure/azure-xplat-cli/blob/bea341b53149246fb61b95883aa34b72a7e980f2/lib/commands/arm/insights/insights._js#L33
@troydai @tjprescott @derekbekoe Please review the PR when you get a chance. Thanks!