common

package
v0.0.142 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MPL-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BypassInfoUrlParam = "BYPASS_URL_PARAM"
	BypassInfoInput    = "BYPASS_INPUT"
)
View Source
const (
	BypassPath         = "PATH"
	BypassDomain       = "DOMAIN"
	BypassHeader       = "HEADER"
	BypassParam        = "PARAM"
	BypassUrlParam     = "URL_PARAM"
	BypassResponse     = "RESPONSE"
	BypassFilePath     = "FILE_PATH"
	BypassResponseData = "RESPONSE_DATA"
)
View Source
const (
	TerraformProviderName    = "terraform-provider-volcengine"
	TerraformProviderVersion = "0.0.142"
)

Variables

View Source
var TagsHash = func(v interface{}) int {
	if v == nil {
		return hashcode.String("")
	}
	m := v.(map[string]interface{})
	var (
		buf bytes.Buffer
	)
	buf.WriteString(fmt.Sprintf("%v#%v", m["key"], m["value"]))
	return hashcode.String(buf.String())
}
View Source
var VkeTagsResponseHash = func(v interface{}) int {
	if v == nil {
		return hashcode.String("")
	}
	m := v.(map[string]interface{})
	var (
		buf bytes.Buffer
	)
	buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["key"].(string))))
	buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["value"].(string))))
	buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["type"].(string))))
	return hashcode.String(buf.String())
}

Functions

func BeforeTosPutAcl added in v0.0.22

func BeforeTosPutAcl(d *schema.ResourceData, call SdkCall, data *map[string]interface{}, err error) (bool, error)

func CallProcess

func CallProcess(calls []SdkCall, d *schema.ResourceData, client *SdkClient, service ResourceService) (err error)

func CheckResourceUtilRemoved

func CheckResourceUtilRemoved(d *schema.ResourceData, readResourceFunc ReadResourceFunc, timeout time.Duration) error

func ClbAclEntryHash

func ClbAclEntryHash(v interface{}) int

func Convert

func Convert(d *schema.ResourceData, k string, v interface{}, t RequestConvert, index int, req *map[string]interface{}, chain string, forceGet bool, contentType RequestContentType, schemaChain string, setIndex []int) (err error)

func DataSourceToRequest

func DataSourceToRequest(d *schema.ResourceData, r *schema.Resource, info DataSourceInfo) (req map[string]interface{}, err error)

func DefaultMapValue added in v0.0.35

func DefaultMapValue(source *map[string]interface{}, key string, defaultStruct map[string]interface{})

func DownLineToFilter

func DownLineToFilter(s string) string

DownLineToFilter instance_name ->instance-name

func DownLineToHump

func DownLineToHump(s string) string

DownLineToHump Convert instance_name -> InstanceName

func DownLineToHumpAndFirstLower

func DownLineToHumpAndFirstLower(s string) string

DownLineToHumpAndFirstLower Convert instance_name -> instanceName

func DownLineToSpace

func DownLineToSpace(s string) string

DownLineToSpace instance_name ->instance name

func FilterSystemTags added in v0.0.64

func FilterSystemTags(tags []interface{}) []interface{}

func GetFinalKey

func GetFinalKey(t RequestConvert, k string, isRoot bool) string

func GetSetDifference

func GetSetDifference(key string, d *schema.ResourceData, f schema.SchemaSetFunc, supportUpdate bool) (add *schema.Set, remove *schema.Set, modify *schema.Set, cache map[int]interface{})

func HumpToDownLine

func HumpToDownLine(s string) string

HumpToDownLine Convert InstanceName -> instance_name

func InitLocks

func InitLocks()

func MergeDateSourceToResource

func MergeDateSourceToResource(source map[string]*schema.Schema, target *map[string]*schema.Schema)

func ObtainSdkValue

func ObtainSdkValue(keyPattern string, obj interface{}) (interface{}, error)

func ReleaseLock

func ReleaseLock(key string)

func RequestConvertDefault

func RequestConvertDefault(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string) error

func RequestConvertListFilter

func RequestConvertListFilter(v interface{}, k string, t RequestConvert, index int, req *map[string]interface{}) (int, error)

func RequestConvertListN

func RequestConvertListN(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string, d *schema.ResourceData, forceGet bool, single bool, contentType RequestContentType, schemaChain string, indexes []int) error

func RequestConvertSingleN

func RequestConvertSingleN(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string) error

func RequestConvertWithFilter

func RequestConvertWithFilter(v interface{}, k string, t RequestConvert, index int, req *map[string]interface{}) (int, error)

func RequestConvertWithN

func RequestConvertWithN(v interface{}, k string, t RequestConvert, req *map[string]interface{}, chain string) error

func RequestCreateConvert

func RequestCreateConvert(d *schema.ResourceData, k string, t RequestConvert, index int, req *map[string]interface{}, forceGet bool, contentType RequestContentType) (int, error)

func RequestUpdateConvert

func RequestUpdateConvert(d *schema.ResourceData, k string, t RequestConvert, index int, req *map[string]interface{}, contentType RequestContentType) (int, error)

func ResourceDateToRequest

func ResourceDateToRequest(d *schema.ResourceData, resource *schema.Resource, isUpdate bool, convert map[string]RequestConvert, mode RequestConvertMode, contentType RequestContentType) (map[string]interface{}, error)

func ResourceFlowLimitExceededError added in v0.0.80

func ResourceFlowLimitExceededError(err error) bool

func ResourceNotFoundError

func ResourceNotFoundError(err error) bool

func ResponseToDataSource

func ResponseToDataSource(d *schema.ResourceData, r *schema.Resource, info DataSourceInfo, collection []interface{}) (err error)

func ResponseToResourceData

func ResponseToResourceData(d *schema.ResourceData, resource *schema.Resource, data interface{}, extra map[string]ResponseConvert, start ...bool) (rd interface{}, err error)

func SortAndStartTransJson added in v0.0.22

func SortAndStartTransJson(source map[string]interface{}) (map[string]interface{}, error)

func TagsSchema added in v0.0.35

func TagsSchema() *schema.Schema

func TagsSchemaComputed added in v0.0.35

func TagsSchemaComputed() *schema.Schema

func TosAccountAclHash added in v0.0.22

func TosAccountAclHash(v interface{}) int

func TryLock

func TryLock(key string)

func UnsubscribeProductConflictError added in v0.0.141

func UnsubscribeProductConflictError(err error) bool

func UnsubscribeProductError added in v0.0.85

func UnsubscribeProductError(err error) bool

func WithNextTokenQuery

func WithNextTokenQuery(condition map[string]interface{}, maxResultsParam string, nextTokenParam string, maxResults int, decode DecodeNextToken, call NextTokenCall) (data []interface{}, err error)

func WithPageNumberQuery

func WithPageNumberQuery(condition map[string]interface{}, pageSizeParam string, pageNumParam string, pageSize int, initPageNumber int, call PageCall) (data []interface{}, err error)

func WithPageOffsetQuery

func WithPageOffsetQuery(condition map[string]interface{}, limitParam string, pageParam string, limit int, start int, call PageCall) (data []interface{}, err error)

func WithSimpleQuery

func WithSimpleQuery(condition map[string]interface{}, call PageCall) (data []interface{}, err error)

Types

type AfterCallFunc

type AfterCallFunc func(d *schema.ResourceData, client *SdkClient, resp *map[string]interface{}, call SdkCall) error

type BeforeCallFunc

type BeforeCallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) (bool, error)

type BypassSvc added in v0.0.78

type BypassSvc struct {
	Session *session.Session
}

func NewBypassClient added in v0.0.78

func NewBypassClient(session *session.Session) *BypassSvc

func (*BypassSvc) DoBypassSvcCall added in v0.0.78

func (u *BypassSvc) DoBypassSvcCall(info BypassSvcInfo, input *map[string]interface{}) (output *map[string]interface{}, err error)

