eventbus

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

sacloud/eventbus-api-go

Go言語向けのさくらのクラウド EventBus APIライブラリ

EventBus APIドキュメント: https://manual.sakura.ad.jp/cloud/appliance/eventbus/index.html

概要

sacloud/eventbus-api-goはさくらのクラウド EventBus APIをGo言語から利用するためのAPIライブラリです。

package main

import (
    "context"
    "fmt"
    "strconv"
    "time"

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

func main() {
    client, err := eventbus.NewClient()
    if err != nil {
        panic(err)
    }
    ctx := context.Background()
    pcOp := eventbus.NewProcessConfigurationOp(client)
    schedOp := eventbus.NewScheduleOp(client)

    // テスト用の実行設定の生成 (1111111111はリソースIDの例)
    pc, err := pcOp.Create(ctx, v1.ProcessConfigurationRequestSettings{
        Name: "実行設定1", Description: "アプリ向け実行設定",
        Settings: eventbus.CreateSimpleNotificationSettings("1111111111", "Hello"),
    })
    if err != nil {
        panic(err)
    }
    pcId := strconv.FormatInt(pc.ID, 10)

    res, err := schedOp.Create(ctx, v1.ScheduleRequestSettings{
        Name: "スケジュール1", Description: "アプリ向けスケジュール",
        Settings: v1.ScheduleSettings{
            ProcessConfigurationID: pcId,
            RecurringStep:          10,
            RecurringUnit:          "min",
            StartsAt:               time.Now().UnixMilli(),
        },
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(res.Name)
}

process_configurations_test.go / schedules_test.go も参照。

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

TODO

  • EventBusが公開用OpenAPI定義を提供したらそちらを利用(現在は内部向けAPIを手動でogenにマッピングしている)

License

eventbus-api-go Copyright (C) 2025- The sacloud/eventbus-api-go authors. This project is published under Apache 2.0 License.

Documentation

Index

Constants

View Source
const DefaultAPIRootURL = "https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/"

DefaultAPIRootURL デフォルトのAPIルートURL

View Source
const Version = "0.3.2"

Variables

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

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

Functions

func CreateSimpleMqSettings

func CreateSimpleMqSettings(queueName string, content string) v1.DestinationSettings

func CreateSimpleNotificationSettings

func CreateSimpleNotificationSettings(groupId string, message string) v1.DestinationSettings

func NewClient

func NewClient(params ...client.ClientParam) (*v1.Client, error)

func NewClientWithApiUrl

func NewClientWithApiUrl(apiUrl string, params ...client.ClientParam) (*v1.Client, error)

Types

type DummySecuritySource

type DummySecuritySource struct {
	Token string
}

SecuritySourceはOpenAPI定義で使用されている認証のための仕組み。api-client-goが処理するので、ogen用はダミーで誤魔化す

func (DummySecuritySource) CloudCtrlAuth

func (ss DummySecuritySource) CloudCtrlAuth(ctx context.Context, operationName v1.OperationName) (v1.CloudCtrlAuth, error)

type Error added in v0.3.0

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

func NewAPIError added in v0.3.1

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

func NewError added in v0.3.0

func NewError(msg string, err error) *Error

func (*Error) Error added in v0.3.0

func (e *Error) Error() string

func (*Error) Unwrap added in v0.3.0

func (e *Error) Unwrap() error

type ScheduleAPI

type ScheduleAPI interface {
	List(ctx context.Context) ([]v1.Schedule, error)
	Read(ctx context.Context, id string) (*v1.Schedule, error)
	Create(ctx context.Context, request v1.ScheduleRequestSettings) (*v1.Schedule, error)
	Update(ctx context.Context, id string, request v1.ScheduleRequestSettings) (*v1.Schedule, error)
	Delete(ctx context.Context, id string) error
}

func NewScheduleOp

func NewScheduleOp(client *v1.Client) ScheduleAPI

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