Skip to content

Commit cf3b217

Browse files
feat(DMD-739): Add workspace unload endpoint
- Create new WorkspaceUnloadAction controller with component validation - Validate keboola.snowflake-transformation component configuration exists - Parse storage.output.tables for outputMappingStrategy: direct-grant - Return array of jobs instead of single job - Add queueUnload() method to PHP client Workspaces class - Update apiary.apib documentation for new endpoint - Support only-direct-grants query parameter This is a placeholder implementation for DMD-739. Several requirements need clarification from the product team: - What should the jobs actually do? - How should only-direct-grants parameter filter behavior? - Verify storage.output.tables is the correct configuration path - Clarify outputMappingStrategy meaning in transformation context Co-Authored-By: Martin Zajic <ja@mzajic.cz>
1 parent 4acd0ad commit cf3b217

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

apiary.apib

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,6 +5826,63 @@ Delete specified workspace credentials. User will be invalidated
58265826
58275827
58285828
5829+
## Workspace Unload [/v2/storage/workspaces/{workspace_id}/unload]
5830+
5831+
### Unload workspace data [POST]
5832+
5833+
Validates Snowflake transformation component configuration and examines output mapping strategies for direct-grant tables.
5834+
Returns an array of jobs instead of a single job.
5835+
5836+
+ Parameters
5837+
+ workspace_id (required, number) - Workspace ID
5838+
5839+
+ Attributes
5840+
+ only-direct-grants (optional, boolean) - Filter for direct-grant tables only
5841+
Default: false
5842+
5843+
+ Request (application/json)
5844+
+ Headers
5845+
5846+
X-StorageApi-Token: your_token
5847+
5848+
+ Response 202 (application/json)
5849+
+ Body
5850+
5851+
[
5852+
{
5853+
"id": 75682260,
5854+
"status": "created",
5855+
"url": "https://connection.keboola.com/v2/storage/jobs/75682260",
5856+
"tableId": null,
5857+
"operationName": "workspaceUnload",
5858+
"operationParams": {
5859+
"workspaceId": "504345774",
5860+
"table": {
5861+
"source": "out.c-bucket.table1",
5862+
"outputMappingStrategy": "direct-grant"
5863+
},
5864+
"onlyDirectGrants": false
5865+
},
5866+
"createdTime": "2025-10-22T10:15:52+0200",
5867+
"startTime": null,
5868+
"endTime": null,
5869+
"runId": null,
5870+
"results": null,
5871+
"creatorToken": {
5872+
"id": "27978",
5873+
"description": "user@keboola.com"
5874+
},
5875+
"metrics": {
5876+
"inCompressed": false,
5877+
"inBytes": 0,
5878+
"inBytesUncompressed": 0,
5879+
"outCompressed": false,
5880+
"outBytes": 0,
5881+
"outBytesUncompressed": 0
5882+
}
5883+
}
5884+
]
5885+
58295886
## Data Structures
58305887
58315888
### Workspace

src/Keboola/StorageApi/Workspaces.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ public function queueWorkspaceCloneInto(int $id, array $options = []): int
187187
return (int) $job['id'];
188188
}
189189

190+
/**
191+
* Queue workspace unload operation
192+
*
193+
* @param int $id Workspace ID
194+
* @param array $options Optional parameters (e.g., only-direct-grants)
195+
* @return array Array of job IDs
196+
*/
197+
public function queueUnload(int $id, array $options = []): array
198+
{
199+
$url = "workspaces/{$id}/unload";
200+
if (!empty($options)) {
201+
$url .= '?' . http_build_query($options);
202+
}
203+
204+
$jobs = $this->client->apiPostJson($url, [], false);
205+
assert(is_array($jobs));
206+
207+
return array_map(fn($job) => (int)$job['id'], $jobs);
208+
}
209+
190210
public function executeQuery(int $id, string $query): array
191211
{
192212
$result = $this->client->apiPostJson(

0 commit comments

Comments
 (0)