func (*BypassSvc) NewTlsClient added in v0.0.78

func (u *BypassSvc) NewTlsClient() *client.Client

func (*BypassSvc) NewTosClient added in v0.0.78

func (u *BypassSvc) NewTosClient(info *BypassSvcInfo) *client.Client

type BypassSvcInfo added in v0.0.78

type BypassSvcInfo struct {
	ContentType ContentType
	HttpMethod  HttpMethod
	Path        []string
	UrlParam    map[string]string
	Header      map[string]string
	Domain      string
	ContentPath string
	Client      *client.Client
}

type CallErrorFunc

type CallErrorFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall, baseErr error) error

type CallFunc added in v0.0.43

type CallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) error

type Callback

type Callback struct {
	Call SdkCall
	Err  error
}

func SetResourceTags added in v0.0.43

func SetResourceTags(serviceClient *SdkClient, addAction, RemoveAction, resourceType string,
	resourceData *schema.ResourceData, getUniversalInfo GetUniversalInfo) []Callback

type Config

type Config struct {
	AccessKey         string
	SecretKey         string
	SessionToken      string
	Region            string
	Endpoint          string
	DisableSSL        bool
	CustomerHeaders   map[string]string
	CustomerEndpoints map[string]string
	ProxyUrl          string
}

func (*Config) Client

func (c *Config) Client() (*SdkClient, error)

type ContentType

type ContentType int
const (
	Default ContentType = iota
	ApplicationJSON
)

type Credentials added in v0.0.22

type Credentials struct {
	AccessKeyID     string
	SecretAccessKey string
	Service         string
	Region          string
	SessionToken    string
}

type DataSourceInfo

type DataSourceInfo struct {
	RequestConverts  map[string]RequestConvert
	ResponseConverts map[string]ResponseConvert
	NameField        string
	IdField          string
	CollectField     string
	ContentType      RequestContentType
	ExtraData        ExtraData
	ServiceCategory  ServiceCategory
	EachResource     EachResource
}

type DecodeNextToken

type DecodeNextToken func(source string) string

type Dispatcher

type Dispatcher struct {
}

func DefaultDispatcher added in v0.0.64

func DefaultDispatcher() *Dispatcher

func (*Dispatcher) Create

func (d *Dispatcher) Create(resourceService ResourceService, resourceDate *schema.ResourceData, resource *schema.Resource) (err error)

func (*Dispatcher) Data

func (d *Dispatcher) Data(resourceService ResourceService, resourceDate *schema.ResourceData, resource *schema.Resource) (err error)

func (*Dispatcher) Delete

func (d *Dispatcher) Delete(resourceService ResourceService, resourceDate *schema.ResourceData, resource *schema.Resource) (err error)

func (*Dispatcher) Read

func (d *Dispatcher) Read(resourceService ResourceService, resourceDate *schema.ResourceData, resource *schema.Resource) (err error)

func (*Dispatcher) Update

func (d *Dispatcher) Update(resourceService ResourceService, resourceDate *schema.ResourceData, resource *schema.Resource) (err error)

type EachResource added in v0.0.103

type EachResource func([]interface{}, *schema.ResourceData) ([]interface{}, error)

type ExecuteCallFunc

type ExecuteCallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) (*map[string]interface{}, error)

type ExtraData

type ExtraData func([]interface{}) ([]interface{}, error)

type ExtraRefreshFunc added in v0.0.100

type ExtraRefreshFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) (map[ResourceService]*StateRefresh, error)

type FieldRequestConvert

type FieldRequestConvert func(*schema.ResourceData, interface{}) interface{}

type FieldResponseConvert

type FieldResponseConvert func(interface{}) interface{}

func ConvertTosAccountAcl added in v0.0.22

func ConvertTosAccountAcl() FieldResponseConvert

func ConvertTosPublicAcl added in v0.0.22

func ConvertTosPublicAcl() FieldResponseConvert

type GetUniversalInfo added in v0.0.43

