fix: update lego.
This commit is contained in:
parent
b8b0c8f3e5
commit
8d848c3d60
169 changed files with 12224 additions and 605 deletions
139
vendor/github.com/sacloud/libsacloud/api/archive.go
generated
vendored
139
vendor/github.com/sacloud/libsacloud/api/archive.go
generated
vendored
|
@ -2,10 +2,11 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"github.com/sacloud/libsacloud/sacloud/ostype"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"github.com/sacloud/libsacloud/sacloud/ostype"
|
||||
)
|
||||
|
||||
// ArchiveAPI アーカイブAPI
|
||||
|
@ -15,25 +16,30 @@ type ArchiveAPI struct {
|
|||
}
|
||||
|
||||
var (
|
||||
archiveLatestStableCentOSTags = []string{"current-stable", "distro-centos"}
|
||||
archiveLatestStableCentOS6Tags = []string{"distro-centos", "distro-ver-6.9"}
|
||||
archiveLatestStableUbuntuTags = []string{"current-stable", "distro-ubuntu"}
|
||||
archiveLatestStableDebianTags = []string{"current-stable", "distro-debian"}
|
||||
archiveLatestStableVyOSTags = []string{"current-stable", "distro-vyos"}
|
||||
archiveLatestStableCoreOSTags = []string{"current-stable", "distro-coreos"}
|
||||
archiveLatestStableRancherOSTags = []string{"current-stable", "distro-rancheros"}
|
||||
archiveLatestStableKusanagiTags = []string{"current-stable", "pkg-kusanagi"}
|
||||
archiveLatestStableSophosUTMTags = []string{"current-stable", "pkg-sophosutm"}
|
||||
archiveLatestStableFreeBSDTags = []string{"current-stable", "distro-freebsd"}
|
||||
archiveLatestStableWindows2012Tags = []string{"os-windows", "distro-ver-2012.2"}
|
||||
archiveLatestStableWindows2012RDSTags = []string{"os-windows", "distro-ver-2012.2", "windows-rds"}
|
||||
archiveLatestStableWindows2012RDSOfficeTags = []string{"os-windows", "distro-ver-2012.2", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2016Tags = []string{"os-windows", "distro-ver-2016"}
|
||||
archiveLatestStableWindows2016RDSTags = []string{"os-windows", "distro-ver-2016", "windows-rds"}
|
||||
archiveLatestStableWindows2016RDSOfficeTags = []string{"os-windows", "distro-ver-2016", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2016SQLServerWeb = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-web"}
|
||||
archiveLatestStableWindows2016SQLServerStandard = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-standard"}
|
||||
archiveLatestStableWindows2016SQLServerStandardAll = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-standard", "windows-rds", "with-office"}
|
||||
archiveLatestStableCentOSTags = []string{"current-stable", "distro-centos"}
|
||||
archiveLatestStableCentOS6Tags = []string{"distro-centos", "distro-ver-6.10"}
|
||||
archiveLatestStableUbuntuTags = []string{"current-stable", "distro-ubuntu"}
|
||||
archiveLatestStableDebianTags = []string{"current-stable", "distro-debian"}
|
||||
archiveLatestStableVyOSTags = []string{"current-stable", "distro-vyos"}
|
||||
archiveLatestStableCoreOSTags = []string{"current-stable", "distro-coreos"}
|
||||
archiveLatestStableRancherOSTags = []string{"current-stable", "distro-rancheros"}
|
||||
archiveLatestStableKusanagiTags = []string{"current-stable", "pkg-kusanagi"}
|
||||
archiveLatestStableSophosUTMTags = []string{"current-stable", "pkg-sophosutm"}
|
||||
archiveLatestStableFreeBSDTags = []string{"current-stable", "distro-freebsd"}
|
||||
archiveLatestStableNetwiserTags = []string{"current-stable", "pkg-netwiserve"}
|
||||
archiveLatestStableOPNsenseTags = []string{"current-stable", "distro-opnsense"}
|
||||
archiveLatestStableWindows2012Tags = []string{"os-windows", "distro-ver-2012.2"}
|
||||
archiveLatestStableWindows2012RDSTags = []string{"os-windows", "distro-ver-2012.2", "windows-rds"}
|
||||
archiveLatestStableWindows2012RDSOfficeTags = []string{"os-windows", "distro-ver-2012.2", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2016Tags = []string{"os-windows", "distro-ver-2016"}
|
||||
archiveLatestStableWindows2016RDSTags = []string{"os-windows", "distro-ver-2016", "windows-rds"}
|
||||
archiveLatestStableWindows2016RDSOfficeTags = []string{"os-windows", "distro-ver-2016", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2016SQLServerWeb = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-web"}
|
||||
archiveLatestStableWindows2016SQLServerStandard = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-standard"}
|
||||
archiveLatestStableWindows2016SQLServer2017Standard = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2017", "edition-standard"}
|
||||
archiveLatestStableWindows2016SQLServerStandardAll = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2016", "edition-standard", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2016SQLServer2017StandardAll = []string{"os-windows", "distro-ver-2016", "windows-sqlserver", "sqlserver-2017", "edition-standard", "windows-rds", "with-office"}
|
||||
archiveLatestStableWindows2019Tags = []string{"os-windows", "distro-ver-2019"}
|
||||
)
|
||||
|
||||
// NewArchiveAPI アーカイブAPI作成
|
||||
|
@ -48,25 +54,29 @@ func NewArchiveAPI(client *Client) *ArchiveAPI {
|
|||
}
|
||||
|
||||
api.findFuncMapPerOSType = map[ostype.ArchiveOSTypes]func() (*sacloud.Archive, error){
|
||||
ostype.CentOS: api.FindLatestStableCentOS,
|
||||
ostype.CentOS6: api.FindLatestStableCentOS6,
|
||||
ostype.Ubuntu: api.FindLatestStableUbuntu,
|
||||
ostype.Debian: api.FindLatestStableDebian,
|
||||
ostype.VyOS: api.FindLatestStableVyOS,
|
||||
ostype.CoreOS: api.FindLatestStableCoreOS,
|
||||
ostype.RancherOS: api.FindLatestStableRancherOS,
|
||||
ostype.Kusanagi: api.FindLatestStableKusanagi,
|
||||
ostype.SophosUTM: api.FindLatestStableSophosUTM,
|
||||
ostype.FreeBSD: api.FindLatestStableFreeBSD,
|
||||
ostype.Windows2012: api.FindLatestStableWindows2012,
|
||||
ostype.Windows2012RDS: api.FindLatestStableWindows2012RDS,
|
||||
ostype.Windows2012RDSOffice: api.FindLatestStableWindows2012RDSOffice,
|
||||
ostype.Windows2016: api.FindLatestStableWindows2016,
|
||||
ostype.Windows2016RDS: api.FindLatestStableWindows2016RDS,
|
||||
ostype.Windows2016RDSOffice: api.FindLatestStableWindows2016RDSOffice,
|
||||
ostype.Windows2016SQLServerWeb: api.FindLatestStableWindows2016SQLServerWeb,
|
||||
ostype.Windows2016SQLServerStandard: api.FindLatestStableWindows2016SQLServerStandard,
|
||||
ostype.Windows2016SQLServerStandardAll: api.FindLatestStableWindows2016SQLServerStandardAll,
|
||||
ostype.CentOS: api.FindLatestStableCentOS,
|
||||
ostype.CentOS6: api.FindLatestStableCentOS6,
|
||||
ostype.Ubuntu: api.FindLatestStableUbuntu,
|
||||
ostype.Debian: api.FindLatestStableDebian,
|
||||
ostype.VyOS: api.FindLatestStableVyOS,
|
||||
ostype.CoreOS: api.FindLatestStableCoreOS,
|
||||
ostype.RancherOS: api.FindLatestStableRancherOS,
|
||||
ostype.Kusanagi: api.FindLatestStableKusanagi,
|
||||
ostype.SophosUTM: api.FindLatestStableSophosUTM,
|
||||
ostype.FreeBSD: api.FindLatestStableFreeBSD,
|
||||
ostype.Netwiser: api.FindLatestStableNetwiser,
|
||||
ostype.OPNsense: api.FindLatestStableOPNsense,
|
||||
ostype.Windows2012: api.FindLatestStableWindows2012,
|
||||
ostype.Windows2012RDS: api.FindLatestStableWindows2012RDS,
|
||||
ostype.Windows2012RDSOffice: api.FindLatestStableWindows2012RDSOffice,
|
||||
ostype.Windows2016: api.FindLatestStableWindows2016,
|
||||
ostype.Windows2016RDS: api.FindLatestStableWindows2016RDS,
|
||||
ostype.Windows2016RDSOffice: api.FindLatestStableWindows2016RDSOffice,
|
||||
ostype.Windows2016SQLServerWeb: api.FindLatestStableWindows2016SQLServerWeb,
|
||||
ostype.Windows2016SQLServerStandard: api.FindLatestStableWindows2016SQLServerStandard,
|
||||
ostype.Windows2016SQLServer2017Standard: api.FindLatestStableWindows2016SQLServer2017Standard,
|
||||
ostype.Windows2016SQLServerStandardAll: api.FindLatestStableWindows2016SQLServerStandardAll,
|
||||
ostype.Windows2016SQLServer2017StandardAll: api.FindLatestStableWindows2016SQLServer2017StandardAll,
|
||||
}
|
||||
|
||||
return api
|
||||
|
@ -137,6 +147,14 @@ func (api *ArchiveAPI) CanEditDisk(id int64) (bool, error) {
|
|||
if archive.HasTag("pkg-sophosutm") || archive.IsSophosUTM() {
|
||||
return false, nil
|
||||
}
|
||||
// OPNsenseであれば編集不可
|
||||
if archive.HasTag("distro-opnsense") {
|
||||
return false, nil
|
||||
}
|
||||
// Netwiser VEであれば編集不可
|
||||
if archive.HasTag("pkg-netwiserve") {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
for _, t := range allowDiskEditTags {
|
||||
if archive.HasTag(t) {
|
||||
|
@ -180,6 +198,14 @@ func (api *ArchiveAPI) GetPublicArchiveIDFromAncestors(id int64) (int64, bool) {
|
|||
if archive.HasTag("pkg-sophosutm") || archive.IsSophosUTM() {
|
||||
return emptyID, false
|
||||
}
|
||||
// OPNsenseであれば編集不可
|
||||
if archive.HasTag("distro-opnsense") {
|
||||
return emptyID, false
|
||||
}
|
||||
// Netwiser VEであれば編集不可
|
||||
if archive.HasTag("pkg-netwiserve") {
|
||||
return emptyID, false
|
||||
}
|
||||
|
||||
for _, t := range allowDiskEditTags {
|
||||
if archive.HasTag(t) {
|
||||
|
@ -249,6 +275,16 @@ func (api *ArchiveAPI) FindLatestStableFreeBSD() (*sacloud.Archive, error) {
|
|||
return api.findByOSTags(archiveLatestStableFreeBSDTags)
|
||||
}
|
||||
|
||||
// FindLatestStableNetwiser 安定版最新のNetwiserパブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableNetwiser() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableNetwiserTags)
|
||||
}
|
||||
|
||||
// FindLatestStableOPNsense 安定版最新のOPNsenseパブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableOPNsense() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableOPNsenseTags)
|
||||
}
|
||||
|
||||
// FindLatestStableWindows2012 安定版最新のWindows2012パブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableWindows2012() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableWindows2012Tags, map[string]interface{}{
|
||||
|
@ -305,13 +341,34 @@ func (api *ArchiveAPI) FindLatestStableWindows2016SQLServerStandard() (*sacloud.
|
|||
})
|
||||
}
|
||||
|
||||
// FindLatestStableWindows2016SQLServer2017Standard 安定版最新のWindows2016 SQLServer2017(Standard) パブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableWindows2016SQLServer2017Standard() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableWindows2016SQLServer2017Standard, map[string]interface{}{
|
||||
"Name": "Windows Server 2016 for MS SQL 2017(Standard)",
|
||||
})
|
||||
}
|
||||
|
||||
// FindLatestStableWindows2016SQLServerStandardAll 安定版最新のWindows2016 SQLServer(RDS+Office) パブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableWindows2016SQLServerStandardAll() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableWindows2016SQLServerStandard, map[string]interface{}{
|
||||
return api.findByOSTags(archiveLatestStableWindows2016SQLServerStandardAll, map[string]interface{}{
|
||||
"Name": "Windows Server 2016 for MS SQL 2016(Std) with RDS / MS Office",
|
||||
})
|
||||
}
|
||||
|
||||
// FindLatestStableWindows2016SQLServer2017StandardAll 安定版最新のWindows2016 SQLServer2017(RDS+Office) パブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableWindows2016SQLServer2017StandardAll() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableWindows2016SQLServer2017StandardAll, map[string]interface{}{
|
||||
"Name": "Windows Server 2016 for MS SQL 2017(Std) with RDS / MS Office",
|
||||
})
|
||||
}
|
||||
|
||||
// FindLatestStableWindows2019 安定版最新のWindows2019パブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindLatestStableWindows2019() (*sacloud.Archive, error) {
|
||||
return api.findByOSTags(archiveLatestStableWindows2019Tags, map[string]interface{}{
|
||||
"Name": "Windows Server 2019 Datacenter Edition",
|
||||
})
|
||||
}
|
||||
|
||||
// FindByOSType 指定のOS種別の安定版最新のパブリックアーカイブを取得
|
||||
func (api *ArchiveAPI) FindByOSType(os ostype.ArchiveOSTypes) (*sacloud.Archive, error) {
|
||||
if f, ok := api.findFuncMapPerOSType[os]; ok {
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/auth_status.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/auth_status.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
4
vendor/github.com/sacloud/libsacloud/api/auto_backup.go
generated
vendored
4
vendor/github.com/sacloud/libsacloud/api/auto_backup.go
generated
vendored
|
@ -1,8 +1,8 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
// "strings"
|
||||
"encoding/json" // "strings"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
5
vendor/github.com/sacloud/libsacloud/api/base_api.go
generated
vendored
5
vendor/github.com/sacloud/libsacloud/api/base_api.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"net/url"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
type baseAPI struct {
|
||||
|
@ -137,7 +138,7 @@ func (api *baseAPI) filterBy(key string, value interface{}, multiple bool) *base
|
|||
if f, ok := state.Filter[key]; ok {
|
||||
if s, ok := f.(string); ok && s != "" {
|
||||
if v, ok := value.(string); ok {
|
||||
state.Filter[key] = fmt.Sprintf("%s %s", s, v)
|
||||
state.Filter[key] = fmt.Sprintf("%s%%20%s", s, v)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/bill.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/bill.go
generated
vendored
|
@ -4,10 +4,11 @@ import (
|
|||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// BillAPI 請求情報API
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/cdrom.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/cdrom.go
generated
vendored
|
@ -2,8 +2,9 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// CDROMAPI ISOイメージAPI
|
||||
|
|
30
vendor/github.com/sacloud/libsacloud/api/client.go
generated
vendored
30
vendor/github.com/sacloud/libsacloud/api/client.go
generated
vendored
|
@ -4,14 +4,15 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -44,6 +45,8 @@ type Client struct {
|
|||
RetryMax int
|
||||
// 503エラー時のリトライ待ち時間
|
||||
RetryInterval time.Duration
|
||||
// APIコール時に利用される*http.Client 未指定の場合http.DefaultClientが利用される
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// NewClient APIクライアント作成
|
||||
|
@ -73,8 +76,11 @@ func (c *Client) Clone() *Client {
|
|||
DefaultTimeoutDuration: c.DefaultTimeoutDuration,
|
||||
UserAgent: c.UserAgent,
|
||||
AcceptLanguage: c.AcceptLanguage,
|
||||
RequestTracer: c.RequestTracer,
|
||||
ResponseTracer: c.ResponseTracer,
|
||||
RetryMax: c.RetryMax,
|
||||
RetryInterval: c.RetryInterval,
|
||||
HTTPClient: c.HTTPClient,
|
||||
}
|
||||
n.API = newAPI(n)
|
||||
return n
|
||||
|
@ -111,6 +117,7 @@ func (c *Client) isOkStatus(code int) bool {
|
|||
func (c *Client) newRequest(method, uri string, body interface{}) ([]byte, error) {
|
||||
var (
|
||||
client = &retryableHTTPClient{
|
||||
Client: c.HTTPClient,
|
||||
retryMax: c.RetryMax,
|
||||
retryInterval: c.RetryInterval,
|
||||
}
|
||||
|
@ -232,12 +239,15 @@ func newRequest(method, url string, body io.ReadSeeker) (*request, error) {
|
|||
}
|
||||
|
||||
type retryableHTTPClient struct {
|
||||
http.Client
|
||||
*http.Client
|
||||
retryInterval time.Duration
|
||||
retryMax int
|
||||
}
|
||||
|
||||
func (c *retryableHTTPClient) Do(req *request) (*http.Response, error) {
|
||||
if c.Client == nil {
|
||||
c.Client = http.DefaultClient
|
||||
}
|
||||
for i := 0; ; i++ {
|
||||
|
||||
if req.body != nil {
|
||||
|
@ -277,6 +287,7 @@ type API struct {
|
|||
Bill *BillAPI // 請求情報API
|
||||
Bridge *BridgeAPI // ブリッジAPi
|
||||
CDROM *CDROMAPI // ISOイメージAPI
|
||||
Coupon *CouponAPI // クーポンAPI
|
||||
Database *DatabaseAPI // データベースAPI
|
||||
Disk *DiskAPI // ディスクAPI
|
||||
DNS *DNSAPI // DNS API
|
||||
|
@ -295,6 +306,7 @@ type API struct {
|
|||
NFS *NFSAPI // NFS API
|
||||
Note *NoteAPI // スタートアップスクリプトAPI
|
||||
PacketFilter *PacketFilterAPI // パケットフィルタAPI
|
||||
ProxyLB *ProxyLBAPI // プロキシLBAPI
|
||||
PrivateHost *PrivateHostAPI // 専有ホストAPI
|
||||
Product *ProductAPI // 製品情報API
|
||||
Server *ServerAPI // サーバーAPI
|
||||
|
@ -337,6 +349,11 @@ func (api *API) GetCDROMAPI() *CDROMAPI {
|
|||
return api.CDROM
|
||||
}
|
||||
|
||||
// GetCouponAPI クーポン情報API取得
|
||||
func (api *API) GetCouponAPI() *CouponAPI {
|
||||
return api.Coupon
|
||||
}
|
||||
|
||||
// GetDatabaseAPI データベースAPI取得
|
||||
func (api *API) GetDatabaseAPI() *DatabaseAPI {
|
||||
return api.Database
|
||||
|
@ -432,6 +449,11 @@ func (api *API) GetPacketFilterAPI() *PacketFilterAPI {
|
|||
return api.PacketFilter
|
||||
}
|
||||
|
||||
// GetProxyLBAPI プロキシLBAPI取得
|
||||
func (api *API) GetProxyLBAPI() *ProxyLBAPI {
|
||||
return api.ProxyLB
|
||||
}
|
||||
|
||||
// GetPrivateHostAPI 専有ホストAPI取得
|
||||
func (api *API) GetPrivateHostAPI() *PrivateHostAPI {
|
||||
return api.PrivateHost
|
||||
|
@ -566,6 +588,7 @@ func newAPI(client *Client) *API {
|
|||
Bill: NewBillAPI(client),
|
||||
Bridge: NewBridgeAPI(client),
|
||||
CDROM: NewCDROMAPI(client),
|
||||
Coupon: NewCouponAPI(client),
|
||||
Database: NewDatabaseAPI(client),
|
||||
Disk: NewDiskAPI(client),
|
||||
DNS: NewDNSAPI(client),
|
||||
|
@ -587,6 +610,7 @@ func newAPI(client *Client) *API {
|
|||
NFS: NewNFSAPI(client),
|
||||
Note: NewNoteAPI(client),
|
||||
PacketFilter: NewPacketFilterAPI(client),
|
||||
ProxyLB: NewProxyLBAPI(client),
|
||||
PrivateHost: NewPrivateHostAPI(client),
|
||||
Product: &ProductAPI{
|
||||
Server: NewProductServerAPI(client),
|
||||
|
|
59
vendor/github.com/sacloud/libsacloud/api/coupon.go
generated
vendored
Normal file
59
vendor/github.com/sacloud/libsacloud/api/coupon.go
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// CouponAPI クーポン情報API
|
||||
type CouponAPI struct {
|
||||
*baseAPI
|
||||
}
|
||||
|
||||
// NewCouponAPI クーポン情報API作成
|
||||
func NewCouponAPI(client *Client) *CouponAPI {
|
||||
return &CouponAPI{
|
||||
&baseAPI{
|
||||
client: client,
|
||||
apiRootSuffix: sakuraBillingAPIRootSuffix,
|
||||
FuncGetResourceURL: func() string {
|
||||
return "coupon"
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CouponResponse クーポン情報レスポンス
|
||||
type CouponResponse struct {
|
||||
*sacloud.ResultFlagValue
|
||||
// AllCount 件数
|
||||
AllCount int `json:",omitempty"`
|
||||
// CountPerPage ページあたり件数
|
||||
CountPerPage int `json:",omitempty"`
|
||||
// Page 現在のページ番号
|
||||
Page int `json:",omitempty"`
|
||||
// Coupons クーポン情報 リスト
|
||||
Coupons []*sacloud.Coupon
|
||||
}
|
||||
|
||||
// Find クーポン情報 全件取得
|
||||
func (api *CouponAPI) Find() ([]*sacloud.Coupon, error) {
|
||||
authStatus, err := api.client.AuthStatus.Read()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
accountID := authStatus.Account.GetStrID()
|
||||
|
||||
uri := fmt.Sprintf("%s/%s", api.getResourceURL(), accountID)
|
||||
data, err := api.client.newRequest("GET", uri, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var res CouponResponse
|
||||
if err := json.Unmarshal(data, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Coupons, nil
|
||||
}
|
3
vendor/github.com/sacloud/libsacloud/api/database.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/database.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
//HACK: さくらのAPI側仕様: Applianceの内容によってJSONフォーマットが異なるため
|
||||
|
|
73
vendor/github.com/sacloud/libsacloud/api/disk.go
generated
vendored
73
vendor/github.com/sacloud/libsacloud/api/disk.go
generated
vendored
|
@ -2,8 +2,9 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -56,7 +57,50 @@ func (api *DiskAPI) Create(value *sacloud.Disk) (*sacloud.Disk, error) {
|
|||
Success string `json:",omitempty"`
|
||||
}
|
||||
res := &diskResponse{}
|
||||
err := api.create(api.createRequest(value), res)
|
||||
|
||||
rawBody := &sacloud.Request{}
|
||||
rawBody.Disk = value
|
||||
if len(value.DistantFrom) > 0 {
|
||||
rawBody.DistantFrom = value.DistantFrom
|
||||
value.DistantFrom = []int64{}
|
||||
}
|
||||
|
||||
err := api.create(rawBody, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Disk, nil
|
||||
}
|
||||
|
||||
// CreateWithConfig ディスク作成とディスクの修正、サーバ起動(指定されていれば)を1回のAPI呼び出しで実行
|
||||
func (api *DiskAPI) CreateWithConfig(value *sacloud.Disk, config *sacloud.DiskEditValue, bootAtAvailable bool) (*sacloud.Disk, error) {
|
||||
//HACK: さくらのAPI側仕様: 戻り値:Successがbool値へ変換できないため文字列で受ける("Accepted"などが返る)
|
||||
type diskResponse struct {
|
||||
*sacloud.Response
|
||||
// Success
|
||||
Success string `json:",omitempty"`
|
||||
}
|
||||
res := &diskResponse{}
|
||||
|
||||
type diskRequest struct {
|
||||
*sacloud.Request
|
||||
Config *sacloud.DiskEditValue `json:",omitempty"`
|
||||
BootAtAvailable bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
rawBody := &diskRequest{
|
||||
Request: &sacloud.Request{},
|
||||
BootAtAvailable: bootAtAvailable,
|
||||
}
|
||||
rawBody.Disk = value
|
||||
rawBody.Config = config
|
||||
|
||||
if len(value.DistantFrom) > 0 {
|
||||
rawBody.DistantFrom = value.DistantFrom
|
||||
value.DistantFrom = []int64{}
|
||||
}
|
||||
|
||||
err := api.create(rawBody, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -90,7 +134,14 @@ func (api *DiskAPI) install(id int64, body *sacloud.Disk) (bool, error) {
|
|||
Success string `json:",omitempty"`
|
||||
}
|
||||
res := &diskResponse{}
|
||||
err := api.baseAPI.request(method, uri, body, res)
|
||||
rawBody := &sacloud.Request{}
|
||||
rawBody.Disk = body
|
||||
if len(body.DistantFrom) > 0 {
|
||||
rawBody.DistantFrom = body.DistantFrom
|
||||
body.DistantFrom = []int64{}
|
||||
}
|
||||
|
||||
err := api.baseAPI.request(method, uri, rawBody, res)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -213,6 +264,14 @@ func (api *DiskAPI) CanEditDisk(id int64) (bool, error) {
|
|||
if disk.HasTag("pkg-sophosutm") || disk.IsSophosUTM() {
|
||||
return false, nil
|
||||
}
|
||||
// OPNsenseであれば編集不可
|
||||
if disk.HasTag("distro-opnsense") {
|
||||
return false, nil
|
||||
}
|
||||
// Netwiser VEであれば編集不可
|
||||
if disk.HasTag("pkg-netwiserve") {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// ソースアーカイブ/ソースディスクともに持っていない場合
|
||||
if disk.SourceArchive == nil && disk.SourceDisk == nil {
|
||||
|
@ -263,6 +322,14 @@ func (api *DiskAPI) GetPublicArchiveIDFromAncestors(id int64) (int64, bool) {
|
|||
if disk.HasTag("pkg-sophosutm") || disk.IsSophosUTM() {
|
||||
return emptyID, false
|
||||
}
|
||||
// OPNsenseであれば編集不可
|
||||
if disk.HasTag("distro-opnsense") {
|
||||
return emptyID, false
|
||||
}
|
||||
// Netwiser VEであれば編集不可
|
||||
if disk.HasTag("pkg-netwiserve") {
|
||||
return emptyID, false
|
||||
}
|
||||
|
||||
for _, t := range allowDiskEditTags {
|
||||
if disk.HasTag(t) {
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/dns.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/dns.go
generated
vendored
|
@ -2,8 +2,9 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"strings"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
//HACK: さくらのAPI側仕様: CommonServiceItemsの内容によってJSONフォーマットが異なるため
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/error.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/error.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
4
vendor/github.com/sacloud/libsacloud/api/gslb.go
generated
vendored
4
vendor/github.com/sacloud/libsacloud/api/gslb.go
generated
vendored
|
@ -1,8 +1,8 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
// "strings"
|
||||
"encoding/json" // "strings"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
24
vendor/github.com/sacloud/libsacloud/api/interface.go
generated
vendored
24
vendor/github.com/sacloud/libsacloud/api/interface.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
@ -81,3 +82,26 @@ func (api *InterfaceAPI) DisconnectFromPacketFilter(interfaceID int64) (bool, er
|
|||
)
|
||||
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)
|
||||
}
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/internet.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/internet.go
generated
vendored
|
@ -2,8 +2,9 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// InternetAPI ルーターAPI
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/ipaddress.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/ipaddress.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/ipv6addr.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/ipv6addr.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
26
vendor/github.com/sacloud/libsacloud/api/load_balancer.go
generated
vendored
26
vendor/github.com/sacloud/libsacloud/api/load_balancer.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
//HACK: さくらのAPI側仕様: Applianceの内容によってJSONフォーマットが異なるため
|
||||
|
@ -38,6 +39,12 @@ type loadBalancerResponse struct {
|
|||
Success interface{} `json:",omitempty"` //HACK: さくらのAPI側仕様: 戻り値:Successがbool値へ変換できないためinterface{}
|
||||
}
|
||||
|
||||
type loadBalancerStatusResponse struct {
|
||||
*sacloud.ResultFlagValue
|
||||
Success interface{} `json:",omitempty"` //HACK: さくらのAPI側仕様: 戻り値:Successがbool値へ変換できないためinterface{}
|
||||
LoadBalancer *sacloud.LoadBalancerStatusResult `json:",omitempty"`
|
||||
}
|
||||
|
||||
// LoadBalancerAPI ロードバランサーAPI
|
||||
type LoadBalancerAPI struct {
|
||||
*baseAPI
|
||||
|
@ -230,3 +237,20 @@ func (api *LoadBalancerAPI) AsyncSleepWhileCopying(id int64, timeout time.Durati
|
|||
func (api *LoadBalancerAPI) Monitor(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
return api.baseAPI.applianceMonitorBy(id, "interface", 0, body)
|
||||
}
|
||||
|
||||
// Status ステータス取得
|
||||
func (api *LoadBalancerAPI) Status(id int64) (*sacloud.LoadBalancerStatusResult, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/status", api.getResourceURL(), id)
|
||||
res = &loadBalancerStatusResponse{}
|
||||
)
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res.LoadBalancer == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return res.LoadBalancer, nil
|
||||
}
|
||||
|
|
72
vendor/github.com/sacloud/libsacloud/api/mobile_gateway.go
generated
vendored
72
vendor/github.com/sacloud/libsacloud/api/mobile_gateway.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// SearchMobileGatewayResponse モバイルゲートウェイ検索レスポンス
|
||||
|
@ -41,6 +42,14 @@ type mobileGatewaySIMResponse struct {
|
|||
Success interface{} `json:",omitempty"` //HACK: さくらのAPI側仕様: 戻り値:Successがbool値へ変換できないためinterface{}
|
||||
}
|
||||
|
||||
type trafficMonitoringBody struct {
|
||||
TrafficMonitoring *sacloud.TrafficMonitoringConfig `json:"traffic_monitoring_config"`
|
||||
}
|
||||
|
||||
type trafficStatusBody struct {
|
||||
TrafficStatus *sacloud.TrafficStatus `json:"traffic_status"`
|
||||
}
|
||||
|
||||
// MobileGatewayAPI モバイルゲートウェイAPI
|
||||
type MobileGatewayAPI struct {
|
||||
*baseAPI
|
||||
|
@ -322,8 +331,8 @@ func (api *MobileGatewayAPI) AddSIMRoute(id int64, simID int64, prefix string) (
|
|||
param := &sacloud.MobileGatewaySIMRoutes{
|
||||
SIMRoutes: routes,
|
||||
}
|
||||
added := param.AddSIMRoute(simID, prefix)
|
||||
if !added {
|
||||
index, added := param.AddSIMRoute(simID, prefix)
|
||||
if index < 0 || added == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
@ -412,3 +421,60 @@ func (api *MobileGatewayAPI) Logs(id int64, body interface{}) ([]sacloud.SIMLog,
|
|||
}
|
||||
return res.Logs, nil
|
||||
}
|
||||
|
||||
// GetTrafficMonitoringConfig トラフィックコントロール 取得
|
||||
func (api *MobileGatewayAPI) GetTrafficMonitoringConfig(id int64) (*sacloud.TrafficMonitoringConfig, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/mobilegateway/traffic_monitoring", api.getResourceURL(), id)
|
||||
)
|
||||
|
||||
res := &trafficMonitoringBody{}
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.TrafficMonitoring, nil
|
||||
}
|
||||
|
||||
// SetTrafficMonitoringConfig トラフィックコントロール 設定
|
||||
func (api *MobileGatewayAPI) SetTrafficMonitoringConfig(id int64, trafficMonConfig *sacloud.TrafficMonitoringConfig) (bool, error) {
|
||||
var (
|
||||
method = "PUT"
|
||||
uri = fmt.Sprintf("%s/%d/mobilegateway/traffic_monitoring", api.getResourceURL(), id)
|
||||
)
|
||||
|
||||
req := &trafficMonitoringBody{
|
||||
TrafficMonitoring: trafficMonConfig,
|
||||
}
|
||||
return api.modify(method, uri, req)
|
||||
}
|
||||
|
||||
// DisableTrafficMonitoringConfig トラフィックコントロール 解除
|
||||
func (api *MobileGatewayAPI) DisableTrafficMonitoringConfig(id int64) (bool, error) {
|
||||
var (
|
||||
method = "DELETE"
|
||||
uri = fmt.Sprintf("%s/%d/mobilegateway/traffic_monitoring", api.getResourceURL(), id)
|
||||
)
|
||||
return api.modify(method, uri, nil)
|
||||
}
|
||||
|
||||
// GetTrafficStatus 当月通信量 取得
|
||||
func (api *MobileGatewayAPI) GetTrafficStatus(id int64) (*sacloud.TrafficStatus, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/mobilegateway/traffic_status", api.getResourceURL(), id)
|
||||
)
|
||||
|
||||
res := &trafficStatusBody{}
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.TrafficStatus, nil
|
||||
}
|
||||
|
||||
// MonitorBy 指定位置のインターフェースのアクティビティーモニター取得
|
||||
func (api *MobileGatewayAPI) MonitorBy(id int64, nicIndex int, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
return api.baseAPI.applianceMonitorBy(id, "interface", nicIndex, body)
|
||||
}
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/newsfeed.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/newsfeed.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
62
vendor/github.com/sacloud/libsacloud/api/nfs.go
generated
vendored
62
vendor/github.com/sacloud/libsacloud/api/nfs.go
generated
vendored
|
@ -2,9 +2,11 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// SearchNFSResponse NFS検索レスポンス
|
||||
|
@ -94,6 +96,58 @@ func (api *NFSAPI) Create(value *sacloud.NFS) (*sacloud.NFS, error) {
|
|||
})
|
||||
}
|
||||
|
||||
// CreateWithPlan プラン/サイズを指定してNFSを作成
|
||||
func (api *NFSAPI) CreateWithPlan(value *sacloud.CreateNFSValue, plan sacloud.NFSPlan, size sacloud.NFSSize) (*sacloud.NFS, error) {
|
||||
|
||||
nfs := sacloud.NewNFS(value)
|
||||
// get plan
|
||||
plans, err := api.GetNFSPlans()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if plans == nil {
|
||||
return nil, errors.New("NFS plans not found")
|
||||
}
|
||||
|
||||
planID := plans.FindPlanID(plan, size)
|
||||
if planID < 0 {
|
||||
return nil, errors.New("NFS plans not found")
|
||||
}
|
||||
|
||||
nfs.Plan = sacloud.NewResource(planID)
|
||||
nfs.Remark.SetRemarkPlanID(planID)
|
||||
|
||||
return api.request(func(res *nfsResponse) error {
|
||||
return api.create(api.createRequest(nfs), res)
|
||||
})
|
||||
}
|
||||
|
||||
// GetNFSPlans プラン一覧取得
|
||||
func (api *NFSAPI) GetNFSPlans() (*sacloud.NFSPlans, error) {
|
||||
notes, err := api.client.Note.Reset().Find()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, note := range notes.Notes {
|
||||
if note.Class == sacloud.ENoteClass("json") && note.Name == "sys-nfs" {
|
||||
rawPlans := note.Content
|
||||
|
||||
var plans struct {
|
||||
Plans *sacloud.NFSPlans `json:"plans"`
|
||||
}
|
||||
|
||||
err := json.Unmarshal([]byte(rawPlans), &plans)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return plans.Plans, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Read 読み取り
|
||||
func (api *NFSAPI) Read(id int64) (*sacloud.NFS, error) {
|
||||
return api.request(func(res *nfsResponse) error {
|
||||
|
@ -223,9 +277,9 @@ func (api *NFSAPI) AsyncSleepWhileCopying(id int64, timeout time.Duration, maxRe
|
|||
return poll(handler, timeout)
|
||||
}
|
||||
|
||||
// MonitorNFS NFS固有項目アクティビティモニター取得
|
||||
func (api *NFSAPI) MonitorNFS(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
return api.baseAPI.applianceMonitorBy(id, "nfs", 0, body)
|
||||
// MonitorFreeDiskSize NFSディスク残量アクティビティモニター取得
|
||||
func (api *NFSAPI) MonitorFreeDiskSize(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
return api.baseAPI.applianceMonitorBy(id, "database", 0, body)
|
||||
}
|
||||
|
||||
// MonitorInterface NICアクティビティーモニター取得
|
||||
|
|
20
vendor/github.com/sacloud/libsacloud/api/polling.go
generated
vendored
20
vendor/github.com/sacloud/libsacloud/api/polling.go
generated
vendored
|
@ -21,16 +21,16 @@ func poll(handler pollingHandler, timeout time.Duration) (chan (interface{}), ch
|
|||
select {
|
||||
case <-tick:
|
||||
exit, state, err := handler()
|
||||
if state != nil {
|
||||
progChan <- state
|
||||
}
|
||||
if err != nil {
|
||||
errChan <- fmt.Errorf("Failed: poll: %s", err)
|
||||
return
|
||||
}
|
||||
if state != nil {
|
||||
progChan <- state
|
||||
if exit {
|
||||
compChan <- state
|
||||
return
|
||||
}
|
||||
if exit {
|
||||
compChan <- state
|
||||
return
|
||||
}
|
||||
case <-bomb:
|
||||
errChan <- fmt.Errorf("Timeout")
|
||||
|
@ -65,9 +65,9 @@ type hasFailed interface {
|
|||
func waitingForAvailableFunc(readFunc func() (hasAvailable, error), maxRetry int) func() (bool, interface{}, error) {
|
||||
counter := 0
|
||||
return func() (bool, interface{}, error) {
|
||||
counter++
|
||||
v, err := readFunc()
|
||||
if err != nil {
|
||||
counter++
|
||||
if maxRetry > 0 && counter < maxRetry {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
@ -96,9 +96,9 @@ type hasUpDown interface {
|
|||
func waitingForUpFunc(readFunc func() (hasUpDown, error), maxRetry int) func() (bool, interface{}, error) {
|
||||
counter := 0
|
||||
return func() (bool, interface{}, error) {
|
||||
counter++
|
||||
v, err := readFunc()
|
||||
if err != nil {
|
||||
counter++
|
||||
if maxRetry > 0 && counter < maxRetry {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ func waitingForUpFunc(readFunc func() (hasUpDown, error), maxRetry int) func() (
|
|||
func waitingForDownFunc(readFunc func() (hasUpDown, error), maxRetry int) func() (bool, interface{}, error) {
|
||||
counter := 0
|
||||
return func() (bool, interface{}, error) {
|
||||
counter++
|
||||
v, err := readFunc()
|
||||
if err != nil {
|
||||
counter++
|
||||
if maxRetry > 0 && counter < maxRetry {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
@ -140,9 +140,9 @@ func waitingForDownFunc(readFunc func() (hasUpDown, error), maxRetry int) func()
|
|||
func waitingForReadFunc(readFunc func() (interface{}, error), maxRetry int) func() (bool, interface{}, error) {
|
||||
counter := 0
|
||||
return func() (bool, interface{}, error) {
|
||||
counter++
|
||||
v, err := readFunc()
|
||||
if err != nil {
|
||||
counter++
|
||||
if maxRetry > 0 && counter < maxRetry {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
|
84
vendor/github.com/sacloud/libsacloud/api/product_server.go
generated
vendored
84
vendor/github.com/sacloud/libsacloud/api/product_server.go
generated
vendored
|
@ -2,8 +2,8 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ProductServerAPI サーバープランAPI
|
||||
|
@ -24,48 +24,50 @@ func NewProductServerAPI(client *Client) *ProductServerAPI {
|
|||
}
|
||||
}
|
||||
|
||||
func (api *ProductServerAPI) getPlanIDBySpec(core int, memGB int) (int64, error) {
|
||||
//assert args
|
||||
if core <= 0 {
|
||||
return -1, fmt.Errorf("Invalid Parameter: CPU Core")
|
||||
}
|
||||
if memGB <= 0 {
|
||||
return -1, fmt.Errorf("Invalid Parameter: Memory Size(GB)")
|
||||
}
|
||||
|
||||
return strconv.ParseInt(fmt.Sprintf("%d%03d", memGB, core), 10, 64)
|
||||
}
|
||||
|
||||
// IsValidPlan 指定のコア数/メモリサイズのプランが存在し、有効であるか判定
|
||||
func (api *ProductServerAPI) IsValidPlan(core int, memGB int) (bool, error) {
|
||||
|
||||
planID, err := api.getPlanIDBySpec(core, memGB)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
productServer, err := api.Read(planID)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if productServer != nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, fmt.Errorf("Server Plan[%d] Not Found", planID)
|
||||
|
||||
}
|
||||
|
||||
// GetBySpec 指定のコア数/メモリサイズのサーバープランを取得
|
||||
func (api *ProductServerAPI) GetBySpec(core int, memGB int) (*sacloud.ProductServer, error) {
|
||||
planID, err := api.getPlanIDBySpec(core, memGB)
|
||||
|
||||
productServer, err := api.Read(planID)
|
||||
|
||||
// GetBySpec 指定のコア数/メモリサイズ/世代のプランを取得
|
||||
func (api *ProductServerAPI) GetBySpec(core int, memGB int, gen sacloud.PlanGenerations) (*sacloud.ProductServer, error) {
|
||||
plans, err := api.Reset().Find()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var res sacloud.ProductServer
|
||||
var found bool
|
||||
for _, plan := range plans.ServerPlans {
|
||||
if plan.CPU == core && plan.GetMemoryGB() == memGB {
|
||||
if gen == sacloud.PlanDefault || gen == plan.Generation {
|
||||
// PlanDefaultの場合は複数ヒットしうる。
|
||||
// この場合より新しい世代を優先する。
|
||||
if found && plan.Generation <= res.Generation {
|
||||
continue
|
||||
}
|
||||
res = plan
|
||||
found = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return productServer, nil
|
||||
if !found {
|
||||
return nil, fmt.Errorf("Server Plan[core:%d, memory:%d, gen:%d] is not found", core, memGB, gen)
|
||||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
// IsValidPlan 指定のコア数/メモリサイズ/世代のプランが存在し、有効であるか判定
|
||||
func (api *ProductServerAPI) IsValidPlan(core int, memGB int, gen sacloud.PlanGenerations) (bool, error) {
|
||||
|
||||
productServer, err := api.GetBySpec(core, memGB, gen)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if productServer == nil {
|
||||
return false, fmt.Errorf("Server Plan[core:%d, memory:%d, gen:%d] is not found", core, memGB, gen)
|
||||
}
|
||||
|
||||
if productServer.Availability != sacloud.EAAvailable {
|
||||
return false, fmt.Errorf("Server Plan[core:%d, memory:%d, gen:%d] is not available", core, memGB, gen)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
|
224
vendor/github.com/sacloud/libsacloud/api/proxylb.go
generated
vendored
Normal file
224
vendor/github.com/sacloud/libsacloud/api/proxylb.go
generated
vendored
Normal file
|
@ -0,0 +1,224 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json" // "strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
//HACK: さくらのAPI側仕様: CommonServiceItemsの内容によってJSONフォーマットが異なるため
|
||||
// DNS/ProxyLB/シンプル監視それぞれでリクエスト/レスポンスデータ型を定義する。
|
||||
|
||||
// SearchProxyLBResponse ProxyLB検索レスポンス
|
||||
type SearchProxyLBResponse struct {
|
||||
// Total 総件数
|
||||
Total int `json:",omitempty"`
|
||||
// From ページング開始位置
|
||||
From int `json:",omitempty"`
|
||||
// Count 件数
|
||||
Count int `json:",omitempty"`
|
||||
// CommonServiceProxyLBItems ProxyLBリスト
|
||||
CommonServiceProxyLBItems []sacloud.ProxyLB `json:"CommonServiceItems,omitempty"`
|
||||
}
|
||||
|
||||
type proxyLBRequest struct {
|
||||
CommonServiceProxyLBItem *sacloud.ProxyLB `json:"CommonServiceItem,omitempty"`
|
||||
From int `json:",omitempty"`
|
||||
Count int `json:",omitempty"`
|
||||
Sort []string `json:",omitempty"`
|
||||
Filter map[string]interface{} `json:",omitempty"`
|
||||
Exclude []string `json:",omitempty"`
|
||||
Include []string `json:",omitempty"`
|
||||
}
|
||||
|
||||
type proxyLBResponse struct {
|
||||
*sacloud.ResultFlagValue
|
||||
*sacloud.ProxyLB `json:"CommonServiceItem,omitempty"`
|
||||
}
|
||||
|
||||
// ProxyLBAPI ProxyLB API
|
||||
type ProxyLBAPI struct {
|
||||
*baseAPI
|
||||
}
|
||||
|
||||
// NewProxyLBAPI ProxyLB API作成
|
||||
func NewProxyLBAPI(client *Client) *ProxyLBAPI {
|
||||
return &ProxyLBAPI{
|
||||
&baseAPI{
|
||||
client: client,
|
||||
FuncGetResourceURL: func() string {
|
||||
return "commonserviceitem"
|
||||
},
|
||||
FuncBaseSearchCondition: func() *sacloud.Request {
|
||||
res := &sacloud.Request{}
|
||||
res.AddFilter("Provider.Class", "proxylb")
|
||||
return res
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Find 検索
|
||||
func (api *ProxyLBAPI) Find() (*SearchProxyLBResponse, error) {
|
||||
|
||||
data, err := api.client.newRequest("GET", api.getResourceURL(), api.getSearchState())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var res SearchProxyLBResponse
|
||||
if err := json.Unmarshal(data, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (api *ProxyLBAPI) request(f func(*proxyLBResponse) error) (*sacloud.ProxyLB, error) {
|
||||
res := &proxyLBResponse{}
|
||||
err := f(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.ProxyLB, nil
|
||||
}
|
||||
|
||||
func (api *ProxyLBAPI) createRequest(value *sacloud.ProxyLB) *proxyLBResponse {
|
||||
return &proxyLBResponse{ProxyLB: value}
|
||||
}
|
||||
|
||||
// New 新規作成用パラメーター作成
|
||||
func (api *ProxyLBAPI) New(name string) *sacloud.ProxyLB {
|
||||
return sacloud.CreateNewProxyLB(name)
|
||||
}
|
||||
|
||||
// Create 新規作成
|
||||
func (api *ProxyLBAPI) Create(value *sacloud.ProxyLB) (*sacloud.ProxyLB, error) {
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.create(api.createRequest(value), res)
|
||||
})
|
||||
}
|
||||
|
||||
// Read 読み取り
|
||||
func (api *ProxyLBAPI) Read(id int64) (*sacloud.ProxyLB, error) {
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.read(id, nil, res)
|
||||
})
|
||||
}
|
||||
|
||||
// Update 更新
|
||||
func (api *ProxyLBAPI) Update(id int64, value *sacloud.ProxyLB) (*sacloud.ProxyLB, error) {
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.update(id, api.createRequest(value), res)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateSetting 設定更新
|
||||
func (api *ProxyLBAPI) UpdateSetting(id int64, value *sacloud.ProxyLB) (*sacloud.ProxyLB, error) {
|
||||
req := &sacloud.ProxyLB{
|
||||
// Settings
|
||||
Settings: value.Settings,
|
||||
}
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.update(id, api.createRequest(req), res)
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 削除
|
||||
func (api *ProxyLBAPI) Delete(id int64) (*sacloud.ProxyLB, error) {
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.delete(id, nil, res)
|
||||
})
|
||||
}
|
||||
|
||||
// ChangePlan プラン変更
|
||||
func (api *ProxyLBAPI) ChangePlan(id int64, newPlan sacloud.ProxyLBPlan) (*sacloud.ProxyLB, error) {
|
||||
var (
|
||||
method = "PUT"
|
||||
uri = fmt.Sprintf("%s/%d/plan", api.getResourceURL(), id)
|
||||
)
|
||||
body := &sacloud.ProxyLB{}
|
||||
body.SetPlan(newPlan)
|
||||
realBody := map[string]interface{}{
|
||||
"CommonServiceItem": map[string]interface{}{
|
||||
"ServiceClass": body.ServiceClass,
|
||||
},
|
||||
}
|
||||
|
||||
return api.request(func(res *proxyLBResponse) error {
|
||||
return api.baseAPI.request(method, uri, realBody, res)
|
||||
})
|
||||
}
|
||||
|
||||
type proxyLBCertificateResponse struct {
|
||||
*sacloud.ResultFlagValue
|
||||
ProxyLB *sacloud.ProxyLBCertificates `json:",omitempty"`
|
||||
}
|
||||
|
||||
// GetCertificates 証明書取得
|
||||
func (api *ProxyLBAPI) GetCertificates(id int64) (*sacloud.ProxyLBCertificates, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/proxylb/sslcertificate", api.getResourceURL(), id)
|
||||
res = &proxyLBCertificateResponse{}
|
||||
)
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res.ProxyLB == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return res.ProxyLB, nil
|
||||
}
|
||||
|
||||
// SetCertificates 証明書設定
|
||||
func (api *ProxyLBAPI) SetCertificates(id int64, certs *sacloud.ProxyLBCertificates) (bool, error) {
|
||||
var (
|
||||
method = "PUT"
|
||||
uri = fmt.Sprintf("%s/%d/proxylb/sslcertificate", api.getResourceURL(), id)
|
||||
res = &proxyLBCertificateResponse{}
|
||||
)
|
||||
err := api.baseAPI.request(method, uri, map[string]interface{}{
|
||||
"ProxyLB": certs,
|
||||
}, res)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// DeleteCertificates 証明書削除
|
||||
func (api *ProxyLBAPI) DeleteCertificates(id int64) (bool, error) {
|
||||
var (
|
||||
method = "DELETE"
|
||||
uri = fmt.Sprintf("%s/%d/proxylb/sslcertificate", api.getResourceURL(), id)
|
||||
)
|
||||
return api.baseAPI.modify(method, uri, nil)
|
||||
}
|
||||
|
||||
type proxyLBHealthResponse struct {
|
||||
*sacloud.ResultFlagValue
|
||||
ProxyLB *sacloud.ProxyLBStatus `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Health ヘルスチェックステータス取得
|
||||
func (api *ProxyLBAPI) Health(id int64) (*sacloud.ProxyLBStatus, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/health", api.getResourceURL(), id)
|
||||
res = &proxyLBHealthResponse{}
|
||||
)
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res.ProxyLB == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return res.ProxyLB, nil
|
||||
}
|
||||
|
||||
// Monitor アクティビティーモニター取得
|
||||
func (api *ProxyLBAPI) Monitor(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
return api.baseAPI.applianceMonitorBy(id, "activity/proxylb", 0, body)
|
||||
}
|
238
vendor/github.com/sacloud/libsacloud/api/proxylb_gen.go
generated
vendored
Normal file
238
vendor/github.com/sacloud/libsacloud/api/proxylb_gen.go
generated
vendored
Normal file
|
@ -0,0 +1,238 @@
|
|||
package api
|
||||
|
||||
/************************************************
|
||||
generated by IDE. for [ProxyLBAPI]
|
||||
************************************************/
|
||||
|
||||
import (
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
/************************************************
|
||||
To support fluent interface for Find()
|
||||
************************************************/
|
||||
|
||||
// Reset 検索条件のリセット
|
||||
func (api *ProxyLBAPI) Reset() *ProxyLBAPI {
|
||||
api.reset()
|
||||
return api
|
||||
}
|
||||
|
||||
// Offset オフセット
|
||||
func (api *ProxyLBAPI) Offset(offset int) *ProxyLBAPI {
|
||||
api.offset(offset)
|
||||
return api
|
||||
}
|
||||
|
||||
// Limit リミット
|
||||
func (api *ProxyLBAPI) Limit(limit int) *ProxyLBAPI {
|
||||
api.limit(limit)
|
||||
return api
|
||||
}
|
||||
|
||||
// Include 取得する項目
|
||||
func (api *ProxyLBAPI) Include(key string) *ProxyLBAPI {
|
||||
api.include(key)
|
||||
return api
|
||||
}
|
||||
|
||||
// Exclude 除外する項目
|
||||
func (api *ProxyLBAPI) Exclude(key string) *ProxyLBAPI {
|
||||
api.exclude(key)
|
||||
return api
|
||||
}
|
||||
|
||||
// FilterBy 指定キーでのフィルター
|
||||
func (api *ProxyLBAPI) FilterBy(key string, value interface{}) *ProxyLBAPI {
|
||||
api.filterBy(key, value, false)
|
||||
return api
|
||||
}
|
||||
|
||||
// FilterMultiBy 任意項目でのフィルタ(完全一致 OR条件)
|
||||
func (api *ProxyLBAPI) FilterMultiBy(key string, value interface{}) *ProxyLBAPI {
|
||||
api.filterBy(key, value, true)
|
||||
return api
|
||||
}
|
||||
|
||||
// WithNameLike 名称条件
|
||||
func (api *ProxyLBAPI) WithNameLike(name string) *ProxyLBAPI {
|
||||
return api.FilterBy("Name", name)
|
||||
}
|
||||
|
||||
// WithTag タグ条件
|
||||
func (api *ProxyLBAPI) WithTag(tag string) *ProxyLBAPI {
|
||||
return api.FilterBy("Tags.Name", tag)
|
||||
}
|
||||
|
||||
// WithTags タグ(複数)条件
|
||||
func (api *ProxyLBAPI) WithTags(tags []string) *ProxyLBAPI {
|
||||
return api.FilterBy("Tags.Name", []interface{}{tags})
|
||||
}
|
||||
|
||||
// func (api *ProxyLBAPI) WithSizeGib(size int) *ProxyLBAPI {
|
||||
// api.FilterBy("SizeMB", size*1024)
|
||||
// return api
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) WithSharedScope() *ProxyLBAPI {
|
||||
// api.FilterBy("Scope", "shared")
|
||||
// return api
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) WithUserScope() *ProxyLBAPI {
|
||||
// api.FilterBy("Scope", "user")
|
||||
// return api
|
||||
// }
|
||||
|
||||
// SortBy 指定キーでのソート
|
||||
func (api *ProxyLBAPI) SortBy(key string, reverse bool) *ProxyLBAPI {
|
||||
api.sortBy(key, reverse)
|
||||
return api
|
||||
}
|
||||
|
||||
// SortByName 名称でのソート
|
||||
func (api *ProxyLBAPI) SortByName(reverse bool) *ProxyLBAPI {
|
||||
api.sortByName(reverse)
|
||||
return api
|
||||
}
|
||||
|
||||
// func (api *ProxyLBAPI) SortBySize(reverse bool) *ProxyLBAPI {
|
||||
// api.sortBy("SizeMB", reverse)
|
||||
// return api
|
||||
// }
|
||||
|
||||
/************************************************
|
||||
To support Setxxx interface for Find()
|
||||
************************************************/
|
||||
|
||||
// SetEmpty 検索条件のリセット
|
||||
func (api *ProxyLBAPI) SetEmpty() {
|
||||
api.reset()
|
||||
}
|
||||
|
||||
// SetOffset オフセット
|
||||
func (api *ProxyLBAPI) SetOffset(offset int) {
|
||||
api.offset(offset)
|
||||
}
|
||||
|
||||
// SetLimit リミット
|
||||
func (api *ProxyLBAPI) SetLimit(limit int) {
|
||||
api.limit(limit)
|
||||
}
|
||||
|
||||
// SetInclude 取得する項目
|
||||
func (api *ProxyLBAPI) SetInclude(key string) {
|
||||
api.include(key)
|
||||
}
|
||||
|
||||
// SetExclude 除外する項目
|
||||
func (api *ProxyLBAPI) SetExclude(key string) {
|
||||
api.exclude(key)
|
||||
}
|
||||
|
||||
// SetFilterBy 指定キーでのフィルター
|
||||
func (api *ProxyLBAPI) SetFilterBy(key string, value interface{}) {
|
||||
api.filterBy(key, value, false)
|
||||
}
|
||||
|
||||
// SetFilterMultiBy 任意項目でのフィルタ(完全一致 OR条件)
|
||||
func (api *ProxyLBAPI) SetFilterMultiBy(key string, value interface{}) {
|
||||
api.filterBy(key, value, true)
|
||||
}
|
||||
|
||||
// SetNameLike 名称条件
|
||||
func (api *ProxyLBAPI) SetNameLike(name string) {
|
||||
api.FilterBy("Name", name)
|
||||
}
|
||||
|
||||
// SetTag タグ条件
|
||||
func (api *ProxyLBAPI) SetTag(tag string) {
|
||||
api.FilterBy("Tags.Name", tag)
|
||||
}
|
||||
|
||||
// SetTags タグ(複数)条件
|
||||
func (api *ProxyLBAPI) SetTags(tags []string) {
|
||||
api.FilterBy("Tags.Name", []interface{}{tags})
|
||||
}
|
||||
|
||||
// func (api *ProxyLBAPI) SetSizeGib(size int) {
|
||||
// api.FilterBy("SizeMB", size*1024)
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) SetSharedScope() {
|
||||
// api.FilterBy("Scope", "shared")
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) SetUserScope() {
|
||||
// api.FilterBy("Scope", "user")
|
||||
// }
|
||||
|
||||
// SetSortBy 指定キーでのソート
|
||||
func (api *ProxyLBAPI) SetSortBy(key string, reverse bool) {
|
||||
api.sortBy(key, reverse)
|
||||
}
|
||||
|
||||
// SetSortByName 名称でのソート
|
||||
func (api *ProxyLBAPI) SetSortByName(reverse bool) {
|
||||
api.sortByName(reverse)
|
||||
}
|
||||
|
||||
// func (api *ProxyLBAPI) SetSortBySize(reverse bool) {
|
||||
// api.sortBy("SizeMB", reverse)
|
||||
// }
|
||||
|
||||
/************************************************
|
||||
To support CRUD(Create/Read/Update/Delete)
|
||||
************************************************/
|
||||
|
||||
// func (api *ProxyLBAPI) New() *sacloud.ProxyLB {
|
||||
// return &sacloud.ProxyLB{}
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) Create(value *sacloud.ProxyLB) (*sacloud.ProxyLB, error) {
|
||||
// return api.request(func(res *sacloud.Response) error {
|
||||
// return api.create(api.createRequest(value), res)
|
||||
// })
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) Read(id string) (*sacloud.ProxyLB, error) {
|
||||
// return api.request(func(res *sacloud.Response) error {
|
||||
// return api.read(id, nil, res)
|
||||
// })
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) Update(id string, value *sacloud.ProxyLB) (*sacloud.ProxyLB, error) {
|
||||
// return api.request(func(res *sacloud.Response) error {
|
||||
// return api.update(id, api.createRequest(value), res)
|
||||
// })
|
||||
// }
|
||||
|
||||
// func (api *ProxyLBAPI) Delete(id string) (*sacloud.ProxyLB, error) {
|
||||
// return api.request(func(res *sacloud.Response) error {
|
||||
// return api.delete(id, nil, res)
|
||||
// })
|
||||
// }
|
||||
|
||||
/************************************************
|
||||
Inner functions
|
||||
************************************************/
|
||||
|
||||
func (api *ProxyLBAPI) setStateValue(setFunc func(*sacloud.Request)) *ProxyLBAPI {
|
||||
api.baseAPI.setStateValue(setFunc)
|
||||
return api
|
||||
}
|
||||
|
||||
//func (api *ProxyLBAPI) request(f func(*sacloud.Response) error) (*sacloud.ProxyLB, error) {
|
||||
// res := &sacloud.Response{}
|
||||
// err := f(res)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return res.ProxyLB, nil
|
||||
//}
|
||||
//
|
||||
//func (api *ProxyLBAPI) createRequest(value *sacloud.ProxyLB) *sacloud.Request {
|
||||
// req := &sacloud.Request{}
|
||||
// req.ProxyLB = value
|
||||
// return req
|
||||
//}
|
32
vendor/github.com/sacloud/libsacloud/api/rate_limit_transport.go
generated
vendored
Normal file
32
vendor/github.com/sacloud/libsacloud/api/rate_limit_transport.go
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"go.uber.org/ratelimit"
|
||||
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// RateLimitRoundTripper 秒間アクセス数を制限するためのhttp.RoundTripper実装
|
||||
type RateLimitRoundTripper struct {
|
||||
// Transport 親となるhttp.RoundTripper、nilの場合http.DefaultTransportが利用される
|
||||
Transport http.RoundTripper
|
||||
// RateLimitPerSec 秒あたりのリクエスト数
|
||||
RateLimitPerSec int
|
||||
|
||||
once sync.Once
|
||||
rateLimit ratelimit.Limiter
|
||||
}
|
||||
|
||||
// RoundTrip http.RoundTripperの実装
|
||||
func (r *RateLimitRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
r.once.Do(func() {
|
||||
r.rateLimit = ratelimit.New(r.RateLimitPerSec)
|
||||
})
|
||||
if r.Transport == nil {
|
||||
r.Transport = http.DefaultTransport
|
||||
}
|
||||
|
||||
r.rateLimit.Take()
|
||||
return r.Transport.RoundTrip(req)
|
||||
}
|
13
vendor/github.com/sacloud/libsacloud/api/server.go
generated
vendored
13
vendor/github.com/sacloud/libsacloud/api/server.go
generated
vendored
|
@ -2,8 +2,9 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// ServerAPI サーバーAPI
|
||||
|
@ -150,14 +151,18 @@ func (api *ServerAPI) SleepUntilDown(id int64, timeout time.Duration) error {
|
|||
}
|
||||
|
||||
// ChangePlan サーバープラン変更(サーバーIDが変更となるため注意)
|
||||
func (api *ServerAPI) ChangePlan(serverID int64, planID string) (*sacloud.Server, error) {
|
||||
func (api *ServerAPI) ChangePlan(serverID int64, plan *sacloud.ProductServer) (*sacloud.Server, error) {
|
||||
var (
|
||||
method = "PUT"
|
||||
uri = fmt.Sprintf("%s/%d/to/plan/%s", api.getResourceURL(), serverID, planID)
|
||||
uri = fmt.Sprintf("%s/%d/plan", api.getResourceURL(), serverID)
|
||||
body = &sacloud.ProductServer{}
|
||||
)
|
||||
body.CPU = plan.CPU
|
||||
body.MemoryMB = plan.MemoryMB
|
||||
body.Generation = plan.Generation
|
||||
|
||||
return api.request(func(res *sacloud.Response) error {
|
||||
return api.baseAPI.request(method, uri, nil, res)
|
||||
return api.baseAPI.request(method, uri, body, res)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
31
vendor/github.com/sacloud/libsacloud/api/sim.go
generated
vendored
31
vendor/github.com/sacloud/libsacloud/api/sim.go
generated
vendored
|
@ -204,6 +204,37 @@ func (api *SIMAPI) Logs(id int64, body interface{}) ([]sacloud.SIMLog, error) {
|
|||
return res.Logs, nil
|
||||
}
|
||||
|
||||
// GetNetworkOperator 通信キャリア 取得
|
||||
func (api *SIMAPI) GetNetworkOperator(id int64) (*sacloud.SIMNetworkOperatorConfigs, error) {
|
||||
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/sim/network_operator_config", api.getResourceURL(), id)
|
||||
)
|
||||
|
||||
res := &sacloud.SIMNetworkOperatorConfigs{}
|
||||
err := api.baseAPI.request(method, uri, nil, res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SetNetworkOperator 通信キャリア 設定
|
||||
func (api *SIMAPI) SetNetworkOperator(id int64, opConfig ...*sacloud.SIMNetworkOperatorConfig) (bool, error) {
|
||||
|
||||
var (
|
||||
method = "PUT"
|
||||
uri = fmt.Sprintf("%s/%d/sim/network_operator_config", api.getResourceURL(), id)
|
||||
)
|
||||
|
||||
err := api.baseAPI.request(method, uri, &sacloud.SIMNetworkOperatorConfigs{NetworkOperatorConfigs: opConfig}, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Monitor アクティビティーモニター(Up/Down link BPS)取得
|
||||
func (api *SIMAPI) Monitor(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
var (
|
||||
|
|
23
vendor/github.com/sacloud/libsacloud/api/simple_monitor.go
generated
vendored
23
vendor/github.com/sacloud/libsacloud/api/simple_monitor.go
generated
vendored
|
@ -1,9 +1,9 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
// "strings"
|
||||
"encoding/json" // "strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
@ -118,6 +118,25 @@ func (api *SimpleMonitorAPI) Delete(id int64) (*sacloud.SimpleMonitor, error) {
|
|||
})
|
||||
}
|
||||
|
||||
// Health ヘルスチェック
|
||||
//
|
||||
// まだチェックが行われていない場合nilを返す
|
||||
func (api *SimpleMonitorAPI) Health(id int64) (*sacloud.SimpleMonitorHealthCheckStatus, error) {
|
||||
var (
|
||||
method = "GET"
|
||||
uri = fmt.Sprintf("%s/%d/health", api.getResourceURL(), id)
|
||||
)
|
||||
res := struct {
|
||||
SimpleMonitor *sacloud.SimpleMonitorHealthCheckStatus `json:",omitempty"`
|
||||
}{}
|
||||
|
||||
err := api.baseAPI.request(method, uri, nil, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.SimpleMonitor, nil
|
||||
}
|
||||
|
||||
// MonitorResponseTimeSec アクティビティーモニター(レスポンスタイム)取得
|
||||
func (api *SimpleMonitorAPI) MonitorResponseTimeSec(id int64, body *sacloud.ResourceMonitorRequest) (*sacloud.MonitorValues, error) {
|
||||
var (
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/ssh_key.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/ssh_key.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
1
vendor/github.com/sacloud/libsacloud/api/switch.go
generated
vendored
1
vendor/github.com/sacloud/libsacloud/api/switch.go
generated
vendored
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/vpc_router.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/vpc_router.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"time"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
//HACK: さくらのAPI側仕様: Applianceの内容によってJSONフォーマットが異なるため
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/webaccel.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/webaccel.go
generated
vendored
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"strings"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// WebAccelAPI ウェブアクセラレータAPI
|
||||
|
|
3
vendor/github.com/sacloud/libsacloud/api/webaccel_search.go
generated
vendored
3
vendor/github.com/sacloud/libsacloud/api/webaccel_search.go
generated
vendored
|
@ -3,9 +3,10 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/sacloud/libsacloud/sacloud"
|
||||
)
|
||||
|
||||
// Reset 検索条件のリセット
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue