Skip to content

Commit 042c65e

Browse files
Merge pull request #1553 from keboola/roman/pat-663-new-component-detail-endpoint
Roman/pat 663 new component detail endpoint
2 parents fd1893e + 0d8cf3c commit 042c65e

3 files changed

Lines changed: 182 additions & 2 deletions

File tree

apiary.apib

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7377,11 +7377,78 @@ Use this API call to obtain the definition of component for [Development Branch]
73777377
"uri": "https://syrup.keboola.com/docker/keboola.app-tree",
73787378
}
73797379
7380-
### Get component - without branch in URL (deprecated) [GET]
7380+
### Get component - without branch in URL (without authentification) [GET]
7381+
7382+
**Without authentication**, you can call this endpoint without the `X-StorageApi-Token` and still get the component details.
7383+
7384+
+ Parameters
7385+
+ componentId - Component ID - e.g. `keboola.app-tree`
73817386
7382-
***Deprecated**, use the branch endpoint and set `branch/default`.*
73837387
73847388
+ Response 200
7389+
+ Headers
7390+
7391+
Content-type: application/json
7392+
+ Body
7393+
7394+
{
7395+
"id": "keboola.app-tree",
7396+
"type": "application",
7397+
"name": "Tree depth",
7398+
"description": "Application which computes a tree depth.",
7399+
"longDescription": "This application computes levels in a table representing a tree (e.g. product categories). The tree data must be stored in a child-parent relationship. A column named **levels** will be added to the table (root nodes will have number 1). Additionally, a column named **root** will be added, containing the ID of the root item.",
7400+
"hasUI": false,
7401+
"hasRun": false,
7402+
"ico32": "https://d3iz2gfan5zufq.cloudfront.net/images/cloud-services/keboola.app-tree-32-1.png",
7403+
"ico64": "https://d3iz2gfan5zufq.cloudfront.net/images/cloud-services/keboola.app-tree-64-1.png",
7404+
"ico128": "https://d3iz2gfan5zufq.cloudfront.net/images/cloud-services/keboola.app-tree-128-1.png",
7405+
"data": {
7406+
"definition": {
7407+
"type": "aws-ecr",
7408+
"uri": "147946154733.dkr.ecr.us-east-1.amazonaws.com/keboola/app-tree",
7409+
"tag": "latest",
7410+
"repository": {
7411+
"region": "us-east-1"
7412+
}
7413+
},
7414+
"cpu_shares": 1024,
7415+
"memory": "8024m",
7416+
"configuration_format": "json",
7417+
"process_timeout": 10800
7418+
},
7419+
"flags": [
7420+
"genericDockerUI",
7421+
"genericDockerUI-tableInput",
7422+
"genericDockerUI-tableOutput",
7423+
"excludeFromNewList"
7424+
],
7425+
"configurationSchema": {
7426+
"title": "Parameters",
7427+
"type": "object",
7428+
"properties": {
7429+
"idColumn": {
7430+
"type": "string",
7431+
"title": "ID Column",
7432+
"description": "Name of the column containing row identifier",
7433+
"default": "categoryId"
7434+
},
7435+
"parentColumn": {
7436+
"type": "string",
7437+
"title": "Parent Column",
7438+
"description": "Name of the column containing parent identifier",
7439+
"default": "categoryParentId"
7440+
}
7441+
},
7442+
"required": [
7443+
"idColumn",
7444+
"parentColumn"
7445+
]
7446+
},
7447+
"emptyConfiguration": {},
7448+
"uiOptions": {},
7449+
"configurationDescription": "The tree data must be stored in a child-parent relationship. A column named **levels** will be added to the table (root nodes will have number 1). Additionally, a column named **root** will be added, containing the ID of the root item.\n\nSample input \n-------------------\n\ncategoryId | categoryParentId\t| title\n--- | --- | --- \n1 |\t0 | foo\n2 | 1 | bar\n3 | 1 | baz\n4 | 2 | buzz\n\n\nSample output\n-------------------\n\ncategoryId | categoryParentId | title | levels | root\n--- | --- | --- | --- | --- |\n1 |\t0 | foo | 1 | 1 |\n2 | 1 | bar | 2 | 1 |\n3 | 1 | baz | 2 | 1 |\n4 | 2 | buzz | 3 | 1 |",
7450+
"uri": "https://syrup.keboola.com/docker/keboola.app-tree",
7451+
}
73857452
73867453
## Get components [/v2/storage/components]
73877454
### Get components [GET /v2/storage/branch/{branch_id}/components?include={include}&componentType={componentType}&isDeleted={isDeleted}]

