Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Release History
* Fix issue #11658: `az group export` command does not support `--query` and `--output` parameters
* Fix issue #10279: The exit code of `az group deployment validate` is 0 when the verification fails

**CDN**

* Add support for rulesEngine feature
* Add new commands group 'cdn endpoint rule' to manage rules
* Update azure-mgmt-cdn version to 4.0.0 to use api version 2019-04-15

**IoT**

* Deprecated 'IoT hub Job' commands.
Expand Down
110 changes: 110 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cdn/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,116 @@
--enable-compression
"""

helps['cdn endpoint rule'] = """
type: group
short-summary: Manage delivery rules for an endpoint.
"""

helps['cdn endpoint rule add'] = """
type: command
short-summary: Add a delivery rule to a CDN endpoint.
examples:
- name: Create a global rule to disable caching.
text: >
az cdn endpoint rule add -g group -n endpoint --profile-name profile --order 0\\
--rule-name global --action-name CacheExpiration --cache-behavior BypassCache
- name: Create a rule for http to https redirect
text: >
az cdn endpoint rule add -g group -n endpoint --profile-name profile --order 1\\
--rule-name "redirect" --match-variable RequestScheme --operator Equal --match-values HTTPS\\
--action-name "UrlRedirect" --redirect-protocol Https --redirect-type Moved
"""

helps['cdn endpoint rule remove'] = """
type: command
short-summary: Remove a delivery rule from an endpoint.
examples:
- name: Remove the global rule.
text: >
az cdn endpoint rule remove -g group -n endpoint --profile-name profile --rule-name Global\\
"""

helps['cdn endpoint rule show'] = """
type: command
short-summary: Show delivery rules asscociate with the endpoint.
examples:
- name: show delivery rules asscociate with the endpoint.
text: >
az cdn endpoint rule show -g group --profile-name profile-name
"""

helps['cdn endpoint rule condition'] = """
type: group
short-summary: Manage delivery rule conditions for an endpoint.
"""

helps['cdn endpoint rule condition add'] = """
type: command
short-summary: Add a condition to a delivery rule.
examples:
- name: Add a remote address condition.
text: >
az cdn endpoint rule condition add -g group -n endpoint --profile-name profile --rule-name name\\
--match-variable RemoteAddress --operator GeoMatch --match-values "TH"
"""

helps['cdn endpoint rule condition remove'] = """
type: command
short-summary: Remove a condition from a delivery rule.
examples:
- name: Remove the first condition.
text: >
az cdn endpoint rule condition remove -g group -n endpoint --profile-name profile --rule-name name\\
--index 0
"""

helps['cdn endpoint rule condition show'] = """
type: command
short-summary: show delivery rules asscociate with the endpoint.
examples:
- name: show delivery rules asscociate with the endpoint.
text: >
az cdn endpoint rule condition show -g group --profile-name profile-name
"""

helps['cdn endpoint rule action'] = """
type: group
short-summary: Manage delivery rule actions for an endpoint.
"""

helps['cdn endpoint rule action add'] = """
type: command
short-summary: Add an action to a delivery rule.
examples:
- name: Add a redirect action.
text: >
az cdn endpoint rule action add -g group -n endpoint --profile-name profile --rule-name name\\
--action-name "UrlRedirect" --redirect-protocol HTTPS --redirect-type Moved
- name: Add a cache expiration action
text: >
az cdn endpoint rule action add -g group -n endpoint --profile-name profile --rule-name name\\
--action-name "CacheExpiration" --cache-behavior BypassCache
"""

helps['cdn endpoint rule action remove'] = """
type: command
short-summary: Remove an action from a delivery rule.
examples:
- name: Remove the first action.
text: >
az cdn endpoint rule action remove -g group -n endpoint --profile-name profile --rule-name name\\
--index 0
"""

helps['cdn endpoint rule action show'] = """
type: command
short-summary: show delivery rules asscociate with the endpoint.
examples:
- name: show delivery rules asscociate with the endpoint.
text: >
az cdn endpoint rule action show -g group --profile-name profile-name
"""

helps['cdn origin'] = """
type: group
short-summary: List or show existing origins related to CDN endpoints.
Expand Down
55 changes: 55 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cdn/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_origin(self, values, option_string):
return deep_created_origin


# pylint:disable=too-many-statements
def load_arguments(self, _):

name_arg_type = CLIArgumentType(options_list=('--name', '-n'), metavar='NAME')
Expand Down Expand Up @@ -82,6 +83,60 @@ def load_arguments(self, _):
c.argument('content_types_to_compress', nargs='+')
c.argument('profile_name', help=profile_name_help, id_part='name')

