Documentation
¶
Index ¶
- Constants
- Variables
- func IsNotFoundError(err error) bool
- type ACLResult
- type API
- type APICaller
- type APIError
- type APIErrorResponse
- type CORSRule
- type Certificates
- type Client
- type CreateOrUpdateCertificateRequest
- type CreateSiteRequest
- type CurrentCertificate
- type DeleteAllCacheRequest
- type DeleteCacheRequest
- type DeleteCacheResult
- type Issuer
- type ListSitesResult
- type LogUploadConfig
- type MonthlyUsage
- type MonthlyUsageResults
- type OldCertificate
- type Op
- func (o *Op) ApplyLogUploadConfig(ctx context.Context, id string, param *LogUploadConfig) (*LogUploadConfig, error)
- func (o *Op) Create(ctx context.Context, param *CreateSiteRequest) (*Site, error)
- func (o *Op) CreateAutoCertUpdate(ctx context.Context, id string) error
- func (o *Op) CreateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
- func (o *Op) CreateNextOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error)
- func (o *Op) CreateOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error)
- func (o *Op) Delete(ctx context.Context, id string) (*Site, error)
- func (o *Op) DeleteACL(ctx context.Context, id string) error
- func (o *Op) DeleteAllCache(ctx context.Context, param *DeleteAllCacheRequest) error
- func (o *Op) DeleteAutoCertUpdate(ctx context.Context, id string) 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) DeleteLogUploadConfig(ctx context.Context, id string) error
- func (o *Op) DeleteNextOriginGuardToken(ctx context.Context, id string) error
- func (o *Op) DeleteOriginGuardToken(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) ReadACL(ctx context.Context, id string) (*ACLResult, error)
- func (o *Op) ReadCertificate(ctx context.Context, id string) (*Certificates, error)
- func (o *Op) ReadLogUploadConfig(ctx context.Context, id string) (*LogUploadConfig, 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)
- func (o *Op) UpdateStatus(ctx context.Context, id string, param *UpdateSiteStatusRequest) (*Site, error)
- func (o *Op) UpsertACL(ctx context.Context, id string, acl string) (*ACLResult, error)
- type OriginGuardTokenResponse
- type Site
- type Subject
- type UpdateSiteRequest
- type UpdateSiteStatusRequest
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 ( NormalizeAEGz = "1" // gzipに正規化 NormalizeAEBrGz = "3" // brとgzipの組に正規化 )
NormalizeAE
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.3.0"
)
Functions ¶
func IsNotFoundError ¶ added in v1.1.2
IsNotFoundError 指定のerrorがAPI呼び出し時の404エラーであるか判定
Types ¶
type API ¶
type API interface { List(ctx context.Context) (*ListSitesResult, error) Create(ctx context.Context, param *CreateSiteRequest) (*Site, error) Read(ctx context.Context, id string) (*Site, error) Update(ctx context.Context, id string, param *UpdateSiteRequest) (*Site, error) UpdateStatus(ctx context.Context, id string, param *UpdateSiteStatusRequest) (*Site, error) CreateOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error) DeleteOriginGuardToken(ctx context.Context, id string) error CreateNextOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error) DeleteNextOriginGuardToken(ctx context.Context, id string) error CreateAutoCertUpdate(ctx context.Context, id string) error DeleteAutoCertUpdate(ctx context.Context, id string) error ReadACL(ctx context.Context, id string) (*ACLResult, error) UpsertACL(ctx context.Context, id string, acl string) (*ACLResult, error) DeleteACL(ctx context.Context, id string) 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) Delete(ctx context.Context, id string) (*Site, error) MonthlyUsage(ctx context.Context, targetYM string) (*MonthlyUsageResults, error) ApplyLogUploadConfig(ctx context.Context, id string, param *LogUploadConfig) (*LogUploadConfig, error) ReadLogUploadConfig(ctx context.Context, id string) (*LogUploadConfig, error) DeleteLogUploadConfig(ctx context.Context, id string) 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 証明書
func (*Certificates) UnmarshalJSON ¶ added in v1.1.3
func (w *Certificates) UnmarshalJSON(data []byte) error
UnmarshalJSON JSONアンマーシャル(配列、オブジェクトが混在するためここで対応)
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 CreateSiteRequest ¶ added in v1.3.0
type CreateSiteRequest struct { // 「オリジン種別」に関係なく設定できる共通項目 Name string `json:",omitempty"` OriginType string `json:",omitempty" validate:"omitempty,oneof=0 1"` // 0:ウェブサーバ, 1:オブジェクトストレージ Domain string `json:",omitempty" validate:"omitempty"` // 独自ドメインを設定する場合のみ DomainType string `json:",omitempty" validate:"omitempty,oneof=own_domain subdomain"` 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:有効 NormalizeAE string `json:",omitempty" validate:"omitempty,oneof=1 3"` // 1:Accept-Encodingをgzipに正規化, 3:bzとgzipの組に正規化 // 「オリジン種別」が「ウェブサーバ」の場合に設定可能な項目 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"` }
CreateSiteRequest サイト作成リクエスト
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 LogUploadConfig ¶ added in v1.3.0
type LogUploadConfig struct { Bucket string `json:","` Endpoint string `json:"," validate:",equal=https://s3.isk01.sakurastorage.jp"` Region string `json:"," validate:",equal=jp-north-1"` AccessKeyID string `json:","` SecretAccessKey string `json:","` Status string `json:"," validate:"oneof=enabled disabled"` }
LogUploadConfig ログアップロード設定
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) ApplyLogUploadConfig ¶ added in v1.3.0
func (o *Op) ApplyLogUploadConfig(ctx context.Context, id string, param *LogUploadConfig) (*LogUploadConfig, error)
ApplyLogUploadConfig ログアップロード設定を作成・更新
func (*Op) CreateAutoCertUpdate ¶ added in v1.3.0
CreateAutoCertUpdate Let's Encrypt 自動更新証明書有効化
func (*Op) CreateCertificate ¶
func (o *Op) CreateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
CreateCertificate サイトに証明書を登録
func (*Op) CreateNextOriginGuardToken ¶ added in v1.3.0
func (o *Op) CreateNextOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error)
CreateNextOriginGuardToken オリジンガードトークンの次期トークン作成
func (*Op) CreateOriginGuardToken ¶ added in v1.3.0
func (o *Op) CreateOriginGuardToken(ctx context.Context, id string) (*OriginGuardTokenResponse, error)
CreateOriginGuardToken オリジンガードトークンの発行・更新
func (*Op) DeleteAllCache ¶
func (o *Op) DeleteAllCache(ctx context.Context, param *DeleteAllCacheRequest) error
DeleteAllCache 全キャッシュ削除
func (*Op) DeleteAutoCertUpdate ¶ added in v1.3.0
DeleteAutoCertUpdate Let's Encrypt 自動更新証明書無効化
func (*Op) DeleteCache ¶
func (o *Op) DeleteCache(ctx context.Context, param *DeleteCacheRequest) ([]*DeleteCacheResult, error)
DeleteCache URLごとにキャッシュ削除
func (*Op) DeleteCertificate ¶
DeleteCertificate サイトの証明書を削除
func (*Op) DeleteLogUploadConfig ¶ added in v1.3.0
DeleteLogUploadConfig ログアップロードを削除
func (*Op) DeleteNextOriginGuardToken ¶ added in v1.3.0
DeleteNextOriginGuardToken オリジンガードトークンの次期トークン更新キャンセル
func (*Op) DeleteOriginGuardToken ¶ added in v1.3.0
DeleteOriginGuardToken オリジンガードトークンの削除
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) ReadLogUploadConfig ¶ added in v1.3.0
ReadLogUploadConfig ログアップロードを取得
func (*Op) UpdateCertificate ¶
func (o *Op) UpdateCertificate(ctx context.Context, id string, param *CreateOrUpdateCertificateRequest) (*Certificates, error)
UpdateCertificate サイトの証明書を更新
func (*Op) UpdateStatus ¶ added in v1.3.0
func (o *Op) UpdateStatus(ctx context.Context, id string, param *UpdateSiteStatusRequest) (*Site, error)
UpdateStatus サイト有効化状態の更新
type OriginGuardTokenResponse ¶ added in v1.3.0
type OriginGuardTokenResponse struct { OriginGuardToken string `json:","` NextOriginGuardToken string `json:","` }
OriginGuardTokenResponse サイトのオリジンガードトークン取得レスポンス
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:有効 // NOTE: List()だと空、Read()でのみ参照可能 NormalizeAE string // 1:Accept-Encodingをgzipに正規化, 3:bzとgzipの組に正規化 OriginType string // 0:ウェブサーバ, 1:オブジェクトストレージ Origin string OriginProtocol string HostHeader string OriginGuardToken string NextOriginGuardToken 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:有効 NormalizeAE string `json:",omitempty" validate:"omitempty,oneof=1 3"` // 1:Accept-Encodingをgzipに正規化, 3:bzとgzipの組に正規化 // 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 サイト更新リクエスト
type UpdateSiteStatusRequest ¶ added in v1.3.0
type UpdateSiteStatusRequest struct {
Status string `validate:"oneof=enabled disabled"`
}
UpdateSiteStatusRequest サイトの有効化状態更新リクエスト