type GetUniversalInfo func(actionName string) UniversalInfo

type HttpMethod

type HttpMethod int
const (
	GET HttpMethod = iota
	HEAD
	POST
	PUT
	DELETE
)

type LockId

type LockId func(d *schema.ResourceData) string

type NextTokenCall

type NextTokenCall func(map[string]interface{}) ([]interface{}, string, error)

type PageCall

type PageCall func(map[string]interface{}) ([]interface{}, error)

type Project added in v0.0.61

type Project struct {
	Client *SdkClient
}

func NewProjectService added in v0.0.61

func NewProjectService(c *SdkClient) *Project

func (*Project) ModifyProject added in v0.0.61

func (p *Project) ModifyProject(trn *ProjectTrn, resourceData *schema.ResourceData, r *schema.Resource, service ResourceService) []Callback

func (*Project) ModifyProjectOld added in v0.0.65

func (p *Project) ModifyProjectOld(trn ProjectTrn, resourceData *schema.ResourceData, resource *schema.Resource, key string, sr *StateRefresh) []Callback

type ProjectTrn added in v0.0.61

type ProjectTrn struct {
	ResourceType         string
	ResourceID           string
	ServiceName          string
	ProjectSchemaField   string
	ProjectResponseField string
}

type ProjectUpdateEnabled added in v0.0.65

type ProjectUpdateEnabled interface {
	ProjectTrn() *ProjectTrn
}

type Rate added in v0.0.52

type Rate struct {
	Limiter   *rate.Limiter
	Semaphore *semaphore.Weighted
}

func GetRateInfoMap added in v0.0.105

func GetRateInfoMap(svc, action, version string) *Rate

type ReadResourceFunc

type ReadResourceFunc func(d *schema.ResourceData, resourceId string) (map[string]interface{}, error)

type RequestContentType

type RequestContentType int
const (
	ContentTypeDefault RequestContentType = iota
	ContentTypeJson
)

type RequestConvert

type RequestConvert struct {
	ConvertType      RequestConvertType
	Convert          FieldRequestConvert
	Ignore           bool
	ForceGet         bool
	TargetField      string
	NextLevelConvert map[string]RequestConvert
	StartIndex       int
	SpecialParam     *SpecialParam
}

type RequestConvertMode

type RequestConvertMode int
const (
	RequestConvertAll RequestConvertMode = iota
	RequestConvertInConvert
	RequestConvertIgnore
)

type RequestConvertType

type RequestConvertType int
const (
	ConvertDefault RequestConvertType = iota
	ConvertWithN
	ConvertListUnique
	ConvertListN
	ConvertSingleN
	ConvertJsonObject
	ConvertJsonArray
	ConvertJsonObjectArray
)

type ResourceResponseHandler

type ResourceResponseHandler func() (map[string]interface{}, map[string]ResponseConvert, error)

type ResourceService

type ResourceService interface {
	//GetClient 获取客户端
	GetClient() *SdkClient
	// ReadResources 读取资源列表
	ReadResources(map[string]interface{}) ([]interface{}, error)
	// ReadResource 读取单个资源
	ReadResource(*schema.ResourceData, string) (map[string]interface{}, error)
	// RefreshResourceState 刷新资源状态
	RefreshResourceState(*schema.ResourceData, []string, time.Duration, string) *resource.StateChangeConf
	// WithResourceResponseHandlers 接口结果 -> terraform 映射
	WithResourceResponseHandlers(map[string]interface{}) []ResourceResponseHandler
	// CreateResource 创建资源
	CreateResource(*schema.ResourceData, *schema.Resource) []Callback
	// ModifyResource 修改资源
	ModifyResource(*schema.ResourceData, *schema.Resource) []Callback
	// RemoveResource 删除资源
	RemoveResource(*schema.ResourceData, *schema.Resource) []Callback
	// DatasourceResources data_source读取资源
	DatasourceResources(*schema.ResourceData, *schema.Resource) DataSourceInfo
	// ReadResourceId 获取资源ID
	ReadResourceId(string) string
}

