Skip to content

Commit b80bd24

Browse files
authored
New Components - keboola (#17157)
* keboola init * [Components] keboola #17051 Actions - Get Bucket Detail - Get Table Detail - Retrieve Bucket Tables - Retrieve Buckets - Update Bucket - Update Table Name * pnpm update * pnpm update
1 parent 32919ca commit b80bd24

File tree

9 files changed

+327
-8
lines changed

9 files changed

+327
-8
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-get-bucket-detail",
5+
name: "Get Bucket Detail",
6+
description: "Get detailed information about a specific bucket in Keboola. [See the documentation](https://keboola.docs.apiary.io/#reference/buckets/manage-bucket/bucket-detail)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
bucketId: {
12+
propDefinition: [
13+
keboola,
14+
"bucketId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.keboola.getBucketDetails({
20+
$,
21+
bucketId: this.bucketId,
22+
});
23+
24+
$.export("$summary", `Successfully retrieved bucket details for bucket ID: ${this.bucketId}`);
25+
return response;
26+
},
27+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-get-table-detail",
5+
name: "Get Table Detail",
6+
description: "Get detailed information about a specific table. [See the documentation](https://keboola.docs.apiary.io/#reference/tables/manage-tables/table-detail)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
bucketId: {
12+
propDefinition: [
13+
keboola,
14+
"bucketId",
15+
],
16+
},
17+
tableId: {
18+
propDefinition: [
19+
keboola,
20+
"tableId",
21+
(c) => ({
22+
bucketId: c.bucketId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.keboola.getTableDetails({
29+
$,
30+
tableId: this.tableId,
31+
});
32+
$.export("$summary", `Successfully retrieved details for table ID: ${this.tableId}`);
33+
return response;
34+
},
35+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-retrieve-bucket-tables",
5+
name: "List Tables In Bucket",
6+
description: "Lists all tables in a specified bucket. [See the documentation](https://keboola.docs.apiary.io/#reference/tables/create-or-list-tables/tables-in-bucket)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
bucketId: {
12+
propDefinition: [
13+
keboola,
14+
"bucketId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const tables = await this.keboola.listTablesInBucket({
20+
$,
21+
bucketId: this.bucketId,
22+
});
23+
$.export("$summary", `Successfully retrieved ${tables.length} tables from bucket ${this.bucketId}.`);
24+
return tables;
25+
},
26+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-retrieve-buckets",
5+
name: "Retrieve Buckets",
6+
description: "Lists all buckets in your Keboola project. [See the documentation](https://keboola.docs.apiary.io/#reference/buckets/create-or-list-buckets/list-all-buckets)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
},
12+
async run({ $ }) {
13+
const buckets = await this.keboola.listBuckets({
14+
$,
15+
});
16+
17+
$.export("$summary", `Successfully retrieved ${buckets.length} buckets.`);
18+
return buckets;
19+
},
20+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-update-bucket",
5+
name: "Update Bucket",
6+
description: "Updates a bucket with a new display name in Keboola. [See the documentation](https://keboola.docs.apiary.io/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
bucketId: {
12+
propDefinition: [
13+
keboola,
14+
"bucketId",
15+
],
16+
reloadProps: true,
17+
},
18+
displayName: {
19+
type: "string",
20+
label: "Display Name",
21+
description: "The new display name for the bucket",
22+
},
23+
color: {
24+
type: "string",
25+
label: "Color",
26+
description: "The new color for the bucket. Format: #RRGGBB",
27+
optional: true,
28+
},
29+
},
30+
async additionalProps(props) {
31+
if (this.bucketId) {
32+
const bucket = await this.keboola.getBucketDetails({
33+
bucketId: this.bucketId,
34+
});
35+
props.displayName.default = bucket.displayName;
36+
props.color.default = bucket.color || "";
37+
}
38+
return {};
39+
},
40+
async run({ $ }) {
41+
const response = await this.keboola.updateBucket({
42+
$,
43+
bucketId: this.bucketId,
44+
data: {
45+
displayName: this.displayName,
46+
color: this.color,
47+
},
48+
});
49+
50+
$.export("$summary", `Successfully updated bucket with ID ${this.bucketId} to have new display name: "${this.displayName}"`);
51+
return response;
52+
},
53+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import keboola from "../../keboola.app.mjs";
2+
3+
export default {
4+
key: "keboola-update-table-name",
5+
name: "Update Table Name",
6+
description: "Update the name of a table. [See the documentation](https://keboola.docs.apiary.io/#reference/tables/manage-tables/table-update)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
keboola,
11+
bucketId: {
12+
propDefinition: [
13+
keboola,
14+
"bucketId",
15+
],
16+
},
17+
tableId: {
18+
propDefinition: [
19+
keboola,
20+
"tableId",
21+
(c) => ({
22+
bucketId: c.bucketId,
23+
}),
24+
],
25+
reloadProps: true,
26+
},
27+
displayName: {
28+
type: "string",
29+
label: "Display Name",
30+
description: "The new display name for the table",
31+
},
32+
},
33+
async additionalProps(props) {
34+
if (this.tableId) {
35+
const table = await this.keboola.getTableDetails({
36+
tableId: this.tableId,
37+
});
38+
props.displayName.default = table.displayName;
39+
}
40+
return {};
41+
},
42+
async run({ $ }) {
43+
const response = await this.keboola.updateTable({
44+
$,
45+
tableId: this.tableId,
46+
data: {
47+
displayName: this.displayName,
48+
},
49+
});
50+
$.export("$summary", `Successfully updated table name to ${this.displayName}`);
51+
return response;
52+
},
53+
};

