Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/keboola/actions/get-bucket-detail/get-bucket-detail.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-get-bucket-detail",
name: "Get Bucket Detail",
description: "Get detailed information about a specific bucket in Keboola. [See the documentation](https://keboola.docs.apiary.io/#reference/buckets/manage-bucket/bucket-detail)",
version: "0.0.1",
type: "action",
props: {
keboola,
bucketId: {
propDefinition: [
keboola,
"bucketId",
],
},
},
async run({ $ }) {
const response = await this.keboola.getBucketDetails({
$,
bucketId: this.bucketId,
});

$.export("$summary", `Successfully retrieved bucket details for bucket ID: ${this.bucketId}`);
return response;
},
};
35 changes: 35 additions & 0 deletions components/keboola/actions/get-table-detail/get-table-detail.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-get-table-detail",
name: "Get Table Detail",
description: "Get detailed information about a specific table. [See the documentation](https://keboola.docs.apiary.io/#reference/tables/manage-tables/table-detail)",
version: "0.0.1",
type: "action",
props: {
keboola,
bucketId: {
propDefinition: [
keboola,
"bucketId",
],
},
tableId: {
propDefinition: [
keboola,
"tableId",
(c) => ({
bucketId: c.bucketId,
}),
],
},
},
async run({ $ }) {
const response = await this.keboola.getTableDetails({
$,
tableId: this.tableId,
});
$.export("$summary", `Successfully retrieved details for table ID: ${this.tableId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-retrieve-bucket-tables",
name: "List Tables In Bucket",
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)",
version: "0.0.1",
type: "action",
props: {
keboola,
bucketId: {
propDefinition: [
keboola,
"bucketId",
],
},
},
async run({ $ }) {
const tables = await this.keboola.listTablesInBucket({
$,
bucketId: this.bucketId,
});
$.export("$summary", `Successfully retrieved ${tables.length} tables from bucket ${this.bucketId}.`);
return tables;
},
};
20 changes: 20 additions & 0 deletions components/keboola/actions/retrieve-buckets/retrieve-buckets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-retrieve-buckets",
name: "Retrieve Buckets",
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)",
version: "0.0.1",
type: "action",
props: {
keboola,
},
async run({ $ }) {
const buckets = await this.keboola.listBuckets({
$,
});

$.export("$summary", `Successfully retrieved ${buckets.length} buckets.`);
return buckets;
},
};
53 changes: 53 additions & 0 deletions components/keboola/actions/update-bucket/update-bucket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-update-bucket",
name: "Update Bucket",
description: "Updates a bucket with a new display name in Keboola. [See the documentation](https://keboola.docs.apiary.io/)",
version: "0.0.1",
type: "action",
props: {
keboola,
bucketId: {
propDefinition: [
keboola,
"bucketId",
],
reloadProps: true,
},
displayName: {
type: "string",
label: "Display Name",
description: "The new display name for the bucket",
},
color: {
type: "string",
label: "Color",
description: "The new color for the bucket. Format: #RRGGBB",
optional: true,
},
},
async additionalProps(props) {
if (this.bucketId) {
const bucket = await this.keboola.getBucketDetails({
bucketId: this.bucketId,
});
props.displayName.default = bucket.displayName;
props.color.default = bucket.color || "";
}
return {};
},
async run({ $ }) {
const response = await this.keboola.updateBucket({
$,
bucketId: this.bucketId,
data: {
displayName: this.displayName,
color: this.color,
},
});

$.export("$summary", `Successfully updated bucket with ID ${this.bucketId} to have new display name: "${this.displayName}"`);
return response;
},
};
53 changes: 53 additions & 0 deletions components/keboola/actions/update-table-name/update-table-name.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import keboola from "../../keboola.app.mjs";

export default {
key: "keboola-update-table-name",
name: "Update Table Name",
description: "Update the name of a table. [See the documentation](https://keboola.docs.apiary.io/#reference/tables/manage-tables/table-update)",
version: "0.0.1",
type: "action",
props: {
keboola,
bucketId: {
propDefinition: [
keboola,
"bucketId",
],
},
tableId: {
propDefinition: [
keboola,
"tableId",
(c) => ({
bucketId: c.bucketId,
}),
],
reloadProps: true,
},
displayName: {
type: "string",
label: "Display Name",
description: "The new display name for the table",
},
},
async additionalProps(props) {
if (this.tableId) {
const table = await this.keboola.getTableDetails({
tableId: this.tableId,
});
props.displayName.default = table.displayName;
}
return {};
},
async run({ $ }) {
const response = await this.keboola.updateTable({
$,
tableId: this.tableId,
data: {
displayName: this.displayName,
},
});
$.export("$summary", `Successfully updated table name to ${this.displayName}`);
return response;
},
};
106 changes: 102 additions & 4 deletions components/keboola/keboola.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,109 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "keboola",
propDefinitions: {},
propDefinitions: {
bucketId: {
type: "string",
label: "Bucket ID",
description: "The ID of the bucket",
async options() {
const buckets = await this.listBuckets();
return buckets.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
tableId: {
type: "string",
label: "Table ID",
description: "The ID of the table",
async options({ bucketId }) {
const tables = await this.listTablesInBucket({
bucketId,
});
return tables.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://${this.$auth.stack_endpoint}/v2/storage`;
},
_headers() {
return {
"x-storageapi-token": `${this.$auth.api_token}`,
"content-type": "multipart/form-data",
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
listBuckets(opts = {}) {
return this._makeRequest({
path: "/buckets",
...opts,
});
},
getBucketDetails({
bucketId, ...opts
}) {
return this._makeRequest({
path: `/buckets/${bucketId}`,
...opts,
});
},
listTablesInBucket({
bucketId, ...opts
}) {
return this._makeRequest({
path: `/buckets/${bucketId}/tables`,
...opts,
});
},
getTableDetails({
tableId, ...opts
}) {
return this._makeRequest({
path: `/tables/${tableId}`,
...opts,
});
},
updateBucket({
bucketId, displayName, ...opts
}) {
return this._makeRequest({
method: "PUT",
path: `/buckets/${bucketId}`,
data: {
displayName,
},
...opts,
});
},
updateTable({
tableId, ...opts
}) {
return this._makeRequest({
method: "PUT",
path: `/tables/${tableId}`,
...opts,
});
},
},
};
7 changes: 5 additions & 2 deletions components/keboola/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/keboola",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Keboola Components",
"main": "keboola.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
8 changes: 6 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading