api

package
v0.9.175 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Period300   = createPeriod(300)
	Period3600  = createPeriod(3600)
	Period86400 = createPeriod(86400)
)

The time interval of statistics data merged by, we defined 3 valid values here.

Functions

func SendCustomRequest

func SendCustomRequest(cli bce.Client, method string, urlPath string, params, reqHeaders map[string]string, bodyObj interface{}, respObj interface{}) error

SendCustomRequest - send a HTTP request, and response data or error, it use the default times for retrying

PARAMS:

  • cli: the client agent which can perform sending request
  • method: the HTTP requested method, e.g. "GET", "POST", "PUT" ...
  • urlPath: a path component, consisting of a sequence of path segments separated by a slash ( / ).
  • params: the query params, which will be append to the query path, and separate by "&" e.g. http://www.baidu.com?query_param1=value1&query_param2=value2
  • reqHeaders: the request http headers
  • bodyObj: the HTTP requested body content transferred to a goland object
  • respObj: the HTTP response content transferred to a goland object

RETURNS:

  • error: nil if success otherwise the specific error

func SetCacheFullUrl

func SetCacheFullUrl(cli bce.Client, domain string, cacheFullUrl bool) error

SetCacheFullUrl - set the rule to calculate the cache key, set `cacheFullUrl` to true means the whole query(the string right after the question mark in URL) will be added to the cache key. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/nkbsxko6t

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • cacheFullUrl: the query part in URL being added to the cache key or not

RETURNS:

  • error: nil if success otherwise the specific error

func SetCacheTTL

func SetCacheTTL(cli bce.Client, domain string, cacheTTLs []CacheTTL) error

SetCacheTTL - add rules to cache asserts. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Zkbstm0vg

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • cacheTTLs: the cache setting list

RETURNS:

  • error: nil if success otherwise the specific error

func SetDomainOrigin

func SetDomainOrigin(cli bce.Client, domain string, origins []OriginPeer) error

SetDomainOrigin - set the origin setting for the new For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Gkbstcgaa

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • origins: the origin servers

RETURNS:

  • error: nil if success otherwise the specific error

func SetHostToOrigin

func SetHostToOrigin(cli bce.Client, domain string, originHost string) error

SetHostToOrigin - Specify a default value for the HOST header for virtual sites in your origin server. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Pkbsxw8xw

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • originHost: specified HOST header for origin server

RETURNS:

  • error: nil if success otherwise the specific error

func SetIpACL

func SetIpACL(cli bce.Client, domain string, ipACL *IpACL) error

SetIpACL - Set an IP whitelist or blacklist to block or allow requests from specific IP addresses. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/2kbsxt693

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • ipACL: IP whitelist or blacklist

RETURNS:

  • error: nil if success otherwise the specific error

func SetRefererACL

func SetRefererACL(cli bce.Client, domain string, refererACL *RefererACL) error

SetRefererACL - Set a Referer whitelist or blacklist to enable hotlink protection. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/ekbsxow69

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • refererACL: referer of whitelist or blacklist

RETURNS:

  • error: nil if success otherwise the specific error

Types

type CRecordQueryData

type CRecordQueryData struct {
	EndTime   string
	StartTime string
	Url       string
	Marker    string
	TaskType  string
}

CRecordQueryData defined a struct for the query conditions about the operated records

type CStatusQueryData

type CStatusQueryData struct {
	EndTime   string
	StartTime string
	Url       string
	Marker    string
	Id        string
}

CStatusQueryData defined a struct for the query conditions about the tasks' progress

type CacheTTL

type CacheTTL struct {
	Type           string `json:"type"`
	Value          string `json:"value"`
	Weight         int    `json:"weight,omitempty"`
	TTL            int    `json:"ttl"`
	OverrideOrigin bool   `json:"override_origin"`
}

CacheTTL defined a struct for cached rules.

type CachedDetail