components/keboola/keboola.app.mjs

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,109 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "keboola",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
bucketId: {
8+
type: "string",
9+
label: "Bucket ID",
10+
description: "The ID of the bucket",
11+
async options() {
12+
const buckets = await this.listBuckets();
13+
return buckets.map(({
14+
id: value, name: label,
15+
}) => ({
16+
label,
17+
value,
18+
}));
19+
},
20+
},
21+
tableId: {
22+
type: "string",
23+
label: "Table ID",
24+
description: "The ID of the table",
25+
async options({ bucketId }) {
26+
const tables = await this.listTablesInBucket({
27+
bucketId,
28+
});
29+
return tables.map(({
30+
id: value, name: label,
31+
}) => ({
32+
label,
33+
value,
34+
}));
35+
},
36+
},
37+
},
538
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
39+
_baseUrl() {
40+
return `https://${this.$auth.stack_endpoint}/v2/storage`;
41+
},
42+
_headers() {
43+
return {
44+
"x-storageapi-token": `${this.$auth.api_token}`,
45+
"content-type": "multipart/form-data",
46+
};
47+
},
48+
_makeRequest({
49+
$ = this, path, ...opts
50+
}) {
51+
return axios($, {
52+
url: this._baseUrl() + path,
53+
headers: this._headers(),
54+
...opts,
55+
});
56+
},
57+
listBuckets(opts = {}) {
58+
return this._makeRequest({
59+
path: "/buckets",
60+
...opts,
61+
});
62+
},
63+
getBucketDetails({
64+
bucketId, ...opts
65+
}) {
66+
return this._makeRequest({
67+
path: `/buckets/${bucketId}`,
68+
...opts,
69+
});
70+
},
71+
listTablesInBucket({
72+
bucketId, ...opts
73+
}) {
74+
return this._makeRequest({
75+
path: `/buckets/${bucketId}/tables`,
76+
...opts,
77+
});
78+
},
79+
getTableDetails({
80+
tableId, ...opts
81+
}) {
82+
return this._makeRequest({
83+
path: `/tables/${tableId}`,
84+
...opts,
85+
});
86+
},
87+
updateBucket({
88+
bucketId, displayName, ...opts
89+
}) {
90+
return this._makeRequest({
91+
method: "PUT",
92+
path: `/buckets/${bucketId}`,
93+
data: {
94+
displayName,
95+
},
96+
...opts,
97+
});
98+
},
99+
updateTable({
100+
tableId, ...opts
101+
}) {
102+
return this._makeRequest({
103+
method: "PUT",
104+
path: `/tables/${tableId}`,
105+
...opts,
106+
});
9107
},
10108
},
11109
};

components/keboola/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/keboola",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Keboola Components",
55
"main": "keboola.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)