lego/vendor/github.com/sacloud/libsacloud/api/cdrom.go
Ludovic Fernandez 42941ccea6
Refactor the core of the lib (#700)
- 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
2018-12-06 22:50:17 +01:00

81 lines
1.9 KiB
Go

package api
import (
"fmt"
"time"
"github.com/sacloud/libsacloud/sacloud"
)
// CDROMAPI ISOイメージAPI
type CDROMAPI struct {
*baseAPI
}
// NewCDROMAPI ISOイメージAPI新規作成
func NewCDROMAPI(client *Client) *CDROMAPI {
return &CDROMAPI{
&baseAPI{
client: client,
FuncGetResourceURL: func() string {
return "cdrom"
},
},
}
}
// Create 新規作成
func (api *CDROMAPI) Create(value *sacloud.CDROM) (*sacloud.CDROM, *sacloud.FTPServer, error) {
f := func(res *sacloud.Response) error {
return api.create(api.createRequest(value), res)
}
res := &sacloud.Response{}
err := f(res)
if err != nil {
return nil, nil, err
}
return res.CDROM, res.FTPServer, nil
}
// OpenFTP FTP接続開始
func (api *CDROMAPI) OpenFTP(id int64, reset bool) (*sacloud.FTPServer, error) {
var (
method = "PUT"
uri = fmt.Sprintf("%s/%d/ftp", api.getResourceURL(), id)
body = map[string]bool{"ChangePassword": reset}
res = &sacloud.Response{}
)
result, err := api.action(method, uri, body, res)
if !result || err != nil {
return nil, err
}
return res.FTPServer, nil
}
// CloseFTP FTP接続終了
func (api *CDROMAPI) CloseFTP(id int64) (bool, error) {
var (
method = "DELETE"
uri = fmt.Sprintf("%s/%d/ftp", api.getResourceURL(), id)
)
return api.modify(method, uri, nil)
}
// SleepWhileCopying コピー終了まで待機
func (api *CDROMAPI) SleepWhileCopying(id int64, timeout time.Duration) error {
handler := waitingForAvailableFunc(func() (hasAvailable, error) {
return api.Read(id)
}, 0)
return blockingPoll(handler, timeout)
}
// AsyncSleepWhileCopying コピー終了まで待機(非同期)
func (api *CDROMAPI) AsyncSleepWhileCopying(id int64, timeout time.Duration) (chan (interface{}), chan (interface{}), chan (error)) {
handler := waitingForAvailableFunc(func() (hasAvailable, error) {
return api.Read(id)
}, 0)
return poll(handler, timeout)
}