Skip to content

Commit d5a5f9f

Browse files
committed
new source
1 parent b8e0715 commit d5a5f9f

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

components/oxylabs/oxylabs.app.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ export default {
55
type: "app",
66
app: "oxylabs",
77
propDefinitions: {
8+
scheduleId: {
9+
type: "string",
10+
label: "Schedule ID",
11+
description: "The ID of the schedule to watch",
12+
async options() {
13+
const { schedules } = await this.listSchedules();
14+
return schedules || [];
15+
},
16+
},
817
geoLocation: {
918
type: "string",
1019
label: "Geo Location",
@@ -38,6 +47,12 @@ export default {
3847
...opts,
3948
});
4049
},
50+
listSchedules(opts = {}) {
51+
return this._makeRequest({
52+
path: "/schedules",
53+
...opts,
54+
});
55+
},
4156
async createSession({
4257
$ = this, proxyUrl, ...opts
4358
}) {
@@ -55,5 +70,13 @@ export default {
5570
...opts,
5671
});
5772
},
73+
getRunsInfo({
74+
scheduleId, ...opts
75+
}) {
76+
return this._makeRequest({
77+
path: `/schedules/${scheduleId}/runs`,
78+
...opts,
79+
});
80+
},
5881
},
5982
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import oxylabs from "../../oxylabs.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
import sampleEmit from "./test-event.mjs";
4+
5+
export default {
6+
key: "oxylabs-new-scheduled-run-completed",
7+
name: "New Scheduled Run Completed",
8+
description: "Emit new event when a new scheduled run is completed. [See the documentation](https://developers.oxylabs.io/scraping-solutions/web-scraper-api/features/scheduler#get-runs-information)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
oxylabs,
14+
timer: {
15+
type: "$.interface.timer",
16+
default: {
17+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
18+
},
19+
},
20+
scheduleId: {
21+
propDefinition: [
22+
oxylabs,
23+
"scheduleId",
24+
],
25+
},
26+
},
27+
methods: {
28+
generateMeta(run) {
29+
return {
30+
id: run.id,
31+
summary: `New Run with ID: ${run.id}`,
32+
ts: Date.now(),
33+
};
34+
},
35+
},
36+
async run() {
37+
const { runs } = await this.oxylabs.getRunsInfo({
38+
scheduleId: this.scheduleId,
39+
});
40+
for (const run of runs) {
41+
const meta = this.generateMeta(run);
42+
this.$emit(run, meta);
43+
}
44+
},
45+
sampleEmit,
46+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export default {
2+
"run_id": 25037485,
3+
"jobs": [
4+
{
5+
"id": 7300439540206948353,
6+
"create_status_code": 202,
7+
"result_status": "done",
8+
"created_at": "2025-02-26 09:00:21",
9+
"result_created_at": "2025-02-26 09:00:23",
10+
},
11+
{
12+
"id": 7300439540169188353,
13+
"create_status_code": 202,
14+
"result_status": "done",
15+
"created_at": "2025-02-26 09:00:21",
16+
"result_created_at": "2025-02-26 09:00:22",
17+
},
18+
{
19+
"id": 7300439540198551553,
20+
"create_status_code": 202,
21+
"result_status": "done",
22+
"created_at": "2025-02-26 09:00:21",
23+
"result_created_at": "2025-02-26 09:00:23",
24+
},
25+
],
26+
"success_rate": 1,
27+
};

0 commit comments

Comments
 (0)