1
0
Fork 0

fix: update lego.

This commit is contained in:
Fernandez Ludovic 2019-04-26 11:08:44 +02:00 committed by Traefiker Bot
parent b8b0c8f3e5
commit 8d848c3d60
169 changed files with 12224 additions and 605 deletions

View file

@ -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),