type ResponseConvert

type ResponseConvert struct {
	TargetField string
	KeepDefault bool
	Convert     FieldResponseConvert
	Ignore      bool
	Chain       string
}

type SdkCall

type SdkCall struct {
	Action           string
	BeforeCall       BeforeCallFunc
	ExecuteCall      ExecuteCallFunc
	CallError        CallErrorFunc
	AfterCall        AfterCallFunc
	Convert          map[string]RequestConvert
	ConvertMode      RequestConvertMode
	SdkParam         *map[string]interface{}
	RequestIdField   string
	Refresh          *StateRefresh
	ExtraRefresh     map[ResourceService]*StateRefresh
	AfterRefresh     CallFunc
	ContentType      RequestContentType
	LockId           LockId
	AfterLocked      CallFunc
	ServiceCategory  ServiceCategory
	ExtraRefreshCall ExtraRefreshFunc
	// contains filtered or unexported fields
}

func (*SdkCall) InitReadCall

func (c *SdkCall) InitReadCall(resourceData *schema.ResourceData, resource *schema.Resource) (err error)

func (*SdkCall) InitWriteCall

func (c *SdkCall) InitWriteCall(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) (err error)

type SdkClient

type SdkClient struct {
	Region            string
	VpcClient         *vpc.VPC
	ClbClient         *clb.CLB
	EcsClient         *ecs.ECS
	EbsClient         *storageebs.STORAGEEBS
	NatClient         *natgateway.NATGATEWAY
	VpnClient         *vpn.VPN
	AutoScalingClient *autoscaling.AUTOSCALING
	RdsClient         *rdsmysql.RDSMYSQL
	RdsClientV2       *rdsmysqlv2.RDSMYSQLV2
	IamClient         *iam.IAM
	UniversalClient   *Universal
	BypassSvcClient   *BypassSvc
}

type ServiceCategory added in v0.0.22

type ServiceCategory int
const (
	DefaultServiceCategory ServiceCategory = iota
	ServiceBypass
)

type SpecialParam added in v0.0.22

type SpecialParam struct {
	Type  SpecialParamType
	Index int
}

type SpecialParamType added in v0.0.22

type SpecialParamType int
const (
	DomainParam SpecialParamType = iota
	HeaderParam
	PathParam
	UrlParam
	FilePathParam
)

type StateRefresh

type StateRefresh struct {
	Target     []string
	Timeout    time.Duration
	ResourceId string
}

type Universal

type Universal struct {
	Session *session.Session
	// contains filtered or unexported fields
}

func NewUniversalClient

func NewUniversalClient(session *session.Session, endpoints map[string]string) *Universal

func (*Universal) DoCall

func (u *Universal) DoCall(info UniversalInfo, input *map[string]interface{}) (output *map[string]interface{}, err error)

type UniversalInfo

type UniversalInfo struct {
	ServiceName string
	Action      string
	Version     string
	HttpMethod  HttpMethod
	ContentType ContentType
}

type UnsubscribeEnabled added in v0.0.85

type UnsubscribeEnabled interface {
	// UnsubscribeInfo 判断是否需要退订
	UnsubscribeInfo(*schema.ResourceData, *schema.Resource) (*UnsubscribeInfo, error)
}

type UnsubscribeInfo added in v0.0.85

type UnsubscribeInfo struct {
	Products        []string
	InstanceId      string
	NeedUnsubscribe bool
	// contains filtered or unexported fields
}

type UnsubscribeService added in v0.0.85

type UnsubscribeService struct {
	Client *SdkClient
}

func NewUnsubscribeService added in v0.0.85

func NewUnsubscribeService(c *SdkClient) *UnsubscribeService

func (*UnsubscribeService) UnsubscribeInstance added in v0.0.85

func (u *UnsubscribeService) UnsubscribeInstance(info *UnsubscribeInfo) []Callback

Jump to

Keyboard shortcuts

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