GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Feature/gce instance node #108

Closed arivictor closed 2 years ago

arivictor commented 2 years ago

Hi!

I created a GCE Instance node to handle basic instance operations:

I have also included an example flow that demonstrates a use case of needing to schedule the start/stop of instances. This flow simply lists all instances and then turns an instance on if its off, and off if its on. The node can be explicitly configured via the UI or you can programmatically inject the required value via msg.payload. I've tried to follow the convention

# function node -> gce-instance node

msg.payload = {
    projectId: "string",
    zone: "string", // e.g. us-central1-a
    instance: "string", // instance name when required
    operation: "string", // get, list, start, stop, delete, reset
    template: "JSON string", // json string template as per API docs
}

After feedback and whether this is something I should continue developing. Happy to implement any changes, conventions, styling, etc. I'd like to keep adding more features/operations and other GCE nodes. Please reach out with any questions!

Example flow

Screen Shot 2022-01-29 at 3 02 14 pm

Node UI

Screen Shot 2022-01-29 at 3 15 49 pm