with self.argument_context('cdn endpoint rule') as c:
c.argument('rule_name', help='Name of the rule.')
c.argument('order', help='The order of the rule. The order number must start from 0 and consecutive.\
Rule with higher order will be applied later.')
c.argument('match_variable', arg_group="Match Condition", help='Name of the match condition.')
c.argument('operator', arg_group="Match Condition", help='Operator of the match condition.')
c.argument('selector', arg_group="Match Condition", help='Selector of the match condition.')
c.argument('match_values', arg_group="Match Condition", nargs='+',
help='Match values of the match condition (comma separated).')
c.argument('transform', arg_group="Match Condition", arg_type=get_enum_type(['Lowercase', 'Uppercase']),
nargs='+', help='Transform to apply before matching.')
Copy link
Contributor

Choose a reason for hiding this comment

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

do you support multiple values like --transform Lowercase Uppercase? If not, please remove nargs='+

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

do you still support list of arguments like --transform Lowercase Uppercase?

c.argument('negate_condition', arg_group="Match Condition", arg_type=get_three_state_flag(),
help='If true, negates the condition')
c.argument('action_name', arg_group="Action", help='Name of the action.')
c.argument('cache_behavior', arg_group="Action",
arg_type=get_enum_type(['BypassCache', 'Override', 'SetIfMissing']),
help='Caching behavior for the requests.')
c.argument('cache_duration', arg_group="Action",
help='The duration for which the content needs to be cached. \
Allowed format is [d.]hh:mm:ss.')
c.argument('header_action', arg_group="Action",
arg_type=get_enum_type(['Append', 'Overwrite', 'Delete']),
help='Header action for the requests.')
c.argument('header_name', arg_group="Action", help='Name of the header to modify.')
c.argument('header_value', arg_group="Action", help='Value of the header.')
c.argument('redirect_type', arg_group="Action",
arg_type=get_enum_type(['Moved', 'Found', 'TemporaryRedirect', 'PermanentRedirect']),
help='The redirect type the rule will use when redirecting traffic.')
c.argument('redirect_protocol', arg_group="Action",
arg_type=get_enum_type(['MatchRequest', 'Http', 'Https']),
help='Protocol to use for the redirect.')
c.argument('custom_hostname', arg_group="Action", help='Host to redirect. \
Leave empty to use the incoming host as the destination host.')
c.argument('custom_path', arg_group="Action",
help='The full path to redirect. Path cannot be empty and must start with /. \
Leave empty to use the incoming path as destination path.')
c.argument('custom_querystring', arg_group="Action",
help='The set of query strings to be placed in the redirect URL. \
leave empty to preserve the incoming query string.')
c.argument('custom_fragment', arg_group="Action", help='Fragment to add to the redirect URL.')
c.argument('query_string_behavior', arg_group="Action",
arg_type=get_enum_type(['Include', 'IncludeAll', 'Exclude', 'ExcludeAll']),
help='Query string behavior for the requests.')
c.argument('query_parameters', arg_group="Action",
help='Query parameters to include or exclude (comma separated).')
c.argument('source_pattern', arg_group="Action",
help='A request URI pattern that identifies the type of requests that may be rewritten.')
c.argument('destination', help='The destination path to be used in the rewrite.')
c.argument('preserve_unmatched_path', arg_group="Action",
arg_type=get_three_state_flag(),
help='If True, the remaining path after the source \
pattern will be appended to the new destination path.')
c.argument('index', type=int, help='The index of the condition/action')

with self.argument_context('cdn endpoint create') as c:
c.argument('name', name_arg_type, id_part='name', help='Name of the CDN endpoint.')

Expand Down
22 changes: 22 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cdn/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
cf_edge_nodes)


# pylint: disable=too-many-statements
def load_command_table(self, _):

def _not_found(message):
Expand Down Expand Up @@ -91,6 +92,27 @@ def _inner_not_found(ex):
doc_string_source='azure.mgmt.cdn.models#EndpointUpdateParameters',
supports_no_wait=True)

with self.command_group('cdn endpoint rule', cdn_endpoints_sdk, is_preview=True) as g:
g.show_command('show', 'get')
g.custom_command('add', 'add_rule', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')
g.custom_command('remove', 'remove_rule', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')

with self.command_group('cdn endpoint rule condition', cdn_endpoints_sdk, is_preview=True) as g:
g.show_command('show', 'get')
g.custom_command('add', 'add_condition', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')
g.custom_command('remove', 'remove_condition', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')

with self.command_group('cdn endpoint rule action', cdn_endpoints_sdk, is_preview=True) as g:
g.show_command('show', 'get')
g.custom_command('add', 'add_action', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')
g.custom_command('remove', 'remove_action', client_factory=cf_cdn,
doc_string_source='azure.mgmt.cdn.models#Endpoint')

with self.command_group('cdn profile', cdn_profiles_sdk) as g:
g.show_command('show', 'get')
g.command('usage', 'list_resource_usage')
Expand Down
Loading