Skip to content

Commit

Permalink
Use DELETE /assets/<id> for deleting files and secrets (#9551)
Browse files Browse the repository at this point in the history
- Closes #9288
  • Loading branch information
radeusgd authored Mar 26, 2024
1 parent 7098c5e commit 431a055
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 431a055

Please sign in to comment.