src/Keboola/StorageApi/Components.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,100 @@ public function getComponent($componentId)
131131
return $this->client->apiGet($this->branchPrefix . "components/{$componentId}");
132132
}
133133

134+
/**
135+
* Get public component detail
136+
* @return array{
137+
* id: string,
138+
* type: string,
139+
* name: string,
140+
* description: string,
141+
* longDescription: string,
142+
* hasUI: bool,
143+
* hasRun: bool,
144+
* ico32: string,
145+
* ico64: string,
146+
* ico128: string,
147+
* data: array{
148+
* definition: array{
149+
* type: string,
150+
* uri: string,
151+
* tag: string,
152+
* repository: array{
153+
* region: string
154+
* }
155+
* },
156+
* cpu_shares: int,
157+
* memory: string,
158+
* configuration_format: string,
159+
* process_timeout: int
160+
* },
161+
* flags: array<string>,
162+
* configurationSchema: array{
163+
* title: string,
164+
* type: string,
165+
* properties: array<string, array{
166+
* type: string,
167+
* title: string,
168+
* description: string,
169+
* default?: string
170+
* }>,
171+
* required: array<string>
172+
* },
173+
* emptyConfiguration: array<mixed>,
174+
* uiOptions: array<mixed>,
175+
* configurationDescription: string,
176+
* uri: string
177+
* }
178+
*/
179+
public function getPublicComponentDetail(string $componentId): array
180+
{
181+
/** @var array{
182+
* id: string,
183+
* type: string,
184+
* name: string,
185+
* description: string,
186+
* longDescription: string,
187+
* hasUI: bool,
188+
* hasRun: bool,
189+
* ico32: string,
190+
* ico64: string,
191+
* ico128: string,
192+
* data: array{
193+
* definition: array{
194+
* type: string,
195+
* uri: string,
196+
* tag: string,
197+
* repository: array{
198+
* region: string
199+
* }
200+
* },
201+
* cpu_shares: int,
202+
* memory: string,
203+
* configuration_format: string,
204+
* process_timeout: int
205+
* },
206+
* flags: array<string>,
207+
* configurationSchema: array{
208+
* title: string,
209+
* type: string,
210+
* properties: array<string, array{
211+
* type: string,
212+
* title: string,
213+
* description: string,
214+
* default?: string
215+
* }>,
216+
* required: array<string>
217+
* },
218+
* emptyConfiguration: array<mixed>,
219+
* uiOptions: array<mixed>,
220+
* configurationDescription: string,
221+
* uri: string
222+
* } $result
223+
*/
224+
$result = $this->client->apiGet('components/'.$componentId);
225+
return $result;
226+
}
227+
134228
public function listComponentConfigurations(ListComponentConfigurationsOptions $options)
135229
{
136230
return $this->client->apiGet($this->branchPrefix . "components/{$options->getComponentId()}/configs?" . http_build_query($options->toParamsArray()));

tests/Common/ComponentsTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ public function setUp(): void
4444
$this->client = $this->clientProvider->createClientForCurrentTest();
4545
}
4646

47+
public function testPublicGetComponentDetail(): void
48+
{
49+
$componentId = 'wr-db';
50+
51+
$componentsClient = new \Keboola\StorageApi\Components(new Client(
52+
['url' => $this->client->getApiUrl(), 'token' => ''],
53+
));
54+
$component = $componentsClient->getPublicComponentDetail($componentId);
55+
56+
$this->assertEquals('wr-db', $component['id']);
57+
58+
$this->assertArrayHasKey('name', $component);
59+
$this->assertArrayHasKey('type', $component);
60+
$this->assertArrayHasKey('description', $component);
61+
$this->assertArrayHasKey('uri', $component);
62+
63+
$this->assertArrayNotHasKey('configurations', $component);
64+
}
65+
4766
public function testDeprecatedUrlWithoutBranchIdStillWorks(): void
4867
{
4968
/** @var array $configuration */

0 commit comments

Comments
 (0)