cdn

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

cdn CDN服务Api @author cbping

Index

Constants

View Source
const (
	OpenCdnServiceAction     = "OpenCdnService"
	DescribeCdnServiceAction = "DescribeCdnService"
	ModifyCdnServiceAction   = "ModifyCdnService"

	AddCdnDomainAction            = "AddCdnDomain"
	DeleteCdnDomainAction         = "DeleteCdnDomain"
	DescribeUserDomainsAction     = "DescribeUserDomains"
	DescribeCdnDomainDetailAction = "DescribeCdnDomainDetail"
	ModifyCdnDomainAction         = "ModifyCdnDomain"
	StartCdnDomainAction          = "StartCdnDomain"
	StopCdnDomainAction           = "StopCdnDomain"

	RefreshObjectCachesAction  = "RefreshObjectCaches"
	PushObjectCacheAction      = "PushObjectCache"
	DescribeRefreshTasksAction = "DescribeRefreshTasks"
	DescribeRefreshQuotaAction = "DescribeRefreshQuota"

	DescribeDomainConfigsAction        = "DescribeDomainConfigs"
	SetOptimizeConfigAction            = "SetOptimizeConfig"
	SetPageCompressConfigAction        = "SetPageCompressConfig"
	SetIgnoreQueryStringConfigAction   = "SetIgnoreQueryStringConfig"
	SetRangeConfigAction               = "SetRangeConfig"
	SetVideoSeekConfigAction           = "SetVideoSeekConfig"
	SetSourceHostConfigAction          = "SetSourceHostConfig"
	SetErrorPageConfigAction           = "SetErrorPageConfig"
	SetForceRedirectConfigAction       = "SetForceRedirectConfig"
	SetReferConfigAction               = "SetReferConfig"
	SetFileCacheExpiredConfigAction    = "SetFileCacheExpiredConfig"
	SetPathCacheExpiredConfigAction    = "SetPathCacheExpiredConfig"
	ModifyFileCacheExpiredConfigAction = "ModifyFileCacheExpiredConfig"
	ModifyPathCacheExpiredConfigAction = "ModifyPathCacheExpiredConfig"
	DeleteCacheExpiredConfigAction     = "DeleteCacheExpiredConfig"
	SetReqAuthConfigAction             = "SetReqAuthConfig"
	SetHttpHeaderConfigAction          = "SetHttpHeaderConfig"
	ModifyHttpHeaderConfigAction       = "ModifyHttpHeaderConfig"
	DeleteHttpHeaderConfigAction       = "DeleteHttpHeaderConfig"
	SetCcConfigAction                  = "SetCcConfig"
	SetWafConfigAction                 = "SetWafConfig"
)
View Source
const (
	// CdnType
	WebCdnType                 CdnType = "web"              //图片及小文件分发
	DownloadCdnType            CdnType = "download"         //大文件下载加速
	VideoCdnType               CdnType = "video"            //视音频点播加速
	LiveStreamCdnType          CdnType = "liveStream"       //直播流媒体加速
	HttpsDeliveryStreamCdnType CdnType = "httpsDelivery"    //Https安全加速
	NullCdnType                CdnType = global.EmptyString //

	// SourceType
	IpaddrSourceType     SourceType = "ipaddr"           //IP源站
	DomainSourceType     SourceType = "domain"           //域名源站
	OSSSourceType        SourceType = "OSS"              //OSS Bucket为源站
	LiveStreamSourceType SourceType = global.EmptyString // 注:若选择了直播流媒体加速的业务类型,无需填写源站类型和信息

	// DomainSearchType 域名查询类型:fuzzy_match 模糊匹配,pre_match 前匹配,suf_match 后匹配,full_match 完全匹配,默认fuzzy_match
	FuzzyMatch DomainSearchType = "fuzzy_match"
	PreMatch   DomainSearchType = "pre_match "
	SufMatch   DomainSearchType = "suf_match "
	FullMatch  DomainSearchType = "full_match"

	// DomainStatus
	// 取值意义:online表示启用;offline表示停用;configuring表示配置中;configure_failed表示配置失败;checking表示正在审核;check_failed表示审核失败
	OnlineDomainStatus          DomainStatus = "online"
	OfflineDomainStatus         DomainStatus = "offline"
	ConfiguringDomainStatus     DomainStatus = "configuring"
	ConfigureFailedDomainStatus DomainStatus = "configure_failed"
	CheckFailedDomainStatus     DomainStatus = "check_failed"
	CheckingDomainStatus        DomainStatus = "checking"

	// CdnPayType
	PayByTrafficType   CdnPayType = "PayByTraffic"   //按流量
	PayByBandwidthType CdnPayType = "PayByBandwidth" //按带宽峰值
	PayNullType        CdnPayType = ""               //空值,默认采用 PayByTrafficType

	// ConfigList参数
	CacheExpiredConfig      ConfigName = "cache_expired"       //目录或文件过期配置
	CcConfig                ConfigName = "cc"                  //cc	String	CC防护功能、IP黑白名单配置
	ErrorPageConfig         ConfigName = "error_page"          //error_page	String	自定义404错误页面跳转
	HttpHeaderConfig        ConfigName = "http_header"         //http_header	String	自定义http头
	OptimizeConfig          ConfigName = "optimize"            //optimize	String	页面优化
	PageCompressConfig      ConfigName = "page_compress"       //page_compress	String	智能压缩
	IgnoreQueryStringConfig ConfigName = "ignore_query_string" //ignore_query_string	String	过滤参数
	RangeConfig             ConfigName = "range"               //range	String	range回源功能
	RefererConfig           ConfigName = "referer"             //referer	String	Refer防盗链功能
	ReqAuthConfig           ConfigName = "req_auth"            //req_auth	String	访问鉴权配置
	SrcHostConfig           ConfigName = "src_host"            //src_host	String	回源host
	VideoSeekConfig         ConfigName = "video_seek"          //video_seek	String	拖拽播放功能
	WafConfig               ConfigName = "waf"                 //waf	String	Waf防护功能
	NotifyRrlConfig         ConfigName = "notify_url"          //notify_url	String	视频直播notify url
	RedirectTypeConfig      ConfigName = "redirect_type"       //redirect_type	String	强制访问跳转方式, 取值: Off, Http, Https

	// RefreshObjectType
	FileRefreshType      RefreshObjectType = "File"
	DirectoryRefreshType RefreshObjectType = "Directory"

	// PageType 错误页面类型; 取值:default:默认页面;charity:公益页面;other:自定义页面
	DefaultPageType PageType = "default"
	CharityPageType PageType = "charity"
	OtherPageType   PageType = "other"

	// RedirectType 强制跳转类型, 取值: Off, Http, Https
	OffRedirectType   RedirectType = "Off"
	HttpRedirectType  RedirectType = "Http"
	HttpsRedirectType RedirectType = "Https"

	// ReferType refer类型,取值:block:黑名单;allow:白名单
	BlockReferType ReferType = "block"
	AllowReferType ReferType = "allow"

	// CacheType 缓存内容类型,取值:suffix:文件名后缀;path:路径,支持目录和完整路
	SuffixCacheType CacheType = "suffix"
	PathCacheType   CacheType = "path"

	// AuthType	String	是	鉴权类型,取值: "no_auth":关闭,"type_a":A方式,"type_b":B方式, "type_c":C方式
	NoAuthType AuthType = "no_auth"
	AAuthType  AuthType = "type_a"
	BAuthType  AuthType = "type_b"
	CAuthType  AuthType = "type_c"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthType

type AuthType string

鉴权类型

type CDN

type CDN struct {
	// contains filtered or unexported fields
}

CDN接口控制器 记住,很多操作需先开通CDN服务才可执行。

func NewCDN

func NewCDN(cert *client.Credentials) *CDN

func (*CDN) AddCdnDomain

func (c *CDN) AddCdnDomain(domainInfo DomainInfo, resp interface{}) (err error)

AddCdnDomain 添加加速域名

@link https://help.aliyun.com/document_detail/27161.html?spm=0.0.0.0.ShLybr

func (*CDN) CdnDomainDetail

func (c *CDN) CdnDomainDetail(domainName string, resp interface{}) (err error)

CdnDomainDetail 获取指定加速域名配置的基本信息

@link https://help.aliyun.com/document_detail/27162.html?spm=0.0.0.0.COpoXo

func (*CDN) DeleteCacheExpiredConfig

func (c *CDN) DeleteCacheExpiredConfig(domainName, configID string, cacheType CacheType, resp interface{}) (err error)

DeleteCacheExpiredConfig 删除自定义缓存策略.

@link https://help.aliyun.com/document_detail/27183.html?spm=5176.doc27182.6.186.DVvk01

func (*CDN) DeleteCdnDomain

func (c *CDN) DeleteCdnDomain(domainName string, resp interface{}) (err error)

DeleteCdnDomain 删除已添加的加速域名

@link https://help.aliyun.com/document_detail/27167.html?spm=0.0.0.0.SyHloH

func (*CDN) DeleteHttpHeaderConfig

func (c *CDN) DeleteHttpHeaderConfig(domainName, configID string, resp interface{}) (err error)

DeleteHttpHeaderConfig 删除加速域名的Refer防盗链配置

@link https://help.aliyun.com/document_detail/27187.html?spm=5176.doc27186.6.190.EvwqYw

func (*CDN) DomainConfigs

func (c *CDN) DomainConfigs(domainName string, resp interface{}, configList ...ConfigName) (err error)

DomainConfigs 获取指定加速域名的配置 @configList 为空时代表查询所有 @link https://help.aliyun.com/document_detail/27169.html?spm=0.0.0.0.fewJpA

func (*CDN) GetRefreshQuota

func (c *CDN) GetRefreshQuota(resp interface{}) (err error)

GetRefreshQuota 刷新(包含预热)URL及目录的最大限制数量

当日剩余刷新(含预热)URL及目录的次数

@link https://help.aliyun.com/document_detail/27203.html?spm=0.0.0.0.qSO8re

func (*CDN) GetRefreshTasks

func (c *CDN) GetRefreshTasks(taskId, objectPath string, pageSize, pageNumber int64, resp interface{}) (err error)

GetRefreshTasks 查询刷新、预热状态,是否在全网生效。

@link https://help.aliyun.com/document_detail/27202.html?spm=0.0.0.0.Otm79O

func (*CDN) ModifyCdnDomain

func (c *CDN) ModifyCdnDomain(domainInfo DomainInfo, resp interface{}) (err error)

ModifyCdnDomain 修改加速域名,目前支持修改源站

@link https://help.aliyun.com/document_detail/27164.html?spm=0.0.0.0.rOMSJ4

func (*CDN) ModifyCdnServicePayType

func (c *CDN) ModifyCdnServicePayType(internetChargeType CdnPayType, resp interface{}) (err error)
ModifyCdnServicePayType 变更CDN服务的计费类型.
  internetChargeType 开通服务的计费类型(默认按流量) 按流量(PayByTraffic)、按带宽峰值(PayByBandwidth)。
                          常量  PayByTrafficType(PayByTraffic)和PayByBandwidthType(PayByBandwidth)

@link https://help.aliyun.com/document_detail/27159.html?spm=0.0.0.0.AuPm7B

func (*CDN) ModifyFileCacheExpiredConfig

func (c *CDN) ModifyFileCacheExpiredConfig(domainName, configID, cacheContent string, ttl, weight int64, resp interface{}) (err error)

ModifyFileCacheExpiredConfig 修改文件过期配置 <br> Qparam ttl 缓存时间设置,单位为秒 <br> @link https://help.aliyun.com/document_detail/27179.html?spm=0.0.0.0.PrOMF2

func (*CDN) ModifyHttpHeaderConfig

func (c *CDN) ModifyHttpHeaderConfig(domainName, configID, headerKey, headerValue string, resp interface{}) (err error)

ModifyHttpHeaderConfig 修改自定义http头

@link https://help.aliyun.com/document_detail/27186.html?spm=5176.doc27185.6.189.LlynbW

func (*CDN) ModifyPathCacheExpiredConfig

func (c *CDN) ModifyPathCacheExpiredConfig(domainName, configID, cacheContent string, ttl, weight int64, resp interface{}) (err error)

ModifyPathCacheExpiredConfig 修改目录过期配置 Qparam ttl 缓存时间设置,单位为秒 @link https://help.aliyun.com/document_detail/27179.html?spm=0.0.0.0.PrOMF2

func (*CDN) OpenCdnService

func (c *CDN) OpenCdnService(internetChargeType CdnPayType, resp interface{}) (err error)

OpenCdnService 开通CDN服务 internetChargeType 开通服务的计费类型(默认按流量) 按流量(PayByTraffic)、按带宽峰值(PayByBandwidth)。

常量  PayByTrafficType(PayByTraffic)和PayByBandwidthType(PayByBandwidth)

@link https://help.aliyun.com/document_detail/27157.html?spm=0.0.0.0.t6wFRF

func (*CDN) PushObjectCache

func (c *CDN) PushObjectCache(objectPath string, resp interface{}) (err error)

PushObjectCache 将源站的内容主动预热到L2 Cache节点上,用户首次访问可直接命中缓存,缓解源站压力。

@link https://help.aliyun.com/document_detail/27201.html?spm=0.0.0.0.PJp719

func (*CDN) ReadUserDomains

func (c *CDN) ReadUserDomains(domainName string, pageSize, pageNumber int64, domainStatus DomainStatus, domainSearchType DomainSearchType, resp interface{}) (err error)

func (*CDN) RefreshObjectCaches

func (c *CDN) RefreshObjectCaches(objectPath string, objectType RefreshObjectType, resp interface{}) (err error)

func (*CDN) ScanCdnService

func (c *CDN) ScanCdnService(resp interface{}) (err error)

ScanCdnService 查询CDN服务状态。包括:当前计费类型,服务开通时间,下次生效的计费类型,当前业务状态等。

@link https://help.aliyun.com/document_detail/27158.html?spm=0.0.0.0.2RRuSQ

func (*CDN) SetCcConfig

func (c *CDN) SetCcConfig(domainName, allowIps, blockIps string, enable bool, resp interface{}) (err error)

SetCcConfig 设置加速域名的CC防护功能、IP黑白名单设置

@link https://help.aliyun.com/document_detail/27188.html?spm=5176.doc27189.6.191.F7funw

func (*CDN) SetDebug

func (c *CDN) SetDebug(debug bool) *CDN

func (*CDN) SetErrorPageConfig

func (c *CDN) SetErrorPageConfig(domainName, customPageUrl string, pageType PageType, resp interface{}) (err error)

SetErrorPageConfig 设置加速域名自定义404错误页面跳转

@link https://help.aliyun.com/document_detail/27176.html?spm=0.0.0.0.2WOcZu

func (*CDN) SetFileCacheExpiredConfig

func (c *CDN) SetFileCacheExpiredConfig(domainName, cacheContent string, ttl, weight int64, resp interface{}) (err error)

SetFileCacheExpiredConfig 设置文件过期配置 <br> Qparam ttl 缓存时间设置,单位为秒 <br> @link https://help.aliyun.com/document_detail/27179.html?spm=0.0.0.0.PrOMF2

func (*CDN) SetForceRedirectConfig

func (c *CDN) SetForceRedirectConfig(domainName string, redirectType RedirectType, resp interface{}) (err error)

SetForceRedirectConfig 设置强制访问跳转方式, 目前支持强制Http或Https跳转.

@link https://help.aliyun.com/document_detail/27177.html?spm=0.0.0.0.kKSTQo

func (*CDN) SetHttpHeaderConfig

func (c *CDN) SetHttpHeaderConfig(domainName, headerKey, headerValue string, resp interface{}) (err error)

SetHttpHeaderConfig 设置自定义http头

@link https://help.aliyun.com/document_detail/27185.html?spm=5176.doc27184.6.188.o8SCqc

func (*CDN) SetIgnoreQueryStringConfig

func (c *CDN) SetIgnoreQueryStringConfig(domainName string, enable bool, resp interface{}) (err error)

SetIgnoreQueryStringConfig 设置过滤参数功能

@link https://help.aliyun.com/document_detail/27172.html?spm=0.0.0.0.1cmlUC

func (*CDN) SetOptimizeConfig

func (c *CDN) SetOptimizeConfig(domainName string, enable bool, resp interface{}) (err error)

SetOptimizeConfig 设置页面优化功能,开启后可以删除 html ,<br>

内嵌 javascript 和 css 中的注释以及重复的空白符;这样可以有效地去除页面的冗余内容,减小文件体积,提高加速分发效率<br>

@link https://help.aliyun.com/document_detail/27170.html?spm=0.0.0.0.w21KyD

func (*CDN) SetPageCompressConfig

func (c *CDN) SetPageCompressConfig(domainName string, enable bool, resp interface{}) (err error)

SetPageCompressConfig 设置智能压缩功能

@link https://help.aliyun.com/document_detail/27170.html?spm=0.0.0.0.w21KyD

func (*CDN) SetPathCacheExpiredConfig

func (c *CDN) SetPathCacheExpiredConfig(domainName, cacheContent string, ttl, weight int64, resp interface{}) (err error)

SetPathCacheExpiredConfig 修改目录过期配置 <br> Qparam ttl 缓存时间设置,单位为秒 <br> @link https://help.aliyun.com/document_detail/27179.html?spm=0.0.0.0.PrOMF2

func (*CDN) SetRangeConfig

func (c *CDN) SetRangeConfig(domainName string, enable bool, resp interface{}) (err error)

SetRangeConfig 设置range回源功能

@link https://help.aliyun.com/document_detail/27173.html?spm=0.0.0.0.dKGEgt

func (*CDN) SetReferConfig

func (c *CDN) SetReferConfig(domainName, referList string, referType ReferType, allowEmpty bool, resp interface{}) (err error)

func (*CDN) SetReqAuthConfig

func (c *CDN) SetReqAuthConfig(domainName, key1, key2 string, authType AuthType, timeout int64, resp interface{}) (err error)

SetReqAuthConfig 设置加速域名的访问鉴权配置. @timeout 鉴权缓存时间,单位为秒;如果不大于零时,则忽略此参数,也就是说采用默认值 @link https://help.aliyun.com/document_detail/27184.html?spm=5176.doc27183.6.187.r0X7ox1

func (*CDN) SetSourceHostConfig

func (c *CDN) SetSourceHostConfig(domainName, backSrcDomain string, resp interface{}) (err error)

SetSourceHostConfig 设置回源host功能

@link https://help.aliyun.com/document_detail/27175.html?spm=0.0.0.0.RLyJt0

func (*CDN) SetVideoSeekConfig

func (c *CDN) SetVideoSeekConfig(domainName string, enable bool, resp interface{}) (err error)

SetVideoSeekConfig 设置拖拽播放功能

@link https://help.aliyun.com/document_detail/27174.html?spm=0.0.0.0.r7OBIj

func (*CDN) SetWafConfig

func (c *CDN) SetWafConfig(domainName string, enable bool, resp interface{}) (err error)

SetWafConfig 设置加速域名的Waf防护功能

@link https://help.aliyun.com/document_detail/27189.html?spm=5176.doc27188.6.192.POkElI

func (*CDN) StartCdnDomain

func (c *CDN) StartCdnDomain(domainName string, resp interface{}) (err error)

StartCdnDomain 启用状态为“停用”的加速域名,将DomainStatus变更为online

@link https://help.aliyun.com/document_detail/27165.html?spm=0.0.0.0.8cQhXd

func (*CDN) StopCdnDomain

func (c *CDN) StopCdnDomain(domainName string, resp interface{}) (err error)

StopCdnDomain 停用某个加速域名,将DomainStatus变更为offline

@link https://help.aliyun.com/document_detail/27166.html?spm=0.0.0.0.JcQVpK

type CacheType

type CacheType string

缓存内容类型,

type CdnPayType

type CdnPayType string

开通服务的计费类型

type CdnType

type CdnType string

加速域名的业务类型

type ConfigName

type ConfigName string

ConfigList参数

type DomainInfo

type DomainInfo struct {
	//添加加速域名用到的信息
	DomainName        string     //(接入CDN进行加速的域名)
	Sources           string     `json:"" xml:"null"` //(源站信息,域名或IP) 输入信息 相当
	CdnType           CdnType    //(加速域名的业务类型 取值含义:web表示图片及小文件加速;download表示大文件下载加速;video表示视音频点播加速;liveStream表示直播流媒体加速 ;httpsDelivery表示HTTPS安全加速)
	SourceType        SourceType //(源站类型 取值含义:ipaddr表示IP源站;domain表示域名源站;oss表示指定OSS Bucket为源站)
	ServerCertificate string     //(如果开启,此处为证书公钥) 如果是HttpsDelivery,需要上传的安全证书。
	SourcePort        int64      //可以指定443,80。默认值80。443的话走https回源。oss不支持443
	PrivateKey        string     //如果是HttpsDelivery,需要上传的私钥。

	//其他信息
	Cname                   string       //(为加速域名生成的一个CNAME域名,需要在域名解析服务商处将加速域名CNAME解析到该域名)
	HttpsCname              string       //(开启https的CNAME域名)
	DomainStatus            DomainStatus //(加速域名运行状态 取值意义:online表示启用;offline表示停用;configuring表示配置中;configure_failed表示配置失败;checking表示正在审核;check_failed表示审核失败)
	ServerCertificateStatus string       //(是否开启ssl证书 on表示开启;off表示关闭)
	GmtCreated              string       //(创建时间)
	GmtModified             string       //(最近修改时间)

	SourcesJson map[string]interface{} `json:"Sources"`       //(Json 返回信息 Sources别名)
	SourcesXml  []string               `xml:"Sources>Source"` //(Xml  返回信息 Sources 别名)
}

type DomainInfoResponse

type DomainInfoResponse struct {
	client.Response
	GetDomainDetailModel DomainInfo
}

type DomainSearchType

type DomainSearchType string

域名查询类型

type DomainStatus

type DomainStatus string

加速域名运行状态

type PageType

type PageType string

错误页面类型

type RedirectType

type RedirectType string

强制跳转类型, 取值: Off, Http, Https

type ReferType

type ReferType string

refer类型,

type RefreshObjectType

type RefreshObjectType string

刷新类型

type SourceType

type SourceType string

源站类型

Jump to

Keyboard shortcuts

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