addon

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

[!WARNING]

このレポジトリの内容は下記に集約・移転しました。 github.com/sacloud/sacloud-sdk-go

今後は上記のレポジトリで開発を行います。 このライブラリを使用している方は、importを変更していただきますようお願いいたします。

// 変更前
import "github.com/sacloud/addon-api-go"

// 変更後
import "github.com/sacloud/sacloud-sdk-go/api/addon"

addon-api-go

Go Reference Tests Go Report Card

さくらのクラウド「Add-on」APIのGoクライアントライブラリ

概要

このライブラリは、さくらのクラウド「Add-on」APIをGo言語から利用するためのクライアントです。 OpenAPI仕様から自動生成された型安全なAPIクライアントと、それをラップして使い勝手を向上させたクライアントを提供します。

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

インストール

go get github.com/sacloud/addon-api-go

使い方

事前準備

SDKを利用開始するにはさくらのクラウド「Add-on」自体を利用開始する必要があります。執筆時点ではさくらのクラウドの利用申請とは別途Add-onの利用申請も必要です。申請手順の詳細に関してはAdd-onマニュアルをご参照ください。

またSDKを利用するにはAPIキーが必要ですが、これには「Add-on」のアクセスレベルを付与してください。アクセスレベルに関してはアクセスレベル マニュアルをご参照ください。

SDK
package main

import (
    "context"
    "os"

    "github.com/sacloud/addon-api-go"
    "github.com/sacloud/saclient-go"
)

var theClient saclient.Client

func main() {
	err := theClient.FlagSet(flag.PanicOnError).Parse(os.Args[1:])
    if err != nil {
        // エラーハンドリング
	}

    err = theClient.SetEnviron(os.Environ())
    if err != nil {
        // エラーハンドリング
	}

    client, err := addon.NewClient(&theClient)
    if err != nil {
        // エラーハンドリング
    }

    // 例: データレーク一覧取得
    ctx := context.Background()
    lakes, err := addon.NewDataLakeOp(client).List(ctx)
    if err != nil {
        // エラーハンドリング
    }
}

APIの詳細はGoDocやapis/v1/配下の型定義を参照してください。

認証情報

APIを実行するには認証が必要です。インタラクティブな環境の場合おすすめは usacloud を使って設定ファイルを作成することです。たとえば

usacloud config create --name production

にて作成したプロファイル production があるとすると、上記のmain関数をもつバイナリは

./a.out --profile=production

のようにして設定を読み込むことができます。

一方でCI環境のようにファイルに書き出すのが適切ではない場合、環境変数経由で

export SAKURA_ACCESS_TOKEN=TOKEN
export SAKURA_ACCESS_TOKEN_SECRET=SECRET

./a.out

のように指定できます。

OpenAPI仕様について

openapi/openapi.jsonはAdd-on APIからダウンロードしたものを一部加工しています。

開発

ビルドやテストはMakefile経由で実行できます。

make
make test

ライセンス

Copyright (C) 2025- The sacloud/addon-api-go Authors. このプロジェクトはApache 2.0 Licenseの下で公開されています。

Documentation

Overview

Deprecated: This module has moved to github.com/sacloud/sacloud-sdk-go. Please migrate to that module. This repository will be archived.

Index

Constants

View Source
const (
	// DefaultAPIRootURL デフォルトのAPIルートURL
	DefaultAPIRootURL = "https://secure.sakura.ad.jp/cloud/api/addon/1.0/"
)
View Source
const Version = "0.1.1"

Variables

View Source
var UserAgent = fmt.Sprintf(
	"addon-api-go/%s (%s/%s; +https://github.com/sacloud/addon-api-go)",
	Version,
	runtime.GOOS,
	runtime.GOARCH,
)

UserAgent APIリクエスト時のユーザーエージェント

Functions

func ErrorFromDecodedResponse

func ErrorFromDecodedResponse[
	T, E any,
](
	method string,
	yield func() (any, error),
) (
	res *T,
	err error,
)

func NewClient

func NewClient(client saclient.ClientAPI) (*v1.Client, error)

func NewClientWithAPIRootURL

