Skip to content

Commit 4d9a1ab

Browse files
committed
Ngrok: new action components
1 parent fb808e1 commit 4d9a1ab

File tree

7 files changed

+313
-10
lines changed

7 files changed

+313
-10
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import app from "../../ngrok.app.mjs";
2+
3+
export default {
4+
key: "ngrok-create-https-edge",
5+
name: "Create HTTPS Edge",
6+
description: "Create an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#create-https-edge).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
description: {
12+
propDefinition: [
13+
app,
14+
"description",
15+
],
16+
},
17+
hostports: {
18+
propDefinition: [
19+
app,
20+
"hostports",
21+
],
22+
},
23+
metadata: {
24+
propDefinition: [
25+
app,
26+
"metadata",
27+
],
28+
},
29+
},
30+
methods: {
31+
createHTTPSEdge(args = {}) {
32+
return this.app.post({
33+
path: "/edges/https",
34+
...args,
35+
});
36+
},
37+
},
38+
async run({ $ }) {
39+
const {
40+
createHTTPSEdge,
41+
description,
42+
hostports,
43+
metadata,
44+
} = this;
45+
46+
const response = await createHTTPSEdge({
47+
$,
48+
data: {
49+
description,
50+
hostports,
51+
metadata: metadata && JSON.stringify(metadata),
52+
},
53+
});
54+
$.export("$summary", `Successfully created new HTTPS edge with ID \`${response.id}\`.`);
55+
return response;
56+
},
57+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import app from "../../ngrok.app.mjs";
2+
3+
export default {
4+
key: "ngrok-delete-https-edge",
5+
name: "Delete HTTPS Edge",
6+
description: "Delete an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#delete-https-edge).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
edgeId: {
12+
propDefinition: [
13+
app,
14+
"edgeId",
15+
],
16+
},
17+
},
18+
methods: {
19+
deleteHTTPSEdge({
20+
edgeId, ...args
21+
} = {}) {
22+
return this.app.delete({
23+
path: `/edges/https/${edgeId}`,
24+
...args,
25+
});
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
deleteHTTPSEdge,
31+
edgeId,
32+
} = this;
33+
await deleteHTTPSEdge({
34+
$,
35+
edgeId,
36+
});
37+
$.export("$summary", "Successfully deleted HTTPS edge.");
38+
return {
39+
success: true,
40+
};
41+
},
42+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import app from "../../ngrok.app.mjs";
2+
3+
export default {
4+
key: "ngrok-get-https-edge",
5+
name: "Get HTTPS Edge",
6+
description: "Get the details of an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#get-https-edge).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
edgeId: {
12+
propDefinition: [
13+
app,
14+
"edgeId",
15+
],
16+
},
17+
},
18+
methods: {
19+
getHTTPSEdge({
20+
edgeId, ...args
21+
} = {}) {
22+
return this.app._makeRequest({
23+
path: `/edges/https/${edgeId}`,
24+
...args,
25+
});
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
getHTTPSEdge,
31+
edgeId,
32+
} = this;
33+
const response = await getHTTPSEdge({
34+
$,
35+
edgeId,
36+
});
37+
$.export("$summary", `Successfully retrieved HTTPS edge with ID \`${response.id}\`.`);
38+
return response;
39+
},
40+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import app from "../../ngrok.app.mjs";
2+
3+
export default {
4+
key: "ngrok-update-https-edge",
5+
name: "Update HTTPS Edge",
6+
description: "Updates an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#update-https-edge).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
edgeId: {
12+
propDefinition: [
13+
app,
14+
"edgeId",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
hostports: {
24+
propDefinition: [
25+
app,
26+
"hostports",
27+
],
28+
},
29+
metadata: {
30+
propDefinition: [
31+
app,
32+
"metadata",
33+
],
34+
},
35+
},
36+
methods: {
37+
updateHTTPSEdge({
38+
edgeId, ...args
39+
} = {}) {
40+
return this.app.patch({
41+
path: `/edges/https/${edgeId}`,
42+
...args,
43+
});
44+
},
45+
},
46+
async run({ $ }) {
47+
const {
48+
updateHTTPSEdge,
49+
edgeId,
50+
description,
51+
hostports,
52+
metadata,
53+
} = this;
54+
55+
const response = await updateHTTPSEdge({
56+
$,
57+
edgeId,
58+
data: {
59+
description,
60+
hostports,
61+
metadata: metadata && JSON.stringify(metadata),
62+
},
63+
});
64+
$.export("$summary", `Successfully updated Agent Ingress ID \`${response.id}\`.`);
65+
return response;
66+
},
67+
};

components/ngrok/ngrok.app.mjs

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,102 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "ngrok",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
description: {
8+
type: "string",
9+
label: "Description",
10+
description: "What this edge will be used for.",
11+
},
12+
hostports: {
13+
type: "string[]",
14+
label: "Host Ports",
15+
description: "Hostports served by this edge. Eg: `example.com:443`",
16+
optional: true,
17+
},
18+
metadata: {
19+
type: "object",
20+
label: "Metadata",
21+
description: "The metadata of the agent ingress. Arbitrary user-defined machine-readable data.",
22+
optional: true,
23+
},
24+
edgeId: {
25+
type: "string",
26+
label: "Edge ID",
27+
description: "The ID of the edge to update.",
28+
async options({ prevContext: { url } }) {
29+
if (url === null) {
30+
return [];
31+
}
32+
const {
33+
next_page_uri: nextPageUri,
34+
https_edges: edges,
35+
} = await this.listHTTPSEdges({
36+
url,
37+
params: {
38+
limit: 10,
39+
},
40+
});
41+
const options = edges.map(({
42+
id: value, description: label,
43+
}) => ({
44+
label,
45+
value,
46+
}));
47+
return {
48+
options,
49+
context: {
50+
url: nextPageUri,
51+
},
52+
};
53+
},
54+
},
55+
},
556
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
57+
getUrl(path) {
58+
return `https://api.ngrok.com${path}`;
59+
},
60+
getHeaders(headers) {
61+
return {
62+
...headers,
63+
"Authorization": `Bearer ${this.$auth.api_key}`,
64+
"Content-Type": "application/json",
65+
"Ngrok-Version": "2",
66+
};
67+
},
68+
_makeRequest({
69+
$ = this, url, path, headers, ...args
70+
} = {}) {
71+
return axios($, {
72+
...args,
73+
url: url || this.getUrl(path),
74+
headers: this.getHeaders(headers),
75+
});
76+
},
77+
post(args = {}) {
78+
return this._makeRequest({
79+
method: "POST",
80+
...args,
81+
});
82+
},
83+
patch(args = {}) {
84+
return this._makeRequest({
85+
method: "PATCH",
86+
...args,
87+
});
88+
},
89+
delete(args = {}) {
90+
return this._makeRequest({
91+
method: "DELETE",
92+
...args,
93+
});
94+
},
95+
listHTTPSEdges(args = {}) {
96+
return this._makeRequest({
97+
path: "/edges/https",
98+
...args,
99+
});
9100
},
10101
},
11102
};

components/ngrok/package.json

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

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)