Help us shape the future of Go! Take the 2026 Go Developer Survey

securitycontrol

package module
v0.3.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: 8 Imported by: 0

README

[!WARNING]

このレポジトリの内容は下記に集約・移転しました。 github.com/sacloud/sacloud-sdk-go

今後は上記のレポジトリで開発を行います。 このライブラリを使用している方は、importを変更していただきますようお願いいたします。

// 変更前
import "github.com/sacloud/security-control-api-go"

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

sacloud/security-control-api-go

Go言語向けのさくらのクラウド セキュリティコントロール APIライブラリ

マニュアル: https://manual.sakura.ad.jp/cloud/controlpanel/eventlog/security-control.html

APIドキュメント/OpenAPIは未公開なため、公開され次第更新。

概要

sacloud/security-control-api-goはさくらのクラウド セキュリティコントロール APIをGo言語から利用するためのAPIライブラリです。

package main

import (
	"context"
	"fmt"

	"github.com/sacloud/saclient-go"
	securitycontrol "github.com/sacloud/security-control-api-go"
	v1 "github.com/sacloud/security-control-api-go/apis/v1"
)

func runEvalRules() {
	var theClient saclient.Client
	client, err := securitycontrol.NewClient(&theClient)
	if err != nil {
		panic(err)
    }
    ctx := context.Background()

    // Evaluation Rules APIs
	erOp := securitycontrol.NewEvaluationRulesOp(client)
	erInput := securitycontrol.SetupEvaluationRuleInput(&securitycontrol.EvaluationRuleInputParams{
		ID:                 "server-no-public-ip",
		ServicePrincipalID: "111111111111",
		Targets:            []string{"is1b", "tk1b"},
		Enabled:            true,
	})
    updated, err := erOp.Update(ctx, "server-no-public-ip", erInput)
    // Read/List

    // Automated Actions API
    aaOp := securitycontrol.NewAutomatedActionsOp(client)
    created, err := aaOp.Create(ctx, &v1.AutomatedActionInput{
		Name:        "example-action",
		Description: v1.NewOptString("example automated action"),
		IsEnabled:   true,
		Action: v1.ActionDefinition{
			OneOf: v1.ActionDefinitionSum{
				Type: v1.ActionDefinitionSumType("simpleNotification"),
				ActionDefinitionSimpleNotification: v1.ActionDefinitionSimpleNotification{
					ActionType: v1.ActionDefinitionSimpleNotificationActionType("simpleNotification"),
					ActionParameter: v1.SakuraSimpleNotification{
						ServicePrincipalId:  "111111111111",
						NotificationGroupId: "111111111112",
					},
				},
			},
		},
		ExecutionCondition: `event.evaluationResult.status == "REJECTED"`,
	})
    // List/Read/Update/Delete

evaluation_rules_test.go / automated_actions_test.go 等も参照。

TODO: Automated Actions向けの設定ヘルパーを用意

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

License

security-control-api-go Copyright (C) 2026- The sacloud/security-control-api-go authors. This project is published under 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 = "https://secure.sakura.ad.jp/cloud/zone/tk1b/api/securitycontrol/1.0/"
)
View Source
const Version = "0.3.1"

Variables

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

Functions

func NewClient

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

func NewClientWithAPIRootURL

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

func SetupEvaluationRuleInput added in v0.2.0

func SetupEvaluationRuleInput(params *EvaluationRuleInputParams) *v1.EvaluationRuleInput

Types

type ActivationAPI added in v0.2.1

type ActivationAPI interface {
	Create(ctx context.Context, servicePrincipalID string) (*v1.ActivationOutput, error)
	Read(ctx context.Context) (*v1.ActivationOutput, error)
	Update(ctx context.Context, servicePrincipalID string, isActive bool) (*v1.ActivationOutput, error)
}

func NewActivationOp added in v0.2.1

func NewActivationOp(client *v1.Client) ActivationAPI

func NewActivationsOp

func NewActivationsOp(client *v1.Client) ActivationAPI

type ActivationsAPI deprecated

type ActivationsAPI interface {
	ActivationAPI
}

Deprecated: use ActivationAPI instead

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 EvaluationRuleInputParams added in v0.2.0

type EvaluationRuleInputParams struct {
	ID                 string
	ServicePrincipalID string
	Targets            []string
	Enabled            bool
}

type EvaluationRulesAPI

type EvaluationRulesAPI interface {
	List(ctx context.Context, parameter v1.EvaluationRulesListParams) (*v1.EvaluationRulesListOK, error)
	Read(ctx context.Context, id string) (*v1.EvaluationRule, error)
	Update(ctx context.Context, id string, req *v1.EvaluationRuleInput) (*v1.EvaluationRule, error)
}

func NewEvaluationRulesOp

func NewEvaluationRulesOp(client *v1.Client) EvaluationRulesAPI

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