monitoringsuite

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

README

monitoring-suite-api-go

Go Reference Tests Go Report Card

さくらのクラウド「モニタリングスイート」APIのGoクライアントライブラリ

概要

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

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

インストール

go get github.com/sacloud/monitoring-suite-api-go

使い方

import (
    "context"

    "github.com/sacloud/monitoring-suite-api-go"
)

ctx := context.Background()
client, err := monitoringsuite.NewClient()
if err != nil {
	// エラーハンドリング
}
// 例: アラートプロジェクト一覧取得
projects, err := NewAlertProjectOp(client).List(ctx, 32768, 0)

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

OpenAPI仕様について

openapi/openapi.jsonモニタリングスイート API ドキュメントからダウンロードしたものを一部加工しています。

$ jq 'del(.paths.[].[].requestBody.content.["application/x-www-form-urlencoded", "multipart/form-data"])' openapi.json

開発

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

make
make test

ライセンス

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

Documentation

Index

Constants

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

Variables

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

	RequestCustomizers = []saht.RequestCustomizer{
		func(req *http.Request) error {
			req.Header.Set("X-Sakura-Bigint-As-Int", "1")
			return nil
		},
	}
)

Functions

func NewClient

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

func NewClientWithApiUrl

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

func NewClientWithApiUrlAndClient

func NewClientWithApiUrlAndClient(apiUrl string, apiClient *http.Client, params ...client.ClientParam) (*v1.Client, error)

func Unwrap

func Unwrap[T json.Unmarshaler, U json.Marshaler](dst T, src U) (T, error)

Types

type AlertProjectAPI

type AlertProjectAPI interface {
	List(ctx context.Context, count *int, from *int) ([]v1.AlertProject, error)
	Create(ctx context.Context, params AlertProjectCreateParams) (*v1.AlertProject, error)
	Read(ctx context.Context, id string) (*v1.WrappedAlertProject, error)
	Update(ctx context.Context, id string, request AlertProjectUpdateParams) (*v1.WrappedAlertProject, error)
	Delete(ctx context.Context, id string) error

	ListHistories(ctx context.Context, params AlertsProjectsHistoriesListParams) ([]v1.History, error)
	ReadHistory(ctx context.Context, projectId string, historyId uuid.UUID) (*v1.History, error)
}

func NewAlertProjectOp

func NewAlertProjectOp(client *v1.Client) AlertProjectAPI

type AlertProjectCreateParams

type AlertProjectCreateParams struct {
	Name        string
	Description *string
}

type AlertProjectUpdateParams

type AlertProjectUpdateParams struct {
	Name        *string
	Description *string
}

type AlertRuleAPI

type AlertRuleAPI interface {
	List(ctx context.Context, projectId string, count *int, from *int) ([]v1.AlertRule, error)
	Create(ctx context.Context, projectId string, params AlertRuleCreateParams) (*v1.AlertRule, error)
	Read(ctx context.Context, projectId string, ruleId uuid.UUID) (*v1.AlertRule, error)
	Update(ctx context.Context, projectId string, ruleId uuid.UUID, params AlertRuleUpdateParams) (*v1.AlertRule, error)
	Delete(ctx context.Context, projectId string, ruleId uuid.UUID) error

	ListHistories(ctx context.Context, projectId string, ruleId uuid.UUID, params AlertRuleListHistoriesParams) ([]v1.History, error)
	ReadHistory(ctx context.Context, projectId string, ruleId uuid.UUID, historyId uuid.UUID) (*v1.History, error)
}

func NewAlertRuleOp

func NewAlertRuleOp(client *v1.Client) AlertRuleAPI

type AlertRuleCreateParams

type AlertRuleCreateParams struct {
	MetricsStorageID          string // mandatory
	Name                      *string
	Query                     string // mandatory
	Format                    *string
	Template                  *string
	EnabledWarning            *bool
	EnabledCritical           *bool
	ThresholdWarning          *string
	ThresholdCritical         *string
	ThresholdDurationWarning  *int64
	ThresholdDurationCritical *int64
}

type AlertRuleListHistoriesParams

type AlertRuleListHistoriesParams struct {
	Count    *int
	From     *int
	Open     *bool
	Severity *v1.AlertsProjectsRulesHistoriesListSeverity
	StartsAt *time.Time
}

type AlertRuleUpdateParams

type AlertRuleUpdateParams struct {
	MetricsStorageID          *string
	Name                      *string
	Query                     *string
	Format                    *string
	Template                  *string
	EnabledWarning            *bool
	EnabledCritical           *bool
	ThresholdWarning          *string
	ThresholdCritical         *string
	ThresholdDurationWarning  *int64
	ThresholdDurationCritical *int64
}

