Skip to content

Go言語向け さくらのクラウド オブジェクトストレージAPIライブラリ

License

Notifications You must be signed in to change notification settings

sacloud/object-storage-api-go

Repository files navigation

object-storage-api-go

Go Reference Tests Go Report Card

Go言語向けのさくらのクラウド オブジェクトストレージAPIライブラリ

オブジェクトストレージAPIドキュメント: https://manual.sakura.ad.jp/cloud/objectstorage/api/api-json.html

概要

sacloud/object-storage-api-goはさくらのクラウド オブジェクトストレージAPIをGo言語から利用するためのAPIライブラリです。

利用イメージ:

import (
    "context"
    "os"
	
    objectstorage "github.com/sacloud/object-storage-api-go"
    v1 "github.com/sacloud/object-storage-api-go/apis/v1"
)

func main() {
    ctx := context.Background()
    client := &objectstorage.Client{} // デフォルトでusacloud互換プロファイル or 環境変数(SAKURACLOUD_ACCESS_TOKEN{_SECRET})が利用される

	// サイト一覧を取得
	siteOp := objectstorage.NewSiteOp(client)
	sites, err := siteOp.List(ctx)
	if err != nil {
		panic(err)
	}
	siteId := sites[0].Id

	// バケットの作成
	bucketName := "your-bucket-name"
	bucketAPI := objectstorage.NewBucketOp(client)
	bucket, err := bucketAPI.Create(ctx, siteId, bucketName)
	if err != nil {
		panic(err)
	}

	// バケットの削除
	defer func() {
		if err := bucketAPI.Delete(ctx, siteId, bucketName); err != nil {
			panic(err)
		}
	}()

	fmt.Println(bucket.Name)
}

⚠️ v1.0に達するまでは互換性のない形で変更される可能性がありますのでご注意ください。

関連プロジェクト

  • sacloud/sacloud-go: sacloud/object-storage-api-goを用いた高レベルAPIライブラリ

License

sacloud/object-storage-api-go Copyright (C) 2022-2023 The sacloud/object-storage-api-go Authors.

This project is published under Apache 2.0 License.

About

Go言語向け さくらのクラウド オブジェクトストレージAPIライブラリ

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published