LoginSignup
3
3

More than 5 years have passed since last update.

cloudatcostのクライアントライブラリを作った

Last updated at Posted at 2015-03-28

概要

激安VPSで有名なcloudatcostのAPIが提供されたのでライブラリを作成した

cloudatcostってなに?

カナダにある激安VPSサービス

CloudatCost
Twitter
人柱: 激安VPSのcloudatcostを試してみた

API仕様

ここ読んでね

現在サポートしているAPI

  • リスト一覧取得
  • テンプレート一覧取得
  • タスク一覧取得
  • コンソールへのログイン情報 取得
  • 電源のON/OFF/REBOOT

作成したライブラリ

github

使い方

準備

ここ読んでね

環境変数の設定

CLOUDATCOST_API_LOGIN:メールアドレス
CLOUDATCOST_API_KEY:ここのsettingsで取得できます

サンプル

package main

import (
    "fmt"
    "github.com/masayukioguni/go-cloudatcost/cloudatcost"
    "os"
)

func main() {
    Login := os.Getenv("CLOUDATCOST_API_LOGIN")
    Key := os.Getenv("CLOUDATCOST_API_KEY")
    client, _ := cloudatcost.NewClient(&cloudatcost.Option{Login: Login, Key: Key})

    listservers, hr, err := client.ListServersService.ListServers()

    if err != nil {
        fmt.Printf("error: %v\n\n", err)
        return
    }

    if hr.StatusCode != 200 {
        fmt.Printf("http response error: %+v %+v \n\n", hr, err)
        return
    }

    fmt.Printf("%v,%v\n", listservers, err)

}

[{1 1 16 c1116353-29235 xxxxx c90000-689604-110144152-29235 1xxx.xxx.xxx.xxx 255.255.255.0 xxx.xxx.xxx.xxx Cloud-ip-7 c111xxxxx-xxxxx.cloudatcost.com xxxxxxx  12345 xxxxxxx Custom Ubuntu-14.04.1-LTS-64bit 1 23 512 214.355 11 0.804909862 03/20/2015 Powered Off  Safe 1}],<nil>

まとめ

  • APIのレスポンスにrootpassが入るのが怖い…
  • go langは楽しいがこれだったら curl + jq でもよかった…

TODO

  • readme更新
  • CloudAtCostのAPIが追加されたら対応予定
  • Terraformのプラグインも書く
  • CLIツールも作る
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3