Go言語向けのさくらのクラウド オブジェクトストレージAPIライブラリ
オブジェクトストレージAPIドキュメント: https://manual.sakura.ad.jp/cloud/objectstorage/api/api-json.html
sacloud/object-storage-api-goはさくらのクラウド オブジェクトストレージAPIをGo言語から利用するためのAPIライブラリです。
- 概要/設計/実装方針: docs/overview.md
利用イメージ:
import (
"context"
"os"
objectstorage "github.com/sacloud/object-storage-api-go"
"github.com/sacloud/saclient-go"
)
func main() {
// デフォルトでusacloud互換プロファイル or 環境変数(SAKURA_ACCESS_TOKEN{_SECRET}が利用される
var theClient saclient.Client
ctx := context.Background()
// サイトに依存しない処理にはFedClientを利用
fedClient, err := objectstorage.NewFedClient(&theClient)
if err != nil {
panic(err)
}
// サイト一覧を取得
siteOp := objectstorage.NewSiteOp(fedClient)
sites, err := siteOp.List(ctx)
if err != nil {
panic(err)
}
siteId := sites[0].ID.Value
// サイトに依存する処理にはSiteClientを利用
siteClient, err := objectstorage.NewSiteClient(&theClient, siteId)
if err != nil {
panic(err)
}
// バケットの作成
bucketName := "your-bucket-name"
bucketOp := objectstorage.NewBucketOp(fedClient, siteClient)
bucket, err := bucketOp.Create(ctx, &objectstorage.BucketCreateParams{
Bucket: bucketName,
SiteId: siteId,
})
// バケットの削除
defer func() {
if err := bucketOp.Delete(ctx, bucketName); err != nil {
panic(err)
}
}()
fmt.Println(bucket.Name.Value)
}- sacloud/sacloud-go: sacloud/object-storage-api-goを用いた高レベルAPIライブラリ
sacloud/object-storage-api-go Copyright (C) 2022-2026 The sacloud/object-storage-api-go Authors.
This project is published under Apache 2.0 License.