services

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 5 Imported by: 13

README

services

さくらのクラウド高レベルAPIライブラリ向け基盤

さくらのクラウドAPIライブラリをラップし、各リソースに対する統一的な操作インターフェースを提供します。

sacloud/servicesの実装プロジェクト

Note: IaaSとオブジェクトストレージは現在sacloud/servicesへの対応作業中です。

License

sacloud/services Copyright (C) 2022-2025 The sacloud/services Authors.

This project is published under Apache 2.0 License.

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Version バージョン

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	OptionDefs             []*meta.Option
	FormatErrorFieldNameFn func(name string) string
	MetaTagName            string // デフォルト: meta.DefaultTagName
}

Config サービスのバリデーションやメタデータ出力のためのコンフィグ

type Info

type Info struct {
	// サービスの名前(ケバブケース)
	Name string

	// サービスの説明
	Description string

	// 親サービスの名称リスト
	//
	// 例えばservice1サービスがservice1/service2/service3という階層構造の場合、
	// ["service1", "service2"]となる。
	// この場合、service3サービスの各操作ではService1IdとService2Idというフィールドが存在し、必須パラメータであることが期待される。
	// (ここで指定した名前をアッパーキャメルケースにしたものがフィールド名になる)
	ParentServices []string

	// カテゴリー名(ケバブケース)
	CategoryName string
}

Info サービスについての情報

func (*Info) Category added in v0.1.0

func (info *Info) Category() string

func (*Info) FullName added in v0.1.0

func (info *Info) FullName() string

FullName 親サービス名まで含めたサービス名称を返す

type OperationType added in v0.1.0

type OperationType int

OperationType サービスがサポートする操作の種別

const (
	OperationTypeUnknown OperationType = iota
	OperationTypeCreate                // Id:不要	/ 戻り値:単体
	OperationTypeRead                  // Id:要 	/ 戻り値:単体
	OperationTypeUpdate                // Id:要 	/ 戻り値:単体
	OperationTypeDelete                // Id:要 	/ 戻り値:なし
	OperationTypeList                  // Id:不要	/ 戻り値: スライス
	OperationTypeAction                // Id:要 	/ 戻り値: なし
)

func (OperationType) HasReturnValue added in v0.1.0

func (o OperationType) HasReturnValue() bool

func (OperationType) String added in v0.1.0

func (o OperationType) String() string

type Operations

type Operations []SupportedOperation

func (*Operations) Categories added in v0.1.0

func (o *Operations) Categories() []string

Categories 各操作のカテゴリーをアッパーキャメルケースにした上で昇順で返す

type ParameterExampleValuer added in v0.1.0

type ParameterExampleValuer interface {
	Examples() interface{}
}

ParameterExampleValuer パラメータが値の例示をサポートする場合に実装するインターフェース

ここで返される値はJSONまたはYAMLで出力されることがあるため適切なタグを付与しておくこと

type ParameterInitializer

type ParameterInitializer interface {
	// Initialize パラメータの初期カスタマイズ
	Initialize()
}

ParameterInitializer パラメータの初期化時に特別な処理を行いたい場合に実装すべきインターフェース

type ParameterValidator

type ParameterValidator interface {
	Validate() error
}

ParameterValidator パラメータが独自のバリデーションを実装する場合に実装すべきインターフェース

type Service

type Service interface {
	// Info サービスについての情報を返す
	Info() *Info

	// Operations サポートしている操作のメタデータ一覧
	// この要素それぞれに対しxxxWithContext()が存在することが期待される
	Operations() Operations

	// Config コンフィグ
	Config() *Config
}

Service 各サービスが実装すべきインターフェース

type Services added in v0.1.0

type Services []Service

func (Services) Categories added in v0.1.0

func (s Services) Categories() []string

Categories 各サービスのカテゴリーをアッパーキャメルケースにした上で昇順で返す

type SupportedOperation

type SupportedOperation struct {
	// 操作(メソッド)の名前(ケバブケース)
	Name string

	// 操作についての説明
	Description string

	// 操作種別、種別によりIdが必要/不要が決定される
	OperationType OperationType

	// この操作が属するカテゴリーの名称(省略可、指定する場合はケバブケース)
	CategoryName string
}

SupportedOperation サービスが提供する操作のメタデータ

func (*SupportedOperation) Category added in v0.1.0

func (op *SupportedOperation) Category() string

func (*SupportedOperation) EqualsByName added in v0.1.0

func (op *SupportedOperation) EqualsByName(name string) bool

func (*SupportedOperation) FuncName added in v0.1.0

func (op *SupportedOperation) FuncName() string

func (*SupportedOperation) WithContextFuncName added in v0.1.0

func (op *SupportedOperation) WithContextFuncName() string

WithContextFuncName Nameを持つFuncに対応する、context.Contextを受け取るFuncの名前を返す

Directories

Path Synopsis
Package examples
Package examples

Jump to

Keyboard shortcuts

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