Skip to content

Instantly share code, notes, and snippets.

View mattoni's full-sized avatar

Alexander Mattoni mattoni

  • https://cycle.io
  • Nevada, USA
View GitHub Profile
@mattoni
mattoni / index.ts
Created August 28, 2019 01:41
List Servers With Stats Cycle API
import { Infrastructure } from "@cycleplatform/cycle-api";
async function listServers() {
const resp = await Infrastructure.Servers.getCollection({
token:
"secret_W8cSxydUl4xPI42bYxG2tx3FGgk81eJolblnZiA3N7ZCY4u7Qx4uI4eaVKkJ",
hubId: "5a14ddd8b6393d0001976f44",
query: {
meta: ["stats"]
},
@mattoni
mattoni / results.json
Last active August 28, 2019 01:47
List Server Stats Query
{
"data": [
{
"id": "5c98267b4146380001eexxxx",
"hostname": "xxxxx-vultr-sjc.s.5a14ddd8b6393d000197xxxx.cycle.io",
"owner": {
"id": "59dafefe91238b0001baxxxx",
"type": "account"
},
"hub_id": "5a14ddd8b6393d000197xxxx",
@mattoni
mattoni / result.json
Last active August 28, 2019 01:09
List servers with Cycle API result
{
"data": [
{
"id": "5a6b729d8dd3030001exxxxx",
"hostname": "xxxx-packet-sjc1.s.5a6b6f3df231a50001cxxxxx.cycle.io",
"owner": {
"id": "5a662f3bfasdf1a50001acbc1a",
"type": "account"
},
"hub_id": "5a6basdff231a50001c2317c",
@mattoni
mattoni / index.ts
Last active August 27, 2019 21:49
List servers using Cycle API
import { Infrastructure } from "@cycleplatform/cycle-api";
async function listServers() {
const resp = await Infrastructure.Servers.getCollection({
token:
"secret_S8yL426IlEP2Xq1EzwG9VyBqqqXPfYwt4yA3xXCMRBY4QXO1110KDJIWbkviB",
hubId: "5a8a8f3df231a50001c2317c"
});
if (!resp.ok) {
export default class ObjectPool<T> {
private metrics = {
allocated: 0,
free: 0
};
private pool: T[] = [];
constructor(private type: new () => T) { }
interface Method<T> {
(payload: T): void;
}
interface FakeData {
name: string;
}
class Action {
private static methods: Method<FakeData>[] = [];