type AlertsProjectsHistoriesListParams

type AlertsProjectsHistoriesListParams struct {
	ProjectID string // mandatory
	Count     *int
	From      *int
	Open      *bool
	Severity  *v1.AlertsProjectsHistoriesListSeverity
	StartsAt  *time.Time
}

type DashboardProjectAPI

type DashboardProjectAPI interface {
	List(ctx context.Context, count *int, from *int) ([]v1.DashboardProject, error)
	Create(ctx context.Context, request DashboardProjectCreateParams) (*v1.DashboardProject, error)
	Read(ctx context.Context, id string) (*v1.DashboardProject, error)
	Update(ctx context.Context, id string, params DashboardProjectUpdateParams) (*v1.DashboardProject, error)
	Delete(ctx context.Context, id string) error
}

func NewDashboardOp

func NewDashboardOp(client *v1.Client) DashboardProjectAPI

type DashboardProjectCreateParams

type DashboardProjectCreateParams struct {
	Name        string
	Description *string
}

type DashboardProjectUpdateParams

type DashboardProjectUpdateParams struct {
	Name        *string
	Description *string
}

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 LogMeasureRuleAPI

type LogMeasureRuleAPI interface {
	List(ctx context.Context, projectId string, count *int, from *int) ([]v1.LogMeasureRule, error)
	Create(ctx context.Context, projectId string, params LogMeasureRuleCreateParams) (*v1.LogMeasureRule, error)
	Read(ctx context.Context, projectId string, ruleId uuid.UUID) (*v1.LogMeasureRule, error)
	Update(ctx context.Context, projectId string, ruleId uuid.UUID, params LogMeasureRuleUpdateParams) (*v1.LogMeasureRule, error)
	Delete(ctx context.Context, projectId string, ruleId uuid.UUID) error

	ListHistories(ctx context.Context, projectId string, params LogMeasureRuleListHistoriesParams) ([]v1.History, error)
	ReadHistory(ctx context.Context, projectId string, historyId uuid.UUID) (*v1.History, error)
}

func NewLogMeasureRuleOp

func NewLogMeasureRuleOp(client *v1.Client) LogMeasureRuleAPI

type LogMeasureRuleCreateParams

type LogMeasureRuleCreateParams struct {
	LogStorageID     string
	MetricsStorageID string
	Name             *string
	Description      *string
	Rule             v1.LogMeasureRuleModel
}

type LogMeasureRuleListHistoriesParams

type LogMeasureRuleListHistoriesParams struct {
	Count    *int
	From     *int
	Open     *bool
	Severity *v1.AlertsProjectsHistoriesListSeverity
	StartsAt *time.Time
}

type LogMeasureRuleUpdateParams

type LogMeasureRuleUpdateParams struct {
	LogStorageID     *string
	MetricsStorageID *string
	Name             *string
	Description      *string
	Rule             *v1.LogMeasureRuleModel
}

type LogRoutingAPI

