Documentation
¶
Index ¶
- Constants
- Variables
- type API
- type APICaller
- type APIError
- type APIErrorResponse
- type CORSRule
- type Certificates
- type Client
- type CreateOrUpdateCertificateRequest
- type CurrentCertificate
- type DeleteAllCacheRequest
- type DeleteCacheRequest
- type DeleteCacheResult
- type Issuer
- type ListSitesResult
- type MonthlyUsage
- type MonthlyUsageResults
- type OldCertificate
- type Op
- func (o *Op) CreateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
- func (o *Op) DeleteAllCache(ctx context.Context, param *DeleteAllCacheRequest) error
- func (o *Op) DeleteCache(ctx context.Context, param *DeleteCacheRequest) ([]*DeleteCacheResult, error)
- func (o *Op) DeleteCertificate(ctx context.Context, id string) error
- func (o *Op) List(ctx context.Context) (*ListSitesResult, error)
- func (o *Op) MonthlyUsage(ctx context.Context, targetYM string) (*MonthlyUsageResults, error)
- func (o *Op) Read(ctx context.Context, id string) (*Site, error)
- func (o *Op) ReadCertificate(ctx context.Context, id string) (*Certificates, error)
- func (o *Op) Update(ctx context.Context, id string, param *UpdateSiteRequest) (*Site, error)
- func (o *Op) UpdateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
- type Site
- type Subject
- type UpdateSiteRequest
Constants ¶
const ( OriginTypesWebServer = "0" // ウェブサーバ OriginTypesObjectStorage = "1" // オブジェクトストレージ )
OriginType
const ( RequestProtocolsHttpAndHttps = "0" // http/https RequestProtocolsHttpsOnly = "1" // httpsのみ RequestProtocolsRedirectToHttps = "2" // httpsに」リダイレクト )
RequestProtocol
const ( OriginProtocolsHttp = "http" OriginProtocolsHttps = "https" )
OriginProtocol
const ( VarySupportDisabled = "0" // 無効 VarySupportEnabled = "1" // 有効 )
VarySupport
const ( DocIndexDisabled = "0" // 無効 DocIndexEnabled = "1" // 有効 )
DocIndex
const DefaultAPIRootURL = "https://secure.sakura.ad.jp/cloud/zone/is1a/api/webaccel/1.0/"
DefaultAPIRootURL デフォルトのAPIルートURL
Variables ¶
var UserAgent = fmt.Sprintf( "webaccel-api-go/v%s (%s/%s; +https://github.com/sacloud/webaccel-api-go) %s", Version, runtime.GOOS, runtime.GOARCH, client.DefaultUserAgent, )
UserAgent APIリクエスト時のユーザーエージェント
var (
// Version app version
Version = "1.1.0"
)
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { List(ctx context.Context) (*ListSitesResult, error) Read(ctx context.Context, id string) (*Site, error) Update(ctx context.Context, id string, param *UpdateSiteRequest) (*Site, error) ReadCertificate(ctx context.Context, id string) (*Certificates, error) CreateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error) UpdateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error) DeleteCertificate(ctx context.Context, id string) error DeleteAllCache(ctx context.Context, param *DeleteAllCacheRequest) error DeleteCache(ctx context.Context, param *DeleteCacheRequest) ([]*DeleteCacheResult, error) MonthlyUsage(ctx context.Context, targetYM string) (*MonthlyUsageResults, error) }
API is interface for operate WebAccel resource
type APIError ¶
type APIError interface { // errorインターフェースを内包 error // ResponseCode エラー発生時のレスポンスコード ResponseCode() int // Code エラーコード Code() string // Message エラー発生時のメッセージ Message() string // Serial エラー追跡用シリアルコード Serial() string // OriginalError エラー(オリジナル) OriginalError() *APIErrorResponse }
APIError APIコール時のエラー情報
func NewAPIError ¶
func NewAPIError(requestMethod string, requestURL *url.URL, responseCode int, err *APIErrorResponse) APIError
NewAPIError APIコール時のエラー情報
type APIErrorResponse ¶
type APIErrorResponse struct { IsFatal bool `json:"is_fatal,omitempty"` // IsFatal Serial string `json:"serial,omitempty"` // Serial Status string `json:"status,omitempty"` // Status ErrorCode string `json:"error_code,omitempty"` // ErrorCode ErrorMessage string `json:"error_msg,omitempty"` // ErrorMessage }
APIErrorResponse APIエラー型
type CORSRule ¶ added in v1.1.0
type CORSRule struct { AllowsAnyOrigin bool // trueの場合全オリジンを許可 AllowedOrigins []string `validate:"omitempty,max=4"` }
CORSRule .
type Certificates ¶
type Certificates struct { Current *CurrentCertificate Old []*OldCertificate }
Certificates 証明書
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 CreateOrUpdateCertificateRequest ¶
CreateOrUpdateCertificateRequest .
type CurrentCertificate ¶
type CurrentCertificate struct { ID string SiteID string CertificateChain string Key string CreatedAt time.Time UpdatedAt time.Time SerialNumber string NotBefore int64 NotAfter int64 Issuer *Issuer Subject *Subject DNSNames []string SHA256Fingerprint string }
CurrentCertificate 現在有効な証明書
type DeleteAllCacheRequest ¶
type DeleteAllCacheRequest struct {
Domain string
}
DeleteAllCacheRequest .
type DeleteCacheResult ¶
DeleteCacheResult .
type Issuer ¶
type Issuer struct { Country string Organization string OrganizationalUnit string CommonName string }
Issuer .
type ListSitesResult ¶
type ListSitesResult struct { Total int `json:",omitempty"` // Total count of target resources From int `json:",omitempty"` // Current page number Count int `json:",omitempty"` // Count of current page Sites []*Site `json:",omitempty"` }
ListSitesResult .
type MonthlyUsage ¶ added in v1.1.0
type MonthlyUsageResults ¶ added in v1.1.0
type MonthlyUsageResults struct { Year int Month int MonthlyUsages []*MonthlyUsage }
MonthlyUsageResults 月別使用量
type OldCertificate ¶
type OldCertificate struct { ID string SiteID string CertificateChain string Key string CreatedAt time.Time UpdatedAt time.Time SerialNumber string NotBefore int64 NotAfter int64 Issuer *Issuer Subject *Subject DNSNames []string SHA256Fingerprint string }
OldCertificate .
type Op ¶
type Op struct {
Client APICaller
}
Op implements WebAccelAPI interface
func (*Op) CreateCertificate ¶
func (o *Op) CreateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
CreateCertificate サイトに証明書を登録
func (*Op) DeleteAllCache ¶
func (o *Op) DeleteAllCache(ctx context.Context, param *DeleteAllCacheRequest) error
DeleteAllCache 全キャッシュ削除
func (*Op) DeleteCache ¶
func (o *Op) DeleteCache(ctx context.Context, param *DeleteCacheRequest) ([]*DeleteCacheResult, error)
DeleteCache URLごとにキャッシュ削除
func (*Op) DeleteCertificate ¶
DeleteCertificate サイトの証明書を削除
func (*Op) List ¶
func (o *Op) List(ctx context.Context) (*ListSitesResult, error)
List サイト一覧
NOTE: 各サイトのCORSRulesはnullになる点に注意
func (*Op) MonthlyUsage ¶ added in v1.1.0
MonthlyUsage クラウドアカウントに登録されている全サイトの月別使用量を取得する。
targetフィールドの値は「yyyymm」形式で対象年月を指定する。 (例: 2021年02月の場合は、「202102」と指定。) 指定がない場合は、今月の月別使用量を取得する。
func (*Op) ReadCertificate ¶
ReadCertificate サイト証明書の参照
func (*Op) UpdateCertificate ¶
func (o *Op) UpdateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
UpdateCertificate サイトの証明書を更新
type Site ¶
type Site struct { ID string Name string DomainType string `validate:"oneof=own_domain subdomain"` Domain string Subdomain string ASCIIDomain string RequestProtocol string // 0:http/https, 1:httpsのみ, 2:httpsにリダイレクト DefaultCacheTTL int `validate:"min=-1,max=604800"` // -1:無効, 0 ~ 604800 の範囲内の数値: デフォルトのキャッシュ期間(秒) VarySupport string // 0:無効, 1:有効 OriginType string // 0:ウェブサーバ, 1:オブジェクトストレージ Origin string OriginProtocol string HostHeader string // オブジェクトストレージをオリジンにする場合 BucketName string S3Endpoint string S3Region string DocIndex string // 0:無効, 1:有効 // CORSRules ルール一覧、設定されている場合単一要素を持つ配列となる // NOTE: List()だと空、Read()でのみ参照可能 CORSRules []*CORSRule OnetimeURLSecrets []string Status string `validate:"oneof=enabled disabled"` HasCertificate bool HasOldCertificate bool GibSentInLastWeek int64 CertValidNotBefore int64 CertValidNotAfter int64 CreatedAt time.Time }
Site サイト
type Subject ¶
type Subject struct { Country string Organization string OrganizationalUnit string Locality string Province string StreetAddress string PostalCode string SerialNumber string CommonName string }
Subject .
type UpdateSiteRequest ¶ added in v1.1.0
type UpdateSiteRequest struct { // 「オリジン種別」に関係なく設定できる共通項目 Name string `json:",omitempty"` OriginType string `json:",omitempty" validate:"omitempty,oneof=0 1"` // 0:ウェブサーバ, 1:オブジェクトストレージ RequestProtocol string `json:",omitempty" validate:"omitempty,oneof=0 1 2"` // 0:http/https, 1:httpsのみ, 2:httpsにリダイレクト OriginProtocol string `json:",omitempty" validate:"omitempty,oneof=http https"` DefaultCacheTTL int `json:",omitempty" validate:"omitempty,min=-1,max=604800"` // -1:無効, 0 ~ 604800 の範囲内の数値: デフォルトのキャッシュ期間(秒) VarySupport string `json:",omitempty" validate:"omitempty,oneof=0 1"` // 0:無効, 1:有効 // CORSRules ルール一覧、設定されている場合単一要素を持つ配列となる CORSRules []*CORSRule `json:",omitempty"` OnetimeURLSecrets []string `json:",omitempty"` // 「オリジン種別」が「ウェブサーバ」の場合に設定可能な項目 Origin string `json:",omitempty"` HostHeader string `json:",omitempty"` // 「オリジン種別」が「オブジェクトストレージ」の場合に設定可能な項目 BucketName string `json:",omitempty"` S3Endpoint string `json:",omitempty"` S3Region string `json:",omitempty"` DocIndex string `json:",omitempty" validate:"omitempty,oneof=0 1"` // 0:無効, 1:有効 AccessKeyID string `json:",omitempty"` SecretAccessKey string `json:",omitempty"` }
UpdateSiteRequest サイト更新リクエスト