func NewClientWithAPIRootURL(client saclient.ClientAPI, apiRootURL string) (*v1.Client, error)

Types

type AIAPI

type AIAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, location string, sku v1.AiServiceSku) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewAIOp

func NewAIOp(client *v1.Client) AIAPI

type AIOp

type AIOp struct{ *v1.Client }

func (*AIOp) Create

func (a *AIOp) Create(ctx context.Context, location string, sku v1.AiServiceSku) (*v1.PostDeploymentResponse, error)

func (*AIOp) Delete

func (a *AIOp) Delete(ctx context.Context, id string) (err error)

func (*AIOp) List

func (a *AIOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*AIOp) Read

func (a *AIOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*AIOp) Status

func (a *AIOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type CDNAPI

type CDNAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params CDNCreateParams) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewCDNOp

func NewCDNOp(client *v1.Client) CDNAPI

type CDNCreateParams

type CDNCreateParams struct {
	Location     string
	PricingLevel v1.PricingLevel
	Patterns     []string
	Origin       v1.FrontDoorOrigin
}

type CDNOp

type CDNOp struct{ *v1.Client }

func (*CDNOp) Create

func (c *CDNOp) Create(ctx context.Context, params CDNCreateParams) (*v1.PostDeploymentResponse, error)

func (*CDNOp) Delete

func (c *CDNOp) Delete(ctx context.Context, id string) (err error)

func (*CDNOp) List

func (c *CDNOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*CDNOp) Read

func (c *CDNOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*CDNOp) Status

func (c *CDNOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type DDoSAPI

type DDoSAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params DDoSCreateParams) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewDDoSOp

func NewDDoSOp(client *v1.Client) DDoSAPI

type DDoSCreateParams

type DDoSCreateParams struct {
	Location     string
	PricingLevel v1.PricingLevel
	Patterns     []string
	Origin       v1.FrontDoorOrigin
}

type DDoSOp

type DDoSOp struct{ *v1.Client }

func (*DDoSOp) Create

func (*DDoSOp) Delete

func (d *DDoSOp) Delete(ctx context.Context, id string) (err error)

func (*DDoSOp) List

func (d *DDoSOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*DDoSOp) Read

func (d *DDoSOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*DDoSOp) Status

func (d *DDoSOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type DWHAPI

type DWHAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewDWHOp

func NewDWHOp(client *v1.Client) DWHAPI

type DWHOp

type DWHOp struct{ *v1.Client }

func (*DWHOp) Create

func (d *DWHOp) Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)

func (*DWHOp) Delete

func (d *DWHOp) Delete(ctx context.Context, id string) (err error)

func (*DWHOp) List

func (d *DWHOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*DWHOp) Read

func (d *DWHOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*DWHOp) Status

func (d *DWHOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type DataLakeAPI

type DataLakeAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params DataLakeCreateParams) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error
	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewDataLakeOp

func NewDataLakeOp(client *v1.Client) DataLakeAPI

type DataLakeCreateParams

type DataLakeCreateParams struct {
	Location    string
	Performance v1.DataLakePerformance
	Redundancy  v1.DataLakeRedundancy
}

type DataLakeOp

type DataLakeOp struct{ *v1.Client }

func (*DataLakeOp) Create

func (*DataLakeOp) Delete

func (d *DataLakeOp) Delete(ctx context.Context, id string) (err error)

func (*DataLakeOp) List

func (d *DataLakeOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*DataLakeOp) Read

func (*DataLakeOp) Status

func (d *DataLakeOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type ETLAPI

type ETLAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewETLOp

func NewETLOp(client *v1.Client) ETLAPI

type ETLOp

type ETLOp struct{ *v1.Client }

func (*ETLOp) Create

func (e *ETLOp) Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)

func (*ETLOp) Delete

func (e *ETLOp) Delete(ctx context.Context, id string) (err error)

func (*ETLOp) List

func (e *ETLOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*ETLOp) Read

func (e *ETLOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*ETLOp) Status