type LogRoutingAPI interface {
	List(ctx context.Context, params LogsRoutingsListParams) ([]v1.LogRouting, error)
	Create(ctx context.Context, params LogsRoutingCreateParams) (*v1.LogRouting, error)
	Read(ctx context.Context, id uuid.UUID) (*v1.LogRouting, error)
	Update(ctx context.Context, id uuid.UUID, params LogsRoutingUpdateParams) (*v1.LogRouting, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

func NewLogRoutingOp

func NewLogRoutingOp(client *v1.Client) LogRoutingAPI

type LogStorageCreateParams

type LogStorageCreateParams struct {
	Name           string
	Description    *string
	IsSystem       bool
	Classification *v1.LogStorageCreateClassification
}

type LogStorageUpdateParams

type LogStorageUpdateParams struct {
	Name        *string
	Description *string
	ExpireDay   *int64
}

type LogsRoutingCreateParams

type LogsRoutingCreateParams struct {
	PublisherCode string
	ResourceID    *string
	Variant       string
	LogStorageID  string
}

type LogsRoutingUpdateParams

type LogsRoutingUpdateParams struct {
	PublisherCode *string
	ResourceID    *string
	Variant       *string
	LogStorageID  *string
}

type LogsRoutingsListParams

type LogsRoutingsListParams struct {
	Count         *int
	From          *int
	PublisherCode *string
	ResourceID    *int64
	Variant       *string
}

type LogsStorageAPI

type LogsStorageAPI interface {
	List(ctx context.Context, params LogsStoragesListParams) ([]v1.LogStorage, error)
	Create(ctx context.Context, params LogStorageCreateParams) (*v1.LogStorage, error)
	Read(ctx context.Context, id string) (*v1.LogStorage, error)
	Update(ctx context.Context, id string, params LogStorageUpdateParams) (*v1.LogStorage, error)
	Delete(ctx context.Context, id string) error

	ListKeys(ctx context.Context, logResourceId string, count *int, from *int) ([]v1.LogStorageAccessKey, error)
	CreateKey(ctx context.Context, logResourceId string, description *string) (*v1.LogStorageAccessKey, error)
	ReadKey(ctx context.Context, logResourceId string, id uuid.UUID) (*v1.LogStorageAccessKey, error)
	UpdateKey(ctx context.Context, logResourceId string, id uuid.UUID, description *string) (*v1.LogStorageAccessKey, error)
	DeleteKey(ctx context.Context, logResourceId string, id uuid.UUID) error
}

func NewLogsStorageOp

func NewLogsStorageOp(client *v1.Client) LogsStorageAPI

type LogsStoragesListParams

type LogsStoragesListParams struct {
	AccountID            *string
	BucketClassification *v1.LogsStoragesListBucketClassification
	Count                *int
	From                 *int
	IsSystem             *bool
	ResourceID           *string
	Status               *v1.LogsStoragesListStatus
}

type ManagementAPI

type ManagementAPI interface {
	ResourceLimits(ctx context.Context) (*v1.ResourcesLimits, error)
	ReadProvisioning(ctx context.Context) (*v1.Provisioning, error)
	CreateProvisioning(ctx context.Context, request ProvisioningCreateParam) (*v1.Provisioning, error)
}

func NewManagementOp

func NewManagementOp(client *v1.Client) ManagementAPI

type MetricsRoutingAPI

type MetricsRoutingAPI interface {
	List(ctx context.Context, params MetricsRoutingsListParams) ([]v1.MetricsRouting, error)
	Create(ctx context.Context, params MetricsRoutingCreateParams) (*v1.MetricsRouting, error)
	Read(ctx context.Context, id uuid.UUID) (*v1.MetricsRouting, error)
	Update(ctx context.Context, id uuid.UUID, params MetricsRoutingUpdateParams) (*v1.MetricsRouting, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

func NewMetricsRoutingOp

func NewMetricsRoutingOp(client *v1.Client) MetricsRoutingAPI

type MetricsRoutingCreateParams

type MetricsRoutingCreateParams struct {
	PublisherCode    string
	ResourceID       *string
	Variant          string
	MetricsStorageID string
}

type MetricsRoutingUpdateParams

type MetricsRoutingUpdateParams struct {
	PublisherCode    *string
	ResourceID       *string
	Variant          *string
	MetricsStorageID *string
}

type MetricsRoutingsListParams

type MetricsRoutingsListParams struct {
	Count         *int
	From          *int
	PublisherCode *string
	ResourceID    *int64
	Variant       *string
}

type MetricsStorageAPI

type MetricsStorageAPI interface {
	List(ctx context.Context, params MetricsStorageListParams) ([]v1.MetricsStorage, error)
	Create(ctx context.Context, request MetricsStorageCreateParams) (*v1.MetricsStorage, error)
	Read(ctx context.Context, id string) (*v1.MetricsStorage, error)
	Update(ctx context.Context, id string, request MetricsStorageUpdateParams) (*v1.MetricsStorage, error)
	Delete(ctx context.Context, id string) error

	ListKeys(ctx context.Context, metricsResourceId string, count *int, from *int) ([]v1.MetricsStorageAccessKey, error)
	CreateKey(ctx context.Context, metricsResourceId string, description *string) (*v1.MetricsStorageAccessKey, error)
	ReadKey(ctx context.Context, metricsResourceId string, id uuid.UUID) (*v1.MetricsStorageAccessKey, error)
	UpdateKey(ctx context.Context, metricsResourceId string, id uuid.UUID, description *string) (*v1.MetricsStorageAccessKey, error)
	DeleteKey(ctx context.Context, metricsResourceId string, id uuid.UUID) error
}

func NewMetricsStorageOp

func NewMetricsStorageOp(client *v1.Client) MetricsStorageAPI

type MetricsStorageCreateParams

type MetricsStorageCreateParams struct {
	Name        string
	Description *string
	IsSystem    bool
}

type MetricsStorageListParams

type MetricsStorageListParams struct {
	Count      *int
	From       *int
	AccountID  *string
	ResourceID *string
	IsSystem   *bool
}

type MetricsStorageUpdateParams

type MetricsStorageUpdateParams struct {
	Name        *string
	Description *string
}

type NotificationRoutingAPI

type NotificationRoutingAPI interface {
	List(ctx context.Context, projectId string, count, from *int) ([]v1.NotificationRouting, error)
	Create(ctx context.Context, projectId string, params NotificationRoutingCreateParams) (*v1.NotificationRouting, error)
	Read(ctx context.Context, projectId string, id uuid.UUID) (*v1.NotificationRouting, error)
	Update(ctx context.Context, projectId string, id uuid.UUID, params NotificationRoutingUpdateParams) (*v1.NotificationRouting, error)
	Delete(ctx context.Context, projectId string, id uuid.UUID) error

	Reorder(ctx context.Context, projectId string, orders []v1.NotificationRoutingOrder) error
}

func NewNotificationRoutingOp

func NewNotificationRoutingOp(client *v1.Client) NotificationRoutingAPI

type NotificationRoutingCreateParams

type NotificationRoutingCreateParams struct {
	// Fields based on v1.NotificationRouting
	NotificationTargetUID uuid.UUID
	MatchLabels           []v1.MatchLabelsItem
	ResendIntervalMinutes *int
}

type NotificationRoutingUpdateParams

type NotificationRoutingUpdateParams struct {
	// Fields based on v1.PatchedNotificationRouting
	NotificationTargetUID *uuid.UUID
	MatchLabels           []v1.MatchLabelsItem
	ResendIntervalMinutes *int
}

type NotificationTargetAPI

type NotificationTargetAPI interface {
	List(ctx context.Context, projectId string, params NotificationTargetsListParams) ([]v1.NotificationTarget, error)
	Create(ctx context.Context, projectId string, params NotificationTargetCreateParams) (*v1.NotificationTarget, error)
	Read(ctx context.Context, projectId string, id uuid.UUID) (*v1.NotificationTarget, error)
	Update(ctx context.Context, projectId string, id uuid.UUID, params NotificationTargetUpdateParams) (*v1.NotificationTarget, error)
	Delete(ctx context.Context, projectId string, id uuid.UUID) error
}

func NewNotificationTargetOp

func NewNotificationTargetOp(client *v1.Client) NotificationTargetAPI

type NotificationTargetCreateParams

type NotificationTargetCreateParams struct {
	ServiceType v1.NotificationTargetServiceType
	URL         url.URL
	Description *string
}

type NotificationTargetUpdateParams

type NotificationTargetUpdateParams struct {
	ServiceType *v1.PatchedNotificationTargetServiceType
	URL         *string
	Description *string
}

type NotificationTargetsListParams

type NotificationTargetsListParams struct {
	Count *int
	From  *int
}

type ProvisioningCreateParam

type ProvisioningCreateParam struct {
	Logs    *v1.ProvisioningExist
	Metrics *v1.ProvisioningExist
}

type PublisherAPI

type PublisherAPI interface {
	List(ctx context.Context, count *int, from *int) ([]v1.Publisher, error)
	Read(ctx context.Context, code string) (*v1.Publisher, error)
}

func NewPublisherOp

func NewPublisherOp(client *v1.Client) PublisherAPI

type TracesStorageAPI

type TracesStorageAPI interface {
	List(ctx context.Context, params TracesStorageListParams) ([]v1.TraceStorage, error)
	Create(ctx context.Context, request TracesStorageCreateParams) (*v1.TraceStorage, error)
	Read(ctx context.Context, id string) (*v1.TraceStorage, error)
	Update(ctx context.Context, id string, request TracesStorageUpdateParams) (*v1.TraceStorage, error)
	Delete(ctx context.Context, id string) error

	ListKeys(ctx context.Context, tracesResourceId string, count *int, from *int) ([]v1.TraceStorageAccessKey, error)
	CreateKey(ctx context.Context, tracesResourceId string, description *string) (*v1.TraceStorageAccessKey, error)
	ReadKey(ctx context.Context, tracesResourceId string, id uuid.UUID) (*v1.TraceStorageAccessKey, error)
	UpdateKey(ctx context.Context, tracesResourceId string, id uuid.UUID, description *string) (*v1.TraceStorageAccessKey, error)
	DeleteKey(ctx context.Context, tracesResourceId string, id uuid.UUID) error
}

func NewTracesStorageOp

func NewTracesStorageOp(client *v1.Client) TracesStorageAPI

type TracesStorageCreateParams

type TracesStorageCreateParams struct {
	Name           string
	Description    *string
	Classification *v1.TraceStorageCreateClassification
}

type TracesStorageListParams

type TracesStorageListParams struct {
	Count                *int
	From                 *int
	AccountID            *string
	ResourceID           *string
	BucketClassification *v1.TracesStoragesListLogStorageBucketClassification
}

type TracesStorageUpdateParams

type TracesStorageUpdateParams struct {
	Name        *string
	Description *string
}

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