-
Notifications
You must be signed in to change notification settings - Fork 1.6k
EventGrid CLI extension: Updates to support new preview API version features #331
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
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4232865
Fixes based on bugbash
kalyanaj fe349e2
Support for new set of domain commands, updates to event subscription…
kalyanaj f358dfc
Improved the usability of event-subscription operations by standardiz…
kalyanaj bd228ac
Bug fixes from bugbash
2d55e87
Merge branch 'master' of https://github.com/Azure/azure-cli-extensions
kalyanaj 3ddd370
Merge branch 'master' of https://github.com/kalyanaj/azure-cli-extens…
kalyanaj d0cfe99
Updated test recordings.
kalyanaj 82f2015
Merge remote-tracking branch 'upstream/master'
kalyanaj 23b57ee
Linter fixes
kalyanaj 1d71a20
Merge remote-tracking branch 'upstream/master'
kalyanaj c39ab22
Deprecated topic-name, RG name, resourceid for EventSubscription crud…
kalyanaj af461e0
Adding back deprecated arguments to eventsubscription list.
kalyanaj 97ab9fb
Linter fixes.
kalyanaj df3c9e0
Re-recorded the tests after adding back the tests for deprecated argu…
kalyanaj 50739d8
Linter fixes
kalyanaj 48e2e7d
Updated recordings.
kalyanaj d6c0468
Ignore import error for dateutil since static checking is happening w…
kalyanaj 26dd000
flake8 fixes.
kalyanaj 915169f
Removed duplication in _params.py per PR feedback.
kalyanaj f3417f2
Fixed a flake8 issue.
kalyanaj 023e6da
Add a missing hide=True deprecation info for one parameter.
kalyanaj 6a051cf
Updated minCliCoreVersion to 2.0.48 due to the Knack 0.4.4 dependency.
kalyanaj c8c3188
Updating minCliCoreVersion to 2.0.49
kalyanaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import argparse | ||
| from knack.util import CLIError | ||
|
|
||
| from azext_eventgrid.mgmt.eventgrid.models import ( | ||
| NumberGreaterThanAdvancedFilter, | ||
| NumberGreaterThanOrEqualsAdvancedFilter, | ||
| NumberInAdvancedFilter, | ||
| NumberLessThanAdvancedFilter, | ||
| NumberLessThanOrEqualsAdvancedFilter, | ||
| NumberNotInAdvancedFilter, | ||
| StringBeginsWithAdvancedFilter, | ||
| StringContainsAdvancedFilter, | ||
| StringEndsWithAdvancedFilter, | ||
| StringInAdvancedFilter, | ||
| StringNotInAdvancedFilter, | ||
| BoolEqualsAdvancedFilter) | ||
|
|
||
| NUMBERIN = "NumberIn" | ||
| NUMBERNOTIN = "NumberNotIn" | ||
| STRINGIN = "StringIn" | ||
| STRINGNOTIN = "StringNotIn" | ||
| STRINGBEGINSWITH = "StringBeginsWith" | ||
| STRINGCONTAINS = "StringContains" | ||
| STRINGENDSWITH = "StringEndsWith" | ||
| NUMBERGREATERTHAN = "NumberGreaterThan" | ||
| NUMBERGREATERTHANOREQUALS = "NumberGreaterThanOrEquals" | ||
| NUMBERLESSTHAN = "NumberLessThan" | ||
| NUMBERLESSTHANOREQUALS = "NumberLessThanOrEquals" | ||
| BOOLEQUALS = "BoolEquals" | ||
|
|
||
| # pylint: disable=protected-access | ||
| # pylint: disable=too-few-public-methods | ||
| class EventSubscriptionAddFilter(argparse._AppendAction): | ||
| def __call__(self, parser, namespace, values, option_string=None): | ||
| if len(values) < 3: | ||
| raise CLIError('usage error: --advanced-filter KEY[.INNERKEY] FILTEROPERATOR VALUE [VALUE ...]') | ||
|
|
||
| key = values[0] | ||
| operator = values[1] | ||
|
|
||
| # operators that support single value | ||
| if operator.lower() == NUMBERLESSTHAN.lower(): | ||
| _validate_only_single_value_is_specified(NUMBERLESSTHAN, values) | ||
| advanced_filter = NumberLessThanAdvancedFilter(key=key, value=float(values[2])) | ||
| elif operator.lower() == NUMBERLESSTHANOREQUALS.lower(): | ||
| _validate_only_single_value_is_specified(NUMBERLESSTHANOREQUALS, values) | ||
| advanced_filter = NumberLessThanOrEqualsAdvancedFilter(key=key, value=float(values[2])) | ||
| elif operator.lower() == NUMBERGREATERTHAN.lower(): | ||
| _validate_only_single_value_is_specified(NUMBERGREATERTHAN, values) | ||
| advanced_filter = NumberGreaterThanAdvancedFilter(key=key, value=float(values[2])) | ||
| elif operator.lower() == NUMBERGREATERTHANOREQUALS.lower(): | ||
| _validate_only_single_value_is_specified(NUMBERGREATERTHANOREQUALS, values) | ||
| advanced_filter = NumberGreaterThanOrEqualsAdvancedFilter(key=key, value=float(values[2])) | ||
| elif operator.lower() == BOOLEQUALS.lower(): | ||
| _validate_only_single_value_is_specified(BOOLEQUALS, values) | ||
| advanced_filter = BoolEqualsAdvancedFilter(key=key, value=bool(values[2])) | ||
|
|
||
| # operators that support multiple values | ||
| elif operator.lower() == NUMBERIN.lower(): | ||
| float_values = [float(i) for i in values[2:]] | ||
| advanced_filter = NumberInAdvancedFilter(key=key, values=float_values) | ||
| elif operator.lower() == NUMBERNOTIN.lower(): | ||
| float_values = [float(i) for i in values[2:]] | ||
| advanced_filter = NumberNotInAdvancedFilter(key=key, values=float_values) | ||
| elif operator.lower() == STRINGIN.lower(): | ||
| advanced_filter = StringInAdvancedFilter(key=key, values=values[2:]) | ||
| elif operator.lower() == STRINGNOTIN.lower(): | ||
| advanced_filter = StringNotInAdvancedFilter(key=key, values=values[2:]) | ||
| elif operator.lower() == STRINGBEGINSWITH.lower(): | ||
| advanced_filter = StringBeginsWithAdvancedFilter(key=key, values=values[2:]) | ||
| elif operator.lower() == STRINGENDSWITH.lower(): | ||
| advanced_filter = StringEndsWithAdvancedFilter(key=key, values=values[2:]) | ||
| elif operator.lower() == STRINGCONTAINS.lower(): | ||
| advanced_filter = StringContainsAdvancedFilter(key=key, values=values[2:]) | ||
| else: | ||
| raise CLIError("--advanced-filter: The specified filter operator '{}' is not" | ||
| " a valid operator. Supported values are ".format(operator) + | ||
| NUMBERIN + "," + NUMBERNOTIN + "," + STRINGIN + "," + | ||
| STRINGNOTIN + "," + STRINGBEGINSWITH + "," + | ||
| STRINGCONTAINS + "," + STRINGENDSWITH + "," + | ||
| NUMBERGREATERTHAN + "," + NUMBERGREATERTHANOREQUALS + "," + | ||
| NUMBERLESSTHAN + "," + NUMBERLESSTHANOREQUALS + "," + BOOLEQUALS + ".") | ||
| if namespace.advanced_filter is None: | ||
| namespace.advanced_filter = [] | ||
| namespace.advanced_filter.append(advanced_filter) | ||
|
|
||
|
|
||
| def _validate_only_single_value_is_specified(operator_type, values): | ||
| if len(values) != 3: | ||
| raise CLIError("--advanced-filter: For '{}' operator, only one filter value " | ||
| "must be specified.".format(operator_type)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would be good to extract this common info to a CliCommandType so that if you have to change it later, it is changed everywhere.
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.
Thanks for the feedback, I have updated this now to remove this duplication.