forked from TrueCloudLab/lego
42941ccea6
- Packages - Isolate code used by the CLI into the package `cmd` - (experimental) Add e2e tests for HTTP01, TLS-ALPN-01 and DNS-01, use [Pebble](https://github.com/letsencrypt/pebble) and [challtestsrv](https://github.com/letsencrypt/boulder/tree/master/test/challtestsrv) - Support non-ascii domain name (punnycode) - Check all challenges in a predictable order - No more global exported variables - Archive revoked certificates - Fixes revocation for subdomains and non-ascii domains - Disable pending authorizations - use pointer for RemoteError/ProblemDetails - Poll authz URL instead of challenge URL - The ability for a DNS provider to solve the challenge sequentially - Check all nameservers in a predictable order - Option to disable the complete propagation Requirement - CLI, support for renew with CSR - CLI, add SAN on renew - Add command to list certificates. - Logs every iteration of waiting for the propagation - update DNSimple client - update github.com/miekg/dns
107 lines
3 KiB
Go
107 lines
3 KiB
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/sacloud/libsacloud/sacloud"
|
|
)
|
|
|
|
// InterfaceAPI インターフェースAPI
|
|
type InterfaceAPI struct {
|
|
*baseAPI
|
|
}
|
|
|
|
// NewInterfaceAPI インターフェースAPI作成
|
|
func NewInterfaceAPI(client *Client) *InterfaceAPI {
|
|
return &InterfaceAPI{
|
|
&baseAPI{
|
|
client: client,
|
|
FuncGetResourceURL: func() string {
|
|
return "interface"
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
// CreateAndConnectToServer 新規作成しサーバーへ接続する
|
|
func (api *InterfaceAPI) CreateAndConnectToServer(serverID int64) (*sacloud.Interface, error) {
|
|
iface := api.New()
|
|
iface.Server = &sacloud.Server{
|
|
// Resource
|
|
Resource: &sacloud.Resource{ID: serverID},
|
|
}
|
|
return api.Create(iface)
|
|
}
|
|
|
|
// ConnectToSwitch スイッチへ接続する
|
|
func (api *InterfaceAPI) ConnectToSwitch(interfaceID int64, switchID int64) (bool, error) {
|
|
var (
|
|
method = "PUT"
|
|
uri = fmt.Sprintf("%s/%d/to/switch/%d", api.getResourceURL(), interfaceID, switchID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|
|
|
|
// ConnectToSharedSegment 共有セグメントへ接続する
|
|
func (api *InterfaceAPI) ConnectToSharedSegment(interfaceID int64) (bool, error) {
|
|
var (
|
|
method = "PUT"
|
|
uri = fmt.Sprintf("%s/%d/to/switch/shared", api.getResourceURL(), interfaceID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|
|
|
|
// DisconnectFromSwitch スイッチと切断する
|
|
func (api *InterfaceAPI) DisconnectFromSwitch(interfaceID int64) (bool, error) {
|
|
var (
|
|
method = "DELETE"
|
|
uri = fmt.Sprintf("%s/%d/to/switch", api.getResourceURL(), interfaceID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|
|
|
|
// Monitor アクティビティーモニター取得
|
|
func (api *InterfaceAPI) Monitor(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
|
return api.baseAPI.monitor(id, body)
|
|
}
|
|
|
|
// ConnectToPacketFilter パケットフィルター適用
|
|
func (api *InterfaceAPI) ConnectToPacketFilter(interfaceID int64, packetFilterID int64) (bool, error) {
|
|
var (
|
|
method = "PUT"
|
|
uri = fmt.Sprintf("/%s/%d/to/packetfilter/%d", api.getResourceURL(), interfaceID, packetFilterID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|
|
|
|
// DisconnectFromPacketFilter パケットフィルター切断
|
|
func (api *InterfaceAPI) DisconnectFromPacketFilter(interfaceID int64) (bool, error) {
|
|
var (
|
|
method = "DELETE"
|
|
uri = fmt.Sprintf("/%s/%d/to/packetfilter", api.getResourceURL(), interfaceID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|
|
|
|
// SetDisplayIPAddress 表示用IPアドレス 設定
|
|
func (api *InterfaceAPI) SetDisplayIPAddress(interfaceID int64, ipaddress string) (bool, error) {
|
|
var (
|
|
method = "PUT"
|
|
uri = fmt.Sprintf("/%s/%d", api.getResourceURL(), interfaceID)
|
|
)
|
|
body := map[string]interface{}{
|
|
"Interface": map[string]string{
|
|
"UserIPAddress": ipaddress,
|
|
},
|
|
}
|
|
return api.modify(method, uri, body)
|
|
}
|
|
|
|
// DeleteDisplayIPAddress 表示用IPアドレス 削除
|
|
func (api *InterfaceAPI) DeleteDisplayIPAddress(interfaceID int64) (bool, error) {
|
|
var (
|
|
method = "DELETE"
|
|
uri = fmt.Sprintf("/%s/%d", api.getResourceURL(), interfaceID)
|
|
)
|
|
return api.modify(method, uri, nil)
|
|
}
|