From 431a0556082698a85feb9c1fe02376eec95d5dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 26 Mar 2024 22:48:17 +0100 Subject: [PATCH] Use `DELETE /assets/` for deleting files and secrets (#9551) - Closes #9288 --- .../Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso | 8 +++++++- .../Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso | 8 +++++++- .../0.0.0-dev/src/Enso_Cloud/Internal/Utils.enso | 12 ++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso index 5e0f742c6a35..49101c6fdcd7 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso @@ -23,6 +23,7 @@ import project.Errors.Time_Error.Time_Error import project.Errors.Unimplemented.Unimplemented import project.Network.HTTP.HTTP import project.Network.HTTP.HTTP_Method.HTTP_Method +import project.Network.URI.URI import project.Nothing.Nothing import project.Runtime import project.Runtime.Context @@ -310,7 +311,8 @@ type Enso_File Deletes the file or directory. delete : Nothing delete self = if self.id == "" then Error.throw (Illegal_Argument.Error "The root directory cannot be deleted.") else - response = Utils.http_request HTTP_Method.Delete self.internal_uri + uri = URI.from (asset_uri self) . add_query_argument "force" "true" + response = Utils.http_request HTTP_Method.Delete uri response.if_not_error Nothing ## ICON data_output @@ -427,3 +429,7 @@ get_download_url_for_file file:Enso_File -> Text = file_description = get_file_description file presigned_url = file_description |> get_required_field "url" expected_type=Text presigned_url + +## PRIVATE +asset_uri : Text +asset_uri file:Enso_File = Utils.assets_api + "/" + file.id diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso index 8e41fd568213..022259a22978 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso @@ -13,6 +13,7 @@ import project.Errors.Illegal_Argument.Illegal_Argument import project.Network.HTTP.HTTP import project.Network.HTTP.HTTP_Method.HTTP_Method import project.Network.HTTP.Request_Body.Request_Body +import project.Network.URI.URI import project.Nothing.Nothing import project.Runtime.Context from project.Data.Boolean import Boolean, False, True @@ -57,7 +58,8 @@ type Enso_Secret delete : Enso_Secret delete self = Context.Output.if_enabled disabled_message="Deleting a secret is forbidden as the Output context is disabled." panic=False <| - response = Utils.http_request HTTP_Method.Delete (secret_resource_uri self) + uri = URI.from (secret_asset_uri self) . add_query_argument "force" "true" + response = Utils.http_request HTTP_Method.Delete uri response.if_not_error self ## GROUP Input @@ -195,3 +197,7 @@ as_hideable_value (value : Text | Enso_Secret | Derived_Secret_Value) = case val ## PRIVATE secret_resource_uri secret = Utils.secrets_api + "/" + secret.id + +## PRIVATE +secret_asset_uri secret = + Utils.assets_api + "/" + secret.id diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Utils.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Utils.enso index 52ca951d4cfe..a91dd1e1be03 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Utils.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Utils.enso @@ -39,22 +39,26 @@ authorization_header = ## PRIVATE Root address for listing folders +assets_api = cloud_root_uri + "assets" + +## PRIVATE + Root address for listing folders. directory_api = cloud_root_uri + "directories" ## PRIVATE - Root address for listing folders + Root address for file details metadata. files_api = cloud_root_uri + "files" ## PRIVATE - Root address for listing folders + Root address for project information. projects_api = cloud_root_uri + "projects" ## PRIVATE - Root address for Secrets API + Root address for Secrets API. secrets_api = cloud_root_uri + "secrets" ## PRIVATE - Root address for DataLinks API + Root address for DataLinks API. datalinks_api = cloud_root_uri + "connectors" ## PRIVATE