-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] scalr #13481 #16663
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
Merged
Merged
[Components] scalr #13481 #16663
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,18 @@ | ||
| { | ||
| "name": "@pipedream/scalr", | ||
| "version": "0.0.2", | ||
| "version": "0.0.1", | ||
| "description": "Pipedream Scalr Components", | ||
| "main": "dist/app/scalr.app.mjs", | ||
| "main": "scalr.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "scalr" | ||
| ], | ||
| "files": ["dist"], | ||
| "homepage": "https://pipedream.com/apps/scalr", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "scalr", | ||
| propDefinitions: { | ||
| accountId: { | ||
| type: "string", | ||
| label: "Account ID", | ||
| description: "The ID of the account you wish to use.", | ||
| async options() { | ||
| const { data: accounts } = await this.getAccounts(); | ||
| return accounts.map((account) => ({ | ||
| label: account.attributes.name, | ||
| value: account.id, | ||
| })); | ||
| }, | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| methods: { | ||
| _baseUrl() { | ||
| return `https://${this.$auth.domain}.scalr.io/api/iacp/v3`; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| headers, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| "Authorization": `Bearer ${this.$auth.api_token}`, | ||
| "Content-type": "application/vnd.api+json", | ||
| ...headers, | ||
| }, | ||
| }); | ||
| }, | ||
| async createWebhook({ ...args }) { | ||
| return this._makeRequest({ | ||
| path: "/integrations/webhooks", | ||
| method: "post", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async removeWebhook(webhookId) { | ||
| return this._makeRequest({ | ||
| path: `/integrations/webhooks/${webhookId}`, | ||
| method: "delete", | ||
| }); | ||
| }, | ||
| async getWebhooks(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/integrations/webhooks", | ||
| ...args, | ||
| }); | ||
| }, | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| async getAccounts(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/accounts", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getEvents(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/event-definitions", | ||
| ...args, | ||
| }); | ||
| }, | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import scalr from "../../scalr.app.mjs"; | ||
|
|
||
| export default { | ||
| props: { | ||
| scalr, | ||
| db: "$.service.db", | ||
| http: "$.interface.http", | ||
| accountId: { | ||
| propDefinition: [ | ||
| scalr, | ||
| "accountId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getWebhookId() { | ||
| return this.db.get("webhookId"); | ||
| }, | ||
| _setWebhookId(webhookId) { | ||
| this.db.set("webhookId", webhookId); | ||
| }, | ||
| getWebhookEventType() { | ||
| throw new Error("getWebhookEventType is not implemented"); | ||
| }, | ||
| emitEvent(event) { | ||
| throw new Error("emitEvent is not implemented", event); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async activate() { | ||
| const { data } = await this.scalr.createWebhook({ | ||
| data: { | ||
| "data": { | ||
| "attributes": { | ||
| "max-attempts": 3, | ||
| "timeout": 15, | ||
| "name": "Webhook Pipedream - " + new Date().toISOString(), | ||
| "url": this.http.endpoint, | ||
| }, | ||
| "relationships": { | ||
| "account": { | ||
| "data": { | ||
| "type": "accounts", | ||
| "id": this.accountId, | ||
| }, | ||
| }, | ||
| "events": { | ||
| "data": [ | ||
| { | ||
| "type": "event-definitions", | ||
| "id": this.getWebhookEventType(), | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| "type": "webhook-integrations", | ||
| }, | ||
| }, | ||
| }); | ||
| this._setWebhookId(data.id); | ||
| }, | ||
| async deactivate() { | ||
| const webhookId = this._getWebhookId(); | ||
| await this.scalr.removeWebhook(webhookId); | ||
| }, | ||
| }, | ||
| async run(event) { | ||
| await this.emitEvent(event.body); | ||
| }, | ||
| }; |
28 changes: 28 additions & 0 deletions
28
components/scalr/sources/new-run-completed/new-run-completed.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import common from "../common/common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| name: "New Run Completed (Instant)", | ||
| version: "0.0.1", | ||
| key: "scalr-new-run-completed", | ||
| description: "Emit new event on each new completed run.", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: "source", | ||
| dedupe: "unique", | ||
| hooks: { | ||
| ...common.hooks, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getWebhookEventType() { | ||
| return "run:completed"; | ||
| }, | ||
| async emitEvent(data) { | ||
|
|
||
| this.$emit(data, { | ||
| id: data.run.id, | ||
| summary: `New run completed with ID ${data.run.id}`, | ||
| ts: Date.parse(data.run["created-at"]), | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
28 changes: 28 additions & 0 deletions
28
components/scalr/sources/new-run-errored/new-run-errored.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import common from "../common/common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| name: "New Run Errored (Instant)", | ||
| version: "0.0.1", | ||
| key: "scalr-new-run-errored", | ||
| description: "Emit new event when a new run encountered an error.", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: "source", | ||
| dedupe: "unique", | ||
| hooks: { | ||
| ...common.hooks, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getWebhookEventType() { | ||
| return "run:errored"; | ||
| }, | ||
| async emitEvent(data) { | ||
|
|
||
| this.$emit(data, { | ||
| id: data.run.id, | ||
| summary: `New run completed with ID ${data.run.id}`, | ||
| ts: Date.parse(data.run["created-at"]), | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
28 changes: 28 additions & 0 deletions
28
components/scalr/sources/new-run-needs-attention/new-run-needs-attention.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import common from "../common/common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| name: "New Run Needs Attention (Instant)", | ||
| version: "0.0.1", | ||
| key: "scalr-new-run-needs-attention", | ||
| description: "Emit new event when a new run needs attention.", | ||
lcaresia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: "source", | ||
| dedupe: "unique", | ||
| hooks: { | ||
| ...common.hooks, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getWebhookEventType() { | ||
| return "run:needs_attention"; | ||
| }, | ||
| async emitEvent(data) { | ||
|
|
||
| this.$emit(data, { | ||
| id: data.run.id, | ||
| summary: `New run with ID ${data.run.id} needs attention`, | ||
| ts: Date.parse(data.run["created-at"]), | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.