Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/devcenter/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
6.1.0
++++++
* Update "az devcenter dev environment delete" to include force delete

6.0.1
++++++
* Update "az devcenter dev environment show-logs-by-operation" to handle escape characters
Expand Down
6 changes: 6 additions & 0 deletions src/devcenter/azext_devcenter/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ def load_arguments(self, _):
type=str,
help="The name " "of the environment.",
)
c.argument(
"force",
arg_type=get_three_state_flag(),
help="Optional to force environment deletion even if the environment definition does not exist. "
"This is a best-effort delete, and anything custom that forces resource creation beyond the associated resource group may not be deleted.",
)

with self.argument_context("devcenter dev catalog list") as c:
c.argument(
Expand Down
2 changes: 2 additions & 0 deletions src/devcenter/azext_devcenter/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ def devcenter_environment_delete(
project_name,
no_wait=False,
user_id="me",
force=None,
dev_center=None,
endpoint=None,
):
Expand All @@ -1268,6 +1269,7 @@ def devcenter_environment_delete(
project_name=project_name,
user_id=user_id,
environment_name=environment_name,
force=force,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6227,7 +6227,7 @@ async def _delete_environment_initial(
project_name=project_name,
environment_name=environment_name,
user_id=user_id,
api_version=self._config.api_version,
api_version="2024-10-01-preview", #Overwriting while this is the only route on this version. Will remove when version bump completes.
headers=_headers,
params=_params,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,12 +1737,12 @@ def build_deployment_environments_create_or_update_environment_request(


def build_deployment_environments_delete_environment_request(
project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any
project_name: str, environment_name: str, user_id: str = "me", force: Optional[bool] = None, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here

Copy link
Owner

Choose a reason for hiding this comment

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

What is happening here is that if an api-version is not provided, it will use 2024-10-01-preview. However, it seems the default is being passed in.

accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -1778,6 +1778,8 @@ def build_deployment_environments_delete_environment_request(

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
if force is not None:
_params["force"] = _SERIALIZER.query("force", force, "bool")

# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
Expand Down Expand Up @@ -8701,7 +8703,7 @@ def get_long_running_output(pipeline_response):
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore

def _delete_environment_initial(
self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any
self, project_name: str, environment_name: str, user_id: str = "me", force: Optional[bool] = None, **kwargs: Any
) -> Optional[JSON]:
error_map = {
401: ClientAuthenticationError,
Expand All @@ -8720,7 +8722,8 @@ def _delete_environment_initial(
project_name=project_name,
environment_name=environment_name,
user_id=user_id,
api_version=self._config.api_version,
force=force,
api_version="2024-10-01-preview", #Overwriting while this is the only route on this version. Will remove when version bump completes.
headers=_headers,
params=_params,
)
Expand Down Expand Up @@ -8761,7 +8764,7 @@ def _delete_environment_initial(

@distributed_trace
def begin_delete_environment(
self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any
self, project_name: str, environment_name: str, user_id: str = "me", force: Optional[bool] = None, **kwargs: Any
) -> LROPoller[JSON]:
"""Deletes an environment and all its associated resources.

Expand All @@ -8772,6 +8775,10 @@ def begin_delete_environment(
:param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the
authentication context. Default value is "me".
:type user_id: str
:keyword force: Optional parameter to force environment deletion even if the environment definition
does not exist. This is a best-effort delete, and anything custom that forces resource creation beyond
the associated resource group may not be deleted. Default value is None.
:paramtype force: bool
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be LROBasePolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
Expand Down Expand Up @@ -8817,6 +8824,7 @@ def begin_delete_environment(
project_name=project_name,
environment_name=environment_name,
user_id=user_id,
force=force,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
Expand Down
2 changes: 1 addition & 1 deletion src/devcenter/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from setuptools import setup, find_packages

# HISTORY.rst entry.
VERSION = '6.0.1'
VERSION = '6.1.0'
try:
from azext_devcenter.manual.version import VERSION
except ImportError:
Expand Down