cloudhsm

package module
v0.4.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: 9 Imported by: ? 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/cloudhsm-api-go"

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

cloudhsm-api-go

Go Reference Tests Go Report Card

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

概要

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

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

インストール

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

使い方

事前準備

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

認証情報

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

usacloud config create --name is1a

にて作成したプロファイル is1a があるとすると、SDKとしては、

import (
    "github.com/sacloud/cloudhsm-api-go"
    "github.com/sacloud/saclient-go"
)

var theClient saclient.Client

func main() {
    _ = theClient.SetEnviron([]string{"SAKURA_PROFILE=is1a"})
    client, err := cloudhsm.NewClient(&theClient)

    // 以下略
}

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

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

import (
    "os"

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

var theClient saclient.Client

func main() {
    _ = theClient.SetEnviron([]string{
        "SAKURA_ZONE=is1a",
        "SAKURA_SERVICE_PRINCIPAL_ID=something",
        // 他、 os.Environ()から必要な環境変数を追加
    })
    client, err := cloudhsm.NewClient(&theClient)

    // 以下略
}

のように指定できます。

SDK
package main

import (
    "context"

    "github.com/sacloud/cloudhsm-api-go"
    v1 "github.com/sacloud/cloudhsm-api-go/apis/v1"
)

func Logic(ctx context.Context, client *v1.Client) {
    // 例: ライセンス一覧取得
    licenses, err := cloudhsm.NewLicenseOp(client).List(ctx)
    if err != nil {
        // エラーハンドリング
    }
}

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

OpenAPI仕様について

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

開発

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

make
make test

ライセンス

Copyright (C) 2022-2025 The sacloud/cloudhsm-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/zone/is1b/api/cloud/1.1/"

	// DefaultEndpoint デフォルトのエンドポイントURL
	DefaultEndpoint = "https://secure.sakura.ad.jp/cloud/zone/"

	// DefaultZone クラウドHSM設置ゾーンのデフォルト
	DefaultZone = "is1b"
)
View Source
const Version = "0.4.1"

Variables

View Source
var (
	// UserAgent APIリクエスト時のユーザーエージェント
	UserAgent = fmt.Sprintf(
		"cloudhsm-api-go/%s (%s/%s; +https://github.com/sacloud/cloudhsm-api-go)",
		Version,
		runtime.GOOS,
		runtime.GOARCH,
	)

	// エンドポイントサービスキー
	ServiceKey = "cloudhsm"
)

Functions

func NewClient

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

func NewClientWithApiUrl

func NewClientWithApiUrl(apiUrl string, client saclient.ClientAPI) (*v1.Client, error)

Types

type ClientAPI

type ClientAPI interface {
	List(ctx context.Context) ([]v1.CloudHSMClient, error)
	Create(ctx context.Context, request CloudHSMClientCreateParams) (*v1.CloudHSMClient, error)
	Read(ctx context.Context, id string) (*v1.CloudHSMClient, error)
	Update(ctx context.Context, id string, params CloudHSMClientUpdateParams) (*v1.CloudHSMClient, error)
	Delete(ctx context.Context, id string) error
}

func NewClientOp

func NewClientOp(client *v1.Client, hsm *v1.CloudHSM) (ClientAPI, error)

type ClientOp

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

func (*ClientOp) Create

func (*ClientOp) Delete

func (op *ClientOp) Delete(ctx context.Context, id string) error

func (*ClientOp) List

func (op *ClientOp) List(ctx context.Context) ([]v1.CloudHSMClient, error)

func (*ClientOp) Read

func (op *ClientOp) Read(ctx context.Context, id string) (*v1.CloudHSMClient, error)

func (*ClientOp) Update

type CloudHSMAPI

type CloudHSMAPI interface {
	List(ctx context.Context) ([]v1.CloudHSM, error)
	Create(ctx context.Context, request CloudHSMCreateParams) (*v1.CreateCloudHSM, error)
	Read(ctx context.Context, id string) (*v1.CloudHSM, error)
	Update(ctx context.Context, id string, params CloudHSMUpdateParams) (*v1.CloudHSM, error)
	Delete(ctx context.Context, id string) error
}

func NewCloudHSMOp

func NewCloudHSMOp(client *v1.Client) CloudHSMAPI

type CloudHSMClientCreateParams

type CloudHSMClientCreateParams struct {
	Name        string
	Certificate string
}

type CloudHSMClientUpdateParams

type CloudHSMClientUpdateParams struct {
	Name string
}

type CloudHSMCreateParams

type CloudHSMCreateParams struct {
	Name               string
	Description        *string
	Tags               []string
	Ipv4NetworkAddress string
	Ipv4PrefixLength   int
}

type CloudHSMOp

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

func (*CloudHSMOp) Create

func (*CloudHSMOp) Delete

func (op *CloudHSMOp) Delete(ctx context.Context, id string) error

func (*CloudHSMOp) List

func (op *CloudHSMOp) List(ctx context.Context) ([]v1.CloudHSM, error)

func (*CloudHSMOp) Read

func (op *CloudHSMOp) Read(ctx context.Context, id string) (*v1.CloudHSM, error)

func (*CloudHSMOp) Update

type CloudHSMPeerCreateParams

type CloudHSMPeerCreateParams struct {
	RouterID  string
	SecretKey string
}

type CloudHSMSoftwareLicenseCreateParams

type CloudHSMSoftwareLicenseCreateParams struct {
	Name        string
	Description *string
	Tags        []string
}

type CloudHSMSoftwareLicenseUpdateParams

type CloudHSMSoftwareLicenseUpdateParams struct {
	Name        string
	Description string
	Tags        []string
}

type CloudHSMUpdateParams

type CloudHSMUpdateParams struct {
	Name               string
	Description        *string
	Tags               []string
	Ipv4NetworkAddress string
	Ipv4PrefixLength   int
}

type EmptySecuritySource

type EmptySecuritySource struct{}

func (EmptySecuritySource) BasicAuth

func (this EmptySecuritySource) BasicAuth(ctx context.Context, operationName v1.OperationName) (v1.BasicAuth, error)

type Error

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

func NewAPIError

func NewAPIError(method string, code int, err error) *Error

func NewError

func NewError(msg string, err error) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type LicenseOp

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

func (*LicenseOp) Delete

func (op *LicenseOp) Delete(ctx context.Context, id string) error

func (*LicenseOp) List

func (*LicenseOp) Read

type PeerAPI

type PeerAPI interface {
	List(ctx context.Context) ([]v1.CloudHSMPeer, error)
	Create(ctx context.Context, request CloudHSMPeerCreateParams) error
	Delete(ctx context.Context, id string) error
}

func NewPeerOp

func NewPeerOp(client *v1.Client, hsm *v1.CloudHSM) (PeerAPI, error)

type PeerOp

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

func (*PeerOp) Create

func (*PeerOp) Delete

func (op *PeerOp) Delete(ctx context.Context, id string) error

func (*PeerOp) List

func (op *PeerOp) List(ctx context.Context) ([]v1.CloudHSMPeer, error)

Directories

Path Synopsis
apis
v1

Jump to

Keyboard shortcuts

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