Documentation
¶
Overview ¶
Package phy さくらの専用サーバPHY API ライブラリ
Example ¶
client := &phy.Client{ APIRootURL: serverURL, // 省略可 } // サーバ操作 serverOp := phy.NewServerOp(client) found, err := serverOp.List(context.Background(), &v1.ListServersParams{}) if err != nil { panic(err) } for _, sv := range found.Servers { fmt.Println(sv.Service.Nickname) }
Output: server01
Index ¶
- Constants
- Variables
- type Client
- type DedicatedSubnetAPI
- type DedicatedSubnetOp
- type PrivateNetworkAPI
- type PrivateNetworkOp
- type ServerAPI
- type ServerOp
- func (op *ServerOp) AssignNetwork(ctx context.Context, serverId v1.ServerId, portId v1.PortId, ...) (*v1.InterfacePort, error)
- func (op *ServerOp) ConfigureBonding(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId, ...) (*v1.PortChannel, error)
- func (op *ServerOp) EnablePort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, enable bool) (*v1.InterfacePort, error)
- func (op *ServerOp) List(ctx context.Context, params *v1.ListServersParams) (*v1.Servers, error)
- func (op *ServerOp) ListOSImages(ctx context.Context, serverId v1.ServerId) ([]*v1.OsImage, error)
- func (op *ServerOp) OSInstall(ctx context.Context, serverId v1.ServerId, params v1.OsInstallParameter) error
- func (op *ServerOp) PowerControl(ctx context.Context, serverId v1.ServerId, operation v1.ServerPowerOperations) error
- func (op *ServerOp) Read(ctx context.Context, serverId v1.ServerId) (*v1.Server, error)
- func (op *ServerOp) ReadPort(ctx context.Context, serverId v1.ServerId, portId v1.PortId) (*v1.InterfacePort, error)
- func (op *ServerOp) ReadPortChannel(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId) (*v1.PortChannel, error)
- func (op *ServerOp) ReadPowerStatus(ctx context.Context, serverId v1.ServerId) (*v1.ServerPowerStatus, error)
- func (op *ServerOp) ReadRAIDStatus(ctx context.Context, serverId v1.ServerId, refresh bool) (*v1.RaidStatus, error)
- func (op *ServerOp) ReadTrafficByPort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, ...) (*v1.TrafficGraph, error)
- func (op *ServerOp) UpdatePort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, ...) (*v1.InterfacePort, error)
- type ServiceAPI
- type ServiceOp
- func (op *ServiceOp) List(ctx context.Context, params *v1.ListServicesParams) (*v1.Services, error)
- func (op *ServiceOp) Read(ctx context.Context, serviceId v1.ServiceId) (*v1.Service, error)
- func (op *ServiceOp) Update(ctx context.Context, serviceId v1.ServiceId, params v1.UpdateServiceParameter) (*v1.Service, error)
Examples ¶
Constants ¶
View Source
const DefaultAPIRootURL = "https://secure.sakura.ad.jp/cloud/api/dedicated-phy/1.0/"
DefaultAPIRootURL デフォルトのAPIルートURL
Variables ¶
View Source
var UserAgent = fmt.Sprintf( "phy-api-go/v%s (%s/%s; +https://github.com/sacloud/phy-api-go) %s", Version, runtime.GOOS, runtime.GOARCH, client.DefaultUserAgent, )
UserAgent APIリクエスト時のユーザーエージェント
View Source
var (
// Version app version
Version = "0.1.3"
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Profile usacloud互換プロファイル名 Profile string // APIRootURL APIのリクエスト先URLプレフィックス、省略可能 APIRootURL string // AccessToken APIキー:トークン // Optionsでの指定より優先される AccessToken string // AccessTokenSecret APIキー:シークレット // Optionsでの指定より優先される AccessTokenSecret string // Options HTTPクライアント関連オプション Options *client.Options // DisableProfile usacloud互換プロファイルからの設定読み取りを無効化 DisableProfile bool // DisableEnv 環境変数からの設定読み取りを無効化 DisableEnv bool // contains filtered or unexported fields }
Client APIクライアント
type DedicatedSubnetAPI ¶
type DedicatedSubnetAPI interface { List(ctx context.Context, params *v1.ListDedicatedSubnetsParams) (*v1.DedicatedSubnets, error) Read(ctx context.Context, dedicatedSubnetId v1.DedicatedSubnetId, refresh bool) (*v1.DedicatedSubnet, error) }
DedicatedSubnetAPI 専用グローバルネットワーク関連API
func NewDedicatedSubnetOp ¶
func NewDedicatedSubnetOp(client *Client) DedicatedSubnetAPI
type DedicatedSubnetOp ¶
type DedicatedSubnetOp struct {
// contains filtered or unexported fields
}
func (*DedicatedSubnetOp) List ¶
func (op *DedicatedSubnetOp) List(ctx context.Context, params *v1.ListDedicatedSubnetsParams) (*v1.DedicatedSubnets, error)
func (*DedicatedSubnetOp) Read ¶
func (op *DedicatedSubnetOp) Read(ctx context.Context, dedicatedSubnetId v1.DedicatedSubnetId, refresh bool) (*v1.DedicatedSubnet, error)
type PrivateNetworkAPI ¶
type PrivateNetworkAPI interface { List(ctx context.Context, params *v1.ListPrivateNetworksParams) (*v1.PrivateNetworks, error) Read(ctx context.Context, privateNetworkId v1.PrivateNetworkId) (*v1.PrivateNetwork, error) }
PrivateNetworkAPI ローカルネットワーク関連API
func NewPrivateNetworkOp ¶
func NewPrivateNetworkOp(client *Client) PrivateNetworkAPI
type PrivateNetworkOp ¶
type PrivateNetworkOp struct {
// contains filtered or unexported fields
}
func (*PrivateNetworkOp) List ¶
func (op *PrivateNetworkOp) List(ctx context.Context, params *v1.ListPrivateNetworksParams) (*v1.PrivateNetworks, error)
func (*PrivateNetworkOp) Read ¶
func (op *PrivateNetworkOp) Read(ctx context.Context, privateNetworkId v1.PrivateNetworkId) (*v1.PrivateNetwork, error)
type ServerAPI ¶
type ServerAPI interface { List(ctx context.Context, params *v1.ListServersParams) (*v1.Servers, error) Read(ctx context.Context, serverId v1.ServerId) (*v1.Server, error) ListOSImages(ctx context.Context, serverId v1.ServerId) ([]*v1.OsImage, error) OSInstall(ctx context.Context, serverId v1.ServerId, params v1.OsInstallParameter) error ReadPortChannel(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId) (*v1.PortChannel, error) ConfigureBonding(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId, params v1.ConfigureBondingParameter) (*v1.PortChannel, error) ReadPort(ctx context.Context, serverId v1.ServerId, portId v1.PortId) (*v1.InterfacePort, error) UpdatePort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, params v1.UpdateServerPortParameter) (*v1.InterfacePort, error) EnablePort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, enable bool) (*v1.InterfacePort, error) AssignNetwork(ctx context.Context, serverId v1.ServerId, portId v1.PortId, params v1.AssignNetworkParameter) (*v1.InterfacePort, error) ReadTrafficByPort(ctx context.Context, serverId v1.ServerId, portId v1.PortId, params v1.ReadServerTrafficByPortParams) (*v1.TrafficGraph, error) PowerControl(ctx context.Context, serverId v1.ServerId, operation v1.ServerPowerOperations) error ReadPowerStatus(ctx context.Context, serverId v1.ServerId) (*v1.ServerPowerStatus, error) ReadRAIDStatus(ctx context.Context, serverId v1.ServerId, refresh bool) (*v1.RaidStatus, error) }
Example ¶
client := &phy.Client{ APIRootURL: serverURL, // 省略可 } // サーバ操作 ctx := context.Background() serverOp := phy.NewServerOp(client) found, err := serverOp.List(ctx, &v1.ListServersParams{}) if err != nil { panic(err) } // 電源がONのサーバをシャットダウン for _, sv := range found.Servers { if sv.CachedPowerStatus.Status == v1.CachedPowerStatusStatusOn { // v1.ServerPowerOperationsSoft == ACPIシャットダウン if err := serverOp.PowerControl(ctx, sv.ServerId, v1.ServerPowerOperationsSoft); err != nil { panic(err) } fmt.Printf("shutting down: %s\n", sv.Service.Nickname) } }
Output: shutting down: server01
func NewServerOp ¶
type ServerOp ¶
type ServerOp struct {
// contains filtered or unexported fields
}
func (*ServerOp) AssignNetwork ¶
func (*ServerOp) ConfigureBonding ¶
func (op *ServerOp) ConfigureBonding(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId, params v1.ConfigureBondingParameter) (*v1.PortChannel, error)
func (*ServerOp) EnablePort ¶
func (*ServerOp) ListOSImages ¶
func (*ServerOp) PowerControl ¶
func (*ServerOp) ReadPortChannel ¶
func (op *ServerOp) ReadPortChannel(ctx context.Context, serverId v1.ServerId, portChannelId v1.PortChannelId) (*v1.PortChannel, error)
func (*ServerOp) ReadPowerStatus ¶
func (*ServerOp) ReadRAIDStatus ¶
func (*ServerOp) ReadTrafficByPort ¶
func (*ServerOp) UpdatePort ¶
type ServiceAPI ¶
type ServiceAPI interface { List(ctx context.Context, params *v1.ListServicesParams) (*v1.Services, error) Read(ctx context.Context, serviceId v1.ServiceId) (*v1.Service, error) Update(ctx context.Context, serviceId v1.ServiceId, params v1.UpdateServiceParameter) (*v1.Service, error) }
ServiceAPI サービス関連API
Example ¶
client := &phy.Client{ APIRootURL: serverURL, // 省略可 } // サービス一覧取得 serviceOp := phy.NewServiceOp(client) found, err := serviceOp.List(context.Background(), &v1.ListServicesParams{}) if err != nil { panic(err) } for _, svc := range found.Services { fmt.Println(svc.Nickname) }
Output: server01
func NewServiceOp ¶
func NewServiceOp(client *Client) ServiceAPI
Source Files
¶
Click to show internal directories.
Click to hide internal directories.