-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[containerapp] Add new commands for httprouteconfig #8302
base: main
Are you sure you want to change the base?
Conversation
Validation for Breaking Change Starting...
Thanks for your contribution! |
Hi @Tratcher, |
Thank you for your contribution! We will review the pull request and get back to you soon. |
CodeGen Tools Feedback CollectionThank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey |
Hi @Tratcher Release SuggestionsModule: containerapp
Notes
|
Can you add a test? This was for maintenance config which was also env level resource similar to Line 30 in 207cad1
list: Line 45 in 207cad1
update: Line 55 in 207cad1
delete: Line 69 in 207cad1
|
@@ -37,6 +37,13 @@ def load_command_table(self, args): | |||
g.custom_command('delete', 'delete_managed_environment', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory()) | |||
g.custom_command('update', 'update_managed_environment', supports_no_wait=True, exception_handler=ex_handler_factory()) | |||
|
|||
with self.command_group('containerapp env httprouteconfig') as g: |
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.
with self.command_group('containerapp env httprouteconfig') as g: | |
with self.command_group('containerapp env http-route-config') as g: |
with self.command_group('containerapp env httprouteconfig') as g: | |
with self.command_group('containerapp env httprouteconfig') as g: |
@@ -37,6 +37,13 @@ def load_command_table(self, args): | |||
g.custom_command('delete', 'delete_managed_environment', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory()) | |||
g.custom_command('update', 'update_managed_environment', supports_no_wait=True, exception_handler=ex_handler_factory()) | |||
|
|||
with self.command_group('containerapp env httprouteconfig') as g: |
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.
with self.command_group('containerapp env httprouteconfig') as g: | |
with self.command_group('containerapp env httprouteconfig', is_preview=True) as g: |
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.
For new commands, we always recommend to support in preview mode first
@@ -3322,3 +3322,43 @@ def list_maintenance_config(cmd, resource_group_name, env_name): | |||
) | |||
r = maintenance_config_decorator.list() | |||
return r | |||
|
|||
|
|||
def update_httprouteconfig(cmd, resource_group_name, name, httprouteconfig_name, yaml): |
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.
Please add help description for your command parameters according to https://github.com/Azure/azure-cli/blob/main/doc/authoring_command_modules/authoring_commands.md#customize-arguments
JMESPathCheck('properties.rules[0].targets[0].containerApp', "app1"), | ||
]) | ||
|
||
self.cmd("az containerapp env httprouteconfig show -g {} -n {} --httprouteconfig-name {}".format(resource_group, env_name, route_name), checks=[ |
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.
add short name for --httproutconfig-name
for better user experience according to https://github.com/Azure/azure-cli/blob/main/doc/authoring_command_modules/authoring_commands.md#customize-arguments
@classmethod | ||
def update_httprouteconfig(cls, cmd, resource_group_name, name, httprouteconfig_name, httprouteconfig_envelope): | ||
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
sub_id = get_subscription_id(cmd.cli_ctx) | ||
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/httpRouteConfigs/{}?api-version={}" | ||
request_url = url_fmt.format( | ||
management_hostname.strip('/'), | ||
sub_id, | ||
resource_group_name, | ||
name, | ||
httprouteconfig_name, | ||
cls.api_version) | ||
|
||
r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(httprouteconfig_envelope)) | ||
return r.json() | ||
|
||
@classmethod | ||
def list_httprouteconfigs(cls, cmd, resource_group_name, name, formatter=lambda x: x): | ||
route_list = [] | ||
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
sub_id = get_subscription_id(cmd.cli_ctx) | ||
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/httpRouteConfigs?api-version={}" | ||
request_url = url_fmt.format( | ||
management_hostname.strip('/'), | ||
sub_id, | ||
resource_group_name, | ||
name, | ||
cls.api_version) | ||
|
||
r = send_raw_request(cmd.cli_ctx, "GET", request_url, body=None) | ||
j = r.json() | ||
for route in j["value"]: | ||
formatted = formatter(route) | ||
route_list.append(formatted) | ||
return route_list | ||
|
||
@classmethod | ||
def show_httprouteconfig(cls, cmd, resource_group_name, name, httprouteconfig_name): | ||
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
sub_id = get_subscription_id(cmd.cli_ctx) | ||
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/httpRouteConfigs/{}?api-version={}" | ||
request_url = url_fmt.format( | ||
management_hostname.strip('/'), | ||
sub_id, | ||
resource_group_name, | ||
name, | ||
httprouteconfig_name, | ||
cls.api_version) | ||
|
||
r = send_raw_request(cmd.cli_ctx, "GET", request_url, body=None) | ||
return r.json() | ||
|
||
@classmethod | ||
def delete_httprouteconfig(cls, cmd, resource_group_name, name, httprouteconfig_name): | ||
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
sub_id = get_subscription_id(cmd.cli_ctx) | ||
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/httpRouteConfigs/{}?api-version={}" | ||
request_url = url_fmt.format( | ||
management_hostname.strip('/'), | ||
sub_id, | ||
resource_group_name, | ||
name, | ||
httprouteconfig_name, | ||
cls.api_version) | ||
|
||
send_raw_request(cmd.cli_ctx, "DELETE", request_url, body=None) | ||
# API doesn't return JSON (it returns no content) | ||
return | ||
|
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.
Recommend using a separate Client for /httpRouteConfigs
, you can refer class StorageClient()
|
||
r = send_raw_request(cmd.cli_ctx, "GET", request_url, body=None) | ||
j = r.json() | ||
for route in j["value"]: |
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 may throw None Error if j["value"]
is None
.
return r.json() | ||
|
||
@classmethod | ||
def delete_httprouteconfig(cls, cmd, resource_group_name, name, httprouteconfig_name): |
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.
def delete_httprouteconfig(cls, cmd, resource_group_name, name, httprouteconfig_name): | |
def delete(cls, cmd, resource_group_name, name, httprouteconfig_name): |
return r.json() | ||
|
||
@classmethod | ||
def list_httprouteconfigs(cls, cmd, resource_group_name, name, formatter=lambda x: x): |
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.
def list_httprouteconfigs(cls, cmd, resource_group_name, name, formatter=lambda x: x): | |
def list(cls, cmd, resource_group_name, name, formatter=lambda x: x): |
@@ -4,6 +4,7 @@ Release History | |||
=============== | |||
upcoming | |||
++++++ | |||
* 'az containerapp env httprouteconfig' Add comands for the httprouteconfig feature area. |
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.
* 'az containerapp env httprouteconfig' Add comands for the httprouteconfig feature area. | |
* 'az containerapp env httprouteconfig': Add comands for the httprouteconfig feature area. |
return r.json() | ||
|
||
@classmethod | ||
def list_httprouteconfigs(cls, cmd, resource_group_name, name, formatter=lambda x: x): |
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.
Why you need the formatter here? Seems lambda x: x
do nothing.
This adds list/create/update/show/delete commands for the new httprouteconfig feature area. For now create/update uses YAML input because the object model is quite complex. We may add more granular input in the future.
Related command
az containerapp env httprouteconfig
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally? (pip install wheel==0.30.0
required)About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.json
automatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json
.