func (e *ETLOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

func NewAPIError

func NewAPIError(method string, j json.Marshaler) *Error

func NewError

func NewError(msg string, err error) *Error

func NewNotFoundError

func NewNotFoundError(method string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type QueryAPI

type QueryAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewQueryOp

func NewQueryOp(client *v1.Client) QueryAPI

type QueryOp

type QueryOp struct{ *v1.Client }

func (*QueryOp) Create

func (q *QueryOp) Create(ctx context.Context, location string) (*v1.PostDeploymentResponse, error)

func (*QueryOp) Delete

func (q *QueryOp) Delete(ctx context.Context, id string) (err error)

func (*QueryOp) List

func (q *QueryOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*QueryOp) Read

func (q *QueryOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*QueryOp) Status

func (q *QueryOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type SearchAPI

type SearchAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params SearchCreateParams) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewSearchOp

func NewSearchOp(client *v1.Client) SearchAPI

type SearchCreateParams

type SearchCreateParams struct {
	Location       string
	PartitionCount int32
	ReplicaCount   int32
	Sku            v1.SearchSku
}

type SearchOp

type SearchOp struct{ *v1.Client }

func (*SearchOp) Create

func (*SearchOp) Delete

func (s *SearchOp) Delete(ctx context.Context, id string) (err error)

func (*SearchOp) List

func (s *SearchOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*SearchOp) Read

func (s *SearchOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*SearchOp) Status

func (s *SearchOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type StreamingAPI

type StreamingAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, location, unitCount string) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewStreamingOp

func NewStreamingOp(client *v1.Client) StreamingAPI

type StreamingOp

type StreamingOp struct{ *v1.Client }

func (*StreamingOp) Create

func (s *StreamingOp) Create(ctx context.Context, location, unitCount string) (*v1.PostDeploymentResponse, error)

func (*StreamingOp) Delete

func (s *StreamingOp) Delete(ctx context.Context, id string) (err error)

func (*StreamingOp) List

func (s *StreamingOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*StreamingOp) Read

func (*StreamingOp) Status

func (s *StreamingOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

type VulnerabilityAPI

type VulnerabilityAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params VulnerabilityCreateParams) (*v1.VulnerabilityResponseBody, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error
}

func NewVulnerabilityOp

func NewVulnerabilityOp(client *v1.Client) VulnerabilityAPI

type VulnerabilityCreateParams

type VulnerabilityCreateParams struct {
	Location string
	Os       v1.ServerOsType
}

type VulnerabilityOp

type VulnerabilityOp struct{ *v1.Client }

func (*VulnerabilityOp) Create

func (*VulnerabilityOp) Delete

func (v *VulnerabilityOp) Delete(ctx context.Context, id string) (err error)

func (*VulnerabilityOp) List

func (v *VulnerabilityOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*VulnerabilityOp) Read

type WAFAPI

type WAFAPI interface {
	List(ctx context.Context) ([]v1.ResourceGroupResource, error)
	Create(ctx context.Context, params WAFCreateParams) (*v1.PostDeploymentResponse, error)
	Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)
	Delete(ctx context.Context, id string) error

	Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)
}

func NewWAFOp

func NewWAFOp(client *v1.Client) WAFAPI

type WAFCreateParams

type WAFCreateParams struct {
	Location     string
	PricingLevel v1.PricingLevel
	Patterns     []string
	Origin       v1.FrontDoorOrigin
}

type WAFOp

type WAFOp struct{ *v1.Client }

func (*WAFOp) Create

func (w *WAFOp) Create(ctx context.Context, params WAFCreateParams) (*v1.PostDeploymentResponse, error)

func (*WAFOp) Delete

func (w *WAFOp) Delete(ctx context.Context, id string) (err error)

func (*WAFOp) List

func (w *WAFOp) List(ctx context.Context) (ret []v1.ResourceGroupResource, err error)

func (*WAFOp) Read

func (w *WAFOp) Read(ctx context.Context, id string) (*v1.GetResourceResponse, error)

func (*WAFOp) Status

func (w *WAFOp) Status(ctx context.Context, resourceGroupName, deploymentName string) (*v1.DeploymentStatus, error)

Directories

Path Synopsis
apis
v1
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址