type CachedDetail struct {
	Status     string `json:"status"`
	CreatedAt  string `json:"createdAt"`
	StartedAt  string `json:"startedAt"`
	FinishedAt string `json:"finishedAt"`
	Progress   int64  `json:"progress"`
}

CachedDetail defined a struct for task details

type DomainConfig

type DomainConfig struct {
	Domain       string       `json:"domain"`
	Origin       []OriginPeer `json:"originConfig"`
	CacheTTL     []CacheTTL   `json:"cacheTtl"`
	CacheFullUrl bool         `json:"cacheFullUrl"`
	OriginHost   *string      `json:"originHost"`
	RefererACL   *RefererACL  `json:"refererACL"`
	IpACL        *IpACL       `json:"ipACL"`
}

DomainConfig defined a struct for total configurations.

func GetDomainConfig

func GetDomainConfig(cli bce.Client, domain string) (*DomainConfig, error)

GetDomainConfig - get the configuration for the specified domain For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/9kbsye6k8

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain

RETURNS:

  • *DomainConfig: the configuration about the specified domain
  • error: nil if success otherwise the specific error

type FlowDetail

type FlowDetail struct {
	Timestamp string `json:"timestamp"`
	Flow      int64  `json:"flow"`
	Bps       int64  `json:"bps"`
	Key       string `json:"key"`
}

FlowDetail hold details of statistics of traffic.

func GetFlow

func GetFlow(cli bce.Client, options ...QueryStatOption) ([]FlowDetail, error)

GetFlow - get the statistics of traffic(flow). For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Bkbszintg

PARAMS:

  • cli: the client agent which can perform sending request
  • options: the querying conditions, valid options are: 1. QueryStatByTimeRange 2. QueryStatByPeriod 3. QueryStatByDomains 4. QueryStatByCountry

RETURNS:

  • []FlowDetail: the details about traffic
  • error: nil if success otherwise the specific error

func GetSrcFlow

func GetSrcFlow(cli bce.Client, options ...QueryStatOption) ([]FlowDetail, error)

GetSrcFlow - get the statistics of traffic(flow) to your origin server. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/rkbsznt4v

PARAMS:

  • cli: the client agent which can perform sending request
  • options: the querying conditions, valid options are: 1. QueryStatByTimeRange 2. QueryStatByPeriod 3. QueryStatByDomains

RETURNS:

  • []FlowDetail: the details about traffic to your origin server.
  • error: nil if success otherwise the specific error

type HitDetail

type HitDetail struct {
	Timestamp string  `json:"timestamp"`
	HitRate   float64 `json:"hitrate"`
	Key       string  `json:"key"`
}

HitDetail defined a struct for hitting ratio of Edge accessing.

func GetRealHit

func GetRealHit(cli bce.Client, options ...QueryStatOption) ([]HitDetail, error)

GetRealHit - get the statistics of hit rate of accessing by traffic. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/ckbszuehh

PARAMS:

  • cli: the client agent which can perform sending request
  • options: the querying conditions, valid options are: 1. QueryStatByTimeRange 2. QueryStatByPeriod 3. QueryStatByDomains

RETURNS:

  • []HitDetail: the details about traffic hit rate.
  • error: nil if success otherwise the specific error

type HttpCodeDetail

type HttpCodeDetail struct {
	Timestamp string      `json:"timestamp"`
	Counters  []KvCounter `json:"counters"`
	Key       string      `json:"key"`
}

HttpCodeDetail hold details of statistics of accessing HTTP codes.

func GetHttpCode

func GetHttpCode(cli bce.Client, options ...QueryStatOption) ([]HttpCodeDetail, error)

GetHttpCode - get the statistics of accessing HTTP codes. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/ekbszvxv5

PARAMS:

  • cli: the client agent which can perform sending request
  • options: the querying conditions, valid options are: 1. QueryStatByTimeRange 2. QueryStatByPeriod 3. QueryStatByDomains

RETURNS:

  • []HttpCodeDetail: the details about accessing HTTP codes.
  • error: nil if success otherwise the specific error

type IpACL

