apprun_dedicated

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

apprun-dedicated-api-go

Go Reference Tests Go Report Card

さくらのクラウド「AppRun 専有型」APIのGoクライアントライブラリ

概要

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

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

インストール

go get github.com/sacloud/apprun-dedicated-api-go

使い方

package main

import (
    "context"
    "os"

    "github.com/sacloud/apprun-dedicated-api-go"
    "github.com/sacloud/saclient-go"
)

var theClient saclient.Client

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

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

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

    // 例: クラスタ一覧取得
    clusters, err := apprun_dedicated.NewClusterOp(client).List(ctx, nil, nil)
    if err != nil {
        // エラーハンドリング
    }
}

APIの詳細はGoDocapis/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.jsonAppRun専有型 APIからダウンロードしたものです。

開発

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

make
make test

ライセンス

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

Documentation

Index

Constants

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

Variables

View Source
var NewApplicationOp = application.NewApplicationOp
View Source
var NewAutoScalingGroupOp = autoscalinggroup.NewAutoScalingGroupOp
View Source
var NewCertificateOp = certificate.NewCertificateOp
View Source
var NewClusterOp = cluster.NewClusterOp
View Source
var NewLoadBalancerOp = loadbalancer.NewLoadBalancerOp
View Source
var NewServiceClassOp = service_class.NewServiceClassOp
View Source
var NewVersionOp = version.NewVersionOp
View Source
var NewWorkerNodeOp = workernode.NewWorkerNodeOp
View Source
var UserAgent = fmt.Sprintf(
	"apprun-dedicated-api-go/%s (%s/%s; +https://github.com/sacloud/apprun-dedicated-api-go)",
	Version,
	runtime.GOOS,
	runtime.GOARCH,
)

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

Functions

func NewClient

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

func NewClientWithAPIRootURL

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

Types

type ApplicationAPI

type ApplicationAPI = application.ApplicationAPI

type CertificateAPI

type CertificateAPI = certificate.CertificateAPI

type ClusterAPI

type ClusterAPI = cluster.ClusterAPI

type LoadBalancerAPI

type LoadBalancerAPI = loadbalancer.LoadBalancerAPI

type ServiceClassAPI

type ServiceClassAPI = service_class.ServiceClassAPI

type VersionAPI

type VersionAPI = version.VersionAPI

type WorkerNodeAPI

type WorkerNodeAPI = workernode.WorkerNodeAPI

Jump to

Keyboard shortcuts

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