npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@genesiscloud/genesiscloud-js

v1.0.2

Published

JavaScript client for the Genesis Cloud API

Downloads

9

Readme

Genesis Cloud JavaScript Client

The JavaScript library for the Genesis Cloud API offers an easy way to manage resources like instances, volumes, snapshots, filesystems, floating IPs, security groups and more in your JavaScript or TypeScript applications.

Installation

You can install the Genesis Cloud SDK using your preferred node package manager:

npm install @genesiscloud/genesiscloud-js
# or
yarn add @genesiscloud/genesiscloud-js
# or
pnpm add @genesiscloud/genesiscloud-js

Configuration

Before you start, you'll need to configure the client with your Genesis Cloud API token. You can generate your API token from the Genesis Cloud console.

Here's how to configure the SDK:

const genesiscloud = new GenesisCloudClient({
  TOKEN: process.env.GENESISCLOUD_TOKEN,
});

Examples

Error handling

Error handling can be done using the try/catch with the async/await syntax. The Genesis Cloud errors are of this format.

try {
  const instance = await genesiscloud.instances.createInstance({
    requestBody: {
      // ...
    },
  });
  //... do something with instance
} catch (error) {
  if (error instanceof ApiError) {
    const { code, message } = error.body;
    // ... handle genesiscloud error
  } else {
    // ... handle other errors
  }
}

Managing Instances

Listing Instances:

const { instances } = await genesiscloud.instances.listInstances({
  page: 1,
  perPage: 100,
});

Creating a new Instance:

const instance = await genesiscloud.instances.createInstance({
  requestBody: {
    name: "test instance",
    hostname: "test instance",
    type: "vcpu-192_memory-1920g_nvidia-h100-sxm5-8",
    image: "ubuntu-ml-nvidia-pytorch",
    region: "NORD-NO-KRS-1",
    ssh_keys: ["ssh_key_id_here"],
  },
});

Updating an Instance:

const updatedInstance = await genesiscloud.instances.updateInstance({
  instanceId: "your_instance_id",
  requestBody: {
    name: "New Instance Name",
    volumes: ["volume_id_here"],
  },
});

Deleting an Instance:

await genesiscloud.instances.deleteInstance({
  instanceId: "your_instance_id",
});

Managing Volumes

Creating a Volume

const volume = await genesiscloud.volumes.createVolume({
  requestBody: {
    name: "volume name",
    description: "volume description",
    type: "ssd",
    size: 10, // in GiB
    region: "NORD-NO-KRS-1",
  },
});

Deleting a Volume

await genesiscloud.volumes.deleteVolume({
  volumeId: "your_volume_id",
});

Managing Snapshots

Creating a Snapshot from an instance:

const snapshot = await genesiscloud.instances.createInstanceSnapshot({
  instanceId: "your_instance_id",
  requestBody: {
    name: "Test snapshot",
  },
});

Deleting a Snapshot:

await genesiscloud.snapshots.deleteSnapshot({
  snapshotId: "your_snapshot_id",
});

Managing SSH Keys

Listing SSH Keys:

const sshKeys = await genesiscloud.sshKeys.listSshKeys({});

Creating an SSH Key:

const sshKey = await genesiscloud.sshKeys.createSshKey({
  requestBody: {
    name: "test key",
    value: "ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXX...",
  },
});

Deleting an SSH Key:

await genesiscloud.sshKeys.deleteSshKey({
  sshKeyId: "your-ssh-key-id",
});

For more detailed information on the Genesis Cloud API refer to the Genesis Cloud API documentation.