type IpACL struct {
	BlackList []string `json:"blackList"`
	WhiteList []string `json:"whiteList"`
}

IpACL defined a struct for IP address blacklist or whitelist.

type KvCounter

type KvCounter struct {
	Name  int64 `json:"name"`
	Count int64 `json:"count"`
}

KvCounter defined a struct for name and count pairs.

type LogBase

type LogBase struct {
	Domain string `json:"domain"`
	Url    string `json:"url"`
	Name   string `json:"name"`
	Size   int64  `json:"size"`
}

type LogEntry

type LogEntry struct {
	*LogBase
	*TimeInterval
}

LogEntry defined a struct for log information

func GetDomainLog

func GetDomainLog(cli bce.Client, domain string, timeInterval TimeInterval) ([]LogEntry, error)

GetDomainLog -get one domain's log urls For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/mjwvxj0ec

PARAMS:

  • cli: the client agent which can perform sending request
  • domain: the specified domain
  • timeInterval: the specified time interval

RETURNS:

  • []LogEntry: the log detail list
  • error: nil if success otherwise the specific error

type OriginPeer

type OriginPeer struct {
	Type   string `json:"type"`
	Addr   string `json:"addr"`
	Backup bool   `json:"backup"`
}

OriginPeer defined a struct for Origin server.

type Period

type Period interface {
	Value() int64
}

type PrefetchDetail

type PrefetchDetail struct {
	*CachedDetail
	Task PrefetchTask `json:"task"`
}

PrefetchDetail defined a struct for prefetch task information

type PrefetchId

type PrefetchId string

func Prefetch

func Prefetch(cli bce.Client, tasks []PrefetchTask) (PrefetchId, error)

Prefetch - tells the CDN system to prefetch the specified files For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Dlj5ch09q

PARAMS:

  • cli: the client agent which can perform sending request
  • tasks: the tasks about prefetch the files from the CDN nodes
  • error: nil if success otherwise the specific error

type PrefetchStatus

type PrefetchStatus struct {
	Details     []PrefetchDetail `json:"details"`
	IsTruncated bool             `json:"isTruncated"`
	NextMarker  string           `json:"nextMarker"`
}

PrefetchStatus defined a struct for prefetch status

func GetPrefetchStatus

func GetPrefetchStatus(cli bce.Client, queryData *CStatusQueryData) (*PrefetchStatus, error)

GetPrefetchStatus - get the prefetch progress For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Mlj5e9y0i

PARAMS:

  • cli: the client agent which can perform sending request
  • queryData: querying conditions, it contains the time interval, the task ID and the specified url

RETURNS:

  • *PrefetchStatus: the details about the prefetch
  • error: nil if success otherwise the specific error

type PrefetchTask

type PrefetchTask struct {
	Url string `json:"url"`
}

PrefetchTask defined a struct for prefetch task

type PurgeTask

type PurgeTask struct {
	Url  string `json:"url"`
	Type string `json:"type,omitempty"`
}

PurgeTask defined a struct for purged task

type PurgedDetail

type PurgedDetail struct {
	*CachedDetail
	Task PurgeTask `json:"task"`
}

PurgedDetail defined a struct for purged task information

type PurgedId

type PurgedId string

func Purge

func Purge(cli bce.Client, tasks []PurgeTask) (PurgedId, error)

Purge - tells the CDN system to purge the specified files For more details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/Zkbsy0k8j

PARAMS:

  • cli: the client agent which can perform sending request
  • tasks: the tasks about purging the files from the CDN nodes

RETURNS:

  • PurgedId: an ID representing a purged task, using it to search the task progress
  • error: nil if success otherwise the specific error

type PurgedStatus

type PurgedStatus struct {
	Details     []PurgedDetail `json:"details"`
	IsTruncated bool           `json:"isTruncated"`
	NextMarker  string         `json:"nextMarker"`
}

PurgedStatus defined a struct for purged status

func GetPurgedStatus

