Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Components] ngrok #14293

Merged
merged 1 commit into from
Oct 16, 2024
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
57 changes: 57 additions & 0 deletions components/ngrok/actions/create-https-edge/create-https-edge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../ngrok.app.mjs";

export default {
key: "ngrok-create-https-edge",
name: "Create HTTPS Edge",
description: "Create an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#create-https-edge).",
version: "0.0.1",
type: "action",
props: {
app,
description: {
propDefinition: [
app,
"description",
],
},
hostports: {
propDefinition: [
app,
"hostports",
],
},
metadata: {
propDefinition: [
app,
"metadata",
],
},
},
methods: {
createHTTPSEdge(args = {}) {
return this.app.post({
path: "/edges/https",
...args,
});
},
},
async run({ $ }) {
const {
createHTTPSEdge,
description,
hostports,
metadata,
} = this;

const response = await createHTTPSEdge({
$,
data: {
description,
hostports,
metadata: metadata && JSON.stringify(metadata),
},
});
$.export("$summary", `Successfully created new HTTPS edge with ID \`${response.id}\`.`);
return response;
},
};
42 changes: 42 additions & 0 deletions components/ngrok/actions/delete-https-edge/delete-https-edge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../ngrok.app.mjs";

export default {
key: "ngrok-delete-https-edge",
name: "Delete HTTPS Edge",
description: "Delete an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#delete-https-edge).",
version: "0.0.1",
type: "action",
props: {
app,
edgeId: {
propDefinition: [
app,
"edgeId",
],
},
},
methods: {
deleteHTTPSEdge({
edgeId, ...args
} = {}) {
return this.app.delete({
path: `/edges/https/${edgeId}`,
...args,
});
},
},
async run({ $ }) {
const {
deleteHTTPSEdge,
edgeId,
} = this;
await deleteHTTPSEdge({
$,
edgeId,
});
$.export("$summary", "Successfully deleted HTTPS edge.");
return {
success: true,
};
},
};
40 changes: 40 additions & 0 deletions components/ngrok/actions/get-https-edge/get-https-edge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import app from "../../ngrok.app.mjs";

export default {
key: "ngrok-get-https-edge",
name: "Get HTTPS Edge",
description: "Get the details of an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#get-https-edge).",
version: "0.0.1",
type: "action",
props: {
app,
edgeId: {
propDefinition: [
app,
"edgeId",
],
},
},
methods: {
getHTTPSEdge({
edgeId, ...args
} = {}) {
return this.app._makeRequest({
path: `/edges/https/${edgeId}`,
...args,
});
},
},
async run({ $ }) {
const {
getHTTPSEdge,
edgeId,
} = this;
const response = await getHTTPSEdge({
$,
edgeId,
});
$.export("$summary", `Successfully retrieved HTTPS edge with ID \`${response.id}\`.`);
return response;
},
};
67 changes: 67 additions & 0 deletions components/ngrok/actions/update-https-edge/update-https-edge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import app from "../../ngrok.app.mjs";

export default {
key: "ngrok-update-https-edge",
name: "Update HTTPS Edge",
description: "Updates an HTTPS Edge. [See the documentation](https://ngrok.com/docs/api/resources/edges-https/#update-https-edge).",
version: "0.0.1",
type: "action",
props: {
app,
edgeId: {
propDefinition: [
app,
"edgeId",
],
},
description: {
propDefinition: [
app,
"description",
],
},
hostports: {
propDefinition: [
app,
"hostports",
],
},
metadata: {
propDefinition: [
app,
"metadata",
],
},
},
methods: {
updateHTTPSEdge({
edgeId, ...args
} = {}) {
return this.app.patch({
path: `/edges/https/${edgeId}`,
...args,
});
},
},
async run({ $ }) {
const {
updateHTTPSEdge,
edgeId,
description,
hostports,
metadata,
} = this;

const response = await updateHTTPSEdge({
$,
edgeId,
data: {
description,
hostports,
metadata: metadata && JSON.stringify(metadata),
},
});
$.export("$summary", `Successfully updated Agent Ingress ID \`${response.id}\`.`);
return response;
},
};
99 changes: 95 additions & 4 deletions components/ngrok/ngrok.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,102 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "ngrok",
propDefinitions: {},
propDefinitions: {
description: {
type: "string",
label: "Description",
description: "What this edge will be used for.",
},
hostports: {
type: "string[]",
label: "Host Ports",
description: "Hostports served by this edge. Eg: `example.com:443`",
optional: true,
},
metadata: {
type: "object",
label: "Metadata",
description: "The metadata of the agent ingress. Arbitrary user-defined machine-readable data.",
optional: true,
},
edgeId: {
type: "string",
label: "Edge ID",
description: "The ID of the edge to update.",
async options({ prevContext: { url } }) {
if (url === null) {
return [];
}
jcortes marked this conversation as resolved.
Show resolved Hide resolved
const {
next_page_uri: nextPageUri,
https_edges: edges,
} = await this.listHTTPSEdges({
url,
params: {
limit: 10,
},
});
const options = edges.map(({
id: value, description: label,
}) => ({
label,
value,
}));
return {
options,
context: {
url: nextPageUri,
},
};
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://api.ngrok.com${path}`;
},
getHeaders(headers) {
return {
...headers,
"Authorization": `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
"Ngrok-Version": "2",
};
},
_makeRequest({
$ = this, url, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: url || this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
patch(args = {}) {
return this._makeRequest({
method: "PATCH",
...args,
});
},
delete(args = {}) {
return this._makeRequest({
method: "DELETE",
...args,
});
},
listHTTPSEdges(args = {}) {
return this._makeRequest({
path: "/edges/https",
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/ngrok/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ngrok",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream ngrok Components",
"main": "ngrok.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

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

Loading