Skip to content

Commit 0d24898

Browse files
committed
Added actions
1 parent a7211d1 commit 0d24898

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from "../../parsehub.app.mjs";
2+
3+
export default {
4+
key: "parsehub-cancel-run",
5+
name: "Cancel Run",
6+
description: "Cancels a run and changes its status to cancelled. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#cancel-a-run)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
runToken: {
12+
propDefinition: [
13+
app,
14+
"runToken",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.cancelRun({
20+
$,
21+
runToken: this.runToken,
22+
});
23+
$.export("$summary", "Successfully cancelled the run with token: " + this.runToken);
24+
return response;
25+
},
26+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from "../../parsehub.app.mjs";
2+
3+
export default {
4+
key: "parsehub-delete-run",
5+
name: "Delete Run",
6+
description: "Cancels a run if running, and deletes the run and its data. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#delete-a-run)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
runToken: {
12+
propDefinition: [
13+
app,
14+
"runToken",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.deleteRun({
20+
$,
21+
runToken: this.runToken,
22+
});
23+
$.export("$summary", "Successfully deleted the run with token: " + this.runToken);
24+
return response;
25+
},
26+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import app from "../../parsehub.app.mjs";
2+
3+
export default {
4+
key: "parsehub-get-projects",
5+
name: "Get Projects",
6+
description: "Lists all projects in your account [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#list-all-projects)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
offset: {
12+
propDefinition: [
13+
app,
14+
"offset",
15+
],
16+
},
17+
limit: {
18+
propDefinition: [
19+
app,
20+
"limit",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.app.listProjects({
26+
$,
27+
params: {
28+
offset: this.offset,
29+
limit: this.limit,
30+
},
31+
});
32+
$.export("$summary", "Successfully listed your projects");
33+
return response;
34+
},
35+
};

components/parsehub/parsehub.app.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ export default {
2929
label: "Start URL",
3030
description: "The url to start running on",
3131
},
32+
offset: {
33+
type: "string",
34+
label: "Offset",
35+
description: "Specifies the offset from which to start listing the projects",
36+
optional: true,
37+
},
38+
limit: {
39+
type: "string",
40+
label: "Limit",
41+
description: "Specifies how many entries will be returned in the list",
42+
optional: true,
43+
},
3244
},
3345
methods: {
3446
_baseUrl() {
@@ -81,5 +93,23 @@ export default {
8193
...args,
8294
});
8395
},
96+
async cancelRun({
97+
runToken, ...args
98+
}) {
99+
return this._makeRequest({
100+
path: `/runs/${runToken}/cancel`,
101+
method: "post",
102+
...args,
103+
});
104+
},
105+
async deleteRun({
106+
runToken, ...args
107+
}) {
108+
return this._makeRequest({
109+
path: `/runs/${runToken}`,
110+
method: "delete",
111+
...args,
112+
});
113+
},
84114
},
85115
};

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)