func GetPurgedStatus(cli bce.Client, queryData *CStatusQueryData) (*PurgedStatus, error)

GetPurgedStatus - get the purged progress For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/ikbsy9cvb

PARAMS:

  • cli: the client agent which can perform sending request
  • queryData: querying conditions, it contains the time interval, the task ID and the specified url

RETURNS:

  • *PurgedStatus: the details about the purged
  • error: nil if success otherwise the specific error

type PvDetail

type PvDetail struct {
	Timestamp string `json:"timestamp"`
	Pv        int64  `json:"pv"`
	Qps       int64  `json:"qps"`
	Key       string `json:"key"`
}

PvDetail hold details of statistics of pv/qps.

func GetPv

func GetPv(cli bce.Client, options ...QueryStatOption) ([]PvDetail, error)

GetPv - get the statistics of pv/qps. For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/dkbszg48s

PARAMS:

  • cli: the client agent which can perform sending request
  • options: the querying conditions, valid options are: 1. QueryStatByTimeRange 2. QueryStatByPeriod 3. QueryStatByDomains 4. QueryStatByCountry

RETURNS:

  • []PvDetail: the details about pv/qps
  • error: nil if success otherwise the specific error

type QueryStatOption

type QueryStatOption func(interface{})

QueryStatOption defined a method for setting optional configurations for query statistics.

func QueryStatByCountry

func QueryStatByCountry(country string) QueryStatOption

QueryStatByCountry the specific Country you want to know about. The country value is one of the GEC codes. More details about GEC, you can read this article: https://baike.baidu.com/item/%E4%B8%96%E7%95%8C%E5%90%84%E5%9B%BD%E5%92%8C%E5%9C%B0%E5%8C%BA%E5%90%8D%E7%A7%B0%E4%BB%A3%E7%A0%81/6560023 and pay attention of the column of the key world "两字母代码".

func QueryStatByDomains

func QueryStatByDomains(domains []string) QueryStatOption

QueryStatByDomains defined a method to pass the CDN domains you are interested in.

func QueryStatByPeriod

func QueryStatByPeriod(period Period) QueryStatOption

QueryStatByPeriod the time interval of statistics data merged by, valid values are 300, 3600 and 86400 represents by Period300, Period3060 and Period86400 respectively

func QueryStatByTimeRange

func QueryStatByTimeRange(startTime, endTime string) QueryStatOption

QueryStatByTimeRange the beginning and the end of the time range to query, The time values are in the ISO 8601 standard with the yyyy-MM-ddTHH:mm:ssZ format, e.g. 2024-04-15T00:00:00Z.

type QuotaDetail

type QuotaDetail struct {
	UrlPurgeQuota  int64 `json:"urlPurgeQuota"`
	UrlPurgeRemain int64 `json:"urlPurgeRemain"`
	DirPurgeQuota  int64 `json:"dirPurgeQuota"`
	DirPurgeRemain int64 `json:"dirPurgeRemain"`
	PrefetchQuota  int64 `json:"prefetchQuota"`
	PrefetchRemain int64 `json:"prefetchRemain"`
}

QuotaDetail defined a struct for query quota

func GetQuota

func GetQuota(cli bce.Client) (*QuotaDetail, error)

GetQuota - get the quota about purge and prefetch For details, please refer https://cloud.baidu.com/doc/CDN-ABROAD/s/flnoakciq

RETURNS:

  • cli: the client agent which can perform sending request
  • QuotaDetail: the quota details about a specified user
  • error: nil if success otherwise the specific error

type RefererACL

type RefererACL struct {
	BlackList  []string `json:"blackList"`
	WhiteList  []string `json:"whiteList"`
	AllowEmpty bool     `json:"allowEmpty"`
}

RefererACL defined a struct for Referer whitelist or blacklist to enable hotlink protection.

type TimeInterval

type TimeInterval struct {
	StartTime string `json:"startTime"`
	EndTime   string `json:"endTime"`
}

TimeInterval defined a struct